function getObj(nm) {
	if (document.getElementById) {
		return document.getElementById(nm);
	} else if (document.all) {
		return document.all[nm];
	} else {
		return eval("document." + nm);
	}
}

// menu

var mtimer=new Array();

// Turns a menu on
function menuOn(whatMenu) {
	if (mtimer[whatMenu]) {
		clearTimeout(mtimer[whatMenu]);
	}
	getObj("menu" + whatMenu).style.display = "inline";
	getObj("menu" + whatMenu).style.zIndex = 99;
}

// Called when mouse is moved away from a menu
function menuOut(whatMenu) {
	if (mtimer[whatMenu]) {
		clearTimeout(mtimer[whatMenu]);
	}
	getObj("menu" + whatMenu).style.zIndex = 98;
	eval("mtimer[whatMenu]=setTimeout('closeMenu(\"" + whatMenu + "\")', 200)");
}

// Turns a menu off
function closeMenu(whatMenu) {
	getObj("menu" + whatMenu).style.display = "none";
}


function wellingtonhelp(helptext)
{
	//nwin=window.open("help.asp?helptext=" + escape(helptext), "help",config="scrollbars=yes,resizable=yes,toolbar=yes,location=yes,status=yes,menubar=yes,");
	var nwin=window.open("help.asp?helptext=" + escape(helptext), "help", "width=280,height=170,locationbar=0,menubar=0,personalbar=0,status=0,scrollbars=1,resizable=1")
	nwin.focus();
}

//buttons
function buttonOn(buttonID, image) {
getObj("buttonImage" + buttonID).src = "graphics/button_" + image + "_on.gif";
}

function buttonOut(buttonID, image) {
getObj("buttonImage" + buttonID).src = "graphics/button_" + image + "_off.gif";
}

function buttonSwap(buttonID, image) {
	getObj(buttonID).src = image;
}

// place dropdown menus
function menuPlace() {
	ns4 = (document.layers)? true:false;
	ie4 = (document.all)? true:false;
	winW = (ns4)? (window.innerWidth / 2) - 210 : (document.body.offsetWidth / 2) - 214;
	getObj("menuaboutus").style.left = winW - 100;
	getObj("menuguernseylaw").style.left = winW - 13;
	getObj("menunews").style.left = winW + 191;
}


function printPage(activationMethod) {
	printAddition = "<img src=\"graphics/logo_bar_print.gif\" width=\"200\" height=\"62\" alt=\"\">";
	printAddition += "<br><br>";

	getObj("printHolder").style.display = "block";
	getObj("printHolder").innerHTML = printAddition;
	getObj("printHolder").innerHTML += getObj("contentHolder").innerHTML;
	getObj("master").style.display = "none";
	if (activationMethod == "button") { // if they used file->print then don't fire print event
		if (window.print) {
			window.print();
			resetPrint = setTimeout("printPageReset()", 2000); // add delay for mozilla based browser which are so fast they reset the page before it prints!
		} else {
			alert("Sorry, your browser doesn't support this feature. Please press Option + P to print this page.");
		}
	}
}

function printPageReset() {
	getObj("printHolder").innerHTML = "";
	getObj("printHolder").style.display = "none";
	getObj("master").style.display = "block";
}

function placeFooter() {
	screenHeight = document.body.clientHeight;
	documentHeight = getObj("contentHolder").scrollHeight + 250;
	if (documentHeight > screenHeight) {
		getObj("toTop").style.display = "block";
	}
}
