var sendOff;
var whichOne = 1; // which style do we use -- increments and rolls over
var howMany = 2; // default
var whatStyle = 'HS2'; // default
var theseRows;
var whatClass = 'greyWhite'; // for now we just make sure the style sheet is loaded before we do this
var addedThese = {}; // put them here as we add them
var hoverRe = new RegExp("Hover$");
var allARef = document.getElementsByTagName('a');
var thisPage;
var testThisPage;
var thisPath = document.location.href;
var splitPath = document.location.href.split('/');
var tossIt = splitPath.pop();
var thisFolder = splitPath.pop();
var thisPathName = window.location.pathname;
var pathnameArray = thisPathName.split('/');
var testLeftOver =  splitPath.join('/');
var againstThisPage;
var allNavs = new Array();
var sideNavs = new Array();
var allDivs = document.getElementsByTagName('div');
var tmpThing;
var tmpThingTwo;
var pullIn = 0;
var pullUp = 16;
var winTimer;
var thisElem;
var notSideNav = [];
var notThese = [];
var pathArray = new Array();
var thisFolder;
var allSectionNavARef = [];
var toOverRe = new RegExp(/^(.*)(\.[^.]+)$/);
var toNormalRe = new RegExp(/^(.*)(_on)(\.[^.]+)$/);
var toOverChangeTo = "$1_on$2";
var toNormalChangeTo = "$1$3";
var pWin;
var submitFlag = false;
var pricelist;
var lookup;

function ucFirst(s) {
    var c = s.charAt(0);
    if (parseInt(s.length)==1) {
        return c.toUpperCase();
    } else {
        return c.toUpperCase() + s.slice(1).toLowerCase();
    }
}

function fromCssToDom(thisLabel) {
    var mySplit = thisLabel.split('-');
    // skip the first one
    for (i=1;i<mySplit.length;i++) {
        mySplit[i]=ucFirst(mySplit[i]);
    }
    thisLabel = mySplit.join('');
    return thisLabel;
}

function findInArray(theValue, theArray) {
    var found = false;
    var arrayLength = theArray.length;
    for (var ctr=0; ctr < arrayLength; ctr++) {
        if (theValue == theArray[ctr]) {
            found=true;
            break;
        }
    }
    return found;
}

function trimString (str) {
    var thisStr = '' + str;
    if (thisStr != '' && (thisStr.search(/^\s+/g) || thisStr.search(/\s+$/g))) {
        thisStr = thisStr.replace(/^\s+/g, '');
        thisStr = thisStr.replace(/\s+$/g, '');
    }
    return thisStr;
}

function saidNo(messageString,urlString,setOnCancel,unSetOnCancel) {
    if (confirm(messageString)) {
        document.location.replace(urlString);
    }
    else {
        setOnCancel.checked = 1;
        unSetOnCancel.checked = 0;
    }
}
/**
 * Throughout, whitespace is defined as one of the characters
 *  "\t" TAB \u0009
 *  "\n" LF  \u000A
 *  "\r" CR  \u000D
 *  " "  SPC \u0020
 *
 * This does not use Javascript's "\s" because that includes non-breaking
 * spaces (and also some other characters).
 *
 * Determine whether a node's text content is entirely whitespace.
 *
 * @param nod  A node implementing the |CharacterData| interface (i.e.,
 *             a |Text|, |Comment|, or |CDATASection| node
 * @return     True if all of the text content of |nod| is whitespace,
 *             otherwise false.
 */

function is_all_ws( nod ) {
    // Use ECMA-262 Edition 3 String and RegExp features
    return !(/[^\t\n\r ]/.test(nod.data));
}
/**
 * Determine if a node should be ignored by the iterator functions.
 *
 * @param nod  An object implementing the DOM1 |Node| interface.
 * @return     true if the node is:
 *                1) A |Text| node that is all whitespace
 *                2) A |Comment| node
 *             and otherwise false.
 */

function is_ignorable( nod ) {
    return ( nod.nodeType == 8) || // A comment node
        ( (nod.nodeType == 3) && is_all_ws(nod) ); // a text node, all ws
}
/**
 * Version of |previousSibling| that skips nodes that are entirely
 * whitespace or comments.  (Normally |previousSibling| is a property
 * of all DOM nodes that gives the sibling node, the node that is
 * a child of the same parent, that occurs immediately before the
 * reference node.)
 *
 * @param sib  The reference node.
 * @return     Either:
 *               1) The closest previous sibling to |sib| that is not
 *                  ignorable according to |is_ignorable|, or
 *               2) null if no such node exists.
 */

function node_before( sib ) {
    while ((sib = sib.previousSibling)) {
        if (!is_ignorable(sib)) return sib;
    }
    return null;
}
/**
 * Version of |nextSibling| that skips nodes that are entirely
 * whitespace or comments.
 *
 * @param sib  The reference node.
 * @return     Either:
 *               1) The closest next sibling to |sib| that is not
 *                  ignorable according to |is_ignorable|, or
 *               2) null if no such node exists.
 */

function node_after( sib ) {
    while ((sib = sib.nextSibling)) {
        if (!is_ignorable(sib)) return sib;
    }
    return null;
}
/**
 * Version of |lastChild| that skips nodes that are entirely
 * whitespace or comments.  (Normally |lastChild| is a property
 * of all DOM nodes that gives the last of the nodes contained
 * directly in the reference node.)
 *
 * @param sib  The reference node.
 * @return     Either:
 *               1) The last child of |sib| that is not
 *                  ignorable according to |is_ignorable|, or
 *               2) null if no such node exists.
 */

function last_child( par ) {
    var res=par.lastChild;
    while (res) {
        if (!is_ignorable(res)) return res;
        res = res.previousSibling;
    }
    return null;
}
/**
 * Version of |firstChild| that skips nodes that are entirely
 * whitespace and comments.
 *
 * @param sib  The reference node.
 * @return     Either:
 *               1) The first child of |sib| that is not
 *                  ignorable according to |is_ignorable|, or
 *               2) null if no such node exists.
 */

function first_child( par ) {
    var res=par.firstChild;
    while (res) {
        if (!is_ignorable(res)) return res;
        res = res.nextSibling;
    }
    return null;
}
/**
 * Version of |data| that doesn't include whitespace at the beginning
 * and end and normalizes all whitespace to a single space.  (Normally
 * |data| is a property of text nodes that gives the text of the node.)
 *
 * @param txt  The text node whose data should be returned
 * @return     A string giving the contents of the text node with
 *             whitespace collapsed.
 */

function data_of( txt ) {
    var data = txt.data;
    // Use ECMA-262 Edition 3 String and RegExp features
    data = data.replace(/[\t\n\r ]+/g, " ");
    if (data.charAt(0) == " ") {
        data = data.substring(1, data.length);
    }
    if (data.charAt(data.length - 1) == " ") {
        data = data.substring(0, data.length - 1);
    }
    return data;
}
/**
 * Adds another method to document to get an array of elements.
 *
 * @param pattern	A RegEx object or string pattern
 * @param flags		Optional only used with string pattern.
 */
document.getElementsByIdRegEx = function() {
    var retVal = false;
    var pattern;
    if (arguments.length > 0) {
        if (typeof(arguments[0]) != 'string') {
            if (arguments[0].exec && arguments[0].test) {
                pattern = arguments[0];
            } else {
                alert('Argument type of object, RegExp object expected.');
            }
        } else {
            if (arguments.length == 2) {
                if (arguments[1].match(/^[igm]$/) || arguments[1] == '') {
                    pattern = new RegExp(arguments[0], arguments[1]);
                } else {
                    alert('Flags can be one of the following: g, i or m.');
                }
            } else {
                pattern = new RegExp(arguments[0]);
            }
        }
        if (pattern != null) {
            matchedElements = [];
            var elements = document.getElementsByTagName('*');
            for (var i=0; i<elements.length; i++) {
                if (elements[i].id) {
                    if (elements[i].id.match(pattern)) { matchedElements.push(elements[i]); }
                }
            }
            retVal = matchedElements;
        }
    }
    return(retVal);
}

function inArray(findThis, inThis) {
    var retval = false;
    for (var i=0;i<inThis.length;i++) {
        if (inThis[i] == findThis) {
            retval = true;
            break;
        }
    }
    return retval;
}

function hasAncestor(elem, ancestor) {
    var retVal = false;
    if (elem.parentNode) {
        if (elem.parentNode == ancestor) {
            retVal = true;
        } else {
            retVal = hasAncestor(ancestor, elem.parentNode);
        }
    }
    return(retVal);
}
//------------------- for clearing and replacing text in form input fields and textareas -------------------//

function clearText(thefield) {
    if (thefield.defaultValue==thefield.value) {
        thefield.value = "";
    }
}

function replaceText(thefield) {
    if (thefield.value=="") {
        thefield.value = thefield.defaultValue;
    }
}
//------------------- DATE -------------------//

function date() {
    var mydate=new Date();
    var year=mydate.getYear();
    if (year < 1000) {
        year+=1900;
    }
    var day=mydate.getDay();
    var month=mydate.getMonth();
    var daym=mydate.getDate();
    if (daym<10) {
        daym="0"+daym;
    }
    var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
    var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
    document.write("<p>"+dayarray[day]+" "+montharray[month]+" "+daym+", "+year+"</p>");
}
//------------------- ADD BOOKMARK -------------------//

function addBookmark(title,url) {
    if (window.sidebar) {
        window.sidebar.addPanel(title, url,"");
    } else if( document.all ) {
        window.external.AddFavorite( url, title);
    } else if( window.opera && window.print ) {
        return true;
    }
}

function MM_validateForm() { //v4.0
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
        if (val) { nm=val.name; if ((val=val.value)!="") {
            if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
                if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
            } else if (test!='R') { num = parseFloat(val);
                if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
                if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
                    min=test.substring(8,p); max=test.substring(p+1);
                    if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
                } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
}
/*
   all styles:
   HS2 2 horizontal colors
 */

function stripeOn() {
    var tArray = document.getElementsByTagName("table");
    var topRow = null;
    for(var i=0;i<tArray.length;i++) {
        if (tArray[i].className.match(/^tf_/)) {
            // split it up
            var tS = tArray[i].className.split('_');
            whatStyle = tS[1];
            whatClass = tS[2];
            if (addedThese[tS[2]]) {
                // already got it
            } else {
                var objHead = document.getElementsByTagName('head');
                if (objHead[0]) {
                    var objCSS = objHead[0].appendChild(document.createElement('link'));
                    objCSS.id = tS[2];
                    objCSS.rel = 'stylesheet';
                    var domainpart = document.location.href.split('/');
                    objCSS.href = 'http://' + domainpart[2] + '/css/tableStripers/'+tS[2]+'.css';
                    //alert(objCSS.href);
                    objCSS.type = 'text/css';
                }
            }
            var theseTables = tArray[i].getElementsByTagName("table");
            for (var tKiller=0;tKiller<theseTables.length;tKiller++) {
                var thoseRows = theseTables[tKiller].getElementsByTagName("tr");
                for (var rIndex=0;rIndex<thoseRows.length;rIndex++) {
                    thoseRows[rIndex].setAttribute("ignoreMe", "true");
                }
            }
            var theseRows = tArray[i].getElementsByTagName("tr");
            for (var j=0;j<theseRows.length;j++) {	
                if (theseRows[j].getAttribute("ignoreMe") == "true") {
                    //don't apply striper to these rows in tables inside outer table
                } else {
                    if (j==0 && whatClass.match(/Top/)) {
                        topRow = theseRows[j];
                        // use the 'TopRow' styles
                        theseRows[j].className = 'tr_'+whatClass + 'TopRow';
                        var theseCels = theseRows[j].getElementsByTagName("td");
                        for(var k=0;k<theseCels.length;k++) {
                            if (theseCels[k].parentNode.getAttribute("ignoreMe") == "true") {
                                // skipping it
                            } else {
                                if (k == 0) {
                                    theseCels[k].className='td_'+whatClass + 'TopRowLeft';
                                }
                                else if (k == theseCels.length - 1) {
                                    theseCels[k].className='td_'+whatClass + 'TopRowRight';
                                } else {
                                    theseCels[k].className='td_'+whatClass + 'TopRow';
                                }
                            }
                        }
                    }
                    else if (j==theseRows.length - 1 && whatClass.match(/Bottom/)) {
                        // use the 'BottomRow' styles
                        theseRows[j].className = 'tr_'+whatClass + 'BottomRow';
                        var theseCels = theseRows[j].getElementsByTagName("td");
                        for(var k=0;k<theseCels.length;k++) {
                            if (theseCels[k].parentNode.getAttribute("ignoreMe") == "true") {
                                // skipping it
                            } else {
                                if (k == 0) {
                                    theseCels[k].className='td_'+whatClass + 'BottomRowLeft';
                                }
                                else if (k == theseCels.length - 1) {
                                    theseCels[k].className='td_'+whatClass + 'BottomRowRight';
                                } else {
                                    theseCels[k].className='td_'+whatClass + 'BottomRow';
                                }
                            }
                        }
                    } else {
                        theseRows[j].className = 'tr_'+whatClass+whichOne + '';
                        var theseCels = theseRows[j].getElementsByTagName("td");
                        for(var k=0;k<theseCels.length;k++) {
                            if (theseCels[k].parentNode.getAttribute("ignoreMe") == "true") {
                                // skipping it
                            } else {
                                if (k == 0) {
                                    theseCels[k].className='td_'+whatClass + whichOne + 'Left';
                                }
                                else if (k == theseCels.length - 1) {
                                    theseCels[k].className='td_'+whatClass + whichOne + 'Right';
                                } else {
                                    theseCels[k].className='td_'+whatClass + whichOne;
                                }
                            }
                        }
                        whichOne++;
                        if (whichOne > howMany) {
                            whichOne = 1;
                        }
                    }
                }
            }
        }
    }
}

function dropIt() {
    // like striper, but for fake dropshadows
    // and it assumes we already have the stylesheet loaded
    var tArray = document.getElementsByTagName("table");
    // look for ones with class names containing 'DropShadow' 	
    for(var i = 0;i<tArray.length;i++) {
        if (tArray[i].className.match(/DropShadow/)) {
            var theseRows = tArray[i].getElementsByTagName("tr");
            for (var j=0;j<theseRows.length;j++) {
                var theseCels = theseRows[j].getElementsByTagName("td");
                for(var k=0;k<theseCels.length;k++) {
                    // here is where the magic happens :-)
                    // this is an uninformative comment
                    if (j == 0 && k == 0) {
                        theseCels[k].className = 'smallDropShadowTopLeft';
                    }
                    if (j == 0 && k == 1) {
                        theseCels[k].className = 'smallDropShadowTop';
                    }
                    if (j == 0 && k == 2) {
                        theseCels[k].className = 'smallDropShadowTopRight';
                    }
                    if (j == 1 && k == 0) {
                        theseCels[k].className = 'smallDropShadowLeftLeft';
                    }
                    if (j == 1 && k == 1) {
                        theseCels[k].className = 'smallDropShadowCenterCenter';
                    }
                    if (j == 1 && k == 2) {
                        theseCels[k].className = 'smallDropShadowRightRight';
                    }
                    if (j == 2 && k == 0) {
                        theseCels[k].className = 'smallDropShadowBottomLeft';
                    }
                    if (j == 2 && k == 1) {
                        theseCels[k].className = 'smallDropShadowBottom';
                    }
                    if (j == 2 && k == 2) {
                        theseCels[k].className = 'smallDropShadowBottomRight';
                    }
                }
            }
        }
    }
}
if (testLeftOver == 'http:/') {
    // we are in the main folder
    thisFolder = '';
}
thisPath = splitPath.join('/') + '/';
if (thisFolder != '') {
    againstThisPage = [document.location.href, thisPath+'index.php', thisPath+'index.htm',thisPath+'index.html',thisPath+'index.asp'];
    if (pathnameArray.length > 2) {
        //Remove the first and the last...
        pathnameArray.shift();
        pathnameArray.pop();
        againstThisPage.push(window.location.protocol+'//'+window.location.hostname+'/'+pathnameArray[0]+'/index.php');
    }
} else {
    againstThisPage = [document.location.href];
}

function inArray(findThis, inThis) {
    var retval = false;
    for (var i=0;i<inThis.length;i++) {
        if (inThis[i] == findThis) {
            retval = true;
            break;
        }
    }
    return retval;
}
//sets site path links to hover state

function lightUp() {
    var pathSplit;
    var testPath;
    var testRe;
    for (var i=0;i<allARef.length;i++) {
        testThisPage = allARef[i].href;
        // console.log(testThisPage.toLowerCase());
        if (!allARef[i].id || allARef[i].id == '') {
            allARef[i].id = 'link_' + i;
        }
        if (allARef[i].className == "pageNavLink") {
            allSectionNavARef.push(allARef[i]);
        }
        for (var j=0;j<againstThisPage.length;j++) {
            // console.log(testThisPage.toLowerCase());
            // console.log(againstThisPage[j].toLowerCase());
            if (testThisPage.toLowerCase()== againstThisPage[j].toLowerCase()) {
                if (!allARef[i].className.match(/horizNavLink/)) {
                    if (!allARef[i].className.match(/Hover$/)) {
                        allARef[i].className=allARef[i].className+'Hover';
                    }
                    if (allARef[i].className == "pageNavLinkHover") {
                        thisPage=allARef[i].id;
                    }
                } else {
                    // get the parent node instead
                    // console.log(allARef[i]);
                    if (!allARef[i].parentNode.className.match(/Hover$/)) {
                        allARef[i].parentNode.className=allARef[i].parentNode.className+'Hover';
                    }
                    if (allARef[i].parentNode.className == "pageNavLinkHover") {
                        thisPage=allARef[i].id;
                    }
                }
            }
        }
    }
    //the current page we are on is not in the nav (for e.g. tabbed nav)
    if ((!thisPage) || (thisPage == '')) {
        pathSplit = document.location.href.split('/');
        testPath = pathSplit.pop();
        testPath = pathSplit.join('/') + '(?:/|/index\\.[^./]+)$';
        testRe = new RegExp("^" + testPath, "i");
        for (var i=0;i<allSectionNavARef.length;i++) {
            if (testRe.test(allSectionNavARef[i].href)) {
                if (!allSectionNavARef[i].className.match(/Hover$/)) {
                    allSectionNavARef[i].className=allSectionNavARef[i].className+'Hover';
                }
                thisPage = allSectionNavARef[i].id;
            }
        }
    }
}

function initTextNav() {
    var aStr = '';
    //MAIN NAV STATE
    //get the folder of the current page (which, in this case is the 3rd element in pathArray)
    //the folder name and the id of the image are set up to use the same name
    //thus we can use the folder name to set the img source to hover
    //designate that this is current page by affixing 'Selected' to its id
    //this is used as a flag so we don't change its state in mouseover and out events
    // var aWin = window.open('', 'aWin');
    // aWin.document.body.innerHTML = '<pre>' + aStr + '</pre>';
    pathArray = document.location.href.split("/");
    thisFolder = pathArray[3];
    if (document.getElementById(thisFolder) && !document.getElementById(thisFolder).className.match(/Hover$/)) {
        document.getElementById(thisFolder).className=document.getElementById(thisFolder).className+'Hover';
    }
}
//Dropdown flyout menu functions

function setUpNavDivs() {
    for(var i=0;i<allDivs.length;i++) {
        if (allDivs[i].className == 'navDiv') {
            allDivs[i].setAttribute("id", 'navDiv_' + i);
            allNavs.push('navDiv_' + i);
            // assumes that the layout is consistent, with 
            // a positioning div around the nav div
            tmpThing = allDivs[i].parentNode;
            //flyout menus positioning
            if (tmpThing.className != 'stopHere') {
                tmpThingTwo = node_before(tmpThing);
                allDivs[i].style.left = (tmpThingTwo.offsetWidth - pullIn) + 'px';
                allDivs[i].style.top = '-' + Math.floor(((tmpThingTwo.offsetHeight/2) + pullUp)) + 'px';
                //debugging code
                //if there is an element in the page with id of 'heyYou' your debugging code will appear here
                if(document.getElementById('heyYou')) {
                    document.getElementById('heyYou').innerHTML += 'tmpThingTwo offsetWidth: ' + tmpThingTwo.offsetWidth + '\n';
                    document.getElementById('heyYou').innerHTML += 'tmpThingTwo offsetHeight: ' + Math.floor(((tmpThingTwo.offsetHeight/2) + pullUp)) + '\n';
                }
            }
        }
        if (allDivs[i].className == 'sideNavDiv') {
            sideNavs.push(allDivs[i]);
        }
    }
    //when page loads navDivs are display: block visibility: hidden - otherwise we can't measure them. This sets them to display: none visibility: visible and display is toggled on mouseover.
    for(var i=0;i<allDivs.length;i++) {
        if (allDivs[i].className == 'navDiv') {
            allDivs[i].style.display='none';
            allDivs[i].style.visibility='visible';
        }
    }
}

function waitASec(elem) {
    window.clearTimeout(winTimer);
    //winTimer = window.setTimeout("clearAll()", 1000);
    winTimer = window.setTimeout("clearAll()", 500);
    if(document.getElementById('heyYou')) {
        document.getElementById('heyYou').innerHTML += 'waitASec setting timer\n';
        document.getElementById('heyYou').innerHTML += elem + ' ' + elem.id + '\n';
    }
}

function clearAll() {
    window.clearTimeout(winTimer);
    if(document.getElementById('heyYou')) {
        document.getElementById('heyYou').innerHTML += 'clearAll clearing timer\n';
    }
    notThese = [];
    for(var i=0;i<allNavs.length;i++) {
        document.getElementById(allNavs[i]).style.display='none';
    }
}

function showAfter(elem) {
    var walkOut = "";
    var thisNode = "";
    var mySib;
    var myChild;
    var prevSib;
    var m;
    if(document.getElementById('heyYou')) {
        document.getElementById('heyYou').innerHTML += '\nshowAfter ' + elem + '\n';
    }
    window.clearTimeout(winTimer);
    notThese = [];
    thisElem = elem;
    if (elem) {
        mySib = node_after(elem);
        // catch the main ones
        if (mySib && (mySib.className == 'stopHere' || !mySib.className)) {
            // get the first child of that div
            mySib = first_child(mySib);
        }
        if (mySib) {
            if (mySib.tagName.toLowerCase() == 'div' && mySib.className == 'navDiv') {
                if(document.getElementById('heyYou')) {
                    document.getElementById('heyYou').innerHTML += 'mySib ' + mySib.id + '\n';
                }
                mySib.style.display='block';
                notThese.push(mySib.id);
            }
        }
        walkOut = elem.parentNode;
        if(document.getElementById('heyYou')) {
            document.getElementById('heyYou').innerHTML += 'walkOut parent: ' + walkOut.id + '\n';
        }
        if (walkOut && walkOut.className == "navDiv" && walkOut.className != 'stopHere') {
            walkOut.style.display='block';
            notThese.push(walkOut.id);
            prevSib = node_before(walkOut);
        }
        while(walkOut && walkOut.className != 'stopHere') {
            walkOut = walkOut.parentNode;
            if (walkOut && walkOut.className != 'stopHere' && walkOut.className == 'navDiv') {
                if(document.getElementById('heyYou')) {
                    document.getElementById('heyYou').innerHTML += 'walkOut ' + walkOut.id + '\n';
                }
                walkOut.style.display='block';
                notThese.push(walkOut.id);
            }
        }
    }
    clearIt();
}

function clearIt() {
    window.clearTimeout(winTimer);
    if(document.getElementById('heyYou')) {
        document.getElementById('heyYou').innerHTML += 'clearIt clearing timer\n';
    }
    for(var i=0;i<allNavs.length;i++) {
        if (inArray(allNavs[i], notThese)) {
            document.getElementById(allNavs[i]).style.display='block';
            if(document.getElementById('heyYou')) {
                document.getElementById('heyYou').innerHTML += allNavs[i] + ' is in notThese -- setting block\n';
            }
        }
        else {
            document.getElementById(allNavs[i]).style.display='none';
            if(document.getElementById('heyYou')) {
                document.getElementById('heyYou').innerHTML += allNavs[i] + ' is not in in notThese -- setting none\n';
            }
        }
    }
}
//Expand collapse menu functions

function hideSectionNavs() {
    for(var i=0;i<sideNavs.length;i++) {
        if (sideNavs[i].className == 'sideNavDiv') {
            sideNavs[i].style.display='none';
            sideNavs[i].style.visibility='visible';
        }
    }
}

function initSetOpen(elem) {
    var walkOut = "";
    var thisNode = "";
    var mySib;
    var myChild;
    var prevSib;
    var m;
    var thisLink;
    if (document.getElementById(elem)) {
        thisLink = document.getElementById(elem);
    }
    //if this object (link) exsts then get the next thing
    if (thisLink) {
        mySib = node_after(thisLink);
        if (mySib) {
            //if its defined and if its a div then show it
            if (mySib.tagName=='div'||mySib.tagName=='DIV') {
                mySib.style.display='block';
            }
        }
        //look for my parents
        walkOut = thisLink.parentNode;
        if (walkOut && walkOut.className == "sideNavDiv") {
            walkOut.style.display='block';
            notSideNav.push(walkOut.id);
            prevSib = node_before(walkOut);
            if (prevSib && prevSib.tagName.toLowerCase() == 'a') {
                if (!hoverRe.test(prevSib.className)) {
                    prevSib.className = prevSib.className+'Hover';
                }
            }
        }
        while(walkOut && walkOut.className != 'stopHere') {
            walkOut = walkOut.parentNode;
            if (walkOut && walkOut.className == "sideNavDiv") {
                walkOut.style.display='block';
                notSideNav.push(walkOut.id);
                prevSib = node_before(walkOut);
                if (prevSib && prevSib.tagName.toLowerCase() == 'a') {
                    if (!hoverRe.test(prevSib.className)) {
                        prevSib.className = prevSib.className+'Hover';
                    }
                }
            }
        }
        if (walkOut && walkOut.className == "stopHere") {
            prevSib = node_before(walkOut);
            if (prevSib && prevSib.className.toLowerCase() == 'a' && prevSib.className == 'horizNavLink') {
                prevSib.className =  prevSib.className+'Hover';
            }
        }
    }
}

function MM_findObj(n, d) { //v4.01
    var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
        if (val) { nm=val.name; if ((val=val.value)!="") {
            if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
                if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
            } else if (test!='R') { num = parseFloat(val);
                if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
                if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
                    min=test.substring(8,p); max=test.substring(p+1);
                    if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
                } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
}

function validateForm() {
    MM_validateForm('email','','RisEmail','firstname','','R','lastname','','R','Math_Answer','','RisNum');
    if (document.MM_returnValue == true) {
        document.contact.submit();
    }
}

function hov(loc,cls) {
    if(loc.className) {
        loc.className=cls;
    }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
}

function checkShowAlert() {
    var errorFound = false;
    var errorMessage = '';
    if ((document.form1.account.value == '') && (document.form1.password.value == '')) {
        errorMessage = 'please enter your account and password';
        errorFound = true;
    } else if ((document.form1.account.value != '') && (document.form1.password.value == '')) {
        errorMessage = 'please enter your password';
        errorFound = true;
    } else if ((document.form1.account.value == '') && (document.form1.password.value != '')) {
        errorMessage = 'please enter your account';
        errorFound = true;
    } else {
        errorFound = false;
    }
    if (document.form1.agree.checked == false) {
        if (errorFound == true) {
            errorMessage += ' and you must agree to the user agreement to use the catalog.';
        } else {
            errorMessage = 'You must agree to the user agreement to use the catalog.';
        }
        errorFound = true;
    }
    if (errorFound == true) {
        alert(errorMessage);
        submitFlag = false;
    } else {
        submitFlag = true;
    }
    // document.form1.textfield.value = submitFlag;
    return submitFlag;
}

function checkShowResellerAlert() {
    var errorFound = false;
    var errorMessage = '';
    if ((document.form1.account.value == '') && (document.form1.password.value == '')) {
        errorMessage = 'please enter your account and password';
        errorFound = true;
    } else if ((document.form1.account.value != '') && (document.form1.password.value == '')) {
        errorMessage = 'please enter your password';
        errorFound = true;
    } else if ((document.form1.account.value == '') && (document.form1.password.value != '')) {
        errorMessage = 'please enter your account';
        errorFound = true;
    } else {
        errorFound = false;
    }

    if (errorFound == true) {
        alert(errorMessage);
        submitFlag = false;
    } else {
        submitFlag = true;
    }
    // document.form1.textfield.value = submitFlag;
    return submitFlag;
}

function checkForm() {
    if (checkShowAlert() == true) {
        document.form1.submit();
    }
}

function checkResellerForm() {
    if (checkShowResellerAlert() == true) {
        document.form1.submit();
    }
}

function collectAndSubmit(thisForm) {
    if (thisForm) {
        document.getElementById('actionFrame').src='/catalog/orderlists/addtoorderlist.php?productid=' + thisForm.productid.value + '&quantity=' + thisForm.quantity.value;
    }
}

function setProduct() {
    if (document.getElementById('quantity').value != '' && document.getElementById('quantity').value == 0) {
        document.getElementById('productkey').value = '';
        document.getElementById('quantity').value = '';
        document.getElementById('productkey').focus();
    }
    document.getElementById('actionFrame').src='/catalog/quickOrder.php?productkey=' + document.getElementById('productkey').value;
}

function setQuantity() {
    if (document.getElementById('quantity').value != '' && document.getElementById('quantity').value == 0) {
        document.getElementById('productkey').value = '';
        document.getElementById('quantity').value = '';
        document.getElementById('productkey').focus();
    } else {
        if (document.getElementById('validItem').value == 'true') {
            document.getElementById('actionFrame').src='/catalog/quickOrder.php?quantity=' + document.getElementById('quantity').value;
        } else {
            document.getElementById('actionFrame').src='/catalog/quickOrder.php?productkey=' + document.getElementById('productkey').value;
        }
    }
}

