//'####################################################################
//' FILE: class_ajax.js
//'
//' AUTHOR: Kevin Wroblewski
//' DATE: 12/14/2006
//' DESCRIPTION: Suite of functions for the hh2 Ajax VB Class
//' REQ. INPUTS:
//'####################################################################

//--------------------------------------------------------------------
// DECLARATIONS
//--------------------------------------------------------------------
var boolHH2AjaxIsPDA = false;
var boolHH2AjaxReconnecting = false;
var arrHH2AjaxRequest = new Array();
var arrHH2AjaxCurrentObjectInstance = new Array();
var arrHH2AjaxObject = new Array();
var arrHH2AjaxStatus = new Array();
var arrHH2AjaxURL = new Array();
var arrHH2AjaxAttemptCount = new Array();
var arrHH2AjaxAttemptMax = new Array();
var arrHH2AjaxData = new Array();
var arrHH2AjaxDisabledButton = new Array();
var intHH2AjaxInstanceID = 0;
var intHH2AjaxCollectionID = 1;
var boolValidObject = true;
var boolHH2AjaxReconnecting = false;

//--------------------------------------------------------------------
// hh2AjaxGetObject()
//--------------------------------------------------------------------
function hh2AjaxGetObject(strHH2AjaxObjectID) {
    if (boolHH2AjaxIsPDA == true) {
        eval("strHH2AjaxTestObjectID=" + strHH2AjaxObjectID + ";");
        return strHH2AjaxTestObjectID;
    }
    else {
        return document.getElementById(String(strHH2AjaxObjectID));
    }
}

//--------------------------------------------------------------------
// hh2AjaxInitiateConnection()
//--------------------------------------------------------------------
function hh2AjaxInitiateConnection() {
    intHH2AjaxInstanceID = (intHH2AjaxInstanceID + 1);
    if (window.XMLHttpRequest) {
        arrHH2AjaxRequest[intHH2AjaxInstanceID] = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        arrHH2AjaxRequest[intHH2AjaxInstanceID] = new ActiveXObject("MSXML2.XMLHTTP");
    }
    return intHH2AjaxInstanceID;
}

//--------------------------------------------------------------------
// hh2AjaxDestroy()
//--------------------------------------------------------------------
function hh2AjaxDestroy(intIndexToDestroy) {
    arrHH2AjaxRequest[intIndexToDestroy] = null;
    arrHH2AjaxCurrentObjectInstance[intIndexToDestroy] = null;
    arrHH2AjaxStatus[intIndexToDestroy] = null;
    arrHH2AjaxAttemptCount[intIndexToDestroy] = null;
    arrHH2AjaxAttemptMax[intIndexToDestroy] = null;
    arrHH2AjaxData[intIndexToDestroy] = null;
    arrHH2AjaxDisabledButton[intIndexToDestroy] = null;
}

//--------------------------------------------------------------------
// hh2AjaxRequestContent()
//--------------------------------------------------------------------
function hh2AjaxRequestContent(strURL, strObjectID, intAjaxStatusType, strData) {

    //### STANDARD VERSION ###
    if (boolHH2AjaxIsPDA == false) {
        //Initiate Ajax
        var intHH2AjaxRequestID = hh2AjaxInitiateConnection();
        arrHH2AjaxObject[intHH2AjaxRequestID] = document.getElementById(String(strObjectID));
        //Check for validity
        if (isObject(arrHH2AjaxObject[intHH2AjaxRequestID]) == false) {
            return false;
        }
        //Ajax Progress Bar
        if (isObject(document.getElementById('ajaxProgressBar')) && strData.indexOf("progressbar=true") != -1) {
            document.getElementById('ajaxProgressBar').style.display = "inline";
            document.getElementById('ajaxProgressBar').src = "https://images.hh2.com/Legacy/ajax_progress_bar_0.gif";
        }
        //Reset Session Timer
        if (isObject(document.getElementById('sessionTimerTotal'))) {
            totalSec = document.getElementById('sessionTimerTotal').value;
            minSec = 60;
        }
        //Ajax Status
        if (intAjaxStatusType == "") {
            intAjaxStatusType = 3;
        }
        //Ajax Status Actions
        if (intAjaxStatusType == 4 && navigator.appName != "Microsoft Internet Explorer") {
            intAjaxStatusType = 3;
        }
        if (intAjaxStatusType == 0) {
            arrHH2AjaxObject[intHH2AjaxRequestID].style.cursor = "wait";
            arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = "&nbsp;";
        }
        else if (intAjaxStatusType == 1) {
            arrHH2AjaxObject[intHH2AjaxRequestID].style.cursor = "wait";
        }
        else if (intAjaxStatusType == 2) {
            arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = "Please Wait...";
        }
        else if (intAjaxStatusType == 3 || (intAjaxStatusType == 4 && arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML == "")) {
            if (findHeight(arrHH2AjaxObject[intHH2AjaxRequestID]) > 600) {
                //arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = "<table width='100%' height='100%'><tr><td align='center' valign='top' style='padding-top:250px;'><img src='https://images.hh2.com/Legacy/ajax_loading_content.gif' width='100' height='50'></td></tr></table>";
                arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = "<table width='100%' height='100%'><tr><td align='center' valign='top' style='padding-top:250px;'><table cellpadding='0' cellspacing='0'><tr><td align='center' valign='center' style='width:40px; height:40px;' background='https://images.hh2.com/Legacy/ajax_loader_container.gif'><img src='https://images.hh2.com/Legacy/ajax_loader_ani.gif' width='16' height='16'></td></tr></table></td></tr></table>";
            }
            else {
                //arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = "<table width='100%' height='100%'><tr><td align='center' valign='center'><img src='https://images.hh2.com/Legacy/ajax_loading_content.gif' width='100' height='50'></td></tr></table>";
                arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = "<table width='100%' height='100%'><tr><td align='center' valign='center'><table cellpadding='0' cellspacing='0'><tr><td align='center' valign='center' style='width:40px; height:40px;' background='https://images.hh2.com/Legacy/ajax_loader_container.gif'><img src='https://images.hh2.com/Legacy/ajax_loader_ani.gif' width='16' height='16'></td></tr></table></td></tr></table>";
            }
        }
        else if (intAjaxStatusType == 4) {
            //Float Loading Graphic
            var intZIndex = getZMax();
            var objAjaxStatusDiv = document.createElement("<div id='divAjaxLoadStatus" + intHH2AjaxRequestID + "' style='display:none; position:absolute; cursor:wait;'>&nbsp;</div>");
            document.body.insertBefore(objAjaxStatusDiv);
            var objAjaxStatusFrame = document.createElement("<iframe id='frameAjaxLoadStatus" + intHH2AjaxRequestID + "' style='display:none; position:absolute; Filter:Alpha(Opacity=0);' src='about:blank' frameBorder='0' scrolling='no'></iframe>");
            document.body.insertBefore(objAjaxStatusFrame);
            if (arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML == "") {
                arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = "<table cellpadding='0' cellspacing='0' width='100%' height='100%'><tr><td></td></tr></table>";
            }
            document.getElementById("frameAjaxLoadStatus" + intHH2AjaxRequestID).style.zIndex = intZIndex;
            document.getElementById("divAjaxLoadStatus" + intHH2AjaxRequestID).style.zIndex = (intZIndex + 1);
            document.getElementById("divAjaxLoadStatus" + intHH2AjaxRequestID).style.top = findPosY(arrHH2AjaxObject[intHH2AjaxRequestID]);
            document.getElementById("frameAjaxLoadStatus" + intHH2AjaxRequestID).style.top = findPosY(arrHH2AjaxObject[intHH2AjaxRequestID]);
            document.getElementById("divAjaxLoadStatus" + intHH2AjaxRequestID).style.top = findPosY(arrHH2AjaxObject[intHH2AjaxRequestID]);
            document.getElementById("frameAjaxLoadStatus" + intHH2AjaxRequestID).style.top = findPosY(arrHH2AjaxObject[intHH2AjaxRequestID]);
            document.getElementById("divAjaxLoadStatus" + intHH2AjaxRequestID).style.left = findPosX(arrHH2AjaxObject[intHH2AjaxRequestID]);
            document.getElementById("frameAjaxLoadStatus" + intHH2AjaxRequestID).style.left = findPosX(arrHH2AjaxObject[intHH2AjaxRequestID]);
            document.getElementById("divAjaxLoadStatus" + intHH2AjaxRequestID).style.width = findWidth(arrHH2AjaxObject[intHH2AjaxRequestID]);
            document.getElementById("frameAjaxLoadStatus" + intHH2AjaxRequestID).style.width = findWidth(arrHH2AjaxObject[intHH2AjaxRequestID]);
            document.getElementById("divAjaxLoadStatus" + intHH2AjaxRequestID).style.height = findHeight(arrHH2AjaxObject[intHH2AjaxRequestID]);
            document.getElementById("frameAjaxLoadStatus" + intHH2AjaxRequestID).style.height = findHeight(arrHH2AjaxObject[intHH2AjaxRequestID]);
            if (findHeight(arrHH2AjaxObject[intHH2AjaxRequestID]) > 600) {
                document.getElementById("divAjaxLoadStatus" + intHH2AjaxRequestID).innerHTML = "<table width='100%' height='100%'><tr><td align='center' valign='top' style='padding-top:250px;'>" + document.getElementById("divAjaxLoadingPopupTemplate").innerHTML + "</td></tr></table>";
            }
            else {
                document.getElementById("divAjaxLoadStatus" + intHH2AjaxRequestID).innerHTML = "<table width='100%' height='100%'><tr><td align='center' valign='center'>" + document.getElementById("divAjaxLoadingPopupTemplate").innerHTML + "</td></tr></table>";
            }
            document.getElementById("divAjaxLoadStatus" + intHH2AjaxRequestID).style.display = "block";
            document.getElementById("frameAjaxLoadStatus" + intHH2AjaxRequestID).style.display = "block";
        }
        //Execute Ajax
        arrHH2AjaxRequest[intHH2AjaxRequestID].open("POST", strURL, true);
        arrHH2AjaxRequest[intHH2AjaxRequestID].setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        arrHH2AjaxRequest[intHH2AjaxRequestID].onreadystatechange = function () {
            //State Changes
            if (arrHH2AjaxRequest[intHH2AjaxRequestID].readyState == 1) {
                if (isObject(document.getElementById('ajaxProgressBar')) && isNaN(strData.match("progressbar=true")) == true) {
                    document.getElementById('ajaxProgressBar').src = "https://images.hh2.com/Legacy/ajax_progress_bar_1.gif";
                }
            }
            else if (arrHH2AjaxRequest[intHH2AjaxRequestID].readyState == 2) {
                if (isObject(document.getElementById('ajaxProgressBar')) && isNaN(strData.match("progressbar=true")) == true) {
                    document.getElementById('ajaxProgressBar').src = "https://images.hh2.com/Legacy/ajax_progress_bar_2.gif";
                }
            }
            else if (arrHH2AjaxRequest[intHH2AjaxRequestID].readyState == 3) {
                if (isObject(document.getElementById('ajaxProgressBar')) && isNaN(strData.match("progressbar=true")) == true) {
                    document.getElementById('ajaxProgressBar').src = "https://images.hh2.com/Legacy/ajax_progress_bar_3.gif";
                }
            }
            else if (arrHH2AjaxRequest[intHH2AjaxRequestID].readyState == 4) {
                if (isObject(document.getElementById('ajaxProgressBar')) && isNaN(strData.match("progressbar=true")) == true) {
                    document.getElementById('ajaxProgressBar').src = "https://images.hh2.com/Legacy/ajax_progress_bar_4.gif";
                }
                //debug
                if (isNaN(arrHH2AjaxRequest[intHH2AjaxRequestID].responseText.match("debug")) == true) {
                    alert(arrHH2AjaxRequest[intHH2AjaxRequestID].responseText);
                }
                //Clear floating load image
                if (intAjaxStatusType == 4 && isObject(document.getElementById("divAjaxLoadStatus" + intHH2AjaxRequestID))) {
                    document.getElementById("divAjaxLoadStatus" + intHH2AjaxRequestID).innerHTML = "";
                    document.getElementById("divAjaxLoadStatus" + intHH2AjaxRequestID).style.display = "none";
                    document.getElementById("frameAjaxLoadStatus" + intHH2AjaxRequestID).style.display = "none";
                    document.getElementById("divAjaxLoadStatus" + intHH2AjaxRequestID).style.top = "1px";
                    document.getElementById("frameAjaxLoadStatus" + intHH2AjaxRequestID).style.top = "1px";
                    document.getElementById("divAjaxLoadStatus" + intHH2AjaxRequestID).style.left = "1px";
                    document.getElementById("frameAjaxLoadStatus" + intHH2AjaxRequestID).style.left = "1px";
                    document.getElementById("divAjaxLoadStatus" + intHH2AjaxRequestID).style.width = "1px";
                    document.getElementById("frameAjaxLoadStatus" + intHH2AjaxRequestID).style.width = "1px";
                    document.getElementById("divAjaxLoadStatus" + intHH2AjaxRequestID).style.height = "1px";
                    document.getElementById("frameAjaxLoadStatus" + intHH2AjaxRequestID).style.height = "1px";
                }
                if (arrHH2AjaxRequest[intHH2AjaxRequestID].status == 200) {
                    //size report
                    if (arrHH2AjaxRequest[intHH2AjaxRequestID].responseText.substr(0, 9) == "[getsize]") {
                        alert("REQUEST DATA:" + strData.length + " Bytes\n RETURN DATA:" + arrHH2AjaxRequest[intHH2AjaxRequestID].responseText.length + " Bytes");
                    }
                    //ajaxProcess
                    if (isObject(arrHH2AjaxObject[intHH2AjaxRequestID])) {
                        if (arrHH2AjaxObject[intHH2AjaxRequestID].id == "ajaxProcess") {
                            var newAJAX = document.getElementById('ajaxProcessCollection').insertCell(1);
                            newAJAX.innerHTML = arrHH2AjaxRequest[intHH2AjaxRequestID].responseText;
                        }
                        else {
                            //### Successful execution ###
                            //populate innerHTML
                            arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = arrHH2AjaxRequest[intHH2AjaxRequestID].responseText;
                            arrHH2AjaxObject[intHH2AjaxRequestID].style.cursor = "";
                        }
                    }
                }
                else {
                    //Error encountered
                    if (isObject(arrHH2AjaxObject[intHH2AjaxRequestID])) {
                        arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = "Error Encountered";
                        enableDiv(arrHH2AjaxObject[intHH2AjaxRequestID]);
                        arrHH2AjaxObject[intHH2AjaxRequestID].style.cursor = "";
                    }
                    ajaxError(intHH2AjaxRequestID, arrHH2AjaxRequest[intHH2AjaxRequestID].responseText);
                }
                hh2AjaxDestroy(intHH2AjaxRequestID);
            }
        }
        if (strData != "") {
            strData = strData.replace(/ /g, "%20");
            strData = strData.replace(/\n/g, "%0D");
        }
        arrHH2AjaxRequest[intHH2AjaxRequestID].send("ajaxRequest=true&" + strData);
        return false;
    }

    //### PDA VERSION ###
    if (boolHH2AjaxIsPDA == true) {
        objTarget = hh2AjaxGetObject(strObjectID);
        boolValidObject = isObject(objTarget);
        //Check Validity
        if (boolValidObject == false) {
            return false;
        }
        //Initiate Ajax
        var intHH2AjaxRequestID = hh2AjaxInitiateConnection();
        arrHH2AjaxObject[intHH2AjaxRequestID] = objTarget;
        arrHH2AjaxStatus[intHH2AjaxRequestID] = intAjaxStatusType;
        //Return if reconnecting
        if (boolHH2AjaxReconnecting == true) {
            return false;
        }
        //Mark Ajax Instance
        if (arrHH2AjaxObject[intHH2AjaxRequestID].id == "paneBody") {
            document.form1.intAjaxInstanceID.value = intHH2AjaxRequestID;
        }
        //Ajax Status
        if (arrHH2AjaxStatus[intHH2AjaxRequestID] == 0 || arrHH2AjaxStatus[intHH2AjaxRequestID] == "") {
            arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = "&nbsp;";
        }
        else if (arrHH2AjaxStatus[intHH2AjaxRequestID] == 1) {
            void (0);
        }
        else if (arrHH2AjaxStatus[intHH2AjaxRequestID] == 2) {
            arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = "Please Wait <i>(0%)</i>...";
        }
        else if (arrHH2AjaxStatus[intHH2AjaxRequestID] == 3) {
            arrHH2AjaxObject[intHH2AjaxRequestID].style.backgroundImage = "url('https://images.hh2.com/Legacy/pda/hh2_molecule_watermark.gif')";
            arrHH2AjaxObject[intHH2AjaxRequestID].style.backgroundRepeat = "no-repeat";
            arrHH2AjaxObject[intHH2AjaxRequestID].style.backgroundPosition = "bottom right";
            arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = "<table width='100%' height='100%'><tr><td valign='top'>Please Wait <i>(0%)</i>...</td></tr><tr><td align='center' valign='center' height='90%'><table cellpadding='0' cellspacing='0'><tr><td align='center' valign='center' style='width:40px; height:40px;' background='https://images.hh2.com/Legacy/ajax_loader_container.gif'><img src='https://images.hh2.com/Legacy/ajax_loader_ani.gif' width='16' height='16'></td></tr></table></td></tr></table>";
        }
        //Build Request
        arrHH2AjaxRequest[intHH2AjaxRequestID].open("POST", strURL, true);
        arrHH2AjaxRequest[intHH2AjaxRequestID].setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        arrHH2AjaxRequest[intHH2AjaxRequestID].onreadystatechange = function () {
            //Check Validity
            if (isObject(arrHH2AjaxObject[intHH2AjaxRequestID]) == false) {
                return false;
            }
            if (arrHH2AjaxObject[intHH2AjaxRequestID].id == "paneBody" && document.form1.intAjaxInstanceID.value != intHH2AjaxRequestID) {
                return false;
            }
            //Handle States
            if (arrHH2AjaxRequest[intHH2AjaxRequestID].readyState == 1 && typeof (arrHH2AjaxObject[intHH2AjaxRequestID]) != "undefined" && (arrHH2AjaxStatus[intHH2AjaxRequestID] == 2 || arrHH2AjaxStatus[intHH2AjaxRequestID] == 3)) {
                arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML.replace("(0%)", "(25%)")
                setTimeout("if(arrHH2AjaxRequest[" + intHH2AjaxRequestID + "].readyState==1&&boolHH2AjaxReconnecting==false){boolHH2AjaxReconnecting=true;paneBody.innerHTML='<b>Your PDA internet connection was reset.</b><br>Attempting to reconnect...<br><table width=100% border=0><tr><td align=center valign=center><br><br><img src=/images/pda/loading.gif></td></tr></table>';window.location.reload();}", 20000);
                setTimeout("if(arrHH2AjaxRequest[" + intHH2AjaxRequestID + "].readyState==1&&boolHH2AjaxReconnecting==true){paneBody.innerHTML='<b>Your PDA has lost its internet connection.</b><br>Connection could not be re-established. Please check your connectivity and reload your browser.';}", 60000);
            }
            else if (arrHH2AjaxRequest[intHH2AjaxRequestID].readyState == 2 && typeof (arrHH2AjaxObject[intHH2AjaxRequestID]) != "undefined" && (arrHH2AjaxStatus[intHH2AjaxRequestID] == 2 || arrHH2AjaxStatus[intHH2AjaxRequestID] == 3)) {
                arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML.replace("(0%)", "(50%)")
                arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML.replace("(25%)", "(50%)")
            }
            else if (arrHH2AjaxRequest[intHH2AjaxRequestID].readyState == 3 && typeof (arrHH2AjaxObject[intHH2AjaxRequestID]) != "undefined" && (arrHH2AjaxStatus[intHH2AjaxRequestID] == 2 || arrHH2AjaxStatus[intHH2AjaxRequestID] == 3)) {
                arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML.replace("(0%)", "(75%)")
                arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML.replace("(25%)", "(75%)")
                arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML.replace("(50%)", "(75%)")
            }
            else if (arrHH2AjaxRequest[intHH2AjaxRequestID].readyState == 4 && typeof (arrHH2AjaxObject[intHH2AjaxRequestID]) != "undefined") {
                if (arrHH2AjaxRequest[intHH2AjaxRequestID].status == 200) {
                    if (arrHH2AjaxRequest[intHH2AjaxRequestID].responseText == "<!-- invalid session -->") {
                        //Invalid session
                        hh2AjaxRequestContent("/pda/system/login.asp", "paneBody", 3, "");
                        return false;
                    }
                    else if (arrHH2AjaxRequest[intHH2AjaxRequestID].responseText == "<!-- expired session -->") {
                        //Expired session
                        hh2AjaxRequestContent("/pda/system/login.asp", "paneBody", 3, "bitExpired=1");
                        return false;
                    }
                    else {
                        //Successful process
                        if (arrHH2AjaxStatus[intHH2AjaxRequestID] == 3) {
                            arrHH2AjaxObject[intHH2AjaxRequestID].style.backgroundImage = "";
                            arrHH2AjaxObject[intHH2AjaxRequestID].style.backgroundRepeat = "";
                            arrHH2AjaxObject[intHH2AjaxRequestID].style.backgroundPosition = "";
                        }
                        arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = arrHH2AjaxRequest[intHH2AjaxRequestID].responseText;
                    }
                }
                else {
                    //Error encountered
                    if (arrHH2AjaxRequest[intHH2AjaxRequestID].status == "12031") {
                        if (arrHH2AjaxObject[intHH2AjaxRequestID].id == "paneBody") {
                            arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = "<i><b>Your PDA's internet connection was reset.</b><br>Attempting to reconnect...</i>";
                        }
                        window.location.reload();
                    }
                    else {
                        if (location.hostname == "siskovm") {
                            arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = "Ajax Error:\n" + arrHH2AjaxRequest[intHH2AjaxRequestID].responseText + " (status code:" + arrHH2AjaxRequest[intHH2AjaxRequestID].status + ")";
                        }
                        else {
                            if (arrHH2AjaxObject[intHH2AjaxRequestID].id == "divAjaxSession" || arrHH2AjaxObject[intHH2AjaxRequestID].id.substr(0, 13) == "divAjaxProcess") {
                                arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = "<!-- " + arrHH2AjaxRequest[intHH2AjaxRequestID].responseText + " -->";
                            }
                            else {
                                arrHH2AjaxObject[intHH2AjaxRequestID].innerHTML = "Error Encountered";
                            }
                        }
                    }
                }
            }
        }
        arrHH2AjaxRequest[intHH2AjaxRequestID].send("ajaxRequest=true&" + strData);
        return false;
    }

}

//--------------------------------------------------------------------
// hh2AjaxRequestElement()
//--------------------------------------------------------------------
function hh2AjaxRequestElement(strURL, strObjectID, intAttemptCount, intAttemptMax, strData) {
    //### STANDARD VERSION ###
    if (boolHH2AjaxIsPDA == false) {
        //Initiate Ajax
        var intHH2AjaxRequestID = hh2AjaxInitiateConnection();
        eval(strObjectID + 'InstanceID=' + intHH2AjaxRequestID + ';');
        arrHH2AjaxURL[intHH2AjaxRequestID] = strURL;
        arrHH2AjaxObject[intHH2AjaxRequestID] = document.getElementById(String(strObjectID));
        arrHH2AjaxAttemptCount[intHH2AjaxRequestID] = intAttemptCount;
        arrHH2AjaxAttemptMax[intHH2AjaxRequestID] = intAttemptMax;
        arrHH2AjaxData[intHH2AjaxRequestID] = strData;
        //Check for validity
        if (isObject(arrHH2AjaxObject[intHH2AjaxRequestID]) == false) {
            return false;
        }
        //Reset Session Timer
        if (isObject(document.getElementById('sessionTimerTotal'))) {
            totalSec = document.getElementById('sessionTimerTotal').value;
            minSec = 60;
        }
        //Change element to pending
        arrHH2AjaxObject[intHH2AjaxRequestID].className = "http_undefined_unsaved";
        //Execute
        arrHH2AjaxRequest[intHH2AjaxRequestID].open("POST", arrHH2AjaxURL[intHH2AjaxRequestID], true);
        arrHH2AjaxRequest[intHH2AjaxRequestID].setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        arrHH2AjaxRequest[intHH2AjaxRequestID].onreadystatechange = function () {
            if (arrHH2AjaxRequest[intHH2AjaxRequestID].readyState == 4) {
                if (arrHH2AjaxRequest[intHH2AjaxRequestID].status == 200) {
                    //Process Successful Response
                    if (arrHH2AjaxRequest[intHH2AjaxRequestID].responseText.indexOf("[ajaxprocess]") != -1) {
                        var objNewAjaxProcess = document.getElementById('ajaxProcessCollection').insertCell(1);
                        objNewAjaxProcess.innerHTML = arrHH2AjaxRequest[intHH2AjaxRequestID].responseText.replace("[ajaxprocess]", "");
                    }
                    if (arrHH2AjaxRequest[intHH2AjaxRequestID].responseText.indexOf("success") != -1) {
                        arrHH2AjaxObject[intHH2AjaxRequestID].className = "http_undefined_saved";
                        setTimeout('if(' + arrHH2AjaxObject[intHH2AjaxRequestID].id + 'InstanceID==' + intHH2AjaxRequestID + '){arrHH2AjaxObject[' + intHH2AjaxRequestID + '].className="";arrHH2AjaxObject[' + intHH2AjaxRequestID + ']=null;}', 2000)
                    }
                    else {
                        //Process Fail Response (#200)
                        arrHH2AjaxObject[intHH2AjaxRequestID].className = "http_undefined_error";
                    }
                    //Retry
                    if (arrHH2AjaxRequest[intHH2AjaxRequestID].responseText.indexOf("[ajaxParam:Retry]") != -1) {
                        if (arrHH2AjaxAttemptCount[intHH2AjaxRequestID] >= arrHH2AjaxAttemptMax[intHH2AjaxRequestID]) {
                            arrHH2AjaxObject[intHH2AjaxRequestID].className = "http_undefined_error";
                            return false;
                        }
                        else {
                            arrHH2AjaxAttemptCount[intHH2AjaxRequestID] = (arrHH2AjaxAttemptCount[intHH2AjaxRequestID] + 1);
                            setTimeout("hh2AjaxRequestElement('" + arrHH2AjaxURL[intHH2AjaxRequestID] + "', '" + arrHH2AjaxObject[intHH2AjaxRequestID].id + "', " + arrHH2AjaxAttemptCount[intHH2AjaxRequestID] + ", " + arrHH2AjaxAttemptMax[intHH2AjaxRequestID] + ", '" + arrHH2AjaxData[intHH2AjaxRequestID] + "');", 500);
                        }
                    }
                }
                else {
                    if (arrHH2AjaxAttemptCount[intHH2AjaxRequestID] >= arrHH2AjaxAttemptMax[intHH2AjaxRequestID]) {
                        //Process Fail Response (#500,#404)
                        arrHH2AjaxObject[intHH2AjaxRequestID].className = "http_undefined_error";
                        return false;
                    }
                    else {
                        if (arrHH2AjaxRequest[intHH2AjaxRequestID].status == 500) {
                            //Retry
                            arrHH2AjaxAttemptCount[intHH2AjaxRequestID] = (arrHH2AjaxAttemptCount[intHH2AjaxRequestID] + 1);
                            setTimeout("hh2AjaxRequestElement('" + arrHH2AjaxURL[intHH2AjaxRequestID] + "', '" + arrHH2AjaxObject[intHH2AjaxRequestID].id + "', " + arrHH2AjaxAttemptCount[intHH2AjaxRequestID] + ", " + arrHH2AjaxAttemptMax[intHH2AjaxRequestID] + ", '" + arrHH2AjaxData[intHH2AjaxRequestID] + "');", 500);
                        }
                    }
                }
                hh2AjaxDestroy(intHH2AjaxRequestID);
            }
        }
        if (arrHH2AjaxData[intHH2AjaxRequestID] != "") {
            arrHH2AjaxData[intHH2AjaxRequestID] = arrHH2AjaxData[intHH2AjaxRequestID].replace(/ /g, "%20");
            arrHH2AjaxData[intHH2AjaxRequestID] = arrHH2AjaxData[intHH2AjaxRequestID].replace(/\n/g, "%0D");
        }
        arrHH2AjaxRequest[intHH2AjaxRequestID].send("ajaxRequest=true&" + arrHH2AjaxData[intHH2AjaxRequestID]);
    }
    //### PDA VERSION ###
    if (boolHH2AjaxIsPDA == true) {
        objTarget = hh2AjaxGetObject(strObjectID);
        boolValidObject = isObject(objTarget);
        //Check for validity
        if (boolValidObject == false) {
            return false;
        }
        //Initiate Ajax
        var intHH2AjaxRequestID = hh2AjaxInitiateConnection();
        eval(strObjectID + 'InstanceID=' + intHH2AjaxRequestID + ';');
        arrHH2AjaxURL[intHH2AjaxRequestID] = strURL;
        arrHH2AjaxObject[intHH2AjaxRequestID] = objTarget;
        arrHH2AjaxAttemptCount[intHH2AjaxRequestID] = intAttemptCount;
        arrHH2AjaxAttemptMax[intHH2AjaxRequestID] = intAttemptMax;
        arrHH2AjaxData[intHH2AjaxRequestID] = strData;
        if (boolHH2AjaxReconnecting == true) {
            return false;
        }
        //Change element to pending
        arrHH2AjaxObject[intHH2AjaxRequestID].style.backgroundImage = "url('https://images.hh2.com/Legacy/pda/ajax_bg_processing.gif')";
        //Execute
        arrHH2AjaxRequest[intHH2AjaxRequestID].open("POST", arrHH2AjaxURL[intHH2AjaxRequestID], true);
        arrHH2AjaxRequest[intHH2AjaxRequestID].setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        arrHH2AjaxRequest[intHH2AjaxRequestID].onreadystatechange = function () {
            if (arrHH2AjaxRequest[intHH2AjaxRequestID].readyState == 1 && typeof (arrHH2AjaxObject[intHH2AjaxRequestID]) != "undefined") {
                setTimeout("if(arrHH2AjaxRequest[" + intHH2AjaxRequestID + "].readyState==1&&boolHH2AjaxReconnecting==false){boolHH2AjaxReconnecting=true;paneBody.innerHTML='<b>Your PDA has lost its internet connection.</b><br>Attempting to reconnect...<br><table width=100% border=0><tr><td align=center valign=center><br><br><img src=/images/pda/loading.gif></td></tr></table>';window.location.reload();}", 10000);
                setTimeout("if(arrHH2AjaxRequest[" + intHH2AjaxRequestID + "].readyState==1&&boolHH2AjaxReconnecting==true){paneBody.innerHTML='<b>Your PDA has lost its internet connection.</b><br>Connection could not be re-established. Please check your connectivity and reload your browser.';}", 60000);
            }
            if (arrHH2AjaxRequest[intHH2AjaxRequestID].readyState == 4 && typeof (arrHH2AjaxObject[intHH2AjaxRequestID]) != "undefined") {
                if (arrHH2AjaxRequest[intHH2AjaxRequestID].status == 200) {
                    //Process Successful Response
                    if (arrHH2AjaxRequest[intHH2AjaxRequestID].responseText.indexOf("[ajaxprocess]") != -1) {
                        eval('objAjaxCollection=divAjaxProcessCollection' + intHH2AjaxCollectionID + ';');
                        if (intHH2AjaxCollectionID >= 20) {
                            intHH2AjaxCollectionID = 0;
                        }
                        intHH2AjaxCollectionID = (intHH2AjaxCollectionID + 1);
                        objAjaxCollection.innerHTML = arrHH2AjaxRequest[intHH2AjaxRequestID].responseText + "<div id='divAjaxProcessCollection" + intHH2AjaxCollectionID + "'></div>";
                    }
                    if (arrHH2AjaxRequest[intHH2AjaxRequestID].responseText.indexOf("[success]") != -1) {
                        arrHH2AjaxObject[intHH2AjaxRequestID].style.backgroundImage = "url('https://images.hh2.com/Legacy/pda/ajax_bg_success.gif')";
                        setTimeout('if(' + arrHH2AjaxObject[intHH2AjaxRequestID].id + 'InstanceID==' + intHH2AjaxRequestID + '){arrHH2AjaxObject[' + intHH2AjaxRequestID + '].style.backgroundImage="";}', 2000)
                    }
                    else {
                        //Process Fail Response (#200)
                        arrHH2AjaxObject[intHH2AjaxRequestID].style.backgroundImage = "url('https://images.hh2.com/Legacy/pda/ajax_bg_fail.gif')";
                    }
                    //Retry
                    if (arrHH2AjaxRequest[intHH2AjaxRequestID].responseText.indexOf("[ajaxParam:Retry]") != -1) {
                        if (arrHH2AjaxAttemptCount[intHH2AjaxRequestID] >= arrHH2AjaxAttemptMax[intHH2AjaxRequestID]) {
                            arrHH2AjaxObject[intHH2AjaxRequestID].style.backgroundImage = "url('https://images.hh2.com/Legacy/pda/ajax_bg_fail.gif')";
                            return false;
                        }
                        else {
                            arrHH2AjaxAttemptCount[intHH2AjaxRequestID] = (arrHH2AjaxAttemptCount[intHH2AjaxRequestID] + 1);
                            setTimeout("hh2AjaxRequestElement('" + arrHH2AjaxURL[intHH2AjaxRequestID] + "', '" + arrHH2AjaxObject[intHH2AjaxRequestID].id + "', " + arrHH2AjaxAttemptCount[intHH2AjaxRequestID] + ", " + arrHH2AjaxAttemptMax[intHH2AjaxRequestID] + ", '" + arrHH2AjaxData[intHH2AjaxRequestID] + "');", 500);
                        }
                    }
                }
                else {
                    if (arrHH2AjaxAttemptCount[intHH2AjaxRequestID] >= arrHH2AjaxAttemptMax[intHH2AjaxRequestID]) {
                        //Process Fail Response (#500,#404)
                        arrHH2AjaxObject[intHH2AjaxRequestID].style.backgroundImage = "url('https://images.hh2.com/Legacy/pda/ajax_bg_fail.gif')";
                        return false;
                    }
                    else {
                        if (arrHH2AjaxRequest[intHH2AjaxRequestID].status == 500) {
                            //Retry
                            arrHH2AjaxAttemptCount[intHH2AjaxRequestID] = (arrHH2AjaxAttemptCount[intHH2AjaxRequestID] + 1);
                            setTimeout("hh2AjaxRequestElement('" + arrHH2AjaxURL[intHH2AjaxRequestID] + "', '" + arrHH2AjaxObject[intHH2AjaxRequestID].id + "', " + arrHH2AjaxAttemptCount[intHH2AjaxRequestID] + ", " + arrHH2AjaxAttemptMax[intHH2AjaxRequestID] + ", '" + arrHH2AjaxData[intHH2AjaxRequestID] + "');", 500);
                        }
                    }
                }
            }
        }
        if (arrHH2AjaxData[intHH2AjaxRequestID] != "") {
            arrHH2AjaxData[intHH2AjaxRequestID] = arrHH2AjaxData[intHH2AjaxRequestID].replace(/ /g, "%20");
            arrHH2AjaxData[intHH2AjaxRequestID] = arrHH2AjaxData[intHH2AjaxRequestID].replace(/\n/g, "%0D");
        }
        arrHH2AjaxRequest[intHH2AjaxRequestID].send("ajaxRequest=true&" + arrHH2AjaxData[intHH2AjaxRequestID]);
    }

}

//--------------------------------------------------------------------
// hh2AjaxGetElementValue()
//--------------------------------------------------------------------
function hh2AjaxGetElementValue(strObjectID) {
    if (boolHH2AjaxIsPDA == true) {
        eval('if(typeof(document.form1.' + strObjectID + ')!="undefined"){objTarget=document.form1.' + strObjectID + '};');
    }
    else {
        eval('objTarget = document.getElementById(String(strObjectID));');
    }
    if (isObject(objTarget)) {
        if (objTarget.type == "checkbox") {
            if (objTarget.checked == true) {
                if (objTarget.value != "") {
                    return hh2AjaxURLEncode(hh2AjaxConvertAscii(objTarget.value));
                }
                else {
                    return "1";
                }
            }
            else {
                return "";
            }
        }
        else if (objTarget.type == "radio") {
            eval('objTarget = document.form1.' + strObjectID + ';');
            for (i = 0; i < objTarget.length; i++) {
                if (objTarget[i].checked) {
                    return objTarget[i].value;
                }
            }
        }
        else {
            return hh2AjaxURLEncode(hh2AjaxConvertAscii(objTarget.value));
        }
    }
    else {
        return "";
    }
    return "";
}

//--------------------------------------------------------------------
// hh2AjaxShowNode()
//--------------------------------------------------------------------
function hh2AjaxShowNode(strObjectID) {
    if (boolHH2AjaxIsPDA == true) {
        objTarget = hh2AjaxGetObject(strObjectID);
    }
    else {
        eval('objTarget = document.getElementById(String(strObjectID));');
    }
    if (isObject(objTarget)) {
        objTarget.style.display = "block";
    }
}

//--------------------------------------------------------------------
// hh2AjaxHideNode()
//--------------------------------------------------------------------
function hh2AjaxHideNode(strObjectID) {
    if (boolHH2AjaxIsPDA == true) {
        objTarget = hh2AjaxGetObject(strObjectID);
    }
    else {
        eval('objTarget = document.getElementById(String(strObjectID));');
    }
    if (isObject(objTarget)) {
        objTarget.style.display = "none";
    }
}

//--------------------------------------------------------------------
// hh2AjaxShowBtn()
//--------------------------------------------------------------------
function hh2AjaxShowBtn(strObjectID) {
    if (boolHH2AjaxIsPDA == true) {
        eval('if(isObject(document.form1.' + strObjectID + ')){objTarget = document.form1.' + strObjectID + ';}');
    }
    else {
        eval('objTarget = document.getElementById(String(strObjectID));');
    }
    if (isObject(objTarget)) {
        objTarget.style.display = "inline";
    }
}

//--------------------------------------------------------------------
// hh2AjaxHideBtn()
//--------------------------------------------------------------------
function hh2AjaxHideBtn(strObjectID) {
    if (boolHH2AjaxIsPDA == true) {
        eval('if(isObject(document.form1.' + strObjectID + ')){objTarget = document.form1.' + strObjectID + ';}');
    }
    else {
        eval('objTarget = document.getElementById(String(strObjectID));');
    }
    if (isObject(objTarget)) {
        objTarget.style.display = "none";
    }
}

//--------------------------------------------------------------------
// hh2AjaxSetFormValue()
//--------------------------------------------------------------------
function hh2AjaxSetFormValue(strObjectID, strFormElementValue) {
    eval('objTarget = document.form1.' + strObjectID + ';');
    if (isObject(objTarget)) {
        objTarget.value = strFormElementValue;
    }
}

//--------------------------------------------------------------------
// hh2AjaxSetNodeClass()
//--------------------------------------------------------------------
function hh2AjaxSetNodeClass(strObjectID, strNodeClassName) {
    if (boolHH2AjaxIsPDA == true) {
        objTarget = hh2AjaxGetObject(strObjectID);
    }
    else {
        eval('objTarget = document.getElementById(String(strObjectID));');
    }
    if (isObject(objTarget)) {
        objTarget.className = strNodeClassName;
    }
}

//--------------------------------------------------------------------
// hh2AjaxSetNodeOpacity()
//--------------------------------------------------------------------
function hh2AjaxSetNodeOpacity(strObjectID, strNodeClassOpacity) {
    if (boolHH2AjaxIsPDA == true) {
        objTarget = hh2AjaxGetObject(strObjectID);
    }
    else {
        eval('objTarget = document.getElementById(String(strObjectID));');
    }
    if (isObject(objTarget)) {
        objTarget.style.filter = "Alpha(Opacity=" + strNodeClassOpacity + ")";
    }
}

//--------------------------------------------------------------------
// hh2AjaxSetInnerHTML()
//--------------------------------------------------------------------
function hh2AjaxSetInnerHTML(strObjectID, strObjectInnerHTML) {
    if (boolHH2AjaxIsPDA == true) {
        objTarget = hh2AjaxGetObject(strObjectID);
    }
    else {
        eval('objTarget = document.getElementById(String(strObjectID));');
    }
    if (isObject(objTarget)) {
        objTarget.innerHTML = strObjectInnerHTML;
    }
}

//--------------------------------------------------------------------
// hh2AjaxCopyInnerHTML()
//--------------------------------------------------------------------
function hh2AjaxCopyInnerHTML(strSourceObjectID, strTargetObjectID) {
    if (boolHH2AjaxIsPDA == true) {
        objSourceObject = hh2AjaxGetObject(strSourceObjectID);
        objTargetObject = hh2AjaxGetObject(strTargetObjectID);
    }
    else {
        eval('objSourceObject=document.getElementById(String(strSourceObjectID));objTargetObject=document.getElementById(String(strTargetObjectID));');
    }
    if (isObject(objSourceObject) && isObject(objTargetObject)) {
        objTargetObject.innerHTML = objSourceObject.innerHTML;
    }
}

//--------------------------------------------------------------------
// hh2AjaxSetOptionLength()
//--------------------------------------------------------------------
function hh2AjaxSetOptionLength(strObjectID, intOptionLength) {
    if (boolHH2AjaxIsPDA == true) {
        objTarget = hh2AjaxGetObject(strObjectID);
    }
    else {
        eval('objTarget = document.getElementById(String(strObjectID));');
    }
    if (isObject(objTarget)) {
        objTarget.options.length = intOptionLength;
    }
}

//--------------------------------------------------------------------
// hh2AjaxSetOptionAdd()
//--------------------------------------------------------------------
function hh2AjaxSetOptionAdd(strObjectID, strOptionValue, strOptionDisplay) {
    if (boolHH2AjaxIsPDA == true) {
        objTarget = hh2AjaxGetObject(strObjectID);
    }
    else {
        eval('objTarget = document.getElementById(String(strObjectID));');
    }
    if (isObject(objTarget)) {
        objTarget.options.length++;
        objTarget.options[objTarget.options.length - 1] = new Option(strOptionDisplay, strOptionValue);
    }
}

//'--------------------------------------------------------------------
//' hh2AjaxConvertAscii()
//'--------------------------------------------------------------------
function hh2AjaxConvertAscii(strInput) {
    if (strInput == "") {
        return "";
    }
    var strScrubbed = "";
    strInput = String(strInput);
    //Convert characters above #122 to code (exclude tildes (#126) and pipes (#124))
    for (i = 0; i < strInput.length; i++) {
        if (strInput.charCodeAt(i) > 122 && strInput.charCodeAt(i) != 126 && strInput.charCodeAt(i) != 124) {
            strScrubbed += "&#" + strInput.charCodeAt(i) + ";";
        }
        else {
            strScrubbed += strInput.charAt(i);
        }
    }
    return strScrubbed;
}

//'--------------------------------------------------------------------
//' hh2AjaxURLEncode()
//'--------------------------------------------------------------------
function hh2AjaxURLEncode(strInput) {
    if (strInput != "") {
        strInput = strInput.replace(/\%/g, "%25");
        strInput = strInput.replace(/ /g, "%20");
        strInput = strInput.replace(/\n/g, "%0D");
        strInput = strInput.replace(/\=/g, "%3D");
        strInput = strInput.replace(/\&/g, "%26");
        strInput = strInput.replace(/\(/g, "%28");
        strInput = strInput.replace(/\)/g, "%29");
    }
    return strInput;
}

//'--------------------------------------------------------------------
//' hh2AjaxClickButton()
//'--------------------------------------------------------------------
function hh2AjaxClickButton(strObjectID) {
    if (boolHH2AjaxIsPDA == true) {
        eval('if(isObject(document.form1.' + strObjectID + ')){document.form1.' + strObjectID + '.click();}');
        return true;
    }
    else {
        eval('objTarget = document.getElementById(String(strObjectID));');
    }
    if (isObject(objTarget)) {
        objTarget.click();
    }
}

//'--------------------------------------------------------------------
//' hh2AjaxExecNodeCode()
//'--------------------------------------------------------------------
function hh2AjaxExecNodeCode(strObjectID) {
    if (boolHH2AjaxIsPDA == true) {
        objTarget = hh2AjaxGetObject(strObjectID);
    }
    else {
        eval('objTarget = document.getElementById(String(strObjectID));');
    }
    if (isObject(objTarget)) {
        strNodeCode = objTarget.innerHTML;
        strNodeCode = strNodeCode.replace("<!-- [STARTAJAXNODECODE] ", "");
        strNodeCode = strNodeCode.replace(" [ENDAJAXNODECODE] -->", "");
        strNodeCode = strNodeCode.replace(/\&amp;/g, "&");
        strNodeCode = strNodeCode.replace(/\&lt;/g, "<");
        strNodeCode = strNodeCode.replace(/\&gt;/g, ">");
        eval(strNodeCode);
    }
}

//'--------------------------------------------------------------------
//' hh2AjaxDisableBtn()
//'--------------------------------------------------------------------
function hh2AjaxDisableBtn(strObjectID) {
    if (boolHH2AjaxIsPDA == true) {
        eval('if(isObject(document.form1.' + strObjectID + ')){objTarget = document.form1.' + strObjectID + ';}');
    }
    else {
        eval('objTarget = document.getElementById(String(strObjectID)+"Btn");');
    }
    if (isObject(objTarget)) {
        if (boolHH2AjaxIsPDA == false) {
            objTarget.style.cursor = "wait";
        }
        arrHH2AjaxDisabledButton[arrHH2AjaxDisabledButton.length] = objTarget.id;
    }
}

//'--------------------------------------------------------------------
//' hh2AjaxEnableBtn()
//'--------------------------------------------------------------------
function hh2AjaxEnableBtn(strObjectID) {
    if (boolHH2AjaxIsPDA == true) {
        eval('if(isObject(document.form1.' + strObjectID + ')){objTarget = document.form1.' + strObjectID + ';}');
    }
    else {
        eval('objTarget = document.getElementById(String(strObjectID)+"Btn");');
    }
    if (isObject(objTarget)) {
        if (boolHH2AjaxIsPDA == false) {
            objTarget.style.cursor = "pointer";
        }
        for (i = 0; i < arrHH2AjaxDisabledButton.length; i++) {
            if (arrHH2AjaxDisabledButton[i] == objTarget.id) {
                arrHH2AjaxDisabledButton[i] = "";
            }
        }
    }
}

//'--------------------------------------------------------------------
//' hh2AjaxIsBtnEnabled()
//'--------------------------------------------------------------------
function hh2AjaxIsBtnEnabled(strObjectID) {
    if (boolHH2AjaxIsPDA == true) {
        eval('if(isObject(document.form1.' + strObjectID + ')){objTarget = document.form1.' + strObjectID + ';}');
    }
    else {
        eval('objTarget = document.getElementById(String(strObjectID)+"");');
    }
    for (i = 0; i < arrHH2AjaxDisabledButton.length; i++) {
        if (arrHH2AjaxDisabledButton[i] == objTarget.id) {
            return false;
        }
    }
    return true;
}

//'--------------------------------------------------------------------
//' hh2AjaxEnableAllBtn()
//'--------------------------------------------------------------------
function hh2AjaxEnableAllBtn() {
    arrHH2AjaxDisabledButton.length = 1;
    arrHH2AjaxDisabledButton[0] = "";
}

//'--------------------------------------------------------------------
//' hh2AjaxCollapsePane()
//'--------------------------------------------------------------------
function hh2AjaxCollapsePane(strWrapperObjectID, strInnerObjectID) {
    if (boolHH2AjaxIsPDA == true) {
        return;
    }
    else {
        strHH2AjaxCollapsePaneOriginalOverflow = objInnerTarget.style.overflow;
        objInnerTarget.style.overflow = "hidden";
        hh2AjaxCollapsePaneStep(document.getElementById(String(strWrapperObjectID) + ""), document.getElementById(String(strInnerObjectID) + ""), strHH2AjaxCollapsePaneOriginalOverflow, findheight(strInnerObjectID));
    }
}

//'--------------------------------------------------------------------
//' hh2AjaxCollapsePaneStep()
//'--------------------------------------------------------------------
function hh2AjaxCollapsePaneStep(objTargetWrapper, objTarget, strOriginalOverflow, intObjectHeight) {
    if (intObjectHeight <= 0) {
        objTargetWrapper.style.display = "none";
        objInnerTarget.style.overflow = strOriginalOverflow;
        return;
    }
    objInnerTarget.style.height = (intObjectHeight - 10);
    setTimeout('hh2AjaxCollapsePaneStep(document.getElementById("' + objTargetWrapper.id + '"),document.getElementById("' + objTarget.id + '"),"' + strOriginalOverflow + '",' + (intObjectHeight - 10) + ');', 100);
}


//'--------------------------------------------------------------------
//' hh2AjaxInsertRemoveFromStringArray()
//'--------------------------------------------------------------------
function hh2AjaxInsertRemoveFromStringArray(strObjectID, strValue, IsLiteral) {
    var IndexToRemove;
    var ValueExistsInArray;
    var ArrTargetArray = new Array();
    if (boolHH2AjaxIsPDA == true) {
        eval('if(isObject(document.form1.' + strObjectID + ')){objTarget = document.form1.' + strObjectID + ';}');
    }
    else {
        eval('objTarget = document.getElementById(String(strObjectID)+"");');
    }
    if (IsLiteral == false) {
        if (boolHH2AjaxIsPDA == true) {
            eval('if(isObject(document.form1.' + strValue + ')){CheckValue = document.form1.' + strValue + '.value;}');
        }
        else {
            eval('if(isObject(document.form1.' + strValue + ')){CheckValue = document.form1.' + strValue + '.value;}else{CheckValue = document.getElementById(String(strValue)).value;}');
        }
    }
    else {
        CheckValue = strValue;
    }
    if (objTarget.value.indexOf(",") != -1) {
        ArrTargetArray = objTarget.value.split(",");
    }
    else {
        if (objTarget.value != "") {
            ArrTargetArray[0] = objTarget.value
        }
    }
    ValueExistsInArray = false;
    for (i = 0; i < ArrTargetArray.length; i++) {
        if (ArrTargetArray[i].replace(/^\s+|\s+$/g, "") == CheckValue) {
            ValueExistsInArray = true;
            IndexToRemove = i;
        }
    }
    if (ValueExistsInArray == false) {
        ArrTargetArray.push(CheckValue);
    }
    else {
        ArrTargetArray.splice(IndexToRemove, 1);
    }
    objTarget.value = ArrTargetArray;
}

