
var theSubMenu;

function init() {
	if (navigator.appName=="Microsoft Internet Explorer" && navigator.platform=="MacPPC") {
		// do nothing
	} else {
		theSubMenu = document.getElementById('sideSubMenu');
		if (self.location.href.indexOf("Programs+and+Services")==-1) {
			theSubMenu.style.position = "absolute";
			theSubMenu.style.left="-999em";
		}
	}
	paintKidsafe();
	if (self.location.href.indexOf("Links+and+Numbers")>-1) {
		paintTables();
	}
}

function toggleMenu()
{
	if (theSubMenu.style.left=="-999em")
	{
		theSubMenu.style.position = "static";
		theSubMenu.style.left="auto";
		theSubMenu.style.zindex = '3';
		theSubMenu.style.overflow="auto"; // IE7 goes cuckoo and sets the height of the menu to 0 if you don't have this.
	}
	else
	{
		theSubMenu.style.position = "absolute";
		theSubMenu.style.left="-999em";
		theSubMenu.style.zindex = '0';
	}
}

function paintTables()
{
	var theTables = document.getElementsByTagName('TABLE'); 		// Get all the Table elements

	for (i=0;i<theTables.length;i++)								// Get all TR elements in this TABLE
	{
		theRows = theTables[i].getElementsByTagName('TR');

		var lcount = 0;
		
		for (j=0;j<theRows.length;j++)	  							// Loop through TR elements
		{
			if (j%2 > 0)	theRows[j].className="o";				// if an even row... Paint!
		}
	}
}

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();
}

function todayStr() {
var m_names = new Array("January", "February", "March", 
"April", "May", "June", "July", "August", "September", 
"October", "November", "December");

var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();
return curr_date + " " + m_names[curr_month] 
+ " " + curr_year;
}
function getTheYear() {
var d = new Date();
var curr_year = d.getFullYear();
return curr_year;
}