//All source code and design by Bowers Programming
//Source code copyright © 1999, 2006 Randy Bowers, Bowers Programming.
//Source code is designated intellectual property of Bowers Programming.
//phn: 360.671.5280
//eml: randy@bowersprogramming.com
//web: www.bowersprogramming.com
//All rights of copyright holders are reserved.

//use: return isNumber(N)
//given a character returns the character if it was 0..9, otherwise it halts the event.
function isNumber(e) {
    var keynum;
    var keychar;
    var numcheck;
    if(window.event) { // IE
        keynum = e.keyCode;
    } else if(e.which) { // Netscape/Firefox/Opera
        keynum = e.which;
    }
    keychar = String.fromCharCode(keynum);
    numcheck = /\d/;
    return numcheck.test(keychar);
}

// Function to 'activate' images.
function imgOn(imgName,windowStatus) {
        if (document.images) {
            document[imgName].src = eval(imgName + 'on.src');
        }
}

// Function to 'deactivate' images.
function imgOff(imgName) {
        if (document.images) {
            document[imgName].src = eval(imgName + 'off.src');
        }
}

//shopping cart on/off
if (document.images) {            // Active images
    imgcartoff = new Image();  imgcartoff.src = 'images/cart_off.gif';
    imgcarton = new Image();  imgcarton.src = 'images/cart_on.gif';
}

//Open a new browser window 
function openWin(page) {
    window_handle = window.open(page,'popup','width=350,height=425,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=yes');
    window_handle.focus();
}

//Open a new browser window 
function openWin500(page) {
    var width=550;
    var height=350;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    window_handle = window.open(page,'popup','width='+width+',height='+height+',scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=yes,left='+left+',top='+top+'screenX='+left+',screenY='+top);
    window_handle.focus();
}

//Open a new browser window 
function printable(page) {
    window_handle = window.open(page,'popup','width=640,height=600,scrollbars=yes,resizable=yes,status=no,toolbar=yes,menubar=yes');
    window_handle.focus();
}


// IE hover and Z-index fix for main navigation
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
	    window.onload = func;
	} else {
        window.onload = function() 
        {
            oldonload();
            func();
        };
    }
}


startList = function() {
    if (document.all&&document.getElementById) {
        zCount = 100;
        navRoot = document.getElementById("nav");
        for (i=0; i<navRoot.childNodes.length; i++) {
            node = navRoot.childNodes[i];
            if (node.nodeName=="LI") {
                node.style.zIndex = zCount;
                zCount--;
                node.onmouseover=function() {
                    this.className+=" over";
                }
                node.onmouseout=function() {
                    this.className=this.className.replace(" over", "");
                }
            }
        }
    }
}

addLoadEvent(startList);
