﻿var imgCollection = new Array();
imgCollection[imgCollection.length] = "./images/online_services/menu_double.jpg";
imgCollection[imgCollection.length] = "./images/online_services/menu_double_roll.jpg";
imgCollection[imgCollection.length] = "./images/online_services/menu_single.jpg";
imgCollection[imgCollection.length] = "./images/online_services/menu_single_roll.jpg";
imgCollection[imgCollection.length] = "./images/online_services/os_banner.jpg.jpg";
imgCollection[imgCollection.length] = "./images/online_services/os_warm_left.jpg";
imgCollection[imgCollection.length] = "./images/online_services/scenery.jpg";
imgCollection[imgCollection.length] = "./images/online_services/spacer.gif";

myImages = new Array();

function preloadImage(currentImage)
{
	if (document.images)
	{
		myImages[myImages.length] = new Image();
		myImages[myImages.length-1].src = currentImage;
	}
}

function doPreload()
{
	window.status = "Preloading...";
	for (var i = 0; i < imgCollection.length; i++)
	{
		preloadImage(imgCollection[i]);
	}
	window.status = "Images preloaded.";
}

function fixHeight()
{
	var numTiles = 6;
	var maxHeight = 113;
	var output = "";

	for (var i = 1; i <= numTiles; i++)
	{
		if (document.getElementById('tile_' + i))
		{
			var height = document.getElementById('tile_' + i).offsetHeight;
			
			if (height > maxHeight)
			{
				maxHeight = height;
			}
		}
	}
	
	for (var i = 1; i <= numTiles; i++)
	{
		if (document.getElementById('tile_' + i))
		{
			document.getElementById('tile_' + i).style.height = maxHeight + "px";
		}
	}
	
/*
	var search_height = document.getElementById('search_column').offsetHeight + document.getElementById('footer').offsetHeight;
	var body_height = document.getElementById('body_column').offsetHeight;
	
	if (body_height < search_height)
	{
		body_height = search_height;
	}
	
	window.status = 'Body: ' + body_height + '; Search: ' + search_height;
*/
}

function elementDisplay(elementID, state)
{
	document.getElementById(elementID).style.display = state;
}

function elementContent(elementID, newContent)
{
	document.getElementById(elementID).innerHTML = newContent;
}

function methodCheck(fieldID, msg)
{
	var field = document.getElementById(fieldID);

	if (field.value.length < 1)
	{
		alert('Please provide your ' + msg + '.');

		document.getElementById(fieldID + 'Row').cells[0].style.borderLeft = 'thin solid #ff0000';
		document.getElementById(fieldID + 'Row').cells[0].style.borderTop = 'thin solid #ff0000';
		document.getElementById(fieldID + 'Row').cells[0].style.borderBottom = 'thin solid #ff0000';

		document.getElementById(fieldID + 'Row').cells[1].style.borderRight = 'thin solid #ff0000';
		document.getElementById(fieldID + 'Row').cells[1].style.borderTop = 'thin solid #ff0000';
		document.getElementById(fieldID + 'Row').cells[1].style.borderBottom = 'thin solid #ff0000';
		
		field.focus();
	}
}

var preferred_method = "";
preferred_method = '' +
'											<table width="100%" cellpadding="2" cellspacing="0" border="0">' +
'												<tr>' +
'													<td width="40%" valign="top">' +
'														Preferred contact method <span style="color: rgb(255, 0, 0); font-weight: bold;">*</span>' +
'													</td>' +
'													<td width="60%" valign="top">' +
'														<input value="Email" type="radio" id="method_email" name="method" accesskey="e"> <label for="method_email"><u>E</u>mail</label>' +
'														<input value="Telephone" type="radio" id="method_phone" name="method" accesskey="t"> <label for="method_phone"><u>T</u>elephone</label><br>' +
'													</td>' +
'												</tr>' +
'											</table>' +
'';

function openSmallWindow(url)
{
	var width = this.screen.availWidth / 2;
	var height = this.screen.availHeight / 2;
	var left = width;
	var top = 0;
	
	var smallWindow = window.open(url,'smallWindow','top=' + top + ',left=' + left + ',width=' + width + ',height=' + height + ',status=1,scrollbars=1,resizable=1');
}

function openImageWindow(url, setWidth, setHeight)
{
	var width = (setWidth != undefined ? setWidth : this.screen.availWidth / 2);
	var height = (setHeight != undefined ? setHeight : this.screen.availHeight / 2);
	var left = 0;
	var top = 0;
	
	var smallWindow = window.open(url,'smallWindow','top=' + top + ',left=' + left + ',width=' + width + ',height=' + height + ',status=0,resizable=1');
	smallWindow.document.body.style.margin = '0';
	
/*
	smallWindow.document.images[0].onclick = function ()
	{
		smallWindow.close();
	};
*/

//	smallWindow.document.images[0].src = '';
	
	var oCopyRight = smallWindow.document.createElement('span');
	oCopyRight.id = 'copyright';
	oCopyRight.style.fontSize = '12px';
	oCopyRight.style.color = '#ffffff';
	oCopyRight.style.fontFamily = 'Arial, Helvetica, sans-serif';
	oCopyRight.style.fontWeight = 'bold';
	oCopyRight.innerHTML = '&copy; 2006 Aurora Energy Pty Ltd';
	smallWindow.document.body.appendChild(oCopyRight);
	
	smallWindow.document.getElementById('copyright').style.left = 8;
	smallWindow.document.getElementById('copyright').style.top = smallWindow.document.body.offsetHeight - smallWindow.document.getElementById('copyright').offsetHeight;
	smallWindow.document.getElementById('copyright').style.zIndex = 2;
	smallWindow.document.getElementById('copyright').style.position = 'absolute';
	
	var oCloseButton = smallWindow.document.createElement('input');
	oCloseButton.id = 'closeButton';
	oCloseButton.type = 'button';
	oCloseButton.value = 'Close';
	oCloseButton.style.position = 'absolute';
	oCloseButton.style.top = '0';
	oCloseButton.style.left = '0';
	oCloseButton.style.zIndex = '50';
	oCloseButton.onclick = function ()
	{
		smallWindow.close();
	};
	smallWindow.document.body.appendChild(oCloseButton);
	
	smallWindow.document.getElementById('closeButton').style.left = smallWindow.document.body.offsetWidth - smallWindow.document.getElementById('closeButton').offsetWidth - 4;
	smallWindow.document.getElementById('closeButton').style.top = smallWindow.document.body.offsetHeight - smallWindow.document.getElementById('closeButton').offsetHeight - 4;
	
	smallWindow.document.oncontextmenu = function () {
		alert('This image is copyright to Aurora Energy Pty Ltd.  Please acquire permission prior to obtaining or using it.');
		return false;
	};
	
//	alert(smallWindow.document.getElementById('closeButton').offsetWidth);
}

var requiredFields = new Array('firstname', 'name', 'address', 'suburb', 'postcode');

function doSearch()
{
	var searchField = document.forms.searchForm.Query;
	var searchTerms = document.forms.searchForm.Query.value;
	
	if (searchTerms == "Search this site")
	{
		searchField.value = '';
//		searchField.focus();
		return true;
	}
	else
	{
		return true;
	}
}