//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 isEmail(s) {
    var filter=/^.+@.+\..{2,4}$/
    return filter.test(s);
}

// 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');
        }
}

//in inc_navigation.asp, this swaps a fake password field for the real deal
// allowing us to show "password" in text when it's not selected and 
// switch the type to "password" when it is selected. IE doesn't allow 
// type changes post onLoad, so this is the work around.
function swapPass(t) {
    if (t==0) { //show fake one
        document.getElementById('passwd').focused=false;
        document.getElementById('passwd').style.display='none';
        document.getElementById('fpass').style.display='inline-block'; 
    }else{
        document.getElementById('fpass').style.display='none'; 
        document.getElementById('passwd').style.display='inline-block';
        document.getElementById('passwd').focused=true;
        document.getElementById('passwd').focus();
    }
    return true;
}

//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();
}

//open a window with defined width and height.
function openDynWin(page,w,h) {
    window_handle = window.open(page,'popup','width='+w+',height='+h+',scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no');
    window_handle.focus();
}

// IE6 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", "");
                }
            }
        }
    }
}

if (document.getElementById("nav")!=null) {addLoadEvent(startList);}

