function ToggleSecondOptionsPanel()
{
    //0 normal reply , 1 internal commment
    selection = document.getElementById('replytype').selectedIndex;
    if (selection == 0){
        document.getElementById('secondOptionsPanel').style.visibility = 'visible';
        document.getElementById('private').value = 0;
    } else if (selection == 1) {
        document.getElementById('secondOptionsPanel').style.visibility = 'hidden';
        document.getElementById('private').value = 1;
    }
}

function AddCannedResponse()
{
    //obtain response text via ajax - with signature attached
    Ext.Ajax.request({
       url: 'index.php?fuse=support&action=getCannedResponse',
       success: function(t) {
           json = ce.parseAjaxResponse(t);
           document.getElementById('message').value = json.response;
       },
       params: {responseid : $('#cannedresponse').val()}
    });
    document.getElementById('cannedresponse').selectedIndex = 0;
}

function assignTicket(ticketId, adminId, reassign)
{
    if (adminId == 0) {return;}

    if (reassign) {

        Ext.Ajax.request({
           url: 'index.php?fuse=support&action=ReasignTicket_Async',
           success: function(t) {
                json = ce.parseAjaxResponse(t);

                document.getElementById('assignedtoname').innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('assignedtoname','support','GetReassignDropdown_Async','assignee');\">"+json.assigneeName+"</a>";
			    document.getElementById('assignedtodept').innerHTML = json.dept;
			    var assignedToId = document.getElementById('assignedToId');
			    var userId = document.getElementById('userId')

			    if(assignedToId != null && userId != null) {
			        assignedToId.value = json.assigneeId;
			        if(assignedToId.value == userId.value) {
			            document.getElementById("btnSubscribe").style.display = "none";
			        } else  {
			            document.getElementById("btnSubscribe").style.display = "";
			        }
			    }

				callTicketSummaries();

           },
           params: {ticket : ticketId, adminid: adminId, from: "ViewTicketDetails"}
        });

    } else {

        Ext.Ajax.request({
           url: 'index.php?fuse=support&action=AssignTickets_Async',
           success: function(t) {
               ce.parseAjaxResponse(t);
           },
           params: {items : ticketId, adminid: adminId, from: "ViewTicketDetails"}
        });

    }
}

function ChangePriority(ticket,fuse,action){
    var priority = document.getElementById('chPriority').value;
        Ext.Ajax.request({
           url: 'index.php?fuse='+fuse+'&action='+action,
           success:function(t) {
				if(t.responseText=='1'){
			    	priorityTxt =  lang('High');
			    }
			    if(t.responseText=='2'){
			    	priorityTxt =  lang('Medium');
			    }
			    if(t.responseText=='3'){
			    	priorityTxt =  lang('Low');
			    }
			    document.getElementById('tdPriority').innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('tdPriority','support','SetPriority_Async','priority');\">"+priorityTxt+"</a>";
			    document.getElementById('originalPriority').value = t.responseText;
	            callTicketSummaries();
           },
           params: {ticket : ticket, priority: priority}
        });
}

function ChangeStatus(ticket,fuse,action){
    var status = document.getElementById('chStatus').value;
    Ext.Ajax.request({
       url: 'index.php?fuse='+fuse+'&action='+action,
       success: function(t) {
            json = ce.parseAjaxResponse(t);
            document.getElementById('ticket_status_link').innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('ticket_status_link','support','SetStatus_Async','status');\">"+json.statusName+"</a>";
            document.getElementById('originalStatus').value = json.status;
            window.location.reload();
       },
       params: {ticket : ticket, status: status}
    });

}

function ShowEditBox(id,fuse,action,field){

    if (field=='priority'){
    	oldvalue = document.getElementById('originalPriority').value;

        content = "<select style='width:100px' id='chPriority' name='chPriority' onChange=\"ChangePriority('"+document.getElementById('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>";
        document.getElementById(id).innerHTML = content;
	    document.getElementById('chPriority').focus();
    }

    if (field=='status'){
    	oldvalue = document.getElementById('originalStatus').value;
        //ce.log(1,oldvalue);
        content = "<select style='width:150px;' id='chStatus' name='chStatus' onChange=\"ChangeStatus('"+document.getElementById('ticketid').value+"','"+fuse+"','"+action+"');\">";
        if(oldvalue == 3){
        	content += "<option value=3 selected='selected'>"+lang('Waiting on customer')+"</option>";
        }else{
        	content += "<option value=3>"+lang('Waiting on customer')+"</option>";
        }

        if(oldvalue == 2){
        	content += "<option value=2 selected='selected'>"+lang('Waiting on tech')+"</option>";
        }else{
        	content += "<option value=2>"+lang('Waiting on tech')+"</option>";
        }

        if(oldvalue == 1){
        	content += "<option value=1 selected='selected'>"+lang('Open')+"</option>";
        }else{
        	content += "<option value=1>"+lang('Open')+"</option>";
        }


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

        content += "</select>";
        document.getElementById(id).innerHTML = content;
	    document.getElementById('chStatus').focus();
    }

    if (field=='subject'){
        document.getElementById(id).innerHTML = "<input type='text' size='40' id='chSubject' name='chSubject' value='"+document.getElementById('originalSubject').value+"' /> <input type=button value=' "+lang('update')+" ' onClick=\"ChangeSubject('"+document.getElementById('ticketid').value+"','"+fuse+"','"+action+"');\" />";
        document.getElementById('chSubject').focus();
    }

    /*
    if (field == 'owner') {
        document.getElementById(id).innerHTML = lang("Migrate to user ID:") + "<form style='display:inline;padding-left:27px;' method='post' action='index.php?fuse="+ fuse +"&action=" + action + "'><input type='hidden' name='oldview' value='"+oldview+"' /><input type='hidden' name='ticket' value='"+ document.getElementById("ticketid").value +"' /><input type='text' size='10' name='userId' value='' /> <input style='position:relative;top:-2px;' type='submit' value='" + lang("go") + "' class='button_small' onclick='return confirmChangeOwnership();' /></form>";
        document.getElementById('chOwner').focus();
    }
    */

    if (field=='log'){
        document.getElementById(id).innerHTML = "<textarea class='textbox' wrap='virtual' rows=5 cols=53 id='ch"+id+"'>"+rmbr(document.getElementById(id).innerHTML)+"</textarea>";
        document.getElementById('editLinks_'+id).innerHTML = "<a class='liveupdate' style='font-size:11px;' href=\"javascript:SaveEditMessage('"+id+"','"+fuse+"','"+action+"');\">"+lang('Save')+"</a>&nbsp;&nbsp;<a class='liveupdate' style='font-size:11px;' href=\"javascript:CancelEditMessage('"+id+"','"+fuse+"');\">"+lang('Cancel')+"</a>";
        document.getElementById('ch'+id).focus();
    }

    if (field=='assignee'){

        Ext.Ajax.request({
           url: 'index.php?fuse=support&action='+action,
           success: function(t) {
                setAssignee(t);
                callTicketSummaries();
           },
           params: {ticketId : document.getElementById('ticketid').value,
                    clientId: document.getElementById('ticket_owner_id').value,
                    execute: 'load'}
        });

    }

    if (field=='type'){

        oldvalue = document.getElementById('originalType').value;

        var select = "<select style='width:123px;' onChange=\"ChangeType('"+document.getElementById('ticketid').value+"','"+fuse+"','"+action+"');\" id='chType' name='chType'>";
        for (var n in typeHash) {
          var v = typeHash[n];
          if(oldvalue == v[0]){
            selected="SELECTED";
          }else{
            selected="";
          }
          select = select+"<option "+selected+" value='"+v[1]+"'>"+varLang(v[0])+"</option>";
        }
        document.getElementById(id).innerHTML = select+"</select>";
        document.getElementById('chType').focus();
    }

    if (field =='domain'){

        Ext.Ajax.request({
           url: 'index.php?fuse=support&action=assignProductIdToTicket',
           success: function(t) {
                setDomains(t);
           },
           params: {selectedDomain : document.getElementById('originalDomain').value,
                    clientId: document.getElementById('ticket_owner_id').value,
                    execute: 'load'}
        });
    }
}

function setDomains(t){
   document.getElementById('tdDomain').innerHTML = t.responseText;
}

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

   document.getElementById('assignedtoname').innerHTML = responseArr[1];
}

function ChangeDomain()
{

     Ext.Ajax.request({
           url: 'index.php?fuse=support&action=assignProductIdToTicket',
           success: function(t) {
                changeDomainsSuccess(t);
           },
           params: {ticketId : document.getElementById('ticketid').value,
                    clientId: document.getElementById('ticket_owner_id').value,
                    domainId:document.getElementById('domainId').value,
                    execute:'save'}
     });

}

function changeDomainsSuccess(t)
{
	//get new plan information as well
	var response = t.responseText.split('||');
	var packagelink = response[0].split('--');
	var id = response[0].split(' ');
	id = id[0].substring(1);
	if(packagelink.length > 1){
	    document.getElementById('tdDomain').innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('tdDomain','support','assignProductIdToTicket','domain');\">"+packagelink[0]+"</a>&nbsp;&nbsp;"+packagelink[1]+"&nbsp;&nbsp;";
	}else{
	    document.getElementById('tdDomain').innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('tdDomain','support','assignProductIdToTicket','domain');\">"+response[0]+"</a>&nbsp;&nbsp;";
	}
    document.getElementById('originalDomain').value = id;
    //document.getElementById('ticket_packagename').innerHTML = response[1];
}


function ChangeType(ticket, fuse, action)
{
    var type = document.getElementById('chType').value;

    Ext.Ajax.request({
        url: 'index.php?fuse='+fuse+'&action='+action,
        params: {type:type, ticket:ticket},
        success: ChangeTypeSuccess
    });

}

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

    changeTicketType(response[0]);
    loadCustomFields()
    callTicketSummaries();
}

function DeleteLog(log,fuse,action)
{
    if (fuse == 'support'){
        var logid = log.substring(4,log.length);
    }else{
        var logid = document.getElementById(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;

    Ext.Ajax.request({
        url: 'index.php?fuse='+fuse+'&action='+action,
        params: {log:logid, logid:log.substring(4,log.length)},
        success: DeleteLogSuccess
    });

}

function DeleteLogSuccess(t)
{
    ret = t.responseText.split('|');
    document.getElementById('div_log_'+ret[0]).innerHTML = '';
}

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

function SaveEditMessage(log,fuse,action)
{
    var message = document.getElementById('ch'+log).value;
    var ticket;
    if (fuse =='support'){
        ticket = document.getElementById('ticketid').value;
    }else{
        ticket = document.getElementById(log.substr(4)).value;
    }
    var logid = log.substring(4,log.length);

    Ext.Ajax.request({
        url: 'index.php?fuse='+fuse+'&action='+action,
        params: {log:logid, message:message, id:ticket},
        success: SaveEditMessageSuccess
    });

}

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

function ChangeSubject(ticket,fuse,action)
{
    var subject = document.getElementById('chSubject').value;
	if(subject==document.getElementById('originalSubject').value || subject == ''){
	    document.getElementById('tdSubject').innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('tdSubject','support','SetSubject_Async','subject');\">"+document.getElementById('originalSubject').value+"</a>&nbsp;&nbsp;&nbsp;";
	    return;
	}

    Ext.Ajax.request({
        url: 'index.php?fuse='+fuse+'&action='+action,
        params: {subject:subject, ticket:ticket},
        success: ChangeSubjectSuccess
    });

}

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)
{
    document.getElementById('tdSubject').innerHTML = "<a class='liveupdate' href=\"javascript:ShowEditBox('tdSubject','support','SetSubject_Async','subject');\">"+t.responseText+"</a>&nbsp;&nbsp;&nbsp;";
    document.getElementById('originalSubject').value = t.responseText;
}

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 = document.getElementById(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";
    linkDelete[0].setAttribute("href", "javascript:removefilefield('"+"delete_"+globalNumberFieldCount+"');");

    linkDelete[0].setAttribute("id", "delete_"+globalNumberFieldCount);
    document.getElementById('fileFieldsContainer').appendChild(newField);
    globalNumberFieldCount++;
 }

function removefilefield(id){
    document.getElementById(id).parentNode.parentNode.removeChild(document.getElementById(id).parentNode);
}

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 (document.getElementById('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 CheckForTicketResolution(){
    /* TODO4.2 ReopenTicket*/
    if(document.getElementById('ticketstatus').value == -1){
        //show the add ticket resolution
        document.getElementById('divTicketResolution').style.display = "";
            /*document.getElementById('reopenticket').style.display = ""; */
    }else{
        //do not show the ticket resolution option
        document.getElementById('divTicketResolution').style.display = "none";
        /*document.getElementById('reopenticket').style.display = "none";*/
    }
}

function showResultText(btn, text){
    submitClosedTicket(text, true)
}

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

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

    Ext.MessageBox.show({
           title: 'Ticket Summary',
           msg: 'Please enter your summary of this ticket:',
           width:400,
           buttons: Ext.MessageBox.OKCANCEL,
           multiline: true,
           fn: showResultText,
           animEl: 'mb3'
       });

    return false;
}

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

    submitonce(document.forms['SupportForm']);
    document.forms['SupportForm'].submit();
}

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

    var newElement = document.getElementById(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){
        if (!getArgs) {
            getArgs = '';
        }

        Ext.Ajax.request({
           url: 'index.php?fuse=support&view=GetTicketTabs' + getArgs,
           success: function(t) {
                applyTicketTabs(t);
           },
           params: {nolog : '1',
                    mainView: gView,
                    ticketId:ticketId}
        });

}

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];
    document.getElementById('ajaxTabs').innerHTML += content;
}

function loadStaffNotesInSupport(selectedId){

        Ext.Ajax.request({
           url: 'index.php?fuse=support&view=TicketNotes',
           success: function(t) {
                applyStaffNotes(t);
           },
           params: {selectedId : selectedId}
        });

}

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

function RateArticle(rate)
{
    var articleId = document.getElementById('articleId').value;

    Ext.Ajax.request({
       url: 'index.php?fuse=knowledgebase&action=KB_RateArticle',
       success: function(t) {
            showResponseRateArticle(t);
       },
       params: {rating : rate,
                articleId : articleId}
    });


}

function showResponseRateArticle(originalRequest)
{
    var response = originalRequest.responseText;
    var arrayResponse = response.split("|");
    if (arrayResponse.length >1){
        document.getElementById("ratearticle").innerHTML = lang("Thank you for rating this article");
    }else{
        alert (arrayResponse);
    }
}

function AddComment()
{
    var articleId = document.getElementById('articleId').value;
    var user = document.getElementById('userName').value;
    var email = document.getElementById('userEmail').value;
    var comment = document.getElementById('userComment').value;

    Ext.Ajax.request({
       url: 'index.php?fuse=knowledgebase&action=KB_AddComment',
       success: function(t) {
            showResponseAddComment(t);
       },
       params: {articleId : articleId,
                user : user,
                email: email,
                comment: comment,
                private: 0}
    });
}

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('**');
        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 );
}

function checkEscalationForm()
{
    var isPrioritySelected = false;
    for (var i = 0; i < document.getElementById('ticketPriority').options.length; i++)
    {
        if (document.getElementById('ticketPriority').options[i].selected)
        {
            isPrioritySelected = true;
            break;
        }
    }

    if (!isPrioritySelected)
    {
        alert(lang("Please select a ticket priority"));
    } else {
        document.getElementById('escalationForm').submit();
    }
}
