function updateView (tagTA,tag){
    tagText = tagTA.val().split("\n");
    output = "";
    $.each(tagText,function(index,value){
        if(index == 0){
            output += '<b>'+value+'</b><br />';
        } else if(index < tagText.length-1){
            output += value+'<br />';
        } else{
            output += value;
        }
    });
    tag.children('div').html(output);
};


$(document).ready(function(){
    newsForm = $('#NewsSMSForm');
    newsLabelText = newsForm.find('label').text();
    newsInput = newsForm.find('#PhoneNumber');
    newsInput.val('');
    if(newsForm.find('.notion').size() && !newsForm.find('.notion.error').size()){
        $.get('?extra=cpsms&ajax=lookupABook');
    }
    initialVal(newsInput,newsLabelText);
    
    editTags = $('#EditTags');
    if(editTags.size()){
        var tagTA1 = $('#Tag1');
        var tag1 = editTags.find('li.tag1');
        var tagTA2 = $('#Tag2');
        var tag2 = editTags.find('li.tag2');
        
        tagTA1.bind('keyup.updateView',function(){
            updateView(tagTA1,tag1);
        });
        tagTA2.bind('keyup.updateView',function(){
            updateView(tagTA2,tag2);
        });
    }
    
});
