// ##################
// 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
// ##################

// Helps set window attributes within PopupWindow. This way the call to
// PopupWindow is a bit less confusing, e.g. can pass boolean values instead
// of all that "yes" and "no" stuff.
function SetWindowAtttribute(strDefault,varValue)
	{
	// Default value is true
	if ((strDefault == "on") || (strDefault == "yes") || (strDefault == 1) || (strDefault == "true"))
		{
		// Passed value is false
		if ((varValue == 0) && (varValue == "no") && (varValue == "false") && (varValue == "off"))
			{
			return "no";
			}
		// Passed value is anything but false
		else
			{
			return "yes";
			}
		}
	// Default value is false (anything but true)
	else
		{
		// Passed value is true
		if ((varValue == 1) && (varValue == "yes") && (varValue == "true") && (varValue == "on"))
			{
			return "yes";
			}
		// Passed value is anything but true
		else
			{
			return "no";
			}
		}
	}
function Popup(strURL,intWidth,intHeight,strWindowID,blnScrollbars,blnResizable,blnToolbar,blnStatus,blnLocation)
	{

	intWidth = (intWidth) ? intWidth : 500;
	intHeight = (intHeight) ? intHeight : 400;
	strWindowID = (strWindowID) ? strWindowID : "PopWindow";

	blnScrollbars = SetWindowAtttribute("yes",blnScrollbars);
	blnResizable = SetWindowAtttribute("yes",blnResizable);
	blnToolbar = SetWindowAtttribute("no",blnToolbar);
	blnStatus = SetWindowAtttribute("yes",blnStatus);
	blnLocation = SetWindowAtttribute("no",blnLocation);

	strAttributes = "";
	strAttributes += "width="+intWidth;
	strAttributes += ",height="+intHeight;
	strAttributes += ",scrollbars="+blnScrollbars;
	strAttributes += ",resizable="+blnResizable;
	strAttributes += ",toolbar="+blnToolbar;
	strAttributes += ",status="+blnStatus;
	strAttributes += ",location="+blnLocation;
		
	NewWindow = window.open(strURL,strWindowID,strAttributes);

	if (window.focus)
		{
		NewWindow.focus();
		}

	}

function wPopup(wPage,wWidth,wHeight,wID,wScrollbars,wLocation,wToolbar,wStatus,wResizable)
	{
	if (!wID) {wID = "Popup"}
	if (!wWidth) {wWidth = 500}
	if (!wHeight) {wHeight = 320}
	if (!wScrollbars) {wScrollbars = "yes"}
	if (!wLocation) {wLocation = "no"}
	if (!wToolbar) {wToolbar = "no"}
	if (!wStatus) {wStatus = "no"}
	//if (isLoaded == 0) { location.reload() }
	if (!wResizable) {wResizable = "yes"}
	popupWindow = window.open(wPage,wID,"width="+wWidth+",height="+wHeight+",scrollbars="+wScrollbars+",location="+wLocation+",toolbar="+wToolbar+",status="+wStatus+",resizable="+wResizable)
	if (window.focus) { popupWindow.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;
			}
		}
	}

// ##################
// 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. :-)
