<!-- hide from JavaScript-challenged browsers


	/* =============================================================================
	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:	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:	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 emailValidate(objEmail) {
		
		var emailStr = objEmail.value
		var emailId = objEmail.id
		var checkTLD=1
		var strMsg = ""

		//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) {
			strMsg="Please check for an @ symbol, and full stops."
		}
		else {
			var user=matchArray[1]
			var domain=matchArray[2]
			for (i=0; i<user.length; i++) {
				if (user.charCodeAt(i)>127) {
					strMsg="The Email address contains invalid characters."
				}
			}
			for (i=0; i<domain.length; i++) {
				if (domain.charCodeAt(i)>127) {
					strMsg="The Email address contains invalid characters."
				}
			}
			if (user.match(userPat)==null) {
				strMsg="The email username doesn't seem to be valid."
			}
			var IPArray=domain.match(ipDomainPat)
			if (IPArray!=null) {
				for (var i=1;i<=4;i++) {
					if (IPArray[i]>255) {
						strMsg="The destination IP address is invalid."
					}
				}
			}
			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) {
					strMsg="The domain name does not seem to be valid."
				}
			}
			if (checkTLD && domArr[domArr.length-1].length<2) {
				strMsg="The domain or two letter country code is missing."
			}
			if (len<2) {
				strMsg="The hostname, domain or country code is missing."
			}
		}

		if (strMsg != "") {
//			alert(strMsg)
			addElementAfter(document.getElementById(emailId),'div',emailId+'_msg',strMsg,'inline','formErrorMsg')
			return false
		}
		else {
			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 isNumLetter(daObject) {
		var results = ""
		var strObject = daObject.value
		var strPatt = new RegExp(/\W/g)
		results=strPatt.test(strObject)

		return results

		
	}
	
	
	function listToggle(theList,theDiv,theIndex) {
		if (theList.selectedIndex == theIndex) {
			show(theDiv);
		}
		else {
			hide(theDiv);	
		}
	}


	
	

	/* =============================================================================
	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:	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" 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.form.inputName)">numbers only</a>
	Notes:		<a href="javascript:numonly(document.getElementById('inputName'))">numbers only</a>
	============================================================================= */

	function numonly(daObject){
	daObject.value=daObject.value.replace(/[^0-9]/g, '')
	}
	
	function alphnum(daObject){
		
		if (daObject.value){
			//daObject.value=daObject.value.replace(/ /g, '_')
			daObject.value=daObject.value.replace(/[^0-9a-zA-Z_-]/g, '')
		}else{
			//daObject=daObject.replace(/ /g, '_')
			daObject=daObject.replace(/[^0-9a-zA-Z_-]/g, '')
		}
		
	}
	
	function alphnum_list(daObject){
		
		if (daObject.value){
			daObject.value=daObject.value.replace(/[^0-9a-zA-Z\,\_\-]/g, '')
		}else{
			daObject=daObject.replace(/[^0-9a-zA-Z\,\_\-]/g, '')
		}
		
	}
	
	function alphnum_under(daObject){
		
		if (daObject.value){
			daObject.value=daObject.value.replace(/ /g, '_')
			daObject.value=daObject.value.replace(/[^0-9a-zA-Z_-]/g, '')
		}else{
			daObject=daObject.replace(/ /g, '_')
			daObject=daObject.replace(/[^0-9a-zA-Z_-]/g, '')
		}
		
	}

	function dateonly(daObject){
	daObject.value=daObject.value.replace(/[^0-9\/]/g, '')
	}


	function safeName(object){
		object.value=object.value.replace(' ', '-')
		object.value=object.value.replace(/[^a-zA-Z0-9\.\-\_]/g, '')
		object.value=object.value.replace('..', '.')
	}

	function safeWords(object){
		//object.value=object.value.toLowerCase()
	//	object.value=object.value.replace(' ', '-')
		object.value=object.value.replace(/[ ]/g, '-')
		object.value=object.value.replace(/[^a-zA-Z0-9\-\_]/g, '')
		
	}

	function safeWords_lower(object){
		object.value=object.value.toLowerCase()
		object.value=object.value.replace(/[ ]/g, '-')
		object.value=object.value.replace(/[^a-zA-Z0-9\-\_]/g, '')
		
	}

	function safeDate(object){
		//object.value=object.value.toLowerCase()
	//	object.value=object.value.replace(' ', '-')
		object.value=object.value.replace(/[ ]/g, '-')
		object.value=object.value.replace(/[\/]/g, '-')
		object.value=object.value.replace(/[^a-zA-Z0-9\-\_]/g, '')
		
	}



	/* =============================================================================
	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=0,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(page, windowname) {
		var propStr = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=770,height=500,top=0,left=0";
		popupWin = window.open(page, windowname, propStr);
		//if (window.focus) { popupWin.focus() }
		popupWin.focus();

	}


	function openWindowOptions(page, windowname, w, h, t, l, s, r) {
		var propStr = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+s+",resizable="+r+",copyhistory=0,width=" + w + ",height=" + h + ",top=" + t + ",left=" + l;
		popupWin = window.open(page, windowname, propStr);
		//if (window.focus) { popupWin.focus() }
		popupWin.focus();

	}


	function openWindowForm(form, windowname, w, h, t, l, s, r) {
		if (!window.focus) {
			window.focus();
			return true;
		}
		else {
			
			popupWin = window.open('', windowname, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+s+',resizable='+r+',copyhistory=0,width=' + w + ',height=' + h + ',top=' + t + ',left=' + l);
			form.target=windowname;
			popupWin.focus();
			return true;
		}
	}


	/* =============================================================================
	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=1,directories=1,menubar=1,scrollbars=1,resizable=1,width=700,height=450,top=0,left=0';
		window.open(page, windowname, propStr);
		
	}

	
	
	
	/* =============================================================================
	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.display == 'none'){
				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];
			//alert(strId);
			if (document.getElementById(strId)){
				document.getElementById(strId).style.display = 'none';
			}else if (strId.style.display == 'block'){
				strId.style.display = 'none';
			}
			
		}
	}


	function toggle_view(){
		var strId;
		for (var i=0;i<arguments.length;i++) {
			strId = arguments[i];
			if (document.getElementById(strId)){
				Obj = document.getElementById(strId)
				if (Obj.className == "disp_block"){
					str_class="disp_none";
				}else if (Obj.className == "disp_none"){
					str_class="disp_block";
				}
				
				try{
					Obj.setAttribute("class", str_class)
				}catch(err){
					Obj.setAttribute("className", str_class)
				}
  
			}
		}
	}

/**
 * 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 (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month. The date format must be: dd/mm/yyyy.")
		return false
	}
	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 false
		
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	else return true
}
	/* =============================================================================
	Function:	submitByEnter(strElement,e)
	Purpose:	submits a form if one of the elements has focus and the enter key is pressed
	Parameters:	strElement: the form element that is calling the function, 
	                        used to check if it has a value and to get the form name.
				e: is the event 
	Returns:	
	Calling:	<input onkeydown="submitByEnter(this,event)"
	============================================================================= */

function submitByEnter(strElement,e){
	var keynum
	if(window.event){// IE
		keynum = e.keyCode;
	}
	else if(e.which){// Netscape/Firefox/Opera
		keynum = e.which;
	}
	if (keynum == '13') {
		if(strElement.value){
		eval("document.forms."+strElement.form.name+".submit()")
		}
	}
}


	
	

function listSubmit(strElement,destObj,whichForm){
	if (strElement.value!=''){
		if (document.getElementById(destObj)){
		document.getElementById(destObj).value = strElement.value
		eval("document.forms."+strElement.form.name+".submit()")
		}
	}
	
}


function addElementBefore(node,tag,id,htm,dispType,className) {
	if (document.getElementById(id)) {
		document.getElementById(id).innerHTML = htm
	}
	else {
		var ne = document.createElement(tag)
		if(id) ne.id = id
		if(htm) ne.innerHTML = htm
		node.parentNode.insertBefore(ne,node)
		ne.style.display = dispType
		ne.className = className 
	}
}
	
function addElementAfter(node,tag,id,htm,dispType,className) {
	if (document.getElementById(id)) {
		document.getElementById(id).innerHTML = htm
	}
	else {
		var ne = document.createElement(tag)
		if(id) ne.id = id
		if(htm) ne.innerHTML = htm
		node.parentNode.insertBefore(ne,node.nextSibling)
		ne.style.display = dispType
		ne.className = className 
	}
}

function clearElement(node) {
	if (node) { node.innerHTML = '' }
}


function validateDontPost(whichform){
	var e=document.getElementById(whichform) 
	var patternRequired = /required/g
	var patternEmail = /email/g
	var patternSelect = /select/g
	var okToPost = true
	var firstOne = ''
	var counter = 0
	var strMessage
	for (var z=0;z<e.length;z++) {
		var blnThisOK = true
		var blnEmailOK = true
		var tmpNodeId = e.elements[z].id
		var tmpElement = e.elements[z].className
		var tmpType = e.elements[z].type
		var tmpEmailRequired = false
		
		if(tmpElement.match(patternRequired)) {
		//alert(tmpNodeId)
			if(tmpType.match(patternSelect)){
				if (e.elements[z].selectedIndex == 0) {
					counter = counter+1
					if (counter == 1) { firstOne = tmpNodeId }
					okToPost = false
					blnThisOK = false
				}
			} 
			else {
				if(!e.elements[z].value){
					counter = counter+1
					if (counter == 1) { firstOne = tmpNodeId }
					okToPost = false
					blnThisOK = false
					if (tmpElement.match(patternEmail)) {
						tmpEmailRequired = true	
					}
				}
			}
		}
		
		if ((tmpElement.match(patternEmail)) && (tmpEmailRequired != true)) {
			if (e.elements[z].value) {
				if (!emailValidate(e.elements[z])) {
					counter = counter+1
					if (counter == 1) { firstOne = tmpNodeId }
					okToPost = false
					blnThisOK = false
					blnEmailOK = false
				} 
			}

		}
		
		if (blnThisOK == false && blnEmailOK == true) {
			strMessage = 'Required information.'
			if (document.getElementById('label_'+tmpNodeId)) {
				toggle_label('label_'+tmpNodeId,'redLabel')
			}
			else {
				//Check for title 
				if (document.getElementById(tmpNodeId).title) {
					strMessage = document.getElementById(tmpNodeId).title.replace(/_/g, ' ')
				}
				addElementAfter(document.getElementById(tmpNodeId),'div',tmpNodeId+'_msg',strMessage,'inline','formErrorMsg')
			}
		}
		else {
			if (blnEmailOK != false) {
				if (document.getElementById('label_'+tmpNodeId)) {
					toggle_label('label_'+tmpNodeId,'')
				}
				else {
					clearElement(document.getElementById(tmpNodeId+'_msg'))
				}
			}
		}
	}
	
	if(!okToPost) {
		document.getElementById('div_form_error_msgs').style.display = 'block'
		window.scrollTo(0,0);
		document.getElementById(firstOne).focus()		
		return false
	} else {
		document.getElementById('div_form_error_msgs').style.display = 'none'
		return true
	}
}




	/* =============================================================================
	Function:	validate()
	Purpose:	
	Parameters:	-
	Returns:	
	Calling:	
	============================================================================= */


function validate(whichform, tmpdtn){
	dtn = tmpdtn;
	var e=document.getElementById(whichform); 
	var patternRequired = /required/g;
	var patternSelect = /select/g;
	var okToPost = true;
	for (var z=0;z<e.length;z++){
		var tmpElement = e.elements[z].className;
		var tmpType = e.elements[z].type;
		if(tmpElement.match(patternRequired)){
			if(tmpType.match(patternSelect)){
				if (e.elements[z].selectedIndex == 0) {
					var strAlert = e.elements[z].title;
					alert(strAlert.replace(/_/g," "));
					e.elements[z].focus();
					okToPost = false;
				}
			}
			else {
				if(!e.elements[z].value){
					var strAlert = e.elements[z].title;
					alert(strAlert.replace(/_/g," "));
					e.elements[z].focus();
					okToPost = false;
				}
			}
		}
		if (!okToPost){
			break;
		}
	}
	if(okToPost){
		postForm(whichform);
	}
}

function loadGroup(strElement){
	formID = strElement.form.name;
	if (strElement.value.length >= 3){
		show(document.getElementById(formID+"_list"));
		document.getElementById(formID+"_list").innerHTML = '<div class=group_note>Searching</div>';
		var p = "value="+strElement.value;
		ajaxpack.postAjaxRequest("/_include/inc_group_list.asp", p, processAJAXlist, "txt", strElement.form.name);
	}else{
		show(document.getElementById(formID+"_list"));
		document.getElementById(formID+"_list").innerHTML = '<div class=group_note >Please type at least 3 characters</div>';

		//hide(document.getElementById(formID+"_list"));
	}
	
}


function loadGroupLong(strElement){
	formID = strElement.form.name;
	if (strElement.value.length >= 3){
		show(document.getElementById(formID+"_list"));
		document.getElementById(formID+"_list").innerHTML = '<div class=group_note>Searching</div>';
		var p = "name="+strElement.value;
		ajaxpack.postAjaxRequest("/_include/inc_group_list.asp", p, processAJAXlist, "txt", strElement.form.name);
	}else{
		show(document.getElementById(formID+"_list"));
		document.getElementById(formID+"_list").innerHTML = '<div class=group_note >Please type at least 3 characters</div>';
		if(strElement.value.length == 0){
			document.getElementById(formID+"_list").innerHTML = '';
			hide(document.getElementById(formID+"_list"));
		}
	}
	
}

function selList(groupID,short_name){
	
	if ((groupID)&&(short_name)){
		
		if(document.getElementById('group')){
			document.getElementById('group').value = groupID;
		}
	
		if(document.getElementById('groupName')){
			document.getElementById('groupName').value = short_name;
		}
		
		hide(document.getElementById("loginsecurity_list"));
		
	document.getElementById("loginsecurity").submit();
	}
}

function selListLong(groupID,short_name){
	
	if ((groupID)&&(short_name)){
		
		if(document.getElementById('groupLong')){
			document.getElementById('groupLong').value = groupID;
		}
	
		if(document.getElementById('groupNameLong')){
			document.getElementById('groupNameLong').value = short_name;
		}
		
		hide(document.getElementById("loginsecurityLong_list"));
		
	document.getElementById("loginsecurityLong").submit();
	}
}
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;
					}
				}
			}
		}
	}
}


function processAJAXlist(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
			var strResponse = postAjax.responseText;
			if (strResponse != "none"){
				//isReady(formID);
				if(document.getElementById(formID+"_list")){
					show(document.getElementById(formID+"_list"))
					document.getElementById(formID+"_list").innerHTML = strResponse;
					document.getElementById("link1").focus();
				}
			}else{
				show(document.getElementById(formID+"_list"));
				document.getElementById(formID+"_list").innerHTML = '<div class=group_note>No Match, please try again</div>';

				//hide(document.getElementById(formID+"_list"))
			}
		}
	}
}





var usedArrow = false;
var currLink = 0

function checkArrow(evt) {
	if (typeof window.event != "undefined") evt = window.event; //if not others then IE
	var keycode = evt.keyCode;
	
	if (keycode == 38 || keycode == 40) { //Do stuff only if arrow key

		if(!document.all) {
			evt.preventDefault();
		} else {
			event.returnValue = false;
		}

		
		var currentField = (typeof evt.target != "undefined") ? evt.target : evt.srcElement; //other or IE
        var currentID = currentField.id;
		var newID	
	
		if(currentID.indexOf("link") > -1) {
			newID = currentID.replace("link","");
			if (keycode == 38 && parseInt(newID) > 1) {
				newID = parseInt(newID) - 1;
			}
			if (keycode == 40) {
				newID = parseInt(newID) + 1;
			}
			newID = "link" + newID;
			if(!checkIDExists(newID)){
				newID = currentID;
			}
		}
		if (newID) {
	 	  document.getElementById(newID).focus();
		}
	
	}
}

function checkIDExists(newID) {
	var idexists = document.getElementById(newID);
	if (idexists == null) {
		return false;
	}
	else {
		return true;
	}	
}
