function ClickTicketTab(divtohide, tabid, ajaxFuse, ajaxView)
{
    for (var i = 0; i < tabDivs.length; i++) {
        Element.hide('div_'+tabDivs[i]);
        Element.removeClassName('tab_'+tabDivs[i] , "current" );
    }

    Element.toggle( divtohide );
    Element.addClassName( tabid , "current" );

    if((ajaxView != null)&&(ajaxView != "")){
        new Ajax.Updater(divtohide, 'index.php?fuse='+ajaxFuse+'&view='+ajaxView,
                         {onLoading : function(request){resetStatus(lang('Loading'))},
                          onComplete: function(request){unsetStatus(lang('Loaded'), 1000)}});
    }
}

function ToggleSecondOptionsPanel(hide)
{
    $('secondOptionsPanel').style.visibility = hide? 'hidden' : 'visible';
}

function rmbr(string){
    var regexp = /(<br>)|(<br\/>)/gi;
     // IE needs the newlines explicitly
    if (isIE == true) {
        string = string.replace(regexp, '\n');
    } else {
        string = string.replace(regexp, '');
    }

    return string;
}

function nl2br(string){
    var regexp = /\n/g;
    string = string.replace(regexp, '<br>\n');
    return string;
}

function assignTicketSuccess(responseObj)
{
    var responseArr = responseObj.responseText.split('|');
    if (typeof responseArr[1] == 'undefined' || responseArr[0] != 'OK') {
        alert(responseObj.responseText.stripTags());
        return;
    }
    $('assignedtoname').innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('assignedtoname','support','GetReassignDropdown_Async','assignee');\">"+responseArr[1]+"</a>";
    unsetStatus('', 1);
    
    var assignedToId = $('assignedToId');
    var userId = $('userId')
    
    if(assignedToId != null && userId != null && typeof responseArr[2] != 'undefined') {
        assignedToId.value = responseArr[2];
        if(assignedToId.value == userId.value) {
            $("notificationButton").style.display = "none";
        }  else  {
            $("notificationButton").style.display = "inline";
        }
    }	
}

function assignTicket(ticketId, adminId, reassign)
{
    if (adminId == 0) {
        return;
    }
	setStatus('Assigning Ticket...');
    if (reassign) {
        new Ajax.Request(   'index.php?fuse=support&action=ReasignTicket_Async&from=ViewTicketDetails',
                            {
                                postBody    : 'ticket='+ticketId+'&adminid='+adminId,
                                onSuccess   : assignTicketSuccess
                            }
        );
    } else {
        new Ajax.Request(   'index.php?fuse=support&action=AssignTickets_Async&from=ViewTicketDetails',
                            {
                                postBody    : 'items=' + ticketId + '&adminid=' + adminId,
                                onSuccess   : assignTicketSuccess
                            }
        );
    }
}

function ChangePrioritySuccess(t){

    if(t.responseText=='1'){
    	priorityTxt =  lang('High');
    	$('tdPriority').className = "innerPriorityOne";
    }
    if(t.responseText=='2'){
    	priorityTxt =  lang('Medium'); 
    	$('tdPriority').className = "innerPriorityTwo";
    }
    if(t.responseText=='3'){ 
    	priorityTxt =  lang('Low');
    	$('tdPriority').className = "formField";
    }

    $('tdPriority').innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('tdPriority','support','SetPriority_Async','priority');\">"+priorityTxt+"</a>";    
    $('originalPriority').value = t.responseText;    
    unsetStatus('', 1);
}

function ChangePriority(ticket,fuse,action){
    var priority = $('chPriority').value;
	setStatus('Changing Ticket Priority...');
	var opt = {
		method: 'post',
		postBody: 'ticket='+ticket+'&priority='+priority,			
		onSuccess: ChangePrioritySuccess,
		on404: on404,
		onFailure: onFailure
	}		
	new Ajax.Request('index.php?fuse='+fuse+'&action='+action, opt);
}

function ChangeStatusSuccess(t){
    if(t.responseText=='-1'){
    	StatusTxt =  lang('Closed');
    }
    if(t.responseText=='1'){
    	StatusTxt =  lang('Open');
    }
    if(t.responseText=='2'){
    	StatusTxt =  lang('Waiting on tech'); 
    }
    if(t.responseText=='3'){ 
    	StatusTxt =  lang('Waiting on customer');
    }

    $('ticket_status_link').innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('ticket_status_link','support','SetStatus_Async','status');\">"+StatusTxt+"</a>";    
    $('originalStatus').value = t.responseText;    
    unsetStatus('', 1);
}

function ChangeStatus(ticket,fuse,action){
   var status = $('chStatus').value;
	setStatus('Changing Ticket Status...');
	var opt = {
		method: 'post',
		postBody: 'ticket='+ticket+'&status='+status,			
		onSuccess: ChangeStatusSuccess,
		on404: on404,
		onFailure: onFailure
	}		
	new Ajax.Request('index.php?fuse='+fuse+'&action='+action, opt);
}

function ShowEditBox(id,fuse,action,field){
 
    if (field=='priority'){
    	oldvalue = $('originalPriority').value;
    
        content = "<select id='chPriority' name='chPriority' onChange=\"ChangePriority('"+$('ticketid').value+"','"+fuse+"','"+action+"');\">";        
        if(oldvalue == 3){
        	content += "<option value=3 SELECTED>"+lang('Low')+"</option>";
        }else{
        	content += "<option value=3>"+lang('Low')+"</option>";
        }
        
        if(oldvalue == 2){
        	content += "<option value=2 SELECTED>"+lang('Medium')+"</option>";
        }else{
        	content += "<option value=2>"+lang('Medium')+"</option>";
        }
        
        if(oldvalue == 1){
        	content += "<option value=1 SELECTED>"+lang('High')+"</option>";
        }else{
        	content += "<option value=1>"+lang('High')+"</option>";
        }                      
        content += "</select>";
        $(id).innerHTML = content;
	    $('chPriority').focus();
    }
    
    if (field=='status'){
    	oldvalue = $('originalStatus').value;
    
        content = "<select style='width:150px;' id='chStatus' name='chStatus' onChange=\"ChangeStatus('"+$('ticketid').value+"','"+fuse+"','"+action+"');\">";        
        if(oldvalue == 3){
        	content += "<option value=3 SELECTED>"+lang('Waiting on customer')+"</option>";
        }else{
        	content += "<option value=3>"+lang('Waiting on customer')+"</option>";
        }
        
        if(oldvalue == 2){
        	content += "<option value=2 SELECTED>"+lang('Waiting on tech')+"</option>";
        }else{
        	content += "<option value=2>"+lang('Waiting on tech')+"</option>";
        }
        
        if(oldvalue == 1){
        	content += "<option value=1 SELECTED>"+lang('Open')+"</option>";
        }else{
        	content += "<option value=1>"+lang('Open')+"</option>";
        }                      

        if(oldvalue == -1){
        	content += "<option value=\"-1\" SELECTED>"+lang('Closed')+"</option>";
        }else{
        	content += "<option value=\"-1\" >"+lang('Closed')+"</option>";
        }                      

        content += "</select>";
        $(id).innerHTML = content;
	    $('chStatus').focus();
    }    
   
    if (field=='subject'){
        $(id).innerHTML = "<input type='text' size='40' onkeypress='return noenter();' id='chSubject' name='chSubject' value='"+$('originalSubject').value+"' /> <input type=button value='"+lang('go')+"' onClick=\"ChangeSubject('"+$('ticketid').value+"','"+fuse+"','"+action+"');\" class='button_small' />";
        $('chSubject').focus();
    }

    if (field == 'owner') {
        $(id).innerHTML = lang("Enter the customer ID:") + "&nbsp;&nbsp;<form style='display:inline' method='post' action='index.php?fuse="+ fuse +"&action=" + action + "'><input type='hidden' name='ticket' value='"+ $("ticketid").value +"' /><input type='text' size='10' name='userId' value='' /> <input type='submit' value='" + lang("go") + "' class='button_small' onclick='return confirmChangeOwnership();' /></form>";
        $('chOwner').focus();
    }

    if (field=='log'){
        $(id).innerHTML = "<textarea class='textbox' WRAP='virtual' rows=10 cols=80 id='ch"+id+"'>"+rmbr($(id).innerHTML)+"</textarea>";
        $('editLinks_'+id).innerHTML = "<a class='liveupdate' href=\"javascript:SaveEditMessage('"+id+"','"+fuse+"','"+action+"');\">"+lang('Save')+"</a>&nbsp;&nbsp;&nbsp;<a class='liveupdate' href=\"javascript:CancelEditMessage('"+id+"','"+fuse+"');\">"+lang('Cancel')+"</a>";
        $('ch'+id).focus();
    }

    if (field=='assignee'){
    	setStatus('Retrieving List...');
        new Ajax.Request('index.php?fuse=support&action='+action+'&ticketId='+$('ticketid').value+'&clientId='+$('ticket_owner_id').value +'&execute=load',{
                                    onComplete    : setAssignee});
    }

    if (field=='type'){

        oldvalue = $('originalType').value;
    
        var select = "<select style='width:150px;' onChange=\"ChangeType('"+$('ticketid').value+"','"+fuse+"','"+action+"');\" id='chType' name='chType'>";
        typeHash.each(function(pair) {
        	if(oldvalue == pair.key){
        	  selected="SELECTED";
        	}else{
        	  selected="";
        	}
            select = select+"<option "+selected+" value='"+pair.value+"'>"+varLang(pair.key)+"</option>";
        });
        $(id).innerHTML = select+"</select>";
        $('chType').focus();
    }

    if (field =='domain'){
    	setStatus('Retrieving List...');    
        new Ajax.Request('index.php?fuse=support&selectedDomain='+$('originalDomain').value+'&action=SetDomain_Async&clientId='+$('ticket_owner_id').value +'&execute=load',{
                                    onComplete    : setDomains});
    }
}

function setDomains(t){
   $('tdDomain').innerHTML = t.responseText;
   unsetStatus('', 1);  
}

function setAssignee(t){
    var responseArr = t.responseText.split('|');
    if (typeof responseArr[1] == 'undefined' || responseArr[0] != 'OK') {
        alert(t.responseText.stripTags());
        return;
    }

   $('assignedtoname').innerHTML = responseArr[1];   
    unsetStatus('', 1);     
}

function ChangeDomain()
{
    new Ajax.Request('index.php?fuse=support&action=SetDomain_Async&ticketId='+$('ticketid').value+'&clientId='+$('ticket_owner_id').value +'&domainId='+$('domainId').value+'&execute=save',{
                                onLoading     : function(request) {resetStatus(lang('Loading'))},
                                onComplete    : changeDomainsSuccess});
}

function changeDomainsSuccess(t)
{
	//get new plan information as well
	var response = t.responseText.split('||');
    $('tdDomain').innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('tdDomain','support','SetDomain_Async','domain');\">"+response[0]+"</a>";
    $('originalDomain').value = response[0];
    $('ticket_packagename').innerHTML = response[1];
    unsetStatus('', 1);    
}


function ChangeType(ticket, fuse, action)
{
    var type = $('chType').value;
	setStatus('Changing Ticket Type...');
	var opt = {
		method: 'post',
		postBody: 'ticket='+ticket+'&type='+type,			
		onSuccess: ChangeTypeSuccess,
		on404: on404,
		onFailure: onFailure
	}		
	new Ajax.Request('index.php?fuse='+fuse+'&action='+action, opt);
}

function ChangeTypeSuccess(t)
{
    var response = t.responseText.split('|');
    $('tdType').innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('tdType','support','SetType_Async','type');\">"+varLang(response[1])+"</a>";
    $('originalType').value = response[1];
    unsetStatus('', 1);

    changeTicketType(response[0]);
}

function DeleteLog(log,fuse,action)
{    
    if (fuse == 'support'){
        var logid = log.substring(4,log.length);
    }else{
        var logid = $(log.substring(4)).value;
    }
    strMessage = lang('Click OK if you are sure you want to delete the selected entry.');
    var answer = confirm(strMessage);
    if (!answer)return;
    setStatus('Deleting Log Message...');
    var opt = {
		method: 'post',
		postBody: 'log='+logid+'&logid='+log.substring(4,log.length),			
		onSuccess: DeleteLogSuccess,
		on404: on404,
		onFailure: onFailure
	}
	new Ajax.Request('index.php?fuse='+fuse+'&action='+action, opt);
}

function DeleteLogSuccess(t)
{        
    ret = t.responseText.split('|');
    $('div_log_'+ret[0]).innerHTML = '';
    unsetStatus('', 1);
}

function CancelEditMessage(id, fuse, action)
{
    $(id).innerHTML = nl2br($('ch'+id).value);
    if (fuse == 'support'){
        $('editLinks_'+id).innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('"+id+"','support','EditTicketLog_Async','log');\">"+lang('Edit')+"</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class='liveupdate' href=\"javascript:DeleteLog('"+id+"','support','DeleteTicketLog_Async');\">"+lang('Delete')+"</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";        
    }else{
        $('editLinks_'+id).innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('"+id+"','knowledgebase','KB_UpdateComment_Async','log');\">"+lang('Edit')+"</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class='liveupdate' href=\"javascript:DeleteLog('"+id+"','knowledgebase','KB_DeleteComment_Async');\">"+lang('Delete')+"</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";        
    }
}

function SaveEditMessage(log,fuse,action)
{ 
    var message = $('ch'+log).value;
    if (fuse =='support'){
        var ticket = $('ticketid').value;
    }else{        
        var ticket = $(log.substr(4)).value;
    }        
    var logid = log.substring(4,log.length);
    setStatus('Editing Log Message...');
    var opt = {
		method: 'post',
		postBody: 'log='+logid+'&message='+encodeURIComponent(message)+'&id='+encodeURIComponent(ticket),
		onSuccess: SaveEditMessageSuccess,
		on404: on404,
		onFailure: onFailure
	}
	new Ajax.Request('index.php?fuse='+fuse+'&action='+action, opt);
}

function SaveEditMessageSuccess(t)
{
    var ret = t.responseText.split("|");
    var x;
    var message = ret[1];
    $('log_'+ret[0]).innerHTML = nl2br(message);
    $('editLinks_log_'+ret[0]).innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('log_"+ret[0]+"','"+ret[2]+"','"+ret[3]+"','log');\">"+lang('Edit')+"</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class='liveupdate' href=\"javascript:DeleteLog('log_'"+ret[0]+",'"+ret[2]+"','"+ret[4]+"');\">"+lang('Delete')+"</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    unsetStatus('', 1);
}

function ChangeSubject(ticket,fuse,action)
{
    var subject = $('chSubject').value;
	if(subject==$('originalSubject').value || subject == ''){
	    $('tdSubject').innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('tdSubject','support','SetSubject_Async','subject');\">"+$('originalSubject').value+"</a>";
	    return;
	}
	
	setStatus('Changing Ticket Subject...');
	var opt = {
		method: 'post',
		postBody: 'ticket='+ticket+'&subject='+encodeURIComponent(subject),			
		onSuccess: ChangeSubjectSuccess,
		on404: on404,
		onFailure: onFailure
	}		
	new Ajax.Request('index.php?fuse='+fuse+'&action='+action, opt);
}

function confirmChangeOwnership()
{
    return confirm(lang("NOTE: This operation will move all the tickets from this E-mail to the user whose ID you just entered.\nAlso, this E-mail will be added as an alternate address for support requests for this user."));
}

function ChangeSubjectSuccess(t)
{
    $('tdSubject').innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('tdSubject','support','SetSubject_Async','subject');\">"+t.responseText+"</a>";
    $('originalSubject').value = t.responseText;
    unsetStatus('', 1);
}

function itemSelected(form){
    strAlertMessage = '\n' + lang("You need to select entry(s) to perform this action on");
    intCount = document.forms['troubletickets'].elements.length;
    bolShowMessage = true;
    for (x=1;x<=intCount;x++)
    {
        if (document.forms['troubletickets'].elements[x-1].checked == true){
             bolShowMessage=false;
        }
    }

    if (bolShowMessage){    
        alert(strAlertMessage);
        document.forms['assignadmin'].elements['adminid'].selectedIndex=0;
        return false;
    }else{
        return true;
    }
}

function submitDelete(myform){
    strMessage = '\n' + lang('Click OK if you are sure you want to delete the selected entries');
    strWorkItems = "";
    intItemChecked=0;

    intCount = document.forms['troubletickets'].elements.length;    
    
    for (x=1;x<=intCount;x++)
    {
        if (document.forms['troubletickets'].elements[x-1].checked == true){
             strWorkItems += document.forms['troubletickets'].elements[x-1].value;
             strWorkItems += " ";
             intItemChecked++;
        }
    }

    var tString;
    String(tString);
    tString = (strWorkItems.substring(0,strWorkItems.length-1));    
    myform.selectedworks.value=tString; 

    var answer=confirm(strMessage);
    if (answer){
        submitonce(myform);
        myform.submit();
    }
}

function submitAdminEntries(myform){
    strWorkItems = "";
    intItemChecked=0;

    for (x=1;x<=intCount;x++)
    {
        if (document.forms['troubletickets'].elements[x-1].checked == true){
             strWorkItems += document.forms['troubletickets'].elements[x-1].value;
             strWorkItems += " ";
             intItemChecked++;
        }
    }

    var tString;
    String(tString);
    tString = (strWorkItems.substring(0,strWorkItems.length-1));
    myform.selectedworks.value=tString;
    submitonce(myform);
    myform.submit();
}

function highPriorityWarning(myform){
    if (myform.options[myform.selectedIndex].value=="1"){
        strMessage = '\n' + lang('Click OK to confirm this is a high priority ticket');
        var answer=confirm(strMessage);
        if (!answer){
            myform.selectedIndex=2;
        }
    }
}

var globalNumberFieldCount = 1;

function Clon(clon)
{
    
    var newId;
    var newName;
    var newValue;

    newField = $(clon).cloneNode(true);
    inputField = newField.getElementsByTagName("input");
    linkDelete = newField.getElementsByTagName("a");
    newId = clon + globalNumberFieldCount;
    newName = clon + globalNumberFieldCount;
    newValue = '';
    inputField[0].setAttribute("id", newId);
    inputField[0].setAttribute("name", newName);
    inputField[0].value=newValue;
    linkDelete[0].style.visibility = "visible";
    $('fileFieldsContainer').appendChild(newField);
    globalNumberFieldCount++;
 }   

function remove(element) 
{
        
    element.parentNode.parentNode.removeChild(element.parentNode);
}

function itemsFilledOut(form){
    strAlertMessage = lang("You must complete all the fields before proceeding");
    bolShowMessage = false;
    
 	if (typeof document.forms['SupportForm'].messagetype != 'undefined' &&  document.forms['SupportForm'].messagetype.value == 0){
         strAlertMessage += '\n' + lang("Select a valid ticket type");
         bolShowMessage = true;
    }

 	if (typeof document.forms['SupportForm'].subject  != 'undefined' && document.forms['SupportForm'].subject.value == ""){
         strAlertMessage += '\n' + lang("You can not leave the subject blank");
         bolShowMessage = true;
    }

 	if ($('fileFieldsContainer')== null || someFilesFieldsEmpty('fileFieldsContainer')){
        if (typeof document.forms['SupportForm'].message != 'undefined' && document.forms['SupportForm'].message.value == ""){
     		 strAlertMessage += '\n' + lang("You can not leave the message blank");
             bolShowMessage = true;
        }
 	 }

    if (bolShowMessage){
        alert(strAlertMessage);
        return false;
    }

    return true;
}

function submitTicketLog(form, skipSummaryForm)
{
    if (!itemsFilledOut(form)) {
        return false
    }

    if (skipSummaryForm || form.ticketstatus.value != -1 || form.usertype.value == 0) {
        return true;
    }

    jsPopup($('divTicketSummary').innerHTML, false);
    return false;
}

function submitClosedTicket(form, saveSummary)
{
    if (saveSummary) {
        document.forms['SupportForm'].ticketSummary.value = form.textareaTicketSummary.value;
    }
    
    submitonce(document.forms['SupportForm']);
    document.forms['SupportForm'].submit();
}

function someFilesFieldsEmpty(element) 
{
    var emptyEvaluation = true;
    var arrayPosition = 0;
    
    var newElement = $(element);

    var newArrayCollection = newElement.getElementsByTagName("input");
    
    for(var i=0; i < newArrayCollection.length; i++){

        if(newArrayCollection[i].value != ''){
            emptyEvaluation = false;   
        }
    }
    
    return emptyEvaluation;
}

function changeTicketType(ticketId, getArgs){
	setStatus(lang('Loading related articles and notes'));
    if (!getArgs) {
        getArgs = '';
    }

	var opt = {
		method: 'post',
		postBody: 'ticketId=' + ticketId,
		onSuccess: applyTicketTabs,
		on404: on404,
		onFailure: onFailure
	}		
	new Ajax.Request('index.php?fuse=support&view=GetTicketTabs' + getArgs, opt);
}
function applyTicketTabs(t){

	var responseArr = t.responseText.split('|');
    if (typeof responseArr[1] == 'undefined' || responseArr[0] != 'OK') {
        alert(t.responseText.stripTags());
        return;
    }
	var content = responseArr[1];
    $('ajaxTabs').innerHTML += content;
    unsetStatus('', 1);     
}

function loadStaffNotesInSupport(selectedId){
	setStatus('Loading Notes');
	var opt = {
		method: 'post',
		postBody: 'selectedId='+selectedId,
		onSuccess: applyStaffNotes,
		on404: on404,
		onFailure: onFailure
	}		
	new Ajax.Request('index.php?fuse=support&view=TicketNotes', opt);
}

function applyStaffNotes(t){
	if(t.responseText.substr(0, 11) == "selectedId=") {
		$('tickettab_notes_tab').style.display = 'none';
		$('activetickettab').innerHTML = "";
        var ticketId = t.responseText.substr(11);
		cSelectTab('support','TicketTab_Messages','tickettab_messages','tickettab','activetickettab','selectedId=' + ticketId + '&from=ViewTicketDetails');
	}else{
		$('activetickettab').innerHTML = t.responseText;
	}
	unsetStatus('', 1);  
}

function showTicketDetails()
{
    $('ticketNotesDiv').style.display = 'none';
    $('ticketDetailsDiv').style.display = 'block';
}

function RateArticle(rate)
{
    var articleId = $('articleId').value;
    new Ajax.Request( 'index.php?fuse=knowledgebase&action=KB_RateArticle&rating=' + rate +'&articleId=' + articleId,
                      {
                          onSuccess     : showResponseRateArticle,
                          onComplete    : function(request) {        setStatus(lang('Article Rated'), 500)}
                      }
                    );
}

function showResponseRateArticle(originalRequest)
{				    
    var response = originalRequest.responseText;
    var arrayResponse = response.split("|");
    if (arrayResponse.length >1){
        $('starRating').innerHTML = "<img src='templates/Raleigh/views/knowledgebase/images/star_"+arrayResponse[0]+".gif'>";
        $('textRating').innerHTML = "<b>"+arrayResponse[1]+"</b>&nbsp;/&nbsp;5&nbsp;("+arrayResponse[2]+"&nbsp;"+arrayResponse[3]+"&nbsp;cast)";
    }else{
        alert (arrayResponse);
    }    		
}

function AddComment()
{
    var articleId = $('articleId').value;
    var user = $('userName').value;
    var email = $('userEmail').value;
    var comment = $('userComment').value;
    var private = 0;
    var pars = '&articleId=' + articleId 
              + '&user=' + user 
              + '&email='+ email 
              + '&comment=' + comment 
              + '&private=' + private
    new Ajax.Request( 'index.php?fuse=knowledgebase&action=KB_AddComment',
                      {
                          method        : 'post',
                          parameters    : pars,
                          onSuccess     : showResponseAddComment,
                          onComplete    : function(request) {        setStatus(lang('Comment Posted'), 500)}
                      }
                    );
}

function showResponseAddComment(originalRequest)
{				    
    var response = originalRequest.responseText;
    var arrayResponse = response.split("|");
    var html = "";
    for (var i = 0; i < arrayResponse.length -1; i++){
        var arrayComments = arrayResponse[i].split('**');
        var 
        html = html + "<tr><td colspan='8' style='padding:5px'><i>["+ arrayComments[0] +"] - " + arrayComments[1] +"</i></td></tr><tr><td colspan='8' style='padding:5px'>"+arrayComments[2]+"</td></tr>";
    }		
    window.location.reload( false );
}
