<!-- hide from JavaScript-challenged browsers
	
	/* =============================================================================
	This file contains all the common/generic javascript fucntions that can
	be used on the website. If adding a function, please preceed each function with 
	the function info (as set out below), leaving five blank lines between each 
	function.
	If you are wishing to access any of the functions below you must place the
	following (simply copy):
	<script language="JavaScript" src="/_js/fns_javascript.js" type="text/javascript"></script>
	and place in the head section of the web page.
	============================================================================= */



	/* =============================================================================
	Function:	
	Purpose:
	Parameters:	
	Returns:	
	Calling:	
	Notes:		
	============================================================================= */
	function shortDate() {
		var dateObj = new Date();
		var dd = dateObj.getDate();
		var mm = dateObj.getMonth()+1;
		var yyyy = dateObj.getFullYear();
		
		if (parseInt(dd) < 10) {
			dd = "0" + dd;
		}
		if (parseInt(mm) < 10) {
			mm = "0" + mm;
		}
		//alert(dd+"/"+mm+"/"+yyyy);
		return dd+"/"+mm+"/"+yyyy;
	}




	/* =============================================================================
	Function:	cCurrency(sInput)
	Purpose:	To format text field into currency format
	Parameters:	sInput - the value of the text field
	Returns:	sOutput - the formatted currency value
	Calling:	form.textField.value = cCurrency(form.textField.value);	
	Notes:		If formatting text field to use in a SQL money column you must include
				the dollar sign so you would call it via:
				form.textField.value = "$" + cCurrency(form.textField.value);
	============================================================================= */
	function cCurrency(sInput) {
	  var sOutput;
	  sOutput=Math.round(sInput*100)/100;
	  sOutput+=""
	  if(sOutput.indexOf(".")+2==sOutput.length && sOutput.indexOf(".")!=-1 && sOutput.indexOf(".")!="")
		sOutput+="0";
	  if(sOutput.indexOf(".")==-1||sOutput.indexOf(".")=="")
	  sOutput+=".00"
	  return sOutput;
	}
	
	
	
	
	
	/* =============================================================================
	Function:	checkBlank
	Purpose:	Checks whether form text field(s) are blank or not.
	Parameters:	* form field name [req] - the field from the form you want to test
				* "error message" [req] (string) - display text
	Returns:	Boolean. True if field is not blank, false if field is blank
	Calling:	Usually used in the form validate function: 
				<form method="post" action="destination.asp" onsubmit="return validate(this)">
				* Validate function code
				function validate(form) {
  					var isOK = checkBlank(form.name, "your name.",
										  form.address, "your address.");
  					if (!isOK) {
    					return false;
  					} 
				}
	Notes:		Multiple pairs can be entered, you must have a comma separating all arguments.
				Limitations - Returns true if just a whitespace has been entered.
	============================================================================= */
	function checkBlank() {
  		for (var i = 0; i < arguments.length; i += 2) {
			if (!arguments[i].value) {
				alert("Please enter " + arguments[i+1]);
      			arguments[i].focus();
      			return false;
    		}
  		}
  		return true;
	}





	/* =============================================================================
	Function:	checkList
	Purpose:	Checks whether an item has been selected from a drop-down list.
	Parameters:	* form field name [req] - the field from the form you want to test
				* "error message" [req] (string) - display text must be enclosed in double quotation marks.
	Returns:	Boolean. True if an item has been selected, False if no item has been selected.
	Calling:	Usually used in the form validate function: 
				<form method="post" action="destination.asp" onsubmit="return validate(this)">
				* Validate function code
				function validate(form) {
				  var isSelected = checkList(form.state, "your state.");
				  if (!isSelected) {
				    return false;
				  } 
				}
	Notes:		Limitations - You must have a null option in the first position e.g. "-select-" or ""
	============================================================================= */
	function checkList() {
	  if (arguments[0].selectedIndex == 0) {
	    alert ("Please select " + arguments[1]);
	    arguments[0].focus();
	    return false;
	  }
	  else return true;
	}




	/* =============================================================================
	Function:	checkNum
	Purpose:	Checks whether form text field(s) contain a number or not.
	Parameters:	* form field name [req] - the field from the form you want to test
				* "error message" [req] (string) - display text
	Returns:	Boolean. True if field is a number, false if field is not a number.
	Calling:	Usually used in the form validate function: 
				<form method="post" action="destination.asp" onsubmit="return validate(this)">
				* Validate function code
				function validate(form) {
  					var isNum = checkNum(form.amount1, "your amount1.",
										  form.amount2, "your amount2.");
  					if (!isNum) {
    					return false;
  					} 
				}
	Notes:		Multiple pairs can be entered, you must have a comma separating all arguments.
				Limitations - Returns true if just a whitespace has been entered.
	============================================================================= */
	function checkNum() {
		for (var i = 0; i < arguments.length; i += 2) {
			if (arguments[i].value) {
				if (isNaN(arguments[i].value)) {
					alert("Please enter a number only for " + arguments[i+1]);
					arguments[i].focus();
					return false;
				}
			}
		}
		return true;
	}




	/* =============================================================================
	Function:	checkPhoneNumber(fieldId)
	Purpose:	Checks whether a ohone number field has at least 10 digits.
	Parameters:	* fieldId [req] - the id of the phone number field
	Returns:	Boolean. True if field is valid, false if field is not not valid.
	Calling:	Usually used in the form validate function: 
				<form method="post" action="destination.asp" onsubmit="return validate(this)">
				* Validate function code
				function validate(form) {
					if (!checkPhoneNumber("Residential_phone")) {
						return false;
					}
				}
	============================================================================= */
	function checkPhoneNumber(fieldId) {
		var phoneNumber;
		var phoneOK;
		
		phoneOK = true;
		
		phoneNumber = document.getElementById(fieldId).value;
	
		if (phoneNumber) {
		//alert(phoneNumber);
			var test;
	
			var phoneEx = /^\+\d|^\d/;
			var numEx = /[^0-9\+\-\s]$/g;
			var digit = /[\d]/;
	
			var numCount = 0;
			for (var i=0; i<phoneNumber.length; i++) {
				var temp = phoneNumber.charAt(i);
				test1 = temp.match(digit);
				if (test1!=null) {
					numCount++;
				}
			}
			if (numCount < 10) {
				if (numCount == 0) {
					alert("There are no digits in the phone number, please check and re-enter.");
					phoneNumber = document.getElementById(fieldId).focus();
					phoneOK = false;
				}
				else {		
					alert("The phone number seems too short. If the number is not a mobile, please ensure you have included the area code (and country code if applicable).");
					phoneNumber = document.getElementById(fieldId).focus();
					phoneOK = false;
				}
			}
		}
		return phoneOK;
	}





/* =============================================================================
	Function:	checkRadio
	Purpose:	Checks whether a radio button has been selected from a group.
	Parameters:	* form field name [req] - the radio button group you want to test
            	* "error message" [req] (string) - display text must be enclosed in double quotation marks.
	Returns:	Boolean. True if an radio button has been selected, False if no radio button has been selected.
	Calling:	Usually used in the form validate function: 
				<form method="post" action="destination.asp" onsubmit="return validate(this)">
				* Validate function code
				function validate(form) {
				  var isSelected = checkRadio(form.radioGroupName, "an option from the radio button group.");
				  if (!isSelected) {
				    return false;
				  }
				}
	Notes:		Limitations - This function is only useful if no radio button has been pre-selected when page is loaded.
	============================================================================= */
	function checkRadio() {
	  var checkedButton = false;
	  var question = arguments[0];
	  var message = arguments[1];
	  for (var b = 0; b < question.length; b++) {
		if (question[b].checked) {
		  checkedButton = true;
		}
	  }
	  if (checkedButton == false) {
		alert("Please select " + message);
		question[0].focus();
	  }
	  return checkedButton;
	} //end of function checkRadio


	/* =============================================================================
	Function:	checkSingleBox
	Purpose:	Check that a single checkbox is checked checkboxes.
	Parameters:	
	Returns:	Boolean. True if an radio button has been selected, False if no radio button has been selected.
	Calling:	
	Notes:		
	============================================================================= */
	function checkSingleBox(){
		var checkedBox = false;
		var whichBox = arguments[0];
		var message = arguments[1];
		
		if (whichBox.checked) {
			checkedButton = true;
		}
		
		if (checkedButton == false) {
		alert("Please select " + message);
		whichBox.focus();
		}
		return checkedBox;
	}
	



	/* =============================================================================
	Function:	emailCheck
	Purpose:	Checks whether the form email address submitted is valid or not.
	Parameters:	emailStr - the value of the email field.
	Returns:	Boolean. True if email address is value, false if invalid.
	Calling:	Usually used in the form validate function: 
			<form method="post" action="destination.asp" onsubmit="return validate(this)">
			* Validate function code
			function validate(form) {
				if (!emailCheck(form.email.value)){
  					form.email.focus();
  					return false;
  				}
			}
	Notes:		Taken from www.goonline.com
	============================================================================= */
	//function emailCheck(emailStr) {
	//	re = new RegExp("^([a-zA-Z0-9_\-]+(\.[a-zA-Z0-9_\-]+)*\@[a-zA-Z0-9_\-]+(\.[a-zA-Z0-9_\-]+)*)$");
	//	if (!re.exec(emailStr)) {
	//		alert('Your email address is invalid. It must be in the format user@server.domain');
	//		return false;
	//	}
	//	return true;
	//}
	function emailCheck(emailStr) {
		var checkTLD=1;

		//Not currently using the known domain names as it is too hard to accurately maintain
		//Update the list of known domain names here
		//var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|info|name|pro|museum|coop|aero)$/;

		var emailPat=/^(.+)@(.+)$/;
		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
		var validChars="\[^\\s" + specialChars + "\]";
		var quotedUser="(\"[^\"]*\")";
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
		var atom=validChars + '+';
		var word="(" + atom + "|" + quotedUser + ")";
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
		var matchArray=emailStr.match(emailPat);
		if (matchArray==null) {
			alert("Your email address seems incorrect (please check for an @ symbol, and full stops.)\n\nPlease check and try again.");
			return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];
		for (i=0; i<user.length; i++) {
			if (user.charCodeAt(i)>127) {
				alert("The username in the Email address contains invalid characters.\n\nPlease check and try again.");
				return false;
			}
		}
		for (i=0; i<domain.length; i++) {
			if (domain.charCodeAt(i)>127) {
				alert("The domain name in the Email address contains invalid characters.\n\nPlease check and try again.");
				return false;
			}
		}
		if (user.match(userPat)==null) {
			alert("The username in your Email address doesn't seem to be valid.\n\nPlease check and try again.");
			return false;
		}
		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null) {
			for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
					alert("The destination IP address in your Email address is invalid.\n\nPlease check and try again.");
					return false;
				}
			}
			return true;
		}
		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;
		for (i=0;i<len;i++) {
			if (domArr[i].search(atomPat)==-1) {
				alert("The domain name in your Email address does not seem to be valid.\n\nPlease check and try again.");
				return false;
			}
		}
		//if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
		if (checkTLD && domArr[domArr.length-1].length<2) {
			//alert("Your Email address must end in a well-known domain or two letter " + "country code.\n\nPlease check and try again.");
			alert("Your Email address must end in a domain or two letter country code.\n\nPlease check and try again.");
			return false;
		}
		if (len<2) {
			alert("Your Email address is missing either a hostname, domain or country code!\n\nPlease check and try again.");
			return false;
		}
		return true;
	}





	/* =============================================================================
	Function:	formAction
	Purpose:	Posts form to the specified script/page.  Used when forms span over more than one page.
	Parameters:	form [req] - the current form
            		displayPage [req] - the destionatio script/page
        Returns:	
        Calling:	* To use the formAction function, the action value in the form tag may or may not have a value.	
        		<form method="post" action="" onsubmit="return validate(this)"> OR
			<form method="post" action="destination.asp" onsubmit="return validate(this)">
			* To call the formAction function you must assign an onclick event to the submit button.
			onclick="formAction(this.form, 'alt_destination.asp')"

        Notes:		
	============================================================================= */
	function formAction(form, displayPage) {
	   form.action = displayPage;
	}


	
	

	/* =============================================================================
	Function:	maintainCheck
	Purpose:	Maintains only one checkbox is selected from a group of checkboxes.
	Parameters:	* checkbox number [req] - starts with 1
	Returns:	Boolean. True if an radio button has been selected, False if no radio button has been selected.
	Calling:	* You call the maintainCheck function using the onClick event when adding checkboxes to the form:
  				<input type="checkbox" name="checkBox1" value="1" onClick="maintainCheck(1)">
  				<input type="checkbox" name="checkBox2" value="1" onClick="maintainCheck(2)">
  				<input type="checkbox" name="checkBox3" value="1" onClick="maintainCheck(3)">
				* You must declare an array with all the CheckBox names to be included in the group
  				var checkBoxArray = new Array (checkBox1, checkBox2, checkBox3);
	Notes:		
	============================================================================= */
	function maintainCheck(checkThis){
		for (var i=1; i<=checkBoxArray.length; i++) { // uncheck all boxes that are checked
			if(eval("document.form.checkBox" + i + ".checked")){
				eval("document.form.checkBox" + i + ".checked = false");
			}
		}
		eval("document.form.checkBox" + checkThis + ".checked = true"); // check the check box that was selected
	}
	
	
	
	
	/* =============================================================================
		Function:	change_disabled(strId,strAction)
		Purpose:	Toggles the form element's property between disabled/enabled
		Parameters:	strId -  the id of the form element to toggle
					strAction - either 'disable' or 'enable'
		Returns:	-
		Calling:	-
		============================================================================= */
	function change_disabled(strId,strAction) {
		if (strAction == 'disable') {
			document.getElementById(strId).disabled=true
			clearForm(document.getElementById(strId))
		}
		else {
			document.getElementById(strId).disabled=false
		}
	}	
	


	function checkbox_disable(objToCheck,strToDisable) {
		if (objToCheck.checked) {
			change_disabled(strToDisable,'enable')
		}
		else {
			change_disabled(strToDisable,'disable')
		}
	}

	
	
	/* =============================================================================
		Function:	clearForm(formElement)
		Purpose:	Clears all the form element types
		Parameters:	formElement - the form object
		Returns:	-
		Calling:	-
		============================================================================= */
	function clearForm(){
		var formElement;
		for (var i=0;i<arguments.length;i++) {

			//check if is string or object
			if (document.getElementById(arguments[i])){
				formElement = document.getElementById(arguments[i]);
			}else {
				formElement = arguments[i];
			}
//alert(formElement.type);

			switch(formElement.type)
			{
				case 'undefined': return;
				case 'button': return;
				case 'reset': return;
				case 'radio': formElement.checked = false; break;
				case 'checkbox': formElement.checked = false; break;
				case 'select-one': formElement.selectedIndex = 0; break;
		
				case 'select-multiple':
					for(var x=0; x < formElement.length; x++) 
						formElement[x].selected = false;
					break;
		
				default: formElement.value = "";
			}

		}
	}

	/* =============================================================================
	Function:	numonly
	Purpose:	Allows only numbers to be entered into text fields and textareas.
	Parameters:	* object [req] - is the name of the form element - use 'this' if function is called from the element itself .

	Returns:	numbers only in the text field 
	Calling:	if called from the form element itself use numonly(this) in onChange, onBlur, onKeyUp to make sure all browseres are covered
				<input type="text" onChange="numonly(this)" onBlur="numonly(this)" onKeyUp="numonly(this)" name="" value="" />
				
				if called from a link declare the element you want the function to run on
				<a href="javascript:numonly(document.survey_form.full_time_retire)">numbers only</a>
	Notes:		
	============================================================================= */
	function numonly(object){
	object.value=object.value.replace(/[^0-9]/g, '');
	}



	/* =============================================================================
	Function:	numonly
	Purpose:	Allows only numbers to be entered into text fields and textareas.
	Parameters:	* object [req] - is the name of the form element - use 'this' if function is called from the element itself .

	Returns:	numbers only in the text field 
	Calling:	if called from the form element itself use numonly(this) in onChange, onBlur, onKeyUp to make sure all browseres are covered
				<input type="text" onChange="numonly(this)" onBlur="numonly(this)" onKeyUp="numonly(this)" name="" value="" />
				
				if called from a link declare the element you want the function to run on
				<a href="javascript:numonly(document.survey_form.full_time_retire)">numbers only</a>
	Notes:		
	============================================================================= */
	function numonlyDec(object){
	object.value=object.value.replace(/[^0-9.]/g, '');
	object.value=object.value.replace('..', '.');
	}





	/* =============================================================================
	Function:	AJAXpost
	Purpose:	Post form without reloading the page.
	Parameters:	form ID

	Returns:	what your processing page returns
	Calling:	
	Notes:		
	============================================================================= */

	function AJAXpost(formID){
	
		var post_dbTable = "/_include/inc_post_form.asp";
		var xx=document.getElementById(formID); 
		if (xx.action){
			post_dbTable = xx.action;
		}
		
		var p="";
		var patternIgnore = /ignore/g;
		for (var z=0;z<xx.length;z++){
	
			var tmpElement = xx.elements[z].className;
			
			if(!tmpElement.match(patternIgnore)){
				//xx.elements[z].value=xx.elements[z].value.replace(/"/g, '')
				//xx.elements[z].value=xx.elements[z].value.replace(/'/g, '')
				
				var tmpValue = escape(xx.elements[z].value);
				
				p = p + xx.elements[z].name+"="+tmpValue+"&";
				
			}
		}
		var cutOff
		cutOff = p.lastIndexOf("&")
	
		p= p.slice(0,cutOff)
		//show('formblock');
		formName = formID;
		//alert(p)
		ajaxpack.postAjaxRequest(post_dbTable, p, processAJAXpost, "txt", formName);
		
	}
	
	function processAJAXpost(formName){
		var formID = formName;
		var postAjax=ajaxpack.ajaxobj;
		var postFiletype=ajaxpack.filetype;
		if (postAjax.readyState == 4){ //if request of file completed
			if (postAjax.status==200){ //if request was successful or running script locally
				if (eval("document."+ formID+".pass_to")){
					var pass_para = eval("document."+ formID+".pass_to.value")
					var pop_size = 225;
					if (eval("document."+ formID+".pop_size")){
						pop_size =eval("document."+ formID+".pop_size.value");
					}
					var dbTable = eval("document."+formName+".tbl.value");
					var parameters = "?tbl="+dbTable;
					var dbCol = eval("document."+formName+".colID.value");
					parameters = parameters + "&colID="+dbCol;
					if (eval("document."+formName+".colMatch")) {
						var dbMatch = eval("document."+formName+".colMatch.value");
						parameters =  parameters + "&colMatch="+dbMatch;
					}
					popit(pass_para+parameters,pop_size);
				}else{
					strResponse = postAjax.responseText;
					if (strResponse == "Up To Date"){
						isReady(formID);
						if(document.getElementById(formID+"_status")){
							document.getElementById(formID+"_status").innerHTML = strResponse;
						}
					}
					if (strResponse == "Message Sent"){
						
						if(document.getElementById(formID+"_status")){
							document.getElementById(formID+"_status").innerHTML = "<h3 style=\" text-align:center\">Your Message Has Been Sent</h3>";
						}
						if(document.getElementById(formID+"_history")){
							document.getElementById(formID+"_history").innerHTML = document.getElementById(formID+"_history").innerHTML + shortDate();
						}
					}
				}
			}
		}
	}

	/* =============================================================================
	Function:	openWindow
	Purpose:	Opens a pop-up window containing specified page.
	Parameters:	* page [req] - consists of the path (if not in same dir. as calling page) and file name of the page to display.
			* windowname [req] - the name of the window, must be unique to open a new window.
			* w - window width
			* h - window height
			* t - window position from top
			* l - window position from let
	Returns:	-
	Calling:	To call the function openWindow to display the page "info/career_obj.htm" in a window called "popup" use the following:
			<a href="javascript:openWindow('info/career_obj.htm','popup', 600, 300, 100, 250);">IMAGE OR LINK TEXT GOES IN HERE</a>
	Notes:		
	============================================================================= */
	function openWindow(page, windowname, w, h, t, l) {
		var propStr = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=" + w + ",height=" + h + ",top=" + t + ",left=" + l;
		popupWin = window.open(page, windowname, propStr);
		//if (window.focus) { popupWin.focus() }
		popupWin.focus();

	}





	/* =============================================================================
	Function:	openWindowFull
	Purpose:	Opens a pop-up window containing specified page.
	Parameters:	* page [req] - consists of the path (if not in same dir. as calling page) and file name of the page to display.
			* windowname [req] - the name of the window, must be unique to open a new window.
			* w - window width
			* h - window height
			* t - window position from top
			* l - window position from let
	Returns:	-
	Calling:	To call the function openWindow to display the page "info/career_obj.htm" in a window called "popup" use the following:
			<a href="javascript:openWindow('info/career_obj.htm','popup', 600, 300, 100, 250);">IMAGE OR LINK TEXT GOES IN HERE</a>
	Notes:		
	============================================================================= */
	function openWindowFullMenu(page, windowname) {
		var propStr = 'toolbar=1,location=0,directories=0,menubar=1,status=0,scrollbars=1,resizable=1,width='+screen.width+',height='+screen.height+',top=0,left=0'
		popupWin = window.open(page, windowname, propStr);
		popupWin.focus();
	}

	
	
	
	/* =============================================================================
	Function:	openWindowFullNoMenus(page, windowname) {
	Purpose:	Opens a pop-up window containing specified page with no menus or
				toolbars displayed
	Parameters:	* page [req] - consists of the path (if not in same dir. as calling page) and file name of the page to display.
	Returns:	-
	Calling:	To call the function openWindow to display the page "info/career_obj.htm" in a window called "popup" use the following:
			<a href="javascript:openWindow('info/career_obj.htm','popup');">IMAGE OR LINK TEXT GOES IN HERE</a>
	Notes:		
	============================================================================= */
	function openWindowFullNoMenus(page, windowname) {
		var propStr = 'toolbar=0,location=0,directories=0,menubar=0,status=0,scrollbars=1,resizable=1,width='+screen.width+',height='+screen.height+',top=0,left=0'
		popupWin = window.open(page, windowname, propStr);
		popupWin.focus();
	}





	/* =============================================================================
	Function:	openWindowDetails
	Purpose:	Opens a pop-up window specifically for e-series use. Used for members wanting to change their membership details in iMIS.
	Parameters:	-
	Returns:	-
	Calling:	To call the function openWindowDetails use the following:
				<a href="javascript:openWindowDetails();">IMAGE OR LINK TEXT GOES IN HERE</a>
	Notes:		Removed two lines (see below) and modified so the window now opens in max size.
			popupWin = window.open('https://federal.apesma.asn.au/scriptcontent/index.cfm', 'popup',
			'toolbar=1,location=0,directories=0,menubar=0,status=0,scrollbars=1,resizable=1,width=650,height=400,top=50,left=120')
	============================================================================= */
	function openWindowDetails() {
		var propStr = 'toolbar=1,location=0,directories=0,menubar=0,status=0,scrollbars=1,resizable=1,width='+screen.width+',height='+screen.height+',top=0,left=0'
		popupWin = window.open('https://federal.apesma.asn.au/scriptcontent/index.cfm', 'popup_eseries', propStr)
	}




	/* =============================================================================
	Function:	openWindowPayment
	Purpose:	Opens a pop-up window specifically for e-series use. Used for members wanting to make sub payments via iMIS
	Parameters:	-
	Returns:	-
	Calling:	To call the function openWindowPayment use the following:
				<a href="javascript:openWindowPayment();">IMAGE OR LINK TEXT GOES IN HERE</a>
	Notes:		Removed two lines (see below) and modified so the window now opens in max size.
			popupWin = window.open('https://federal.apesma.asn.au/source/apesma/duespaid.cfm', 'popup',
			'toolbar=1,location=0,directories=0,menubar=0,status=0,scrollbars=1,resizable=1,width=650,height=400,top=50,left=120')
	============================================================================= */
	function openWindowPayment() {
		var propStr = 'toolbar=1,location=0,directories=0,menubar=0,status=0,scrollbars=1,resizable=1,width='+screen.width+',height='+screen.height+',top=0,left=0'
		popupWin = window.open('https://federal.apesma.asn.au/source/apesma/duespaid.cfm', 'popup_eseries', propStr)
	}


	/* =============================================================================
	Function:	paymentsConfirmBox()
	Purpose:	Displays a javascript confirmation box used for all e-commerce forms on submission.
	Parameters:	-
	Returns:	boolean
	Calling:	
	============================================================================= */
	function paymentsConfirmBox() {
		if (confirm ("You are about to proceed to enter payment details. Once your transaction is complete, a payment receipt/tax invoice will be presented. Please PRINT this payment receipt/tax invoice as proof of payment.")) {
			return true;
		}
		else return false;	
	}
	
	
	

/* =============================================================================
	Function:	show(strId)
	Purpose:	Displays the div as passed.
	Parameters:	-
	Returns:	-
	Calling:	
	============================================================================= */
	function show() {
		var strId;
		for (var i=0;i<arguments.length;i++) {
			strId = arguments[i];
			if (document.getElementById(strId)){
				document.getElementById(strId).style.display = 'block';
			}else if (strId.style){
				strId.style.display = 'block';
			}
			
		}
	}





	/* =============================================================================
	Function:	hide(strId)
	Purpose:	Displays the div as passed.
	Parameters:	-
	Returns:	-
	Calling:	
	============================================================================= */
	function hide() {
		var strId;
		for (var i=0;i<arguments.length;i++) {
			strId = arguments[i];
			if (document.getElementById(strId)){
				document.getElementById(strId).style.display = 'none';
			}else if (strId.style){
				strId.style.display = 'none';
			}
		}
	}


/* =============================================================================
	Function:	showinline(strId)
	Purpose:	Displays the div as passed.
	Parameters:	-
	Returns:	-
	Calling:	
	============================================================================= */
	function showinline() {
		var strId;
		for (var i=0;i<arguments.length;i++) {
			strId = arguments[i];
			if (document.getElementById(strId)){
				document.getElementById(strId).style.display = 'inline';
			}else if (strId.style){
				strId.style.display = 'inline';
			}
			
		}
	}





	/* =============================================================================
	Function:	hideinline(strId)
	Purpose:	Displays the div as passed.
	Parameters:	-
	Returns:	-
	Calling:	
	============================================================================= */
	function hideinline(strId) {
		
		for (var i=0;i<arguments.length;i++) {
			strId = arguments[i];
			if (document.getElementById(strId)){
				document.getElementById(strId).style.display = 'none';
			}else if (strId.style){
				strId.style.display = 'none';
			}
		}
	}





	/* =============================================================================
	Function:	toggle_view(strId)
	Purpose:	Toggles between class of disp_block and disp_none for turning elements off and on
	Parameters:	Object ID
	Returns:	-
	Calling:	
	============================================================================= */

	function toggle_view(){
		var strId;
		var currentClass;
		for (var i=0;i<arguments.length;i++) {
			strId = arguments[i];
			if (document.getElementById(strId)){
				Obj = document.getElementById(strId);
				currentClass = Obj.className;
				
				if (currentClass.indexOf("disp_block") != -1){	
					str_class=currentClass.replace("disp_block","disp_none");
				}
				else if (currentClass.indexOf("disp_none") != -1){
					str_class=currentClass.replace("disp_none","disp_block");
				}
				if (Obj.setAttribute("className", str_class)){
					Obj.setAttribute("className", str_class);
				}else{
					Obj.setAttribute("class", str_class);
				}
			}
		}
	}


	/* =============================================================================
	Function:	validateCompetitionForm(strId)
	Purpose:	Displays the div as passed.
	Parameters:	-
	Returns:	-
	Calling:	
	============================================================================= */
	function validateCompetitionForm() {
		if (document.getElementById("title").selectedIndex == 0){
			alert("Please select your title.");
			document.getElementById("title").focus();
			return false;
		}
		var isBlank = checkBlank(document.getElementById("first_name"),"your first_name",
								document.getElementById("last_name"),"your last_name",
								document.getElementById("address"),"your address",
								document.getElementById("suburb"),"your suburb");
		if (!isBlank) {
			return false;
		}
		if (document.getElementById("state").selectedIndex == 0){
			alert("Please select your state.");
			document.getElementById("state").focus();
			return false;
		}
		isBlank = checkBlank(document.getElementById("postcode"),"your postcode",
							document.getElementById("phone_number"),"your phone_number");
		if (!isBlank) {
			return false;
		}
	}




	/* =============================================================================
	Function:	isValidCreditCardNumber(strCardNumber, intCardType)
	Purpose:	Checks the credit card number length, prexfix and whether the number 
				cofirms to the Luhn algorithm
	Parameters:	- strCardNumber: a string containing the credit card number
				- intCardType: an integer representing the credit card type - must be
				  as per the switch statement in the function.
	Returns:	- isValid: could have the following values
							- false --> card number prefix and length failed test
							- 0		--> card number is valid
							- a number != 0  --> card number failed Luhn algorithm
	Calling:	
	============================================================================= */
	function isValidCreditCardNumber(strCardNumber, intCardType) {
		var isValid = false;
		var ccCheckRegExp = /[^\d ]/;
		isValid = !ccCheckRegExp.test(strCardNumber);
		
		if (isValid) {
			var strCardNumbersOnly = strCardNumber.replace(/ /g,"");
			var intCardNumberLength = strCardNumbersOnly.length;
			var lengthIsValid = false;
			var prefixIsValid = false;
			var prefixRegExp;
			
			switch(intCardType) {
				case 1: //"visa":
					//lengthIsValid = (cardNumberLength == 16 || cardNumberLength == 13);
					lengthIsValid = (intCardNumberLength == 16);
					prefixRegExp = /^4/;
				break;
				
				case 2: //"mastercard":
					lengthIsValid = (intCardNumberLength == 16);
					prefixRegExp = /^5[1-5]/;
				break;
				
				case 3: //"diners":
					lengthIsValid = (intCardNumberLength == 14);
					prefixRegExp = /^36/; /* Only Diners International */
				break;
				
				case 4: //"amex":
					lengthIsValid = (intCardNumberLength == 15);
					prefixRegExp = /^3(4|7)/;
				break;
				
				default:
					prefixRegExp = /^$/;
					alert("Card type not found");
			}
			
			prefixIsValid = prefixRegExp.test(strCardNumbersOnly);
			isValid = prefixIsValid && lengthIsValid;
		}
		
		if (isValid) {
			var numberProduct;
			var numberProductDigitIndex;
			var checkSumTotal = 0;
			
			for (digitCounter = intCardNumberLength - 1; digitCounter >= 0; digitCounter--) {
				checkSumTotal += parseInt (strCardNumbersOnly.charAt(digitCounter));
				digitCounter--;
				numberProduct = String((strCardNumbersOnly.charAt(digitCounter) * 2));
				for (var productDigitCounter = 0; productDigitCounter < numberProduct.length; productDigitCounter++) {
					checkSumTotal += parseInt(numberProduct.charAt(productDigitCounter));
				}
			}
			isValid = (checkSumTotal % 10 == 0);
		}
		
		return isValid;
	}




/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

	/* =============================================================================
	Function:	isInteger(s)
	Purpose:	Check that current character is number
	Parameters:	-
	Returns:	-
	Calling:	To call the function openWindowPayment use the following:
				<a href="javascript:openWindowPayment();">IMAGE OR LINK TEXT GOES IN HERE</a>
	============================================================================= */
	function isInteger(s){
		var i;
		for (i = 0; i < s.length; i++){   
			// Check that current character is number.
			var c = s.charAt(i);
			if (((c < "0") || (c > "9"))) return false;
		}
		// All characters are numbers.
		return true;
	}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be: dd/mm/yyyy.")
		return 1
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month. The date format must be: dd/mm/yyyy.")
		return 2
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day. The date format must be: dd/mm/yyyy.")
		return 1
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return 3
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date. The date format must be: dd/mm/yyyy.")
		return 1
	}
return 0
}


/* =============================================================================
NEWSTICKER
called like so
<div id="ticker_container" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">
	<div id="ticker1" style="position: absolute; width: 98%;">
	DATA HERE
	</div>
</div>
Only attach the event of the ticker is in the page		
<script type="text/javascript" language="javascript">
	if (window.addEventListener){
		window.addEventListener("load", initializemarquee, false);
	}
	else if (window.attachEvent){
		window.attachEvent("onload", initializemarquee);
	}
	else if (document.getElementById){
		window.onload=initializemarquee;
	}
</script>
============================================================================= */
var delayb4=1 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var mSpeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?
var resetOffset=34 //The ammount to offset the ticker when it returns to the top - so the first story scrolls up rather than just appearing
var xSpeed=mSpeed
var noSpeed=(pauseit==0)? xSpeed: 0
var inner_height=''

function scrollTicker(){
	if (parseInt(inner_ticker.style.top)>(inner_height*(-1)+48))
		inner_ticker.style.top=parseInt(inner_ticker.style.top)-xSpeed+"px"
	else
		inner_ticker.style.top=resetOffset+"px"
}

function initializemarquee(){
	inner_ticker=document.getElementById("ticker1")
	inner_ticker.style.top=0
	contain_height=document.getElementById("ticker_container").offsetHeight
	inner_height=inner_ticker.offsetHeight
	setTimeout('lefttime=setInterval("scrollTicker()",60)', delayb4)
	
	/*SCREEN SIZE TEST*/
	var screenwidth = screen.width;
	var screenheight = screen.height;
	
	var p = "screenwidth="+screenwidth+"&screenheight="+screenheight
	ajaxpack.postAjaxRequest("/_include/inc_user.asp", p, emptyfunction, "text/xml", "")	
	
}

function emptyfunction(){}



// done hiding -->
