	window.onload=montre;
//	function montre(id) {
//		var d = document.getElementById(id);
//		for (var i = 1; i<=10; i++) {
//			if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
//		}
//		if (d) {d.style.display='block';}
//	}

	function montre()
	{
		var pageId = getURLParam("pageId");
		var d = document.getElementById('smenu'+pageId);
		for (var i = 1; i<=10; i++) {
			if (document.getElementById('smenu'+i)) 
			{
				document.getElementById('smenu'+i).style.display='none';
			}
		}
		if (d) {d.style.display='block';}
	}
	
	function NewWindow(mypage,myname,w,h,scroll,pos){
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(mypage,myname,settings);}
	
	
	
	
	
	// Current Page Reference
	// copyright Stephen Chapman, 1st Jan 2005
	// you may copy this function but please keep the copyright notice with it
	function getURLObject() 
	{
		var uri = new Object();
		
		uri.dir = location.href.substring(0,location.href.lastIndexOf('\/'));
		uri.dom = uri.dir; 
		if (uri.dom.substr(0,7) == 'http:\/\/') uri.dom = uri.dom.substr(7);
		uri.path = ''; 
		var pos = uri.dom.indexOf('\/'); 
		if (pos > -1) {
			uri.path = uri.dom.substr(pos+1); uri.dom = uri.dom.substr(0,pos);
		}
		uri.page = location.href.substring(uri.dir.length+1,location.href.length+1);
		pos = uri.page.indexOf('?');
		if (pos > -1) {
			uri.page = uri.page.substring(0, pos);
		}
		pos = uri.page.indexOf('#');
		if (pos > -1) {
			uri.page = uri.page.substring(0, pos);
		}
		uri.ext = ''; 
		pos = uri.page.indexOf('.');
		if (pos > -1) {
			uri.ext =uri.page.substring(pos+1); 
			uri.page = uri.page.substr(0,pos);
		}
		uri.file = uri.page;
		if (uri.ext != '') uri.file += '.' + uri.ext;
		if (uri.file == '') uri.page = 'index';
		uri.args = location.search.substr(1).split("?");
		return uri;
	}
	
	
	
	function getURLParam(strParamName)
	{
		strParamName = strParamName.toLowerCase();
		
		var strReturn = "";
		var strHref = window.location.href;
		if ( strHref.indexOf("?") > -1 )
		if ( strHref.indexOf("?") > -1 )
		{
			var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
			var aQueryString = strQueryString.split("&");
			for ( var iParam = 0; iParam < aQueryString.length; iParam++ )
			{
				if (aQueryString[iParam].indexOf(strParamName + "=") > -1 )
				{
					var aParam = aQueryString[iParam].split("=");
					strReturn = aParam[1];
					break;
				}
			}
		}
		return strReturn;
	}
	
	function confirmUpdate()
	{
		if (confirm("Are you certain you wish to update your details?"))
		{
			return true;
		}
		return false;
	}
	
	
	/**
	 * confirm registration request can proceed
	 */
	function confirmRegistration()
	{
		var form = document.getElementById("publicform");
		
		var username = document.getElementById("username");
		if (!validateString(username.value, 4, 20))
		{
			alert("You must enter a username between 4 and 20 characters long.");
			return false;
		}
		
		var email = document.getElementById("email");
		if(!validateEmailAddress(email))
		{
			alert("You must enter a valid email address.");
			return false;
		}
		
		var memberTypeObj = form.elements.memberTypeId;
		if (!radioIsChecked(memberTypeObj))
		{
			alert("You must select the type of membership you require.");
			return false;
		}
		
		var paymentTypeObj = form.elements.paymentType;
		if (!radioIsChecked(paymentTypeObj))
		{
			alert("You must select your method of payment.");
			return false;
		}
		// if credit card payment type selected, validate cc details
		if ("cc" == getRadioCheckedValue(paymentTypeObj))
		{
			var ccName = document.getElementById("ccName");
			if (!validateString(ccName.value, 1, 255))
			{
				alert("You must enter a valid credit card holder name.");
				return false;
			}
			var ccNumber = document.getElementById("ccNumber");
			if (!validateString(ccNumber.value, 12, 20))
			{
				alert("You must enter a valid credit card number.");
				return false;
			}
		}
		
		
		// if not errors found, confirm that user wishes to proceed
		if (confirm("Are your details correct and your request for registration ready for submission?"))
		{
			return true;
		}
		return false;
	}
	
	
	/**
	 * validate the event registration form
	 */
	function confirmEventRegistration()
	{
		var form = document.getElementById("publicform");
		
		var givenName = document.getElementById("givenName");
		if (!validateString(givenName.value, 1, 45))
		{
			alert("You must enter a given name between 1 and 45 characters long.");
			return false;
		}
		var familyName = document.getElementById("familyName");
		if (!validateString(familyName.value, 1, 45))
		{
			alert("You must enter a family name between 1 and 45 characters long.");
			return false;
		}
		var email = document.getElementById("email");
		if(!validateEmailAddress(email))
		{
			alert("You must enter a valid email address.");
			return false;
		}
		var organisation = document.getElementById("organisation");
		if (!validateString(organisation.value, 0, 255))
		{
			alert("You must enter an organisation name between 0 and 255 characters long.");
			return false;
		}
		var phone = document.getElementById("phone");
		if (!validateString(phone.value, 0, 15))
		{
			alert("You must enter a phone number between 0 and 15 characters long.");
			return false;
		}
		var mobile = document.getElementById("mobile");
		if (!validateString(mobile.value, 0, 15))
		{
			alert("You must enter a mobile number between 0 and 15 characters long.");
			return false;
		}
		var street = document.getElementById("street");
		if (!validateString(street.value, 0, 255))
		{
			alert("You must enter a street address between 0 and 255 characters long.");
			return false;
		}
		var suburb = document.getElementById("suburb");
		if (!validateString(suburb.value, 0, 255))
		{
			alert("You must enter a suburb between 0 and 255 characters long.");
			return false;
		}
		var town = document.getElementById("town");
		if (!validateString(town.value, 0, 255))
		{
			alert("You must enter a town between 0 and 255 characters long.");
			return false;
		}
		var state = document.getElementById("state");
		if (!validateString(state.value, 0, 25))
		{
			alert("You must enter a state between 0 and 25 characters long.");
			return false;
		}
		var postcode = document.getElementById("postcode");
		if (!validateString(postcode.value, 0, 4))
		{
			alert("You must enter a postcode between 0 and 4 characters long.");
			return false;
		}
		
		var paymentTypeObj = form.elements.paymentType;
		if (!radioIsChecked(paymentTypeObj))
		{
			alert("You must select your method of payment.");
			return false;
		}
		// if credit card payment type selected, validate cc details
		if ("cc" == getRadioCheckedValue(paymentTypeObj))
		{
			var ccName = document.getElementById("ccName");
			if (!validateString(ccName.value, 6, 255))
			{
				alert("You must enter a valid credit card holder name.");
				return false;
			}
			var ccNumber = document.getElementById("ccNumber");
			if (!validateString(ccNumber.value, 12, 20))
			{
				alert("You must enter a valid credit card number.");
				return false;
			}
		}
		
		
		// if not errors found, confirm that user wishes to proceed
		if (confirm("Are your details correct and your request for event registration ready for submission?"))
		{
			return true;
		}
		return false;
	}
	
	/**
	 * Test if a radio element has been checked.
	 */
	function radioIsChecked(radioObj)
	{
		for(var i=0; i < radioObj.length; i++)
		{
	        if (radioObj[i].checked) 
	        {
	        	return true;
	        }
	    }
	    return false;
	}
	
	
	/**
	 * Get value of checked radio button
	 */
	function getRadioCheckedValue(radioObj)
	{
		for(var i=0; i < radioObj.length; i++)
		{
	        if (radioObj[i].checked) 
	        {
	        	return radioObj[i].value;
	        }
	    }
	    return false;
	}
	
	
	function validateString(inputString, minLength, maxLength)
	{
		inputString = trimString(inputString);
		if (inputString.length < minLength)
		{
			return false;
		}
		if (inputString.length > maxLength)
		{
			return false;
		}
		return true;
	}
	
	
	
	function trimString(aString) 
	{
		var aSource = new String(aString)
		return (aSource.replace(/^\s*/,"")).replace(/\s*$/,"")	
	}
	
	function validateEmailAddress(obj) 
	{
		sEmail = obj.value;
		if (sEmail.search( /\w+((-\w+)|(\.\w+)|(\_\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]{2,5}/ ) == -1) 
		{
			return false;
		}
		return true;
	}
	
	/*
	function isDefined(arg) {
		return typeof(arg) != "undefined"
	}

	

	function CheckPostCode(objStr)	{
		var strPostCode = objStr.value;
		var bValid = true;
		if (strPostCode.length != 4) {
			alert("Invalid PostCode");
			objStr.focus();
			return false;
		} else {
			for (i = 0; i <= strPostCode.length - 1; i++) {
				// Grab each character of the string
				var chrCurr = strPostCode.charCodeAt(i);

				// if the character is a letter [0-9]
				if ((parseInt(chrCurr) != 0) && ((parseInt(chrCurr) < 48)  || (parseInt(chrCurr) > 57))) {
					bValid = false;
					break;
				}
			}
			if (! bValid) {
				alert("Invalid PostCode");
				objStr.focus();
				return false;
			} else {
				return true;
			}
		}
	}

	function CheckPostCodeOrSpace(objStr)	{
		var strPostCode = TrimString("" + objStr.value);
		var bValid = true;
		if (strPostCode.length != 0) {
			if (strPostCode.length != 4) {
				alert("Invalid PostCode");
				objStr.focus();		
				return false;
			} else if (strPostCode.length > 0)	{
				for (i = 0; i <= strPostCode.length - 1; i++) {
					// Grab each character of the string
					var chrCurr = strPostCode.charCodeAt(i);
					
					// if the character is a letter [0-9]
					if ((parseInt(chrCurr) != 0) && ((parseInt(chrCurr) < 48)  || (parseInt(chrCurr) > 57))) {
						bValid = false;
					}
				}
				if (! bValid) {
					alert("Invalid PostCode");
					objStr.focus();		
					return false;
				}		
			} else {
				return true;
			}
		} else {
			//string length 0
			return true;
		}
	}
	
	function validMobileNumber(aObject) {
		var mobile = aObject.value.toLowerCase()
		var validMobile = false
		if(mobile.length==10) {
			if(mobile.indexOf("04")==0) {
				validMobile = true
				aObject.value = "614" + aObject.value.substring(2)
			}
		} else if (mobile.length==11) {
			if(mobile.indexOf("614")==0) {
				validMobile = true
			}
		}
		
		if(!validMobile) {
			alert("Invalid mobile number")
			aObject.focus()
			return false
		}
					
		return true
	}

	function CheckNumber(objNum, blnZeroAllowed, blnDecimalAllowed)	{
		var intLen = objNum.value.length;	// the length of the number
		var strCurrNum = objNum.value;	// the value of the number
		var strNewNum = '';
		var blnZero = true;
		// if the length of the number is greater than 0
		if (intLen > 0)	{
			for (i = 0; i <= intLen - 1; i++) {
				// Grab each character of the string
				var chrCurr = strCurrNum.charAt(i);
				
				// if the character is a valid number then we have a number that is not zero
				if ((parseInt(chrCurr) != 0) && (!isNaN(parseInt(chrCurr)))) {
					blnZero = false;
				}

				if ((isNaN(parseInt(chrCurr))) && (chrCurr != '.') && (chrCurr != ',')) {
					// if the character is not a decimal place and not a number then we have an error
					return null;
				} else if ((chrCurr == '.') && (!blnDecimalAllowed)) {
					// if the character is a decimal and we aren't allowing them then we have an error
					return null;	
				} else {
					// otherwise we add it to the valid number string
					strNewNum = strNewNum + chrCurr;
				}
			}

			// after going through the number string if we have no valid numbers and we aren't allowing zeroes then error
			if ((blnZero) && (!blnZeroAllowed)) {
				return null;
			}
		}
		// return the valid number string
		return strNewNum;
	}

	function validateReal(objNum, aOptErrorMsg) {
		var integer	= CheckNumber(objNum, true, true);
		if ((integer == null) || (integer.length == 0))	{
			if (typeof(aOptErrorMsg) == "undefined") {
				alert('Invalid value.');
			} else {
				alert(aOptErrorMsg);
			}
			objNum.focus();
			return false;
		}
		return true;
	}

	function validateRealOrSpace(objNum)	{
		var integer	= CheckNumber(objNum, true, true);
		var nowhitespace = (new String(objNum.value)).replace(/ /g,'');

		if (((integer == null) || (integer.length == 0)) && (nowhitespace.length != 0))	{
			alert('Invalid value.');
			objNum.focus();
			return false;
		}
		return true;
	}

	function validateIntegerOrSpace(objNum,aFriendlyName)	{
		var integer	= CheckNumber(objNum, true, false);		
		var nowhitespace = (new String(objNum.value)).replace(/ /g,'');
		if ((integer == null) && (nowhitespace.length != 0))	{
			alert('Invalid integer value.\n\nOn field:' + aFriendlyName);
			objNum.focus();
			return false;
		}
		return true;
	}

	function validateIntegerOrSpaceNoAlert(objNum)	{
		var integer	= CheckNumber(objNum, true, false);		
		var nowhitespace = (new String(objNum.value)).replace(/ /g,'');
		if ((integer == null) && (nowhitespace.length != 0))	{
			objNum.focus();
			return false;
		}
		return true;
	}

	function validateInteger(objNum,aFriendlyName,aCustomMsg)	{
		var integer	= CheckNumber(objNum, true, false);
		if ((integer == null) || (integer.length == 0))	{
			if (typeof(aCustomMsg) == "undefined") {
				alert('Invalid integer value.\n\nOn field:' + aFriendlyName);
			} else {
				alert(aCustomMsg);
			}
			objNum.focus();
			return false;
		}
		return true;
	}

	function validateMoney(objNum) {
		var money	= CheckNumber(objNum, true, true);
		var	dec		= true;

		if (money != null) {
			dec = money.indexOf('.');
			if (dec == -1) {
				dec = true;
			} else {
				dec = ((money.indexOf('.', dec + 1)) == -1 && (money.length - dec == 3));
			}
		}
		if ((money == null) || (money.length == 0) || !dec)	{
			alert('Invalid currency value.');
			objNum.focus();
			return false;
		}
		return true;
	}

	function validateMoneyOrSpace(objNum) {
		var nowhitespace = (new String(objNum.value)).replace(/ /g,'');
		if (nowhitespace.length != 0)	{
			var money	= CheckNumber(objNum, true, true);
			var	dec		= true;
	
			if (money != null) {
				dec = money.indexOf('.');
				if (dec == -1) {
					dec = true;
				} else {
					dec = ((money.indexOf('.', dec + 1)) == -1 && (money.length - dec == 3));
				}
			}
			if ((money == null) || (money.length == 0) || !dec)	{
				alert('Invalid currency value.');
				objNum.focus();
				return false;
			}
		}
		return true;
	}

	function validatePercentage(objNum) {
		var money	= CheckNumber(objNum, true, true);
		var	dec		= true;

		if (money != null) {
			dec = money.indexOf('.');
			if (dec == -1) {
				dec = true;
			} else {
				dec = ((money.indexOf('.', dec + 1)) == -1);
			}
		}
		if ((money == null) || (money.length == 0) || !dec)	{
			alert('Invalid percentage value.');
			objNum.focus();
			return false;
		}
		return true;
	}
	*/
	
//	
	

function formCheck(formobj){
	// Enter name of mandatory fields
	var fieldRequired = Array("Name","Email","Subject","Body");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Name","Email","Subject","Body");
	// dialog message
	var alertMsg = "Please complete the following fields:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}

