/*MENU SCRIPT */

var navhidedelay=1000  //disappear speed (in miliseconds)
var ie4=document.all
var ns6=document.getElementById&&!document.all
var topOffset = 23
var leftOffset = 0


if (ie4||ns6)
document.write('<div id="fixednavdiv" class="header_bg_popup" style="visibility:hidden" onMouseOver="javascript:clearhideNav()" onMouseOut="javascript:delayhideNav()"></div>')

function getparentOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
	totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
	parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhidenav(obj, e, visible, hidden){
if (ie4||ns6)
	dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
	obj.visibility=visible
else if (e.type=="click")
	obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function GoGomenu(menucontents, obj, e){
var loadcontent = document.getElementById(menucontents).innerHTML
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
	clearhideNav()
	dropmenuobj=document.getElementById? document.getElementById("fixednavdiv") : fixednavdiv
	dropmenuobj.innerHTML=loadcontent
	showhidenav(dropmenuobj.style, e, "visible", "hidden")
	dropmenuobj.style.left=getparentOffset(obj, "left")+leftOffset+"px"
	dropmenuobj.style.top=getparentOffset(obj, "top")+topOffset+"px"
}

function hideNav(e){
if (typeof dropmenuobj!="undefined"){
	if (ie4||ns6)
		dropmenuobj.style.visibility="hidden"
	}
}

function delayhideNav(){
if (ie4||ns6)
	delayhide=setTimeout("hideNav()",navhidedelay)
}

function clearhideNav(){
if (typeof delayhide!="undefined")
	clearTimeout(delayhide)
}



	/* =============================================================================
	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:	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];
			}

			switch(formElement.type)
			{
				case 'undefined': 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:	clearForm(formElement)
		Purpose:	Clears all the form element types
		Parameters:	formElement - the form object
		Returns:	-
		Calling:	-
		============================================================================= */
	function clearRadioGroup(){
		var objRadioGroup;
		for (var i=0;i<arguments.length;i++) {
			objRadioGroup = eval('document.'+arguments[i]);
			for (var j=0;j<objRadioGroup.length;j++) {
				objRadioGroup[j].checked = false;
			}
		}
	}


	
	
	/* =============================================================================
	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 appears to be 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 appears to be invalid.\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 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 dateonly(daObject){
	daObject.value=daObject.value.replace(/[^0-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=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.display = 'none'){
				strId.style.display = 'block';
			}
			
		}
	}





	/* =============================================================================
	Function:	hide(strId)
	Purpose:	Displays the div as passed.
	Parameters:	-
	Returns:	-
	Calling:	
	============================================================================= */
	function hide(strId) {
		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.display = 'block'){
				strId.style.display = 'none';
			}
		}
	}



/**
 * 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:	validate()
	Purpose:	
	Parameters:	-
	Returns:	
	Calling:	
	============================================================================= */


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 sessiontimer_check(){
	//check the session timer
}


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)) {

			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 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)) {
			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
					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
				}
				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'
		document.getElementById(firstOne).focus()		
		return false
	} else {
		document.getElementById('div_form_error_msgs').style.display = 'none'
		postForm(whichform)
	}
}



function addjob(job_num,da_div){
	
	if (job_num != ''){
		var p = "job_num="+job_num+'&action=add'
		ajaxpack.postAjaxRequest("/_include/mem_add_job.asp", p, addjobAJAX, "text/xml", da_div)
	}
	
}


function removejob(job_num,da_div){
	if (job_num != ''){
		var p = 'job_num='+job_num+'&action=delete'
		ajaxpack.postAjaxRequest("/_include/mem_add_job.asp", p, addjobAJAX, "text/xml", da_div)
	}
}

function addjobAJAX(da_div){
	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 != ""){
				xmlDoc=loadXMLString(strResponse)
				if(document.getElementById(da_div)){
					tmpStr = ''
					show(document.getElementById(da_div))
					
					x=xmlDoc.getElementsByTagName('JOB_DETAILS')
					for (i=0;i<x.length;i++){
						if(fromXML(x[i].getElementsByTagName('JOB_TITLE')[0].childNodes[0].nodeValue) == 'You have no saved jobs at this time'){
							tmpStr = '<div class=\"my_jobs_list\"><div style="margin-top:12px;margin-bottom:12px; font-size:12px">' + fromXML(x[i].getElementsByTagName('JOB_TITLE')[0].childNodes[0].nodeValue) + '</div></div>'
						}else{
							tmpStr = tmpStr + '<div class=\"my_jobs_list\">'
							tmpStr = tmpStr + '<a href=\"javascript:viewjob(\'' + fromXML(x[i].getElementsByTagName('JOB_NUMBER')[0].childNodes[0].nodeValue) + '\')" style=\"display:block\">' + fromXML(x[i].getElementsByTagName('JOB_TITLE')[0].childNodes[0].nodeValue) + '</a>'
							tmpStr = tmpStr + '<div class=\"comment\" style="margin:0px; border-bottom: dotted 1px #9DA0C4; padding-bottom:2px;"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>'
							tmpStr = tmpStr + '<td>' + x[i].getElementsByTagName('INDUSTRY')[0].childNodes[0].nodeValue + '</td>'
							tmpStr = tmpStr + '<td align="right"><span class=\"my_jobs_list_date\" style=" display:inline; float:right; clear:none; width:48px;">' + x[i].getElementsByTagName('CLOSING_DATE')[0].childNodes[0].nodeValue + '</span><span style="float:right; clear:none;">Closing: </span> </td>'
							tmpStr = tmpStr + '</tr></table></div></div>'
						}
					}
					document.getElementById(da_div).innerHTML = tmpStr
					
					toggle_view('href_addjob','href_removejob')
					
				}
			}
		}
	}
}



function checkUsername(da_ele,da_div){
	if(da_ele.value == ''){
		show(document.getElementById('div_form_error_msgs'))
		document.getElementById(da_div).innerHTML = ' Please enter a Username.'
		document.getElementById('inputCheck').value = '1'
		toggle_label('label_'+da_ele.id,'redLabel')
		
	}else if(isNumLetter(da_ele) != ''){
		show(document.getElementById('div_form_error_msgs'))
		document.getElementById(da_div).innerHTML = ' Only use numbers or letters please.'
		document.getElementById('inputCheck').value = '1'
		toggle_label('label_'+da_ele.id,'redLabel')
		
	}else{
		var p = "username="+da_ele.value+"&action=add"
		ajaxpack.postAjaxRequest("/_include/ajax_check_username.asp", p, processAJAXcheck_username, "text/xml", da_div)
	}
}


function checkUsernameOptional(da_ele,da_div){
	if(da_ele.value == ''){
		hide(document.getElementById('div_form_error_msgs'))
		document.getElementById(da_div).innerHTML = ''
		document.getElementById('inputCheck').value = '0'
		toggle_label('label_'+da_ele.id,'redLabel')
		
	}else if(isNumLetter(da_ele) != ''){
		show(document.getElementById('div_form_error_msgs'))
		document.getElementById(da_div).innerHTML = ' Only use numbers or letters please.'
		document.getElementById('inputCheck').value = '1'
		toggle_label('label_'+da_ele.id,'redLabel')
		
	}else{
		var p = "username="+da_ele.value+"&action=add"
		ajaxpack.postAjaxRequest("/_include/ajax_check_username.asp", p, processAJAXcheck_username, "text/xml", da_div)
	}
}

function editUsername(da_ele,da_div){
	if(da_ele.value == ''){
		show(document.getElementById('div_form_error_msgs'))
		document.getElementById(da_div).innerHTML = ' Please enter a Username.'
		document.getElementById('inputCheck').value = '1'
		toggle_label('label_'+da_ele.id,'redLabel')
		
	}else if(isNumLetter(da_ele) != ''){
		show(document.getElementById('div_form_error_msgs'))
		document.getElementById(da_div).innerHTML = ' Only use numbers or letters please.'
		document.getElementById('inputCheck').value = '1'
		toggle_label('label_'+da_ele.id,'redLabel')
		
	}else{
		var p = "username="+da_ele.value+"&action=edit&id="+document.getElementById('ID').value
		ajaxpack.postAjaxRequest("/_include/ajax_check_username.asp", p, processAJAXcheck_username, "text/xml", da_div)
	}
}

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, "text/plain", 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 processAJAXupdate(da_div){
	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 != ""){
				if(document.getElementById(da_div)){
					show(document.getElementById(da_div))
					document.getElementById(da_div).innerHTML = strResponse
				}
			}
		}
	}
}

function fromXML(davalue){
	var tmpStr
	tmpStr = davalue.replace(/chr{/g, '&#')
	tmpStr = tmpStr.replace(/}chr/g, ';')
	return tmpStr
}


function processAJAXcheck_username(da_div){
	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
			//alert(strResponse)
			if (strResponse != ""){
				xmlDoc=loadXMLString(strResponse)
				x=xmlDoc.getElementsByTagName('USERNAME_CHECK')
				for (i=0;i<x.length;i++){
					if (x[i].getElementsByTagName('U_STATUS')[0].childNodes[0].nodeValue == 'Used') {
						show(document.getElementById('div_form_error_msgs'))
						document.getElementById(da_div).innerHTML = 'That Username has been used.'
						document.getElementById('inputCheck').value = '1'
						document.getElementById('WEB_LOGIN').select()
					}else{
						document.getElementById(da_div).innerHTML = ''
						hide(document.getElementById('div_form_error_msgs'))
						document.getElementById('inputCheck').value = '0'
						document.getElementById(da_div).innerHTML = ''
					}
				}
			}
/*

			var strResponse = postAjax.responseText
			if (strResponse != 'none'){
				toggle_label('label_WEB_LOGIN','redLabel')
				show(document.getElementById('div_form_error_msgs'))
				document.getElementById(da_div).innerHTML = strResponse
				document.getElementById('inputCheck').value = '1'
				document.getElementById('WEB_LOGIN').select()

			} else {
				toggle_label('label_WEB_LOGIN','none')
				document.getElementById(da_div).innerHTML = ''
				hide(document.getElementById('div_form_error_msgs'))
				document.getElementById('inputCheck').value = '0'
				document.getElementById(da_div).innerHTML = ''
				document.getElementById('PASSWORD').focus()
			}
*/
		}
	}
}



function loadXMLString(txt)
{
try //Internet Explorer
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
  xmlDoc.async="false"
  xmlDoc.loadXML(txt)
  return xmlDoc
  }
catch(e)
  {
  try //Firefox, Mozilla, Opera, etc.
    {
    parser=new DOMParser()
    xmlDoc=parser.parseFromString(txt,"text/xml")
    return xmlDoc
    }
  catch(e) {alert(e.message)}
  }
return null
}
// done hiding -->
