﻿var preloadFlag = false;

function test4illegal(strng, theID) {
    var illegal = "!@#$%^&*()=_+[]\{}|;':,./?><";
    for (var i = 0; i < strng.length; i++) {
        temp = strng.substring(i, i + 1);
    }

    if (illegal.indexOf(temp) != -1 && strng != "") {
        error = "The page Alias contains illegal characters.\nPlease remove any special characters.\nSpecial characters include: !@#$%^&*()=_+[]\{}|;':,./?><";
        alert(error);
        document.getElementById(theID).focus();
        return false;
    }
    else if (strng.indexOf(' ') > 0) {
        error = "The page Alias may NOT contain spaces.\nPlease remove any spaces in the Page Alias";
        alert(error);
        //alert("theID= " + theID);
        document.getElementById(theID).focus();
        return false;
    }
    else {
        return true;
    }
}

function navSelect(theID) {
    var theSRC = document.getElementById(theID).src;
    var theIMG = theSRC.substring(theSRC.lastIndexOf('/') + 1, theSRC.lastIndexOf('.'));

    //IF '_over' is in the theIMG, remove it. If it's NOT in the theIMG, add it!
    if (theIMG.indexOf('_over') > -1)
        theIMG = theSRC.replace(/_over/, "");
    else
        theIMG = theSRC.replace(theIMG, theIMG + "_over");

    if (document.getElementById(theID) && (preloadFlag == true))
        document.getElementById(theID).src = theIMG;
}

function getPageName() {
    var strHref = window.location.href;
    var mypage_array = strHref.split("/");

    var TheFileName = mypage_array[(mypage_array.length - 1)]
    //alert("TheFileName:" + TheFileName);

    //Get the Index of the '.'
    var TheName = TheFileName.substring(0, TheFileName.lastIndexOf('.'));
    //alert("TheName= " + TheName);		

    return TheName;
}

function getQueryStringValue(strValue) {
    var qsParm = new Array();
    qsParm[strValue] = null;

    var query = window.location.search.substring(1);
    var parms = query.split('&');
    for (var i = 0; i < parms.length; i++) {
        var pos = parms[i].indexOf('=');
        if (pos > 0) {
            var key = parms[i].substring(0, pos);
            var val = parms[i].substring(pos + 1);
            qsParm[key] = val;
        }
    }
    //Get the value of ID from the queryString
    var qsVal = qsParm[strValue];

    return qsVal;
}

function clickIt(nodeName) {
    //alert("nodeName= " + nodeName);
    if (nodeName.style.display == "none") {
        //alert("nodeName= STYLE IS NONE" + nodeName);
        nodeName.style.display = "";
    }
    else {
        //alert("nodeName= STYLE IS NOT NONE!! Set it to none" + nodeName);
        nodeName.style.display = "none";
    }

}

function OpenNewWindow(theURL, winName, features) { //v2.0
    window.open(theURL, winName, features);
}

function funSearch(q) {
    //alert("q= " + q);
    var q2 = encodeURIComponent(q);
    //q2 = q2.replace(/ /gi, '%20');
    //alert("q2= " + q2);
    window.location = "http://www.google.com/search?sitesearch=www.cota.com&q=" + q2;
}