// get browser versions that support dhtml
var useDHTML = false;
if (document.getElementById) {
	useDHTML = true;
}

/*
var isIE = false;
//alert(navigator.userAgent);
if ((navigator.userAgent.indexOf("MSIE") > 0) && (navigator.userAgent.indexOf("Win") > 0) && (navigator.userAgent.indexOf("Opera") == -1))  {
	isIE = true;
}
*/

function switchClass(whichElement,classname) {
// swaps classname for element
	if (document.getElementById) {
		whichElement.className = classname;
	}
}


function getAbsoluteTop(whichElement) {
// returns the top pixel position of an element on a page
	var t; 
	if (whichElement == document.body) {
		t = 0;
	} else {
		t = whichElement.offsetTop + getAbsoluteTop(whichElement.offsetParent);
	}
	return t;
} 


function getAbsoluteLeft(whichElement) {
// returns the left pixel position of an element on a page
	var l; 
	if (whichElement == document.body) {
		l = 0;
	} else {
		l = whichElement.offsetLeft + getAbsoluteLeft(whichElement.offsetParent);
	}
	return l;
} 


function getElementHeight(whichElement) {
// returns the height of an element
	var h = whichElement.offsetHeight;
	return h;
}


function getElementWidth(whichElement) {
// returns the width of an element
	var w = whichElement.offsetWidth;
	return w;
}


function getBodyWidth() {
	var w;
	if (window.innerWidth) {
		w = window.innerWidth;
	} else {
		w = document.body.offsetWidth;
	}
	return w;
}


function setVisibility(elementID,visibility) {
// set the visibility of elementID
	//alert(elementID+" "+visibility);
	var e = document.getElementById(elementID);
	//if (e && (e.style.visibility != visibility)) {
		e.style.visibility = visibility;
	//}
}


function doRollOn(whichMenu) {
	if (useDHTML) {
		var s = whichMenu.split("-");
		var doRoll = true;
		if (s[0] == "mainmenu") {
			if (parseInt(s[1]) == currentMainMenu) doRoll = false;
		} else {
			ss = s[0].split("_");
			if ((parseInt(ss[1]) == currentMainMenu) && (parseInt(s[1]) == currentSubMenu)) doRoll = false;
		}
		if (doRoll) {
			var id = s[0] + "_" + s[1];
			var src = "images/" + s[0] + "_on_" + s[1] + ".gif";
			document.getElementById(id).src = src;
		}
	}
}


function doRollOff(whichMenu) {
	if (useDHTML) {
		var s = whichMenu.split("-");
		var doRoll = true;
		if (s[0] == "mainmenu") {
			if (parseInt(s[1]) == currentMainMenu) doRoll = false;
		} else {
			ss = s[0].split("_");
			if ((parseInt(ss[1]) == currentMainMenu) && (parseInt(s[1]) == currentSubMenu)) doRoll = false;
		}
		if (doRoll) {
			var id = s[0] + "_" + s[1];
			var src = "images/" + s[0] + "_off_" + s[1] + ".gif";
			document.getElementById(id).src = src;
		}
	}
}


function showMenu(whichMenu) {
	if (useDHTML) {
		if (whichMenu != currentMainMenu) {
			var m = document.getElementById("submenu_"+whichMenu);
			setMenuPosition(m);
			m.style.visibility = "visible";
		}
	}
}


function hideMenu(whichMenu) {
	if (useDHTML) {
		if (whichMenu != currentMainMenu) {
			var m = document.getElementById("submenu_"+whichMenu);
			//setMenuPosition(m);
			m.style.visibility = "hidden";
		}
	}
}


function setMenuPosition(whichMenu) {
	var t = getAbsoluteTop(document.getElementById("mainmenu_1")) +23;
	var l = getAbsoluteLeft(document.getElementById("mainmenu_1"));
	whichMenu.style.top = t + "px";
	whichMenu.style.left = l + "px";
	
}


function showPage(whichPage) {
// load a file to the top level window
	top.location = whichPage;
}


function doPreload() {
// preload rollovers
	if (useDHTML) {
		var imgSrcs = new Array("menu_2_on_2.gif",
								"menu_2_on_3.gif",
								"menu_3_on_2.gif",
								"menu_3_on_3.gif",
								"menu_5_on_2.gif",
								"menu_5_on_3.gif",
								"menu_8_on_2.gif",
								"menu_8_on_3.gif",
								"menu_9_on_2.gif",
								"mainmenu_on_2.gif",
								"mainmenu_on_3.gif",
								"mainmenu_on_4.gif",
								"mainmenu_on_5.gif",
								"mainmenu_on_6.gif",
								"mainmenu_on_7.gif",
								"mainmenu_on_8.gif",
								"mainmenu_on_9.gif");
		var imgObjs =new Array();
		for (var i=0; i<imgSrcs.length; i++) {
			imgObjs[i] = new Image();
			imgObjs[i].src = imgSrcs[i];
		}
	}
}

function showMap() {
	if ((contactPage) && (GBrowserIsCompatible())) {
		var map = new GMap(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.centerAndZoom(new GPoint(-73.98655, 40.74315), 2);
		var point = new GPoint(-73.98655, 40.74315);
		var marker = new GMarker(point);
		map.addOverlay(marker);
	}
}

javascriptEnd = true;
