﻿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;
	}
}


function CLoadNotify(){
}


function CreateTrail()
{
	var i;
	URL=location.toString();
	
	if (URL.indexOf("#") > 0) {
		URL = URL.substr(0, URL.indexOf("#"));
	}
	
	DIVIDER=(" &raquo; ");
	var SUBDIRS=URL.substr(3+URL.indexOf("au/")).split("/");
	
	var blank = false;
	switch(SUBDIRS[SUBDIRS.length - 1])
	{
		case "example":
			break;
		case "default.asp":
				blank = true;
			break;
		case "default.asp?DISP=1":
				blank = true;
			break;
		case "default.asp?DISP=2":
				blank = true;
			break;
		case "landinga.asp":
				blank = true;
			break;
		case "landingb.asp":
				blank = true;
			break;
		case "index.asp":
				blank = true;
			break;
		case "index.html":
				blank = true;
			break;
		case "#":
				blank = true;
			break;
		case "":
				blank = true;
			break;
		default:
			break;
	}
	if (blank)
	{
		SUBDIRS.length = SUBDIRS.length - 1;
	}
	
	var NUMDIRS=SUBDIRS.length;
	var BASEURL = "/"
	var URLTRAIL
	
	
	//Write the initial Navigation Trail
	document.write('<div class="breadcrumb"><a href="' + BASEURL +'">Home</a>'); 
	URLTRAIL = BASEURL
	for (i = 0; i < NUMDIRS; i++)
	{
		if (i < NUMDIRS -1)
		{
			URLTRAIL = URLTRAIL + unescape(SUBDIRS[i]) + "/";
			document.write(DIVIDER  + '<a href="' + URLTRAIL + '">' + Dirname(unescape(SUBDIRS[i])) + '</a>');
		} //end if
		else
		{
			document.write(DIVIDER + Dirname(unescape(SUBDIRS[i])));
		} //end if
	} //end for
	document.write('</div>');
}


function Dirname(name)
{
	var Newname = ""
	switch(name)
	{
		case "example": Newname="Here's an Example";
			break;
		case "default.asp":
			break;
		case "default.asp?DISP=1":
			break;
		case "default.asp?DISP=2":
			break;
		case "landinga.asp":
			break;
		case "landingb.asp":
			break;
		case "index.asp":
			break;
		case "index.html":
			break;
		case "#":
			break;
		case "":
			break;
		default:
			if (typeof namechange != "undefined" && typeof namechange[name] != "undefined")
			{
				Newname = namechange[name];
				break;
			}
			proper=name.split('_');
			Newname=proper.join(" ");
			Newname=toUpper(Newname);
			break;
	}
	return Newname;
}


function toUpper(word)
{
	var pattern =/(\w)(\w*)/;
	var a = word.split(/\s+/g);
	var firstLetter;
	var restOfWord;
	
	if (word.length)
	{
		for (i = 0 ; i < a.length ; i ++ )
		{
			if (i == 0)
			{
				var parts = a[i].match(pattern);
				
				if (a[i].toLowerCase() == 'apayg') {
					firstLetter = parts[1].toUpperCase();
					restOfWord = parts[2].toUpperCase();
				} else {
					firstLetter = parts[1].toUpperCase();
					restOfWord = parts[2].toLowerCase();
				}
				
				a[i] = firstLetter + restOfWord;
			}
			else
			{
				var parts = a[i].match(pattern);
				
				if(a[i].toLowerCase() == 'aurora') {
					firstLetter = parts[1].toUpperCase();
					restOfWord = parts[2].toLowerCase();
				} else if (a[i].toLowerCase() == 'apayg') {
					firstLetter = parts[1].toUpperCase();
					restOfWord = parts[2].toUpperCase();
				} else {
					firstLetter = parts[1];
					restOfWord = parts[2].toLowerCase();
				}
				
				a[i] = firstLetter + restOfWord;
			}
		}
	}
	word = a.join(' ');
	
	return word;
}