
//' -----------------------------------------------------------------------------
//' Global Variables
//' -----------------------------------------------------------------------------
var strNothing = "";

//' -----------------------------------------------------------------------------
//' Source to Destination List Functions
//' -----------------------------------------------------------------------------

// Add the selected items from the source to destination list
function addDestToSrcList(destList, srcList) {
    var len = srcList.length;
    for (var i = 0; i < destList.length; i++) {
        if ((destList.options[i] != null) && (destList.options[i].selected)) {
            srcList.options[len] = new Option(destList.options[i].text, destList.options[i].value);
            len++;
        }
    }
    deleteFromDestList(destList)
}

// Add the selected items from the source to destination list
function addSrcToDestList(destList, srcList) {
    var len = destList.length;
    for (var i = 0; i < srcList.length; i++) {
        if ((srcList.options[i] != null) && (srcList.options[i].selected)) {
            destList.options[len] = new Option(srcList.options[i].text, srcList.options[i].value);
            len++;
        }
    }
    deleteFromSrcList(srcList)
}

// Deletes from the destination list.
function deleteFromDestList(destList) {
    var len = destList.options.length;
    for (var i = (len - 1); i >= 0; i--) {
        if ((destList.options[i] != null) && (destList.options[i].selected == true)) {
            destList.options[i] = null;
        }
    }
}

// Deletes from the src list.
function deleteFromSrcList(srcList) {
    var len = srcList.options.length;
    for (var i = (len - 1); i >= 0; i--) {
        if ((srcList.options[i] != null) && (srcList.options[i].selected == true)) {
            srcList.options[i] = null;
        }
    }
}

function selectList(destList, srcList) {
    for (var i = 0; i < destList.options.length; i++) {
        if (destList.options[i] != null)
            destList.options[i].selected = true;
    }
    for (var i = 0; i < srcList.options.length; i++) {
        if (srcList.options[i] != null)
            srcList.options[i].selected = true;
    }
}

function processList() {
    for (var i = 0; i < document.form1.destinationList.length; i++) {
        if (i != 0) {
            document.form1.destinationListFinal.value = document.form1.destinationListFinal.value + ",";
        }
        document.form1.destinationListFinal.value = document.form1.destinationListFinal.value + document.form1.destinationList.options[i].value;
    }
    document.form1.submit();
}

//'-----------------------------------------------------------------------------
//' isEnter()
//'-----------------------------------------------------------------------------
function isEnter(e) {

    var keycode;
    if (window.event) {
        keycode = window.event.keyCode;
    }
    else if (e) {
        keycode = e.which;
    }
    if (keycode == 13) {
        return true;
    }

}

//' -----------------------------------------------------------------------------
//' isObject()
//' -----------------------------------------------------------------------------
function isObject(a) {
    return (typeof a == 'object' && !!a) || isFunction(a);
}

//' -----------------------------------------------------------------------------
//' isFunction()
//' -----------------------------------------------------------------------------
function isFunction(a) {
    return typeof a == 'function';
}

//' -----------------------------------------------------------------------------
//' durationdate()
//' -----------------------------------------------------------------------------
function durationdate(intDuration, dateStart, dateEnd) {
    if (dateStart.value != '') {
        dateNew = new Date(dateStart.value);
        if (intDuration.value != '' && intDuration.value != '0') {
            dateNew.setMilliseconds(dateNew.getMilliseconds() + Math.round(intDuration.value - 1) * 86400000);
            strYear = new String();
            if (dateNew.getFullYear() < 1970) dateNew.setFullYear(dateNew.getFullYear() + 100);
            dateEnd.value = dateNew.getMonth() + 1 + '/' + dateNew.getDate() + '/' + dateNew.getFullYear();
        } else {
            dateEnd.value = '';
            intDuration.value = '';
        }
    }
}

//' -----------------------------------------------------------------------------
//' dateduration()
//' -----------------------------------------------------------------------------
function dateduration(intDuration, dateStart, dateEnd) {
    if (dateStart.value != '') {
        dateNewStart = new Date(dateStart.value);
        if (dateEnd.value != '') {
            dateNewEnd = new Date(dateEnd.value);
            if (dateNewEnd > dateNewStart) {
                intDuration.value = Math.round(((dateNewEnd - dateNewStart) / 86400000) + 1);
            }
        } else intDuration = '';
    }
}

//' -----------------------------------------------------------------------------
//' expandMenu()
//' -----------------------------------------------------------------------------
function expandMenu(objTableID, intEndHeight) {
    if (isObject(document.getElementById(objTableID))) {
        document.getElementById(objTableID).style.height = parseInt(document.getElementById(objTableID).style.height) + 2;
        if (parseInt(document.getElementById(objTableID).style.height) <= intEndHeight) {
            self.setTimeout('expandMenu("' + objTableID + '",' + intEndHeight + ')', 1);
        }
    }
}

//' -----------------------------------------------------------------------------
//' contractMenu()
//' -----------------------------------------------------------------------------
function contractMenu(objTableID) {
    if (isObject(document.getElementById(objTableID)) && parseInt(document.getElementById(objTableID).style.height) > 0) {
        document.getElementById(objTableID).style.height = parseInt(document.getElementById(objTableID).style.height) - 2;
        if (parseInt(document.getElementById(objTableID).style.height) > 0) {
            self.setTimeout('contractMenu("' + objTableID + '")', 1);
        }
    }
}

//' -----------------------------------------------------------------------------
//' clearItems()
//' -----------------------------------------------------------------------------
function clearItems(strForm, strObjects) {
    if (strObjects == "all") {
        for (x = 0; x <= (document.forms.length - 1); x++) {
            if (document.forms[x].name == strForm) {
                for (y = 0; y <= (document.forms[x].elements.length - 1); y++) {
                    if (document.forms[x].elements[y].type == "checkbox") {
                        document.forms[x].elements[y].checked = false;
                    }
                    else {
                        document.forms[x].elements[y].value = "";
                    }
                }
            }
        }
    }
    else {
        arrObjects = strObjects.split(",");
        for (i = 0; i <= (arrObjects.length - 1); i++) {
            for (x = 0; x <= (document.forms.length - 1); x++) {
                if (document.forms[x].name == strForm) {
                    for (y = 0; y <= (document.forms[x].elements.length - 1); y++) {
                        if (document.forms[x].elements[y].name == arrObjects[i]) {
                            if (document.forms[x].elements[y].type == "checkbox") {
                                document.forms[x].elements[y].checked = false;
                            }
                            else {
                                document.forms[x].elements[y].value = "";
                            }
                        }
                    }
                }
            }
        }
    }
}


//--------------------------------------------------------------------
// findPosX()
//--------------------------------------------------------------------
function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curleft = curleft + obj.offsetLeft - obj.scrollLeft;
            obj = obj.offsetParent;
        }
    }
    else if (obj.x) {
        curleft += obj.x;
    }
    return curleft;
}

//--------------------------------------------------------------------
// findPosY()
//--------------------------------------------------------------------
function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curtop = curtop + obj.offsetTop - obj.scrollTop;
            obj = obj.offsetParent;
        }
    }
    else if (obj.y) {
        curtop += obj.y;
    }
    return curtop;
}


//--------------------------------------------------------------------
// findWidth()
//--------------------------------------------------------------------
function findWidth(obj, intRangeID) {
    if (isObject(obj)) {
        //if (navigator.appName == "Microsoft Internet Explorer") {
        //    range[intRangeID] = document.body.createTextRange();
        //}
        //else {
        //    return obj.offsetWidth;
        //}
        return obj.offsetWidth;
        //range[intRangeID].moveToElementText(obj);
        //return range[intRangeID].boundingWidth;
    }
}


//--------------------------------------------------------------------
// findHeight()
//--------------------------------------------------------------------
function findHeight(obj, intRangeID) {
    if (isObject(obj)) {
        //if (navigator.appName == "Microsoft Internet Explorer") {
        //    range[intRangeID] = document.body.createTextRange();
        //}
        //else {
        //    return obj.offsetHeight;
        //}
        return obj.offsetHeight;
        //range[intRangeID].moveToElementText(obj);
        //return range[intRangeID].boundingHeight;
    }
}


//--------------------------------------------------------------------
// findBrowserWidth()
//--------------------------------------------------------------------
function findBrowserWidth() {
    var myWidth = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
    }
    return myWidth;
}


//--------------------------------------------------------------------
// findBrowserHeight()
//--------------------------------------------------------------------
function findBrowserHeight() {
    var myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myHeight = document.body.clientHeight;
    }
    return myHeight;
}



//'--------------------------------------------------------------------
//' inArray()
//'--------------------------------------------------------------------
function inArray(arrInArray, strElementMatch) {
    bitInArrayResponse = false;
    if (typeof (arrInArray) == "string") {
        arrInArray = arrInArray.split(",");
    }
    for (iInArray = 0; iInArray < arrInArray.length; iInArray++) {
        if (arrInArray[iInArray] != "" && arrInArray[iInArray] == strElementMatch) {
            bitInArrayResponse = true;
        }
    }
    return bitInArrayResponse;
}

//'--------------------------------------------------------------------
//' removeFromArray()
//'--------------------------------------------------------------------
function removeFromArray(arrArray, strValue) {
    for (iRemove = 0; iRemove < arrArray.length; iRemove++) {
        if (arrArray[iRemove] == strValue) {
            arrArray.splice(iRemove, 1);
        }
    }
}

//'--------------------------------------------------------------------
//' ArrayToString()
//'--------------------------------------------------------------------
function ArrayToString(arrArray) {
    var strArrayToString = "";
    for (iToString = 0; iToString < arrArray.length; iToString++) {
        if (strArrayToString != "") {
            strArrayToString = strArrayToString + ",";
        }
        strArrayToString = strArrayToString + arrArray[iToString];
    }
    return strArrayToString;
}

//'--------------------------------------------------------------------
//' getFormElements()
//'--------------------------------------------------------------------
function getFormElements(strArrElements) {
    strArrElements = strArrElements + ",";
    arrElements = strArrElements.split(",");
    var strFormElementsData = "";
    var strFormValue = "";
    for (x = 0; x <= (document.forms.length - 1); x++) {
        for (y = 0; y <= (document.forms[x].elements.length - 1); y++) {
            if (inArray(arrElements, document.forms[x].elements[y].name) == true) {
                if (document.forms[x].elements[y].type == "checkbox") {
                    if (document.forms[x].elements[y].checked == true) {
                        if (strFormElementsData != "") {
                            strFormElementsData = strFormElementsData + "&";
                        }
                        strFormElementsData = strFormElementsData + document.forms[x].elements[y].name + "=1&" + document.forms[x].elements[y].name + "_value=" + document.forms[x].elements[y].value;
                    }
                    else {
                        if (strFormElementsData != "") {
                            strFormElementsData = strFormElementsData + "&";
                        }
                        strFormElementsData = strFormElementsData + document.forms[x].elements[y].name + "=";
                    }
                }
                else if (document.forms[x].elements[y].type == "radio") {
                    if (document.forms[x].elements[y].checked == true) {
                        if (strFormElementsData != "") {
                            strFormElementsData = strFormElementsData + "&";
                        }
                        strFormElementsData = strFormElementsData + document.forms[x].elements[y].name + "=" + document.forms[x].elements[y].value;
                    }
                }
                else {
                    strFormValue = document.forms[x].elements[y].value;
                    if (strFormElementsData != "") {
                        strFormElementsData = strFormElementsData + "&";
                    }
                    strFormElementsData = strFormElementsData + document.forms[x].elements[y].name + "=" + urlEncode(convertAscii(strFormValue));
                }
            }
        }
    }
    return strFormElementsData;
}

//'--------------------------------------------------------------------
//' getAllFormElements()
//'--------------------------------------------------------------------
function getAllFormElements() {
    var strFormElementsData = "";
    var strFormValue = "";
    for (x = 0; x <= (document.forms.length - 1); x++) {
        for (y = 0; y <= (document.forms[x].elements.length - 1); y++) {
            if (document.forms[x].elements[y].name != "") {
                if (document.forms[x].elements[y].type == "checkbox") {
                    if (document.forms[x].elements[y].checked == true) {
                        if (strFormElementsData != "") {
                            strFormElementsData = strFormElementsData + "&";
                        }
                        strFormElementsData = strFormElementsData + document.forms[x].elements[y].name + "=1&" + document.forms[x].elements[y].name + "_value=" + document.forms[x].elements[y].value;
                    }
                    else {
                        if (strFormElementsData != "") {
                            strFormElementsData = strFormElementsData + "&";
                        }
                        strFormElementsData = strFormElementsData + document.forms[x].elements[y].name + "=";
                    }
                }
                else if (document.forms[x].elements[y].type == "radio") {
                    if (document.forms[x].elements[y].checked == true) {
                        if (strFormElementsData != "") {
                            strFormElementsData = strFormElementsData + "&";
                        }
                        strFormElementsData = strFormElementsData + document.forms[x].elements[y].name + "=" + document.forms[x].elements[y].value;
                    }
                }
                else {
                    strFormValue = document.forms[x].elements[y].value;
                    if (strFormElementsData != "") {
                        strFormElementsData = strFormElementsData + "&";
                    }
                    strFormElementsData = strFormElementsData + document.forms[x].elements[y].name + "=" + urlEncode(convertAscii(strFormValue));
                }
            }
        }
    }
    return strFormElementsData;
}


//'--------------------------------------------------------------------
//' resizeObj()
//'--------------------------------------------------------------------
var range = new Array();
function resizeObj(intRangeID, sourceObj, targetObj, doWidth, doHeight, intOffsetX, intOffsetY) {
    if (isObject(sourceObj) && isObject(targetObj)) {
        if (navigator.appName == "Microsoft Internet Explorer") {
            range[intRangeID] = document.body.createTextRange();
            range[intRangeID].moveToElementText(sourceObj);
            if (doWidth == 1) {
                if ((range[intRangeID].boundingWidth + intOffsetX) < 1) {
                    //targetObj.style.width = "1px";
                }
                else {
                    targetObj.style.width = (range[intRangeID].boundingWidth + intOffsetX) + "px";
                }
            }
            if (doHeight == 1) {
                if ((range[intRangeID].boundingHeight + intOffsetY) < 1) {
                    //targetObj.style.height = "1px";
                }
                else {
                    targetObj.style.height = (range[intRangeID].boundingHeight + intOffsetY) + "px";
                }
            }
        }
        else {
            sourceObj.style.width = "auto";
            sourceObj.style.height = "auto";
            if (doWidth == 1) {
                targetObj.style.width = sourceObj.offsetWidth + "px";
            }
            if (doHeight == 1) {
                targetObj.style.height = sourceObj.offsetHeight + "px";
            }
        }
    }
}

//--------------------------------------------------------------------
// getID()
//--------------------------------------------------------------------
intGetID = 1000
function getID() {
    intGetID = (intGetID + 1);
    return intGetID;
}


//'--------------------------------------------------------------------
//' sortOrder()
//'--------------------------------------------------------------------
function sortOrder(strColumnName, arrColumnName) {
    arrColumnName = arrColumnName.split(",");
    for (i = 0; i < arrColumnName.length; i++) {
        document.getElementById("sortArrow" + arrColumnName[i]).src = "https://images.hh2.com/Legacy/spacer.gif";
    }
    if (document.form1.sortColumn.value == strColumnName) {
        if (document.form1.sortDirection.value == "ASC") {
            document.form1.sortDirection.value = "DESC";
            document.getElementById("sortArrow" + strColumnName).src = "https://images.hh2.com/Legacy/sort_desc.gif";
        }
        else {
            document.form1.sortDirection.value = "ASC";
            document.getElementById("sortArrow" + strColumnName).src = "https://images.hh2.com/Legacy/sort_asc.gif";
        }
    }
    else {
        if (document.form1.sortDirection.value == "ASC") {
            document.getElementById("sortArrow" + strColumnName).src = "https://images.hh2.com/Legacy/sort_asc.gif";
        }
        else {
            document.getElementById("sortArrow" + strColumnName).src = "https://images.hh2.com/Legacy/sort_desc.gif";
        }
    }
    document.form1.sortColumn.value = strColumnName;
}


//'--------------------------------------------------------------------
//' disableDiv()
//'--------------------------------------------------------------------
function disableDiv(objTarget, strCursorStyle) {

    if (strCursorStyle == undefined) {
        var strCursorStyle = "wait";
    }

    var intZIndex = getZMax();
    document.getElementById('divDisabler').style.zIndex = (intZIndex + 1);
    if (objTarget == window.document.body) {
        document.getElementById('divDisabler').style.width = findBrowserWidth();
        document.getElementById('divDisabler').style.height = findBrowserHeight();
    }
    else {
        document.getElementById('divDisabler').style.width = findWidth(objTarget);
        document.getElementById('divDisabler').style.height = findHeight(objTarget);
    }
    document.getElementById('divDisabler').style.left = findPosX(objTarget) + "px";
    document.getElementById('divDisabler').style.top = findPosY(objTarget) + "px";
    document.getElementById('divDisabler').style.cursor = strCursorStyle;
    document.getElementById('divDisablerFrame').style.zIndex = intZIndex;
    if (objTarget == window.document.body) {
        document.getElementById('divDisablerFrame').style.width = findBrowserWidth();
        document.getElementById('divDisablerFrame').style.height = findBrowserHeight();
    }
    else {
        document.getElementById('divDisablerFrame').style.width = findWidth(objTarget);
        document.getElementById('divDisablerFrame').style.height = findHeight(objTarget);
    }
    document.getElementById('divDisablerFrame').style.left = findPosX(objTarget) + "px";
    document.getElementById('divDisablerFrame').style.top = findPosY(objTarget) + "px";

    document.getElementById('divDisablerFrame').style.display = "block";
    document.getElementById('divDisabler').style.display = "block";
}

//'--------------------------------------------------------------------
//' enableDiv()
//'--------------------------------------------------------------------
function enableDiv(objTarget) {
    document.getElementById('divDisabler').style.width = "1px";
    document.getElementById('divDisabler').style.height = "1px";
    document.getElementById('divDisabler').style.left = "0px";
    document.getElementById('divDisabler').style.top = "0px";
    document.getElementById('divDisabler').style.cursor = "";
    document.getElementById('divDisablerFrame').style.width = "1px";
    document.getElementById('divDisablerFrame').style.height = "1px";
    document.getElementById('divDisablerFrame').style.left = "0px";
    document.getElementById('divDisablerFrame').style.top = "0px";
    document.getElementById('divDisablerFrame').style.cursor = "";

    document.getElementById('divDisablerFrame').style.display = "none";
    document.getElementById('divDisabler').style.display = "none";
}


//'--------------------------------------------------------------------
//' resetSubmitBtn()
//'--------------------------------------------------------------------
var strBtnName
var strBtnText
function resetSubmitBtn(strBtnName) {
    if (isObject(document.getElementById(strBtnName)) && isObject(document.getElementById(strBtnName + 'Clicked'))) {
        document.getElementById(strBtnName).innerHTML = document.getElementById(strBtnName + 'Text').value;
        document.getElementById(strBtnName).style.cursor = "pointer";
        document.getElementById(strBtnName + 'Clicked').value = "";
        if (isObject(document.getElementById(strBtnName + 'Btn'))) {
            document.getElementById(strBtnName + 'Btn').style.cursor = "pointer";
        }
    }
}

//'--------------------------------------------------------------------
//' disableBtn()
//'--------------------------------------------------------------------
var arrDisabledButton = new Array();
function disableBtn(objButton, strButtonCursor) {
    arrDisabledButton[arrDisabledButton.length] = objButton.id;
    if (strButtonCursor != "") {
        objButton.style.cursor = strButtonCursor;
    }
    else {
        objButton.style.cursor = "not-allowed";
    }
}

//'--------------------------------------------------------------------
//' enableBtn()
//'--------------------------------------------------------------------
function enableBtn(objButton, strButtonCursor) {
    for (i = 0; i < arrDisabledButton.length; i++) {
        if (arrDisabledButton[i] == objButton.id) {
            arrDisabledButton[i] = "";
        }
    }
    if (strButtonCursor != "") {
        objButton.style.cursor = strButtonCursor;
    }
    else {
        objButton.style.cursor = "pointer";
    }
}

//'--------------------------------------------------------------------
//' enableAllBtn()
//'--------------------------------------------------------------------
function enableAllBtn() {
    arrDisabledButton.length = 1;
    arrDisabledButton[0] = "";
}

//'--------------------------------------------------------------------
//' isBtnEnabled()
//'--------------------------------------------------------------------
function isBtnEnabled(objButton) {
    for (i = 0; i < arrDisabledButton.length; i++) {
        if (arrDisabledButton[i] == objButton.id) {
            return false;
        }
    }
    return true;
}


//'--------------------------------------------------------------------
//' elementFocus()
//'--------------------------------------------------------------------
var arrFocusColor = new Array("FFFFFF", "FFFFEF", "FFFFDF", "FFFFCF", "FFFFBF", "FFFFAF", "FFFF9F", "FFFF8F", "FFFF7F");
function elementFocus(objTarget) {
    if (isObject(objTarget) == false) {
        return true;
    }

    if (objTarget.type == "select-one") {
        return true;
    }
    else {
        elementFocusColor(objTarget.id, 0);
    }
}
function elementFocusColor(objTargetName, iFocusColor) {
    if (isObject(document.getElementById(String(objTargetName))) == false) {
        return true;
    }
    if (iFocusColor < arrFocusColor.length) {
        document.getElementById(String(objTargetName)).style.backgroundColor = "#" + arrFocusColor[iFocusColor];
        setTimeout("elementFocusColor('" + objTargetName + "'," + (iFocusColor + 1) + ")", 30);
        return false;
    }
}

//'--------------------------------------------------------------------
//' elementBlur()
//'--------------------------------------------------------------------
function elementBlur(objTarget) {
    if (isObject(objTarget) == false) {
        return true;
    }
    if (objTarget.type == "select-one") {
        return true;
    }
    else {
        elementBlurColor(objTarget.id, (arrFocusColor.length - 1));
    }
}
function elementBlurColor(objTargetName, iFocusColor) {
    if (isObject(document.getElementById(String(objTargetName))) == false) {
        return true;
    }
    if (iFocusColor >= 0) {
        document.getElementById(String(objTargetName)).style.backgroundColor = "#" + arrFocusColor[iFocusColor];
        setTimeout("elementBlurColor('" + objTargetName + "'," + (iFocusColor - 1) + ")", 30);
        return true;
    }
}

//'--------------------------------------------------------------------
//' elementDisable()
//'--------------------------------------------------------------------
function elementDisable(objTarget) {
    objTarget.className = "elementDisabled";
    objTarget.disabled = true;
}

//'--------------------------------------------------------------------
//' elementEnable()
//'--------------------------------------------------------------------
function elementEnable(objTarget) {
    objTarget.className = "";
    objTarget.disabled = false;
}


//'--------------------------------------------------------------------
//' imageFadeUp()
//'--------------------------------------------------------------------
function imageFadeUp(objTarget, intAlpha) {
    if (!isObject(objTarget)) {
        return false;
    }

    objTarget.style.filter = "Alpha(Opacity=" + intAlpha + ")";

    if (intAlpha < 100) {
        setTimeout("imageFadeUp(document.getElementById('" + objTarget.id + "'),'" + (intAlpha + 5) + "')", 50);
    }
}

//'--------------------------------------------------------------------
//' imageFadeDown()
//'--------------------------------------------------------------------
function imageFadeDown(objTarget, intAlpha) {
    if (!isObject(objTarget)) {
        return false;
    }

    objTarget.style.filter = "Alpha(Opacity=" + intAlpha + ")";

    if (intAlpha > 75) {
        setTimeout("imageFadeDown(document.getElementById('" + objTarget.id + "'),'" + (intAlpha - 5) + "')", 50);
    }
}

//'--------------------------------------------------------------------
//' getZMax()
//'--------------------------------------------------------------------
function getZMax() {
    var intMaxZ = 0;
    var arrAllDiv = new Array();
    arrAllDiv = document.all.tags("DIV");
    for (i = 0; i < arrAllDiv.length; i++) {
        if (arrAllDiv[i].style.zIndex >= intMaxZ) {
            intMaxZ = (arrAllDiv[i].style.zIndex + 1);
        }
    }
    intMaxZ = (intMaxZ + 1);
    return intMaxZ;
}


//'--------------------------------------------------------------------
//' convertAscii()
//'--------------------------------------------------------------------
function convertAscii(strConvertAsciiInput) {
    if (strConvertAsciiInput == "") {
        return "";
    }
    var strScrubbed = "";
    strConvertAsciiInput = String(strConvertAsciiInput);
    //Convert characters above #122 to code (exclude tildes (#126) and pipes (#124))
    for (i = 0; i < strConvertAsciiInput.length; i++) {
        if (strConvertAsciiInput.charCodeAt(i) > 122 && strConvertAsciiInput.charCodeAt(i) != 126 && strConvertAsciiInput.charCodeAt(i) != 124) {
            strScrubbed += "&#" + strConvertAsciiInput.charCodeAt(i) + ";";
        }
        else {
            strScrubbed += strConvertAsciiInput.charAt(i);
        }
    }
    return strScrubbed;
}

//'--------------------------------------------------------------------
//' urlEncode()
//'--------------------------------------------------------------------
function urlEncode(urlEncodeInput) {
    if (urlEncodeInput != "") {

        //urlEncodeInput = urlEncodeInput.replace(/\“/g,"&ldquo;");
        //urlEncodeInput = urlEncodeInput.replace(/\”/g,"&rdquo;");
        //urlEncodeInput = urlEncodeInput.replace(/\—/g,"&mdash;");
        //urlEncodeInput = urlEncodeInput.replace(/\–/g,"&ndash;");

        urlEncodeInput = urlEncodeInput.replace(/\%/g, "%25");
        urlEncodeInput = urlEncodeInput.replace(/ /g, "%20");
        urlEncodeInput = urlEncodeInput.replace(/\n/g, "%0D");
        urlEncodeInput = urlEncodeInput.replace(/\=/g, "%3D");
        urlEncodeInput = urlEncodeInput.replace(/\&/g, "%26");
        urlEncodeInput = urlEncodeInput.replace(/\(/g, "%28");
        urlEncodeInput = urlEncodeInput.replace(/\)/g, "%29");
        urlEncodeInput = urlEncodeInput.replace(/\’/g, "%27");

    }
    return urlEncodeInput;
}

//'--------------------------------------------------------------------
//' getElementValue()
//'--------------------------------------------------------------------
function getElementValue(objTarget) {
    if (isObject(objTarget) == false && isObject(document.getElementById(objTarget))) {
        objTarget = document.getElementById(objTarget);
    }
    if (isObject(objTarget)) {
        if (objTarget.type == "checkbox") {
            if (objTarget.checked == true) {
                return objTarget.value;
            }
            else {
                return "";
            }
        }
        else {
            return objTarget.value;
        }
    }
    else {
        return "";
    }
}

//'--------------------------------------------------------------------
//' Shortcut Keys
//'--------------------------------------------------------------------
var arrBtnShortcutKeyCode = new Array();
var arrBtnShortcutElement = new Array();
document.onkeydown = function () {
    if (event) {
        if (event.ctrlKey == true) {
            if (arrBtnShortcutKeyCode.length > 0) {
                for (i = arrBtnShortcutKeyCode.length; i >= 0; i--) {
                    if (event.keyCode == arrBtnShortcutKeyCode[i]) {
                        if (isObject(document.getElementById(String(arrBtnShortcutElement[i])))) {
                            document.getElementById(String(arrBtnShortcutElement[i])).click();
                            window.event.cancelBubble = true;
                            return false;
                        }
                    }
                }
            }
        }
    }
}
