

// Browser Sniff

var iasp_UserAgent = navigator.userAgent.toLowerCase();
var iasp_BrowserVer = navigator.appVersion
var iasp_Opera = (iasp_UserAgent.indexOf('opera') != -1);
var iasp_Opera8 = ((iasp_UserAgent.indexOf('opera 8') != -1 || iasp_UserAgent.indexOf('opera/8') != -1) ? 1 : 0);
var iasp_NS4 = (document.layers) ? true : false;
var iasp_IE4 = (document.all && !document.getElementById) ? true : false;
var iasp_IE5 = (document.all && document.getElementById) ? true : false;
var iasp_IsIE = (iasp_IE4 || iasp_IE5) ? true : false;
var iasp_NS6 = (!document.all && document.getElementById) ? true : false;
var iasp_FireFox = (iasp_UserAgent.indexOf("firefox/") != -1);
var iasp_Chrome = (iasp_UserAgent.indexOf("chrome/") != -1);


function iasp_FindControl(strControlName) {
    var objReturn = null;
    if (iasp_IE5 || iasp_NS6 || iasp_Opera || iasp_Opera8)
    { objReturn = document.getElementById(strControlName); }
    else if (iasp_IE4) { objReturn = document.all[strControlName]; }
    else if (iasp_NS4) { objReturn = document.layers[strControlName]; }
    return objReturn;
}


/* scipr to pick update enter key for simple menu search */
function ikb_SimpleSearchKeyPress(butid) {

    try {
        if ((event.keyCode && event.keyCode == 13)) {
            iasp_FindControl(butid).click();
            return false;
        } else return true;

    }
    catch (e) { };

}

function iasp_EncodeString(s) {
    if (!s) { return ''; }
    s = s.replace(/\+/g, '%2B');
    s = s.replace(/\"/g, '%22')
    s = s.replace(/\'/g, '\'')
    return encodeURI(s);
}

/* enter we have search terms in simple menu site wide search in mainnavigation.ascx */
function ikb_SimpleSearchValidate(strKeywords) {


    if (strKeywords != "") {
        return true;

    } else {
        return false;
    }
}

function doHelpSearch(searchURL, txt) {

    var txt = iasp_FindControl(txt);

    if (txt != null) {
        if (txt.value != "Enter Keywords..." && txt.value != "") {
            location = searchURL + "?Keywords=" + iasp_EncodeString(txt.value);
        } else {
            txt.focus();
            txt.value = "";
        }
    }
    return false;

}


function clearTxt(txt, defaultVal, clear) {

    var strDefaultVal = "";
    if (defaultVal != null) { strDefaultVal = defaultVal; }
    if (!clear) { clear = false; }

    if (txt != null) {
        if (clear) {
            if (txt.value == strDefaultVal) {
                txt.value = "";
            }
        } else {
            if (txt.value == "") {
                txt.value = strDefaultVal;
            }
        }

    }

    return false;
}