
var theSubMenu1;
var theSubMenu2;
var theSubMenu3;
var isMac = false;

function init() {
	theBrowser = self.navigator.userAgent;
	if ((theBrowser.indexOf("MSIE 5")>-1 || theBrowser.indexOf("Safari")>-1 ) && theBrowser.indexOf("Mac")>-1) isMac=true;

	theSubMenu2 = document.getElementById('sideSubMenu2');
	theSubMenu3 = document.getElementById('sideSubMenu3');

	if (self.location.href.indexOf("viewStoryHtml")==-1 && isMac==false) {
		theSubMenu3.style.position = "absolute";
		theSubMenu3.style.left="-999em";
	} else {
		theSubMenu3.style.position = "static";
		theSubMenu3.style.left="auto";
	}

	if ((self.location.href.indexOf("Projects+and+Services")==-1 && self.location.href.indexOf("m2=1")==-1 ) && isMac==false) {
		theSubMenu2.style.position = "absolute";
		theSubMenu2.style.left="-999em";
	} else {
		theSubMenu2.style.position = "static";
		theSubMenu2.style.left="auto";
	}

	paintKidsafe();
	if (self.location.href.indexOf("Links+and+Numbers")>-1) {
		paintTables();
	}
}


function toggleMenu(num) {
	switch (num) {
		case 2: thisMenu = theSubMenu2; antiMenu = theSubMenu3; break;
		case 3: thisMenu = theSubMenu3; antiMenu = theSubMenu2; break;
	}

	if (thisMenu.style.left=="-999em") {
		thisMenu.style.position = "static";
		thisMenu.style.left="0";
		thisMenu.style.top="0";
		thisMenu.style.overflow="auto"; // IE7 goes cuckoo and sets the height of the menu to 0 if you don't have this.


		if (antiMenu.style.left!="-999em") {
			antiMenu.style.position = "absolute";
			antiMenu.style.left="-999em";
		}

	} else {
		thisMenu.style.position = "absolute";
		thisMenu.style.left="-999em";
	}
}

function paintTables() {
	// Get all the Table elements
	var theTables=document.getElementsByTagName('TABLE');
	// Loop through them
	for (i=0;i<theTables.length;i++) {
		// Get all TR elements in this TABLE
		theRows = theTables[i].getElementsByTagName('TR');
		// Loop through TR elements
		var lcount=0;
		for (j=0;j<theRows.length;j++) {
			// if an even row...
			if (j%2 > 0) {
				// Paint!
				theRows[j].className="o";
			}
		}
	}
}

function paintKidsafe() {
	// Get all the INS elements
	var theINS=document.getElementsByTagName('INS');
	// Loop through them
	for (i=0;i<theINS.length;i++) {
		theINS[i].innerHTML = "<img src='statimages/replace_logo_big.gif' alt='Kidsafe WA' style='display:inline;vertical-align:baseline;'>";
	}
}

function popImage(theImage,theWidth,theHeight) {

	var winWidth=theWidth+30;
	if (winWidth<100) winWidth=100;

	var winHeight=theHeight+50;
	if (winHeight<100) winHeight=100;

	var theParams = "left=100,top=100,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no";
	theParams += ",width="+winWidth;
	theParams += ",height="+winHeight;
	var theWin = window.open("","",theParams);

	theWin.document.open();
	theWin.document.writeln("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
	theWin.document.writeln("<html><head>");
	theWin.document.writeln("<title>Kidsafe WA</title><meta content=\"text/html; charset=iso-8859-1\" http-equiv=Content-Type>");
	theWin.document.writeln("<style type=\"text/css\">");
	theWin.document.writeln("<!--");
	theWin.document.writeln("body {background-color:#FDC412;font-size:11px;margin:5px;text-align:center;font-family:\"trebuchet ms\",arial,helvetica,sans-serif;}");
	theWin.document.writeln("img {border:1px solid #000;margin:0 auto;}");
	theWin.document.writeln("a {font-weight:bold;display:block;padding-top:5px;color:#008;text-decoration:none;}");
	theWin.document.writeln("a:hover {color:#008;text-decoration:underline;}");
	theWin.document.writeln("//-->");
	theWin.document.writeln("</style>");
	theWin.document.writeln("</head>");
	theWin.document.writeln("<body onload=\"self.focus();\">");
	theWin.document.writeln("<img src=\""+theImage+"\" width=\""+theWidth+"\" height=\""+theHeight+"\" alt=\"Kidsafe WA\">");
	theWin.document.writeln("<a onclick=\"self.close();\">Close Window</a>");
	theWin.document.writeln("</body></html>");
	theWin.document.close();

	theWin.document.title="Kidsafe WA Map";
	theWin.focus();
	
}

function checkQty(theField) {
	var quantity=theField.value-0;

	if (isNaN(quantity) || quantity.length<1) {
		quantity="0";
		theField.value = 0;
	}
	if (Math.abs(Math.round(quantity))!=quantity) {
		quantity=Math.abs(Math.round(quantity));
		theField.value = quantity;
	}
}

function searchBy(subcat)	{
	var thisForm = document.searchform01;
	thisForm.searchString.value = subcat;
	thisForm.submit();
}

function NewsLetterFormCheckIt() {
	if (document.NewsLetterForm.email){
		if (AssessAll(document.NewsLetterForm.email,"15","Please enter your email address") == false) return false;
	} else {
		alert('You have not supplied an email input field');
		return false;
	}
	return true;
}

function submitListProd() {
	var theForm = document.Form0;
	var prodCount = theForm.productcount.value;
	var totalProds=0;
	for (i=0;i<prodCount;i++) {
		var theQTY = eval("document.Form0.QTY"+i+".value")-0;
		totalProds += theQTY;
	}
	if (totalProds>0) theForm.submit();
}

function donate() {

	var winWidth=540;
	var winHeight=500;
	theUrl = "https://www.gtp.com.au/gtp/kidsafewa2/donate.jsp?owner=kidsafewa2";

	var theParams = "left=100,top=100,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no";
	theParams += ",width="+winWidth;
	theParams += ",height="+winHeight;
	var theWin = window.open(theUrl,"",theParams);

	theWin.document.focus();
}

