//window.onload = flashHeight;
//window.onresize = flashHeight;




var LBD_ImgId = "CaptchaImage";
var LBD_Img = null;
var LBD_NewImg = null;
var LBD_Parent = null;
var LBD_Prompt = null;

function LBD_ReloadImage()
{
	if(LBD_ImgId)
	{
		LBD_Img = document.getElementById(LBD_ImgId);
		var newSrc = LBD_Img.src + '&d=' + new Date().getTime();

		LBD_NewImg = document.createElement('img');
		LBD_NewImg.onload = LBD_ShowImage;
		LBD_NewImg.id = LBD_Img.id;
		LBD_NewImg.alt = LBD_Img.alt;
		LBD_NewImg.src = newSrc;

		LBD_Prompt = document.createElement('span');
		LBD_Prompt.appendChild(document.createTextNode('loading...'));

		LBD_Parent = LBD_Img.parentNode;
		LBD_Parent.removeChild(LBD_Img);
		LBD_Parent.appendChild(LBD_Prompt);
	}
}

function LBD_ShowImage()
{
	if(LBD_NewImg && LBD_Parent && LBD_Prompt)
	{
		LBD_Parent.removeChild(LBD_Prompt);
		LBD_Parent.appendChild(LBD_NewImg);
	}
}








function PopUp(id){
	if(id!=""){
		var strURL = "/photo.asp?id=" + id
		var objPhotoWindow = window.open(strURL,'photo','height=500,width=550,left=10,top=10,directories=0,fullscreen=0,location=0,menubar=0,scrollbars=1,resizable=0,status=0,toolbar=0');
	}

}

function OpenWindow(strURL,strOptions){
	var objPhotoWindow = window.open(strURL,'popup',strOptions);
}
function strTrim(strText) {
	if(typeof strText!='undefined' && strText!=''){
		for (i=0; i<strText.length; ++i) {
			if (strText.charAt(i) != ' ') break;
		}
		if (i >= strText.length) return ('');
		if (i > 0) strText = strText.substring(i, strText.length);
		for (j=strText.length-1; j > i; --j) {
			if (strText.charAt(j) != ' ') break;
		}
		if (j < strText.length -1)
			strText = strText.substring(0, j+1);
	}
	return strText;
	
	
}
function ValidEmail(s){
    var i = 1;
    var sLength = s.length;
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }
    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
} 

function AutoLink(strURL){
	var urlLength = strURL.length
	var endStringPos = urlLength - 4
	if(strURL !='0'){
	//	if(strURL.substring(0,4)=="http"){
	//		window.open(strURL,'')
	//	}else
		if(
		   		strURL.substring(endStringPos,urlLength)==".exe" || 
		   		strURL.substring(endStringPos,urlLength)==".xlt" || 
		   		strURL.substring(endStringPos,urlLength)==".pdf" || 
				strURL.substring(endStringPos,urlLength)==".xls" || 
				strURL.substring(endStringPos,urlLength)==".doc" || 
				strURL.substring(endStringPos,urlLength)==".ppt" ||
				strURL.substring(endStringPos,urlLength)=="xlsx" ||  // xlsx
				strURL.substring(endStringPos,urlLength)=="docx" ||  // docx
				strURL.substring(endStringPos,urlLength)=="pptx"	 // pptx								
							
			){
			window.open(strURL,'');
		}
		else{
			document.location.href=strURL;
		}
	}
}

function MM_findObj(n, d) { //v4.01
		  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		  if(!x && d.getElementById) x=d.getElementById(n); return x;
		}

		function MM_validateForm() { //v4.0
		  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
		  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
		    if (val) { nm=val.name; if ((val=val.value)!="") {
		      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
			if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
		      } else if (test!='R') { num = parseFloat(val);
			if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
			if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
			  min=test.substring(8,p); max=test.substring(p+1);
			  if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
		    } } } else if (test.charAt(0) == 'R') { if(nm == 'Picture Characters') { errors += '- '+nm+' are required.\n' } else { errors += '- '+nm+' is required.\n'; } } }
		  } if (errors) alert('The following error(s) occurred:\n'+errors);
		  document.MM_returnValue = (errors == '');
		}

function checkSearch(query) {
	if(!query) {
		alert('Please enter a search term');
		return false;
	}
}


var strPrevId = ""
var objPrevContent = ""
var objPrevHeading = ""
function toggle(id) {
		
		var objContentLayer = xDOM('c' + id,0);
		var objHeadingLayer = xDOM('h' + id,0);
		
		if(strPrevId != ""){
			objPrevContent = xDOM('c' + strPrevId,0);
			objPrevHeading = xDOM('h' + strPrevId,0);
		}

		if(objPrevContent != "" & id == strPrevId){
			objPrevContent.style.display = "none";
			objPrevHeading.className = 'heading';
			objHeadingLayer.blur();
			objPrevContent = "";
			strPrevId = "";
		} else if(objPrevContent != "" & id != strPrevId){
			objPrevContent.style.display = "none";
			objPrevHeading.className = 'heading';
			objContentLayer.style.display = "block";
			objHeadingLayer.className = 'headingOn';
			objHeadingLayer.blur();
			objPrevContent = objContentLayer;
			strPrevId = id;
		} else {
			objContentLayer.style.display = "block";
			objHeadingLayer.className = 'headingOn';
			objHeadingLayer.blur();
			objPrevContent = objContentLayer;
			strPrevId = id;
		}
		
	}

function delayFlashHeight(){
	setTimeout(flashHeight,2000);
}

function flashHeight(){
	var objFlashDiv = xDOM('flashMovie',0);
	var varWidth
	var varWidthNumber
	if(document.all){
		varWidth = objFlashDiv.offsetWidth;
		varWidthNumber = varWidth;
	} else {
		varWidth = document.defaultView.getComputedStyle(objFlashDiv, "").getPropertyValue("width");
		varWidthNumber = parseInt(varWidth.substring(0,varWidth.length - 2));
	}
	
	//alert(varWidth + "," + varWidthNumber);
	objFlashDiv.style.height = varWidthNumber * 0.75 + "px";
}

// Cross Browser DOM Functions used to create objects and get top / left coords
// copyright Stephen Chapman, 4th Jan 2005
// you may copy this code but please keep the copyright notice as well
var aDOM = 0, ieDOM = 0, nsDOM = 0
var stdDOM = document.getElementById;
if (stdDOM) aDOM = 1; else {
  ieDOM = document.all;
  if (ieDOM) aDOM = 1; else {
    var nsDOM = (
      (navigator.appName.indexOf('Netscape') != -1)
      && (parseInt(navigator.appVersion) ==4));
    if (nsDOM) aDOM = 1;
  }
}
function xDOM(objectId, withStyle) {
var st = ''; if (withStyle) st = '.style';
if (stdDOM) return (eval('document.getElementById(objectId)'+st));
if (ieDOM) return (eval('document.all[objectId]'+st));
if (nsDOM) return (document.layers[objectId]);
}

function submitform(frm,page)
{	
	var oldAction = document.forms[frm].action;
	var newAction = '';
	
	if(page){
		if (page == 'shortlist') {
			newAction = oldAction.substring(0,oldAction.indexOf('.html/') + 5);
			document.forms[frm].nextaction.value = 'shortlist';
		}else if(oldAction.indexOf('/page') != -1) {
			newAction = oldAction.substring(0,oldAction.indexOf('/page')) + '/page/' + page;
		}else {
			newAction = oldAction + '/page/' + page;
		}
		document.forms[frm].action = newAction;
	}
  document.forms[frm].submit();
}

function CheckAll(frm)
{
count = document.forms[frm].elements.length;
    for (i=0; i < count; i++) 
	{
    document.forms[frm].elements[i].checked = 1;
	}
}
function UncheckAll(frm){
count = document.forms[frm].elements.length;
    for (i=0; i < count; i++) 
	{
    document.forms[frm].elements[i].checked = 0;
	}
}

location.querystring = (function() {   
	// The return is a collection of key/value pairs   
	var result = {};   
  
	// Gets the query string with a preceeding '?'   
	var querystring = window.document.location.toString();   
  
	// document.location.search is empty if a query string is absent   
	if (!querystring)   
		return result;   
  
	// substring(1) to remove the '?'   
	var pairs = querystring.substring(1).split("&");   
	var splitPair;   
  
	// Load the key/values of the return collection   
	for (var i = 0; i < pairs.length; i++) {   
		splitPair = pairs[i].split("=");
		if(splitPair[1] != null && splitPair[1] != ""){
			formatSplitPair = splitPair[1].substring(1, splitPair[1].length-1)
			while(formatSplitPair.indexOf("%20") != -1) {
				  formatSplitPair = formatSplitPair.replace("%20"," ");
			}
		} else {
			formatSplitPair = splitPair[1];
		}
		result[splitPair[0]] = formatSplitPair;   
	}   
  
	return result;   
})();  

function ValidateUpdateUser(objForm){

	var strAlert = "";
	strAlert = "______________________________________\n\nPlease\n\n";
	var isAlert = false;
	var strFirstName = strTrim(objForm.firstName.value);
	var strLastName = strTrim(objForm.lastName.value);
	var strAddress = strTrim(objForm.address.value);
	var strSuburb = strTrim(objForm.suburb.value);
	var strState = strTrim(objForm.state.value);
	var strPostcode = strTrim(objForm.postcode.value);
	var strCountry = strTrim(objForm.country.value);
	var strEmail = strTrim(objForm.email.value);

	
	if (strFirstName==""){
		strAlert += "- Enter your first name\n";
		isAlert = true;
	}
	if (strLastName==""){
		strAlert += "- Enter your last name\n";
		isAlert = true;
	}			
	if (strAddress==""){
		strAlert += "- Enter your address\n";
		isAlert = true;
	}
	if (strSuburb==""){
		strAlert += "- Enter your suburb\n";
		isAlert = true;
	}
	if (strState==""){
		strAlert += "- Enter your state\n";
		isAlert = true;
	}
	if (strPostcode==""){
		strAlert += "- Enter your postcode\n";
		isAlert = true;
	}
	if (strCountry==""){
		strAlert += "- Enter your country\n";
		isAlert = true;
	}
	if(strEmail == ""){
		strAlert += "- Enter your email address\n";
		isAlert = true;
	}else if(!ValidEmail(strEmail)){
		strAlert += "- Enter a valid email address\n";
		isAlert = true;
	}
	
	
	
	if (isAlert == true){
		strAlert += "\n\n______________________________________";
		alert (strAlert);
		return false;
	}else{
		return true;
	}
	
	
	
}


function ValidateNewUser(objForm){
	var strAlert = "";
	strAlert = "______________________________________\n\nPlease\n\n";
	var isAlert = false;
	var strFirstName = strTrim(objForm.firstName.value);
	var strLastName = strTrim(objForm.lastName.value);
	var strEmail = strTrim(objForm.email.value);
	var strGroupCompany = strTrim(objForm.groupCompany.value);
	var strAddress = strTrim(objForm.address.value);
	var strSuburb = strTrim(objForm.suburb.value);
	var strState = strTrim(objForm.state.value);
	var strPostcode = strTrim(objForm.postcode.value);
	var strCountry = strTrim(objForm.country.value);
	var strEmail = strTrim(objForm.email.value);
	var strPassword = strTrim(objForm.password.value);
	var strConfirmPassword = strTrim(objForm.confirmpassword.value);
	var strTelephone = strTrim(objForm.telephone.value);	
	
	if (strFirstName==""){
		strAlert += "- Enter your first name\n";
		isAlert = true;
	}
	if (strLastName==""){
		strAlert += "- Enter your last name\n";
		isAlert = true;
	}	
	
	if (strGroupCompany==""){
		strAlert += "- Enter your group company\n";
		isAlert = true;
	}	
	if (strAddress==""){
		strAlert += "- Enter your address\n";
		isAlert = true;
	}
	if (strSuburb==""){
		strAlert += "- Enter your suburb\n";
		isAlert = true;
	}
	if (strState==""){
		strAlert += "- Enter your state\n";
		isAlert = true;
	}
	if (strPostcode==""){
		strAlert += "- Enter your postcode\n";
		isAlert = true;
	}
	if (strCountry==""){
		strAlert += "- Enter your country\n";
		isAlert = true;
	}
	if (strTelephone==""){
		strAlert += "- Enter your telephone\n";
		isAlert = true;
	}	
	if(strEmail == ""){
		strAlert += "- Enter your email address\n";
		isAlert = true;
	}else if(!ValidEmail(strEmail)){
		strAlert += "- Enter a valid email address\n";
		isAlert = true;
	}		
	if(strPassword == "") {
		strAlert += "- Enter a password\n";
		isAlert = true;
	}else if(strConfirmPassword == "") {
		strAlert += "- Enter a confirmation password\n";
		isAlert = true;
	}else if(strPassword != strConfirmPassword){
		strAlert += "- Ensure your password and confirm password match\n";
		isAlert = true;
	}			
	
	if (isAlert == true){
		strAlert += "\n\n______________________________________";
		alert (strAlert);
		return false;
	}else{
		return true;
	}
}

function CheckLogin(objForm){
	var strAlert = "";
	strAlert = "______________________________________\n\nPlease\n\n";
	var isAlert = false;

	var username = strTrim(objForm.username.value)
	var password = strTrim(objForm.password.value)

	if (username==""){
		strAlert += "- Please enter your username (email address)\n";
		isAlert = true;
	}		

	if (password==""){
		strAlert += "- Please enter your password\n";
		isAlert = true;
	}			
	if (isAlert == true){
		strAlert += "\n\n______________________________________";
		alert (strAlert);
		return false;
	}else{
		return true;
	}
}


function ValidatePersonUpdate(objForm){
	
	var strAlert = "";
	strAlert = "______________________________________\n\nPlease\n\n";
	var isAlert = false;

	var strName = strTrim(objForm.Name.value)

	if (strName==""){
		strAlert += "- Please enter your name\n";
		isAlert = true;
	}		

	if (isAlert == true){
		strAlert += "\n\n______________________________________";
		alert (strAlert);
		return false;
	}else{
		return true;
	}	
}


function ValidatePlaceUpdate(objForm){
	
	var strAlert = "";
	strAlert = "______________________________________\n\nPlease\n\n";
	var isAlert = false;

	var strName = strTrim(objForm.Company.value)

	if (strName==""){
		strAlert += "- Please enter your company\n";
		isAlert = true;
	}		

	if (isAlert == true){
		strAlert += "\n\n______________________________________";
		alert (strAlert);
		return false;
	}else{
		return true;
	}	
}
function ValidateImageUpload(objForm){
	
	var strAlert = "";
	strAlert = "______________________________________\n\nPlease\n\n";
	var isAlert = false;

	var strName = strTrim(objForm.Name.value)
	var strImage = strTrim(objForm.NewImage.value)

	if (strName==""){
		strAlert += "- Please enter your name\n";
		isAlert = true;
	}		

	if (strImage==""){
		strAlert += "- Please select an image to upload\n";
		isAlert = true;
	}			
	if (isAlert == true){
		strAlert += "\n\n______________________________________";
		alert (strAlert);
		return false;
	}else{
		return true;
	}	
}

function ClearInputs(objForm){
	// Called Via the onReset event
	for (i=0; i < objForm.elements.length; i++) {
		element = objForm.elements[i];
		if (element.type == "text" || element.type == "password" || element.type == "textarea"){
			element.value = '';
		}else if(element.type.indexOf("select") != -1){
			element.selectedIndex = -1;
		}else if(element.type == "checkbox" && element.checked){
			element.checked = false;
		}
	}
	return false
}


function UpdateRelatedCompany(objSelect,idRelatedSelect){
	var selectedCompany = objSelect.options[objSelect.selectedIndex].value
	
	//PleaseWait();
	//var objSourceSelect = getObj(sourceSelectID)
	var strURL = "/remote/getRelatedCompanyOptions.asp?company=" + selectedCompany;
	//alert(strURL);
	xmlhttp.open("GET", strURL, true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			//alert(xmlhttp.responseText)
			if(xmlhttp.responseText!='' && xmlhttp.responseText!='undefined'){
				RepopulateOptions(getObj(idRelatedSelect),ConvertToOptionArray(xmlhttp.responseText.substring(0,xmlhttp.responseText.length -0)),true);
			}else{
				getObj(idRelatedSelect).options.length = 0;
			}
			//DontWait();
		}
	}
	xmlhttp.send(null)	
}




function DisplayPassword(){
	var obj = xDOM("forgotPassword",0);
	if(obj.style.height == "0px"){
		obj.style.height = "120px";
		setTimeout("setPassFocus()",10);
	}else{
		obj.style.height = "0px";
	}	
}

function setPassFocus(){
	var objInput = xDOM("forgotForm",0);
	objInput.username.focus();	
}

// *****************************************************
// Create XMLHttpRequest Object
// 
// DO NOT EDIT or DELETE ANY OF THE CODE BELOW. What appaers to be comments is IE conditional code
var xmlhttp=false;
function CreateXMLHttpRequestObject(){
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	  xmlhttp = new XMLHttpRequest();
	}	
}

var xmlhttp2=false;
function CreateSecondXMLHttpRequestObject(){
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp2 = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp2 = false;
	  }
	 }
	@end @*/
	if (!xmlhttp2 && typeof XMLHttpRequest!='undefined') {
	  xmlhttp2 = new XMLHttpRequest();
	}	
}

function PleaseWait(){
	if(!getObj("pleaseWait")){ 
		var objContent = getObj("Content")
		//alert(objContent)
		var newText = document.createTextNode("Please Wait.....");
		var newNode = document.createElement("div");
		newNode.appendChild(newText);
		newNode.setAttribute("id","wait")
		objContent.appendChild(newNode);
		
	}
	var objPleaseWait = getObj("wait")
	//objPleaseWait.style.left = getWidth()/2 - 150 + "px"
	//objPleaseWait.style.top = "250px"
	objPleaseWait.style.display = "block"
}

function DontWait(){
	getObj("wait").style.display = "none";
	//alert(getObj("pleaseWait").style.display)
}

function ConvertToOptionArray(strHTTPResponse){
	var arrNewOptions = [];
	if(strHTTPResponse.indexOf("|") != -1){ 
		var arrItems = strHTTPResponse.split(',|,')
		for(var i=0; i<arrItems.length; i++) {
			var arrItemProperties =  arrItems[i].split(',-,')
			arrNewOptions[i] = {optText:strTrim(arrItemProperties[0]), optValue:strTrim(arrItemProperties[1])};
		}		
	}else{
		var arrItems = strHTTPResponse
		var arrItemProperties =  arrItems.split(',-,')
		arrNewOptions[0] = {optText:strTrim(arrItemProperties[0]), optValue:strTrim(arrItemProperties[1])};
	}
	return arrNewOptions
}

function RepopulateOptions(objSelect, arrNewOptions, blnPleaseSelect){
	// Create an array of the current items in the array
	var arrCurrentOptions = [];
	arrCurrentOptions = getExsistingOptions(objSelect)
	// Reset the options to 0	
	
	for(var i = objSelect.options.length - 1 ; i >= 0 ; i--){ 
		objSelect.options[i] = null; 
	}	
	// Loop through the New options and create a new option
	for (var loop=0; loop<arrNewOptions.length; loop++) {
		if(arrNewOptions[loop].optValue != '' && arrNewOptions[loop].optValue != 'undefined' && arrNewOptions[loop].optValue != null)
		{
		var optObj = document.createElement('option');
		//optObj.text = arrNewOptions[loop].optText.unescapeHTML();
		optObj.text = UnescapeHTML(arrNewOptions[loop].optText)	
		optObj.value = arrNewOptions[loop].optValue;

		for(var i=0; i<arrCurrentOptions.length; i++){
			if(arrNewOptions[loop].optValue == arrCurrentOptions[i].optValue && arrCurrentOptions[i].optSelected == true){
				optObj.selected = true; 
				break
			}
		} 
		// Now load the Item into the array	
		try {
			objSelect.add(optObj, null) //elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
		}
		catch(ex) {
			objSelect.add(optObj); //elSel.add(elOptNew); // IE only
		}		
		}
	}
	sortSelect(objSelect, true, blnPleaseSelect);

} 
/*
Sort Select
sortSelect will sort any selects items and maintain the "selected" states
*/
function sortSelect(selectToSort, ascendingOrder, blnPleaseSelect) {
	if (arguments.length == 1) ascendingOrder = true;    // default to ascending sort
	// copy options into an array
	var myOptions = [];
	for (var loop=0; loop<selectToSort.options.length; loop++) {
		myOptions[loop] = { optText:selectToSort.options[loop].text, optValue:selectToSort.options[loop].value, optSelected:selectToSort.options[loop].selected};
	}
	// sort array
	if (ascendingOrder){
		myOptions.sort(sortFuncAsc);
	}else{
		myOptions.sort(sortFuncDesc);
	}
	selectToSort.options.length = 0;
	if(blnPleaseSelect){
		var optPlsSelect = document.createElement('option');
		optPlsSelect.text = "Please select";
		optPlsSelect.value = "";
		optPlsSelect.selected = "selected"; 	
		try {
			selectToSort.add(optPlsSelect, null) //elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
		}
		catch(ex) {
			selectToSort.add(optPlsSelect); //elSel.add(elOptNew); // IE only
		}			
	}
	for (var loop=0; loop<myOptions.length; loop++) {
		var optObj = document.createElement('option');
		optObj.text = myOptions[loop].optText;
		optObj.value = myOptions[loop].optValue;
		if(!blnPleaseSelect){optObj.selected = myOptions[loop].optSelected;}
		try {
			selectToSort.add(optObj, null) //elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
		}
		catch(ex) {
			selectToSort.add(optObj); //elSel.add(elOptNew); // IE only
		}		
	}
}
function sortFuncAsc(record1, record2) {
	var value1 = record1.optText.toLowerCase();
	var value2 = record2.optText.toLowerCase();
	if (value1 > value2) return(1);
	if (value1 < value2) return(-1);
	return(0);
}
function sortFuncDesc(record1, record2, selected) {
	var value1 = record1.optText.toLowerCase();
	var value2 = record2.optText.toLowerCase();
	if (value1 > value2) return(-1);
	if (value1 < value2) return(1);
	return(0);
}


function PrintAll(){
	var strURL = "/print.asp" + document.PrintInfo.PrintString.value
	var objPrintWindow = window.open(strURL,'print','height=500,width=650,left=10,top=10,directories=0,fullscreen=0,location=0,menubar=1,scrollbars=1,resizable=0,status=0,toolbar=0');

}


function UpdateWeather(strCity,intID){
	var strURL = "/remote/getWeather.asp?id=" + intID + "&city=" + strCity;
	xmlhttp.open("GET", strURL, true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			if(xmlhttp.responseText!=''){
				xDOM("WeatherWrapper",0).innerHTML = xmlhttp.responseText;
			}else{
				alert("Error retrieving weather data. Please try again soon.")	
			}
		}
	}
	xmlhttp.send(null)
	return false;
}
var blnGlossaryLoaded = false
var blnGlossaryOn = false
function initGlossary(){
	var strAssetList = ""
	var g=document.getElementsByTagName('a');
	for (i=0;i<g.length;i++){
		if(g[i].getAttribute('href')){
			if(g[i].getAttribute('href').indexOf("showGlossary") > 0){
				g[i].className = "glossaryDisabled"
				strAssetList = strAssetList + g[i].getAttribute('href').substring(24,g[i].getAttribute('href').length - 2) + ","
			}
		}
	}

	if(xDOM("glossaryPrintContent", 0)){

		if(strAssetList!=''){
			xmlhttp.open("GET", location.protocol + "//" + location.hostname + "/remote/getGlossaryContent.asp?id=" + strAssetList,true);
			xmlhttp.onreadystatechange=function() {
				if (xmlhttp.readyState==4) {
					//alert(xmlhttp.responseText)	
					xDOM("glossaryPrintContent", 0).innerHTML = xmlhttp.responseText
					blnGlossaryLoaded = true
				}
			}
			xmlhttp.send(null)	
		}else{
			blnGlossaryLoaded = true	
		}
	}
	
}

function ToggleGlossary(objButton){
	var cssClassName 
	//objButton.blur();
	if(blnGlossaryLoaded){
		if(blnGlossaryOn){
			cssClassName = "glossaryDisabled"
			blnGlossaryOn = false
			xDOM('GlossaryContainer',1).display="none";
			xDOM('glossaryPrintContent',0).className='yesPrint'
			xDOM('GlossarySwitch',0).innerHTML='Turn glossary on';
		}else{
			cssClassName = "glossaryEnabled"
			blnGlossaryOn = true
			xDOM('glossaryPrintContent',0).className='yesPrint';
			xDOM('GlossaryBody',0).innerHTML="<strong>Glossary</strong><p>Words highlighted in yellow are defined in our glossary. Click on a word to see its meaning displayed here. Toggle the glossary on and off using the button near the print button/s.</p><p>Glossary meanings will only print at the end of a document when the glossary is turned on.</p>"
			xDOM('GlossaryContainer',1).display="block";
			xDOM('GlossarySwitch',0).innerHTML='Turn glossary off';
		}
		var g=document.getElementsByTagName('a');
		for (i=0;i<g.length;i++){
			if(g[i].getAttribute('href')){
				if(g[i].getAttribute('href').indexOf("showGlossary") > 0){
					g[i].className = cssClassName
				}
			}
		}
	}
}

function HideGlossary(){
	xDOM('GlossaryContainer',1).display="none";
	
	
}

function showGlossary(intID){
	if(blnGlossaryOn && xDOM('gloss' + intID,0)){
		var g=document.getElementsByTagName('a');
		xDOM('GlossaryBody',0).innerHTML=xDOM('gloss' + intID,0).innerHTML;
		xDOM('GlossaryContainer',1).display="block";
	}
}

CreateXMLHttpRequestObject();
if(xmlhttp)CreateSecondXMLHttpRequestObject();

function createMarker(point,html) {
	
	var redIcon = new GIcon();
	redIcon.image = "http://www.leighton.com.au/css/images/red-dot.png";
	redIcon.iconSize = new GSize(31, 31);
	redIcon.shadowSize = new GSize(40, 31);
	redIcon.iconAnchor = new GPoint(10, 31);
	redIcon.infoWindowAnchor = new GPoint(20, 5);
	redIcon.infoShadowAnchor = new GPoint(20, 25);

	// Set up our GMarkerOptions object
	markerOptions = { icon:redIcon };	
	
	var marker = new GMarker(point,markerOptions);
		GEvent.addListener(marker, "click", function() {
		  //marker.openInfoWindowHtml(html);
		});
	return marker;
}

function SortResults(column,order){
    var objForm = document.SortInfo;
    
    objForm.orderby.value = column;
    objForm.order.value = order;
    objForm.submit();
}

function OpenMapbox(link, title, moremapsURL){
	stopRefresh();
	var objMapsLink = xDOM('sb-nav-moremaps',0);
	//need to clear url in case it has already been populated on current page
	if (objMapsLink){
        objMapsLink.href = "";
        objMapsLink.style.display = 'none';
    }    
	
	if(title == undefined){
	    title = "&nbsp;";
	}
	if(moremapsURL == undefined){
	    moremapsURL = "";
	}
	
	if (moremapsURL != ""){
	    if (objMapsLink){
	        objMapsLink.href = moremapsURL;
	        objMapsLink.style.display = 'block';
	    }
	}
	
	var boxWidth = getViewportWidth() - 200;
	var boxHeight = getViewportHeight() - 200;

	if(boxWidth < 600){boxWidth = 600;}
	if(boxHeight < 450){boxHeight = 450;}

	Shadowbox.open({
        content:    link.href + "&mapwidth=" + boxWidth + "&mapheight=" + boxHeight,
        player:     "iframe",
        title:      title,
        height:     boxHeight,
        width:      boxWidth
    });
}

function OpenVideo(id,width,height,res,withright,section){
	stopRefresh();

    var objMapsLink = xDOM('sb-nav-moremaps',0);
	//need to clear url in case it has already been populated on current page
	if (objMapsLink){
        objMapsLink.href = "";
        objMapsLink.style.display = 'none';
    }

	var videoWidth = 530;
	if (width > 0)
	{
		videoWidth = width;
	}
	
	var videoHeight = 298;
	if (height > 0)
	{
		videoHeight = height;
	}

	var boxWidth = videoWidth + 40;
	if (withright)
	{
		boxWidth = videoWidth + 220;
	}

	boxHeight = videoHeight + 150;
		
	var url = "/video.asp?id=" + id + "&resolution=" + res + "&section=" + section;

	Shadowbox.open({
//		options: {
//			onFinish: function() {
//				xDOM('sb-body',1).height = xDOM('VideoContent',0).offsetHeight +"px";
//			}
//		},
		content:    url,
		player:     "iframe",
		title:      "&nbsp;",
		height:     boxHeight,
		width:      boxWidth
	});
	
	return false;	

}

function SwitchRes(id,width,height,res,withright,section){
    OpenVideo(id,width,height,res,withright,section);
}

function ResetOptions(form){
    if (document.forms[form] != null){
        var selects = document.forms[form].getElementsByTagName("SELECT");
        for (var i=0; i<selects.length; i++){
        selects.item(i).selectedIndex = 0;
        }
    }
}

function SBox(url,bheight,bwidth)	{
	stopRefresh();
	var boxHeight,boxWidth;
	boxHeight = 300;
	boxWidth = 400;
	if(IsNumeric(bheight))
		boxHeight = parseInt(bheight) + 150;
	if(IsNumeric(bwidth))
		boxWidth = parseInt(bwidth) + 220;
	//document.getElementById('sb-body-inner').style.display="block";
	Shadowbox.open({
//		options: {
//			onFinish: function() {
//				xDOM('sb-body',1).height = xDOM('VideoContent',0).offsetHeight +"px";
//			}
//		},
		content:    url,
		player:		"iframe",
		title:      "&nbsp;",
		height:     boxHeight,
		width:      boxWidth
	});
}
function ShBox(url,bheight,bwidth)	{
	stopRefresh();
	var boxHeight,boxWidth;
	boxHeight = 300;
	boxWidth = 400;
	if(IsNumeric(bheight))
		boxHeight = parseInt(bheight) + 130;
	if(IsNumeric(bwidth))
		boxWidth = parseInt(bwidth) + 20;
	//document.getElementById('sb-body-inner').style.display="block";
	Shadowbox.open({
//		options: {
//			onFinish: function() {
//				xDOM('sb-body',1).height = xDOM('VideoContent',0).offsetHeight +"px";
//			}
//		},
		content:    url,
		player:     "iframe",
		title:      "&nbsp;",
		height:     boxHeight,
		width:      boxWidth
	});
}
function FixBox(url,bheight,bwidth)	{
	stopRefresh();
	var boxHeight,boxWidth;
	boxHeight = 300;
	boxWidth = 400;
	if(IsNumeric(bheight))
		boxHeight = parseInt(bheight);
	if(IsNumeric(bwidth))
		boxWidth = parseInt(bwidth);
	//document.getElementById('sb-body-inner').style.display="block";
	Shadowbox.open({
//		options: {
//			onFinish: function() {
//				xDOM('sb-body',1).height = xDOM('VideoContent',0).offsetHeight +"px";
//			}
//		},
		content:    url,
		player:     "iframe",
		title:      "&nbsp;",
		height:     boxHeight,
		width:      boxWidth
	});
}
function IsNumeric(sText){
   var ValidChars = "0123456789.";
   var IsNumber=false;
   var Char;
   for (i = 0; i < sText.length; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
			return false;
         }
		else{
			IsNumber = true;
		}
      }
   return IsNumber;
   
   }


function getViewportWidth(){
	
	var viewportwidth;
 
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
	if (typeof window.innerWidth != 'undefined')
	{
		viewportwidth = window.innerWidth
	}
 
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

	else if (typeof document.documentElement != 'undefined'
		&& typeof document.documentElement.clientWidth !=
		'undefined' && document.documentElement.clientWidth != 0)
	{
       viewportwidth = document.documentElement.clientWidth
	}
 
	// older versions of IE
 
	else
	{
		viewportwidth = document.getElementsByTagName('body')[0].clientWidth
	}

	return viewportwidth;

}

function getViewportHeight(){
	
	var viewportheight;
 
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
	if (typeof window.innerHeight != 'undefined')
	{
		viewportheight = window.innerHeight
	}
 
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

	else if (typeof document.documentElement != 'undefined'
		&& typeof document.documentElement.clientHeight !=
		'undefined' && document.documentElement.clientHeight != 0)
	{
		viewportheight = document.documentElement.clientHeight
	}
 
	// older versions of IE
 
	else
	{
		viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}

	return viewportheight;

}
