// ##################
// Custom stuff
// ##################

// Configure remote surveys
var gstrSurveysPortal = "surveys.adf.org.au";
var gstrSubModalScriptDir = "/includes/subModal/";

// ##################
// Browser Detection
// ##################

// Note: Browser detection may be outside this file if
// site is heavily JS driven and different JS files are
// loaded for each browser (e.g. separate DOM / NS / IE
// files)

DOM = (document.getElementById) ? true : false;
NS4 = (document.layers) ? true : false;						//Netscape 4 specifically
NS6 = (!document.all && document.getElementById) ? 1 : 0;	//Netscape 6 & 7
IE = (document.all) ? true : false;							//Any IE
IE4 = IE && !DOM;											//IE4 specifically
IE5 = (IE4 && navigator.appVersion.indexOf("5.") != -1);	//Any IE 5 series
IE50 = (navigator.appVersion.indexOf("MSIE 5.0") != -1);	//IE5.0 specifically
ver4 = (NS4 || IE4 || DOM);									//Version 4 or ABOVE
isMac = (navigator.appVersion.indexOf("Mac") != -1);		//Any Mac browser
isDynamic = (DOM || NS4 || NS6 || (IE4 && !isMac) || (IE5 && isMac));
															//Any browsing supporting dHTML (Apparently... This may need work!)
canPrint = (window.print) ? 1 : 0;


// ##################
// Website-specific Elements
// ##################

// Pre-load images for mouseovers (global images only)
if (document.images)
	{
	//an_image_off = new Image();an_image_off.src = ''; //Put path to image in quotes
	//an_image_on = new Image();an_image_on.src = ''; //Put path to image in quotes
	}

// ##################
// Navigation
// ##################

function GoThere(frmName,fdName)
	{
	intSelected = document[frmName].elements[fdName].options.selectedIndex;
	strURL = document[frmName].elements[fdName].options[intSelected].value;
	document[frmName].elements[fdName].options.selectedIndex = 0;
	if (strURL != "")
		{
		location.href = strURL;
		}
	}

// ##################
// Windows & Alerts
// ##################

function Popup(strPage,intWidth,intHeight,strID,strScrollbars,strLocation,strToolbar,strStatus,strResizable)
	{
	if (!strPage)
		{
		strPage = "/";
		}
	if (!intWidth)
		{
		intWidth = 500;
		}
	if (!intHeight)
		{
		intHeight = 320;
		}
	if (!strID)
		{
		strID = "PopupWindow";
		}
	if (!strScrollbars)
		{
		strScrollbars = "yes";
		}
	if (!strLocation)
		{
		strLocation = "no";
		}
	if (!strToolbar)
		{
		strToolbar = "no";
		}
	if (!strStatus)
		{
		strStatus = "no";
		}
	if (!strResizable)
		{
		strResizable = "yes";
		}
	//if (isLoaded == 0)
	//	{
	//	location.reload();
	//	}
	idPopup = window.open(strPage,strID,"width="+intWidth+",height="+intHeight+",scrollbars="+strScrollbars+",location="+strLocation+",toolbar="+strToolbar+",status="+strStatus+",resizable="+strResizable);
	if (window.focus)
		{
		idPopup.focus();
		}
	}

function PopupLink(URL)
	{
	top.opener.location.href = URL;
	top.close();
	}

function CS()
	{
	alert("That function is coming soon.");
	}

// ##################
// Image Manipulation
// ##################

// Swap any image to another
function ImageSwap(id,name)
	{
	if (document.images)
		{
		document.images[id].src=eval(name+".src");
		}
	}

// Swap images with an optional fade effect
// - Requires fading style to be set.
// - Only works for IE5.5+ but falls back nicely
var transitionToggle = 0;
function ImageSwapFX(id,name,transitionDisable)
	{
	if (transitionDisable || !document.images[id].filters || IE50)
		{
		if (document.images)
			{
			document.images[id].src=eval(name+".src");
			}
		}
	else
		{
		document.images[id].filters[0].Apply();
		// After setting Apply, changes to the object
		// are not displayed until Play is called.

		if (transitionToggle)
			{
			transitionToggle = 0;
			document.images[id].src=eval(name+".src");
			}
		else
			{
			transitionToggle = 1;
			document.images[id].src=eval(name+".src");
			}
		document.images[id].filters[0].Play();
		}
	}

// ##################
// Layer Manipulation
// ##################

// Turn any layer on and off
function LayerToggle(togglelayer,state)
	{
	if (NS4)
		{
		if (document.layers[togglelayer])
			{
			document.layers[togglelayer].visibility = state;
			}
		}
	else
		{
		if (document.all[togglelayer])
			{
			document.all[togglelayer].style.visibility = state;
			}
		}
	}

// ====================
// Function:    toggleElement
//
// Purpose:     Turn visibility of any element on or off.
//
// Input:       strDivId - ID of the element being altered
//              strDisplayVal = "block", "inline" or "none"
//
// Output:      Turns specified element on or off.
//
// Assumptions: Specified element exists in document hierarchy.
//
// History:     RW Created 2006-07-20
// ====================
function toggleElement(strDivId,strDisplayVal)
{
	if (!strDisplayVal)
	{
		strDisplayVal = document.getElementById(strDivId).style.display;

		switch (strDisplayVal)
		{
			case "block" :
				strDisplayVal = "none";
				break;
			case "inline" :
				strDisplayVal = "none";
				break;
			case "none" :
				strDisplayVal = "block";
				break;
			case "" :
				break;
		}
	}
	document.getElementById(strDivId).style.display = strDisplayVal;
}

// ##################
// Printing
// ##################

if (IE4 && !canPrint && !isMac) with (document)
	{
	writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
	writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
	writeln('Sub window_onunload');
	writeln('    On Error Resume Next');
	writeln('    Set WB = nothing');
	writeln('End Sub');
	writeln('Sub vbPrintPage');
	writeln('    OLECMDID_PRINT = 6');
	writeln('    OLECMDEXECOPT_DONTPROMPTUSER = 2');
	writeln('    OLECMDEXECOPT_PROMPTUSER = 1');
	writeln('    On Error Resume Next');
	writeln('    WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
	writeln('End Sub');
	writeln('<' + '/SCRIPT>');
	}

function PrintPage()
	{
	if (canPrint)
		{
		window.print();
		}
	else if (IE4 && !isMac)
		{
		vbPrintPage();
		}
	else
		{
		alert("Your web browser does not appear to support the automatic\nPrint function. To print this page, please select the \"Print\"\noption from the \"File\" menu of your web browser.");
		}
	}

// ##################
// Fun Stuff / Easter Eggs
// ##################

// No easter eggs currently present. :-)
