// <!--
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Declare global variables
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var zindex = 100;
var ie4 = document.all;
var ns4 = document.layers;
var ns6 = document.getElementById&&!document.all;
var opr = navigator.userAgent.indexOf("Opera");
var mac = navigator.userAgent.indexOf("Mac");
var dd = true;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// For menu hiding
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var timerID = null;
var timerRunning = false;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Changes menu images
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function navOver(divID, strImage) {
	strImage = '/images/'+strImage;
	divID = 'top_nav_'+divID;
	if(ns6) {
		document.getElementById(divID).src = strImage;
	} else {
		eval(divID).src = strImage;
	}
}
function navOut(divID, strImage) {
	strImage = '/images/'+strImage;
	divID = 'top_nav_'+divID;
	if(ns6) {
		document.getElementById(divID).src = strImage;
	} else {
		eval(divID).src = strImage;
	}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Changes sub-menu background color
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function subNavOver(divID){
	if(ns6) {
		document.getElementById(divID).style.backgroundColor="#b6d4f1";
	} else {
		eval(divID).style.backgroundColor="#b6d4f1";
	}
}
function subNavOut(divID){
	if(ns6) {
		document.getElementById(divID).style.backgroundColor="#ffffff";
	} else {
		eval(divID).style.backgroundColor="#ffffff";
	}
}
function subNavMouseDown(divID){
	if(ns6) {
		document.getElementById(divID).style.backgroundColor="#ffff33";
	} else {
		eval(divID).style.backgroundColor="#ffff33";
	}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Pre-load images
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function newImage(arg) {
        rslt = new Image();
        rslt.src = arg;
        return rslt;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Time out the sub menu pop
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function startSubTimeout(whichone) {
        if(!timerRunning) {
                timerID = setTimeout("hidemenu('')",1000);
                timerRunning = true;
        }
}

function stopSubTimeout(whichone) {
        if(timerID) {
                clearTimeout(timerID);
		timerRunning = false;
        }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Layer Pop-Up
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function pop_it(whichone, intTop, intLeft) {
	// Stop the timer
	stopSubTimeout(whichone);

	// Hide everything else
	hidemenu(whichone);

        curmenuID=ns6? document.getElementById(whichone).id : eval(whichone).id

        if ((window.themenu&&themenu.id!=curmenuID) && (curmenuID != ''))
                themenuStyle.visibility=ns4?"hide" : "hidden"

        themenu=ns6? document.getElementById(whichone): eval(whichone)
        themenuStyle=(ns6||ie4)? themenu.style : themenu

//      themenuoffsetX=(ie4&&opr==-1)? document.body.scrollLeft : 200;
//      themenuoffsetY=(ie4&&opr==-1)? document.body.scrollTop : 400;

	intLeft += this.document.getElementById('OuterDiv').offsetLeft;
	if(mac > 0) {
		intLeft -= 15;
	}
	intTop += this.document.getElementById('OuterDiv').offsetTop;
        themenuStyle.left = intLeft+'px';
        themenuStyle.top = intTop+'px';

        hiddenconst=(ns6||ie4)? "hidden" : "hide"
        if (themenuStyle.visibility==hiddenconst){
                if(dd == true) {
                        themenuStyle.visibility=(ns6||ie4)? "visible" : "show"
                        themenuStyle.zIndex=zindex++
                }
        }
        dd = true;
        return false
}

function hidemenu(whichone){
	var subMenu = new Array('subnav_about_us','subnav_services','subnav_staff','subnav_contact_us','subnav_links','subnav_pg');
	hiddenconst=(ns6||ie4)? "hidden" : "hide"
	for(x = 0;x < subMenu.length;x++) {
		if(subMenu[x] != whichone) {
		        themenu = ns6 ? document.getElementById(subMenu[x]) : eval(subMenu[x])
		        themenuStyle = (ns6||ie4) ? themenu.style : themenu

		        if ((ie4||ns6)&&window.themenu)
		                themenuStyle.visibility = "hidden";
		        else if (ns4)
		                themenu.visibility = "hide";
		}
	}
}


function alertSize() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return [myWidth, myHeight];
}

function getScrollXY() {
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return [ scrOfX, scrOfY ];
}
