<!--
// filename: clearview-online_form-functions.js -->

	// this compares stored table data, to any changes a person types or chooses, and sets textbox: wasitchanged with value, so that Elec Sig can be reset (if applicable)
	original_valuesform = new Object();
	pForm = document.applicationform;
	
					if(typeof(pForm.FName) == 'object')
					{
						original_valuesform.FName = pForm.FName.value;
					}					
				
					if(typeof(pForm.LName) == 'object')
					{
						original_valuesform.LName = pForm.LName.value;
					}					
				
					if(typeof(pForm.millenia1537) == 'object')
					{
						original_valuesform.millenia1537 = pForm.millenia1537.value;
					}					
				
					if(typeof(pForm.millenia2017) == 'object')
					{
						original_valuesform.millenia2017 = pForm.millenia2017.value;
					}					
				
					original_valuesform.Spec = getCheckboxValueCheck(pForm.Spec);
				
					if(typeof(pForm.Cert) == 'object')
					{
						original_valuesform.Cert = pForm.Cert.value;
					}					
				
					if(typeof(pForm.millenia1534) == 'object')
					{
						original_valuesform.millenia1534 = pForm.millenia1534.value;
					}					
				
					if(typeof(pForm.millenia1536) == 'object')
					{
						original_valuesform.millenia1536 = pForm.millenia1536.value;
					}					
				
					if(typeof(pForm.Email) == 'object')
					{
						original_valuesform.Email = pForm.Email.value;
					}					
				
					if(typeof(pForm.Zip) == 'object')
					{
						original_valuesform.Zip = pForm.Zip.value;
					}					
				
			//Only Valid for Online Application that have left Navigation and right content
			if(typeof(document.all.load) == 'object' && typeof(document.all.right) == 'object')
			{
				if(typeof(document.all.load.style) == 'object' && typeof(document.all.right.style) == 'object')
				{
					document.all.load.style.display = "none";
					document.all.right.style.display = "inline";				
				}
			}
		
	var zipType = "us";
	function getCheckboxValueCheck(object)
	{
		var result = "";
		var index = 0;
		
		for (index = 0; index < object.length; index++)
		{
			if (object[index].checked)
			{
				result += object[index].value + ",";
			}
		}
		
		result = result.substr(0, result.length - 1);
		return result;
	}
	
	function getRadioValueCheck(object)
	{
		var index = 0;
		var result = "";
		
		for (index = 0; index < object.length; index++)
		{
			if (object[index].checked)
			{
				result = index;
				break;
			}
		}
	
		return result;
	}
		
	var dtCh= "/";
	var minYear=1900;
	var maxYear=2100;
	
	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 strMonth=dtStr.substring(0,pos1)
		var strDay=dtStr.substring(pos1+1,pos2)
		var strYear=dtStr.substring(pos2+1)
	
		//var invalChar = "01234567890";
		strYr=strYear
		//if (invalChar.indexOf(dtStr) == -1){
		//	alert('Please enter a valid date.  If trying to enter current or present, enter todays date') 
		//			alert(dt.value)
					
		//			return false;}
		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('Either enter a properly formated date: mm/dd/yyyy, or the term "Present" to indicate a present or current date.');
			return false;
		}
		if (strMonth.length<1 || month<1 || month>12){
			alert("Please enter a valid month")
			return false
		}
		if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
			alert("Please enter a valid day")
			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
		}
		if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
			alert("Please enter a valid date")
			return false
		}
		
		return true
	}
	
	function checkZipType(field,KeyTyped)
	{
		var Val = field.value + KeyTyped;
		if(Val != "")
		{
			if(IsNumeric(Val.substring(0,5)))
			{
				zipType = "us";
			}
			else
			{
				zipType = "canada";
			}
		}
	}		
	
	// 11-9-2006 Have zip, phone, and ssn checking available on all form pages.  this is done to remove duplicates during loop
	// FORM MASKING
	// MG - 05/05/2006
	// Call from form using: onKeyPress="return autoMask(this,event,'type');"
	
	function autoMask(field, event, type){
		var KeyTyped = String.fromCharCode(getKeyCode(event));

		//Check for zipcode type
		checkZipType(field,KeyTyped);
	
		if(getKeyCode(event) == 0)//added by Gabe Chino to skip the tab in firefox
			return;
		
		var targ = getTarget(event);
		var keyCount = targ.value.length;				

		// Determine type of input and setting mask pattern				
		switch (type){
			case "phone":
				sMask = "###-###-#####";
				break;
			case "date":
				sMask = "##/##/####";
				break;
			case "ssan":
				sMask = "###-##-####";
				break;
			case "zip":
				if(zipType == "us")
				{
					sMask = "#####-#####";
				}
				else if(zipType == "canada")
				{
					sMask = "### ###";
				}
				break;
		}
									
		// Allows use of backspace and delete key once user has reached masks length
		// Checks for a valid date
		// disabled - Auto Tabs to next input
					
		if (getKeyCode(event) == 8 || getKeyCode(event)==127)
		{
			return true;
		}
		if(keyCount + 1 == sMask.length){
			if (type == "date"){
				if (chkdate(field) == false){
					alert("That date is invalid. Please try again.");
					return false;
				}
			}
		}	
				
		// Compares key typed to mask and allows entry if not equal to mask placeholder
		if ((sMask.charAt(keyCount+1) != '#') && (sMask.charAt(keyCount+1) != '@' )){	
						
			if (type == 'phone')
			{								
				if (keyCount > '11') // For Phone Field, don't let user type more than 12 total characters
				{								
				return false;
				}
			}
	
			if (type == 'ssan')
			{
				if (keyCount > '10') // For SSN Field, don't let user type more than 11 total characters
				{
				return false;
				}
			}
			
			if (type == 'zip')
			{
			
				if(zipType == "us")
				{
					// this checks for the character before dash is entered, and prevents it.
					if (sMask.charAt(keyCount-1) && (!isNumber(KeyTyped)))
					{
						return false;
					}			
	
					if (keyCount > '9') // For Zip Code Field, don't let user type more than 10 total characters, including mask when applicable
					{
					return false;
					}				
				}
				
				if(zipType == "canada")
				{	
					if (keyCount > '6') // For Zip Code Field, don't let user type more than 7 total characters, including mask when applicable
					{
						return false;
					}			
				}
			}
			field.value = field.value + KeyTyped + sMask.charAt(keyCount+1);					
			
			return false;
		}												
								
//		if (sMask.charAt(keyCount) == KeyTyped){
//			return true;
//		}
							
					
		if ((sMask.charAt(keyCount) == '#') || (sMask.charAt(keyCount) == '-') || (sMask.charAt(keyCount) == ' '))
		{
		
			// adds the dash to phone number being inserted, if erased by user
			if (type == 'phone')
			{
				if ((keyCount == '3') || (keyCount == '7'))
				{
					if (isNumber(KeyTyped))
					{
						field.value = field.value + '-' + KeyTyped;
					}
					else
					{
						field.value = field.value + '-';
					}
				}
			}
					
			// adds the dash to ssn number being inserted, if erased by user
			if (type == 'ssan')
			{
				if ((keyCount == '3') || (keyCount == '6'))
				{
					if (isNumber(KeyTyped))
					{
						field.value = field.value + '-' + KeyTyped;
					}
					else
					{
						field.value = field.value + '-';
					}
				}
			}
					
			// adds the dash to US zip code being inserted, if erased by user
			// adds the space to Canadian zip code, if erased by user
			if (type == 'zip')
			{			

				if (keyCount == '3' && zipType == "canada")
				{
					if (!IsNumeric(field.value) && isAlphanumeric(field.value))
					{
						field.value = field.value + ' ' + KeyTyped;
					}
					else
					{
						field.value = field.value + ' ';
					}			
				}
				else if (keyCount == '5' && zipType == "us")
				{				
					if (IsNumeric(field.value) && isNumber(KeyTyped))
					{
						field.value = field.value + '-' + KeyTyped;
					}
					else
					{
						field.value = field.value + '-';
					}
				}
			}		
		}

		//Added by Sylvia
		//Check for Zip US and Canadian.
		if ((sMask.charAt(keyCount) == '#') && type =='zip'){		
			//US
			if(keyCount >= '4')	
			{
						
				if(IsNumeric(field.value.substring(0,5)))
				{
					if(isNumber(KeyTyped))
					{
						return true;
					}	
					else
					{
						return false;
					}
					if (keyCount > '9') // For Zip Code Field, don't let user type more than 10 total characters, including mask when applicable
					{
						return false;
					}		
				}		
			}
			
			//Canada
			if(keyCount >= '3')	
			{
				if(isAlphanumeric(field.value.substring(0,3)))
				{
					if (keyCount > '6') // For Zip Code Field, don't let user type more than 7 total characters, including mask when applicable
					{
						return false;
					}
										
				}
			}
			if(isAlphanumeric(KeyTyped))
			{
				return true;
			}
			else
			{
				return false;
			}			
					
			return true;	
		} 			
		
		// Check Number For all others but not Zipcode							
		if ((sMask.charAt(keyCount) == '#') && type !='zip'){													
			if(isNumber(KeyTyped))
			{
				return true;
			}			
		} 

	
		if (KeyTyped.charCodeAt(0) < 32){
			return true;
		}
						
		return false;
	}//close AutoMask function
					
	function getTarget(e){
		if (e.srcElement){
			return e.srcElement;
		}
		if (e.target){
			return e.target;
		}
	}
					
	function getKeyCode(e) {
		if (e.srcElement){ //IE
			return e.keyCode
		}
		else if (e.which){//NETSCAPE
			return e.which
		}
		else if (e.target){//FIREFOX
		   return e.which
		}
	}
					
	function isNumber(n){
		var sNumbers = "01234567890";
		if (sNumbers.indexOf(n) == -1){
			alert('Enter numbers only.');
			return false;
		}
		
		else return true;
	}
					
	//AutoTab Function
	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
					
	function autoTab(input, e){
		
		var keyCode = (isNN) ? e.which : e.keyCode; 
		var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	
		if(!containsElement(filter,keyCode)){
			input.form[(getIndex(input)+1) % input.form.length].focus();
		}
					
		function containsElement(arr, ele) {
			var found = false, index = 0;
			
			while(!found && index < arr.length)
		
			if(arr[index] == ele){
				found = true;
			}
			else
				index++;
			
			return found;
		}
					
		function getIndex(input){
			var index = -1, i = 0, found = false;
		
			while (i < input.form.length && index == -1)
				if (input.form[i] == input){
					index = i;
				}
				else 
					i++;
			
			return index;
		}
		
		return true;
	}//close AutoTab function		
			
	function checkOnSubmit(applicationform) {		
		// this compares stored table data, to any changes a person types or chooses, and sets textbox: wasitchanged with value, so that Elec Sig can be reset (if applicable)
		var original_valuenow = "";
		var current_valuenow = "";
		var index = 0;
					
		var ithasbeenchanged = 'false';
		
		
			if(typeof(pForm.FName) == 'object')
			{				
				
					original_valuenow = original_valuesform.FName;
					
								if(typeof(pForm.FName).style == 'object'){
									pForm.FName.style.backgroundColor ="";
								}						
								current_valuenow = pForm.FName.value;
						
				
				if (current_valuenow != original_valuenow)
				{
					ithasbeenchanged = 'true';
				}
			}
		
			if(typeof(pForm.LName) == 'object')
			{				
				
					original_valuenow = original_valuesform.LName;
					
								if(typeof(pForm.LName).style == 'object'){
									pForm.LName.style.backgroundColor ="";
								}						
								current_valuenow = pForm.LName.value;
						
				
				if (current_valuenow != original_valuenow)
				{
					ithasbeenchanged = 'true';
				}
			}
		
			if(typeof(pForm.millenia1537) == 'object')
			{				
				
					original_valuenow = original_valuesform.millenia1537;
					
								if(typeof(pForm.millenia1537).style == 'object'){
									pForm.millenia1537.style.backgroundColor ="";
								}						
								current_valuenow = pForm.millenia1537.value;
						
				
				if (current_valuenow != original_valuenow)
				{
					ithasbeenchanged = 'true';
				}
			}
		
			if(typeof(pForm.millenia2017) == 'object')
			{				
				
					original_valuenow = original_valuesform.millenia2017;
					
								if(typeof(pForm.millenia2017).style == 'object'){
									pForm.millenia2017.style.backgroundColor ="";
								}						
								current_valuenow = pForm.millenia2017.value;
						
				
				if (current_valuenow != original_valuenow)
				{
					ithasbeenchanged = 'true';
				}
			}
		
			if(typeof(pForm.Spec) == 'object')
			{				
				
					original_valuenow = original_valuesform.Spec;
					
							current_valuenow = getCheckboxValueCheck(pForm.Spec);
						
				
				if (current_valuenow != original_valuenow)
				{
					ithasbeenchanged = 'true';
				}
			}
		
			if(typeof(pForm.Cert) == 'object')
			{				
				
					original_valuenow = original_valuesform.Cert;
					
								if(typeof(pForm.Cert).style == 'object'){
									pForm.Cert.style.backgroundColor ="";
								}						
								current_valuenow = pForm.Cert.value;
						
				
				if (current_valuenow != original_valuenow)
				{
					ithasbeenchanged = 'true';
				}
			}
		
			if(typeof(pForm.millenia1534) == 'object')
			{				
				
					original_valuenow = original_valuesform.millenia1534;
					
								if(typeof(pForm.millenia1534).style == 'object'){
									pForm.millenia1534.style.backgroundColor ="";
								}						
								current_valuenow = pForm.millenia1534.value;
						
				
				if (current_valuenow != original_valuenow)
				{
					ithasbeenchanged = 'true';
				}
			}
		
			if(typeof(pForm.millenia1536) == 'object')
			{				
				
					original_valuenow = original_valuesform.millenia1536;
					
								if(typeof(pForm.millenia1536).style == 'object'){
									pForm.millenia1536.style.backgroundColor ="";
								}						
								current_valuenow = pForm.millenia1536.value;
						
				
				if (current_valuenow != original_valuenow)
				{
					ithasbeenchanged = 'true';
				}
			}
		
			if(typeof(pForm.Email) == 'object')
			{				
				
					original_valuenow = original_valuesform.Email;
					
								if(typeof(pForm.Email).style == 'object'){
									pForm.Email.style.backgroundColor ="";
								}						
								current_valuenow = pForm.Email.value;
						
				
				if (current_valuenow != original_valuenow)
				{
					ithasbeenchanged = 'true';
				}
			}
		
			if(typeof(pForm.Zip) == 'object')
			{				
				
					original_valuenow = original_valuesform.Zip;
					
								if(typeof(pForm.Zip).style == 'object'){
									pForm.Zip.style.backgroundColor ="";
								}						
								current_valuenow = pForm.Zip.value;
						
				
				if (current_valuenow != original_valuenow)
				{
					ithasbeenchanged = 'true';
				}
			}
			
		
		if (ithasbeenchanged == 'true')
		{					
			document.getElementById('wasitchanged').value= 'true';
		}

		// The job here is to alert users to required fields, and makes sure something is typed or chosen.
		
			if( typeof(applicationform.FName) == "object")
			{		
			
													
									if (applicationform.FName.value == "") {
										var ok=false;
										
										try{
											if(applicationform.FName.multiple)
											{
												for(multipleSelectIndex=0;multipleSelectIndex<applicationform.FName.length;multipleSelectIndex++)
												{
													if(applicationform.FName[multipleSelectIndex].selected)
													{
														ok = true;
														break
													}
												}
											}
										}
										catch(e)
										{}
							
										if(!ok){
											alert("Please enter an answer for the question \"First Name\".");
											document.applicationform.FName.focus();
											applicationform.FName.style.backgroundColor ="red";
											return false;
										}
									}
									
									
		}
		
			if( typeof(applicationform.LName) == "object")
			{		
			
													
									if (applicationform.LName.value == "") {
										var ok=false;
										
										try{
											if(applicationform.LName.multiple)
											{
												for(multipleSelectIndex=0;multipleSelectIndex<applicationform.LName.length;multipleSelectIndex++)
												{
													if(applicationform.LName[multipleSelectIndex].selected)
													{
														ok = true;
														break
													}
												}
											}
										}
										catch(e)
										{}
							
										if(!ok){
											alert("Please enter an answer for the question \"Last Name\".");
											document.applicationform.LName.focus();
											applicationform.LName.style.backgroundColor ="red";
											return false;
										}
									}
									
									
		}
		
			if( typeof(applicationform.millenia1537) == "object")
			{		
			
													
									if (applicationform.millenia1537.value == "") {
										var ok=false;
										
										try{
											if(applicationform.millenia1537.multiple)
											{
												for(multipleSelectIndex=0;multipleSelectIndex<applicationform.millenia1537.length;multipleSelectIndex++)
												{
													if(applicationform.millenia1537[multipleSelectIndex].selected)
													{
														ok = true;
														break
													}
												}
											}
										}
										catch(e)
										{}
							
										if(!ok){
											alert("Please enter an answer for the question \"Discipline\".");
											document.applicationform.millenia1537.focus();
											applicationform.millenia1537.style.backgroundColor ="red";
											return false;
										}
									}
									
									
		}
		
			if( typeof(applicationform.millenia2017) == "object")
			{		
			
													
									if (applicationform.millenia2017.value == "") {
										var ok=false;
										
										try{
											if(applicationform.millenia2017.multiple)
											{
												for(multipleSelectIndex=0;multipleSelectIndex<applicationform.millenia2017.length;multipleSelectIndex++)
												{
													if(applicationform.millenia2017[multipleSelectIndex].selected)
													{
														ok = true;
														break
													}
												}
											}
										}
										catch(e)
										{}
							
										if(!ok){
											alert("Please enter an answer for the question \"Years of Experience\".");
											document.applicationform.millenia2017.focus();
											applicationform.millenia2017.style.backgroundColor ="red";
											return false;
										}
									}
									
									
		}
		
			if( typeof(applicationform.Spec) == "object")
			{		
			
				 
							if(checkChecked(applicationform.Spec)==false) {
								alert("Please select an answer for the question \"Specialty(ies)\".");
								return false;
							}
						
		}
		
			if( typeof(applicationform.Cert) == "object")
			{		
			
				
								if (applicationform.Cert.value.length > 0 && applicationform.Cert.value.length < 12) {
									//alert("The phone number needs to have 10 numbers.");
									alert("The \"Cell Phone Number\" needs to have 10 numbers.");
									applicationform.Cert.focus();
									applicationform.Cert.style.backgroundColor ="red";
									return false;
									}
									
								if(applicationform.Cert.value == "") {
									//alert("Please enter your phone number.");
									alert("Please enter your \"Cell Phone Number\".");
									document.applicationform.Cert.focus();
									applicationform.Cert.style.backgroundColor ="red";
									return false;
								}									
							
						
		}
		
			if( typeof(applicationform.millenia1534) == "object")
			{		
			
				
						//NOT REQUIRED FIELD						
						
								if(IsNumeric(applicationform.millenia1534.value)==false) {
								alert("Your must enter a numeric answer for the question \"Professional Recruiter's Name\".");
								document.applicationform.millenia1534.focus();
								applicationform.millenia1534.style.backgroundColor ="red";
								return false;
								}
						
		}
		
			if( typeof(applicationform.millenia1536) == "object")
			{		
			
													
									if (applicationform.millenia1536.value == "") {
										var ok=false;
										
										try{
											if(applicationform.millenia1536.multiple)
											{
												for(multipleSelectIndex=0;multipleSelectIndex<applicationform.millenia1536.length;multipleSelectIndex++)
												{
													if(applicationform.millenia1536[multipleSelectIndex].selected)
													{
														ok = true;
														break
													}
												}
											}
										}
										catch(e)
										{}
							
										if(!ok){
											alert("Please enter an answer for the question \"Type of Opportunity\".");
											document.applicationform.millenia1536.focus();
											applicationform.millenia1536.style.backgroundColor ="red";
											return false;
										}
									}
									
									
		}
		
			if( typeof(applicationform.Email) == "object")
			{		
			
													
									if (applicationform.Email.value == "") {
										var ok=false;
										
										try{
											if(applicationform.Email.multiple)
											{
												for(multipleSelectIndex=0;multipleSelectIndex<applicationform.Email.length;multipleSelectIndex++)
												{
													if(applicationform.Email[multipleSelectIndex].selected)
													{
														ok = true;
														break
													}
												}
											}
										}
										catch(e)
										{}
							
										if(!ok){
											alert("Please enter an answer for the question \"Email Address\".");
											document.applicationform.Email.focus();
											applicationform.Email.style.backgroundColor ="red";
											return false;
										}
									}
									
									

											if(typeof(applicationform.ConfirmEmail) == "object")
											{
												if(applicationform.ConfirmEmail.value == "")
												{
													alert("Please enter an answer for the question \"Confirm Email Address\".");
													document.applicationform.ConfirmEmail.focus();
													applicationform.ConfirmEmail.style.backgroundColor ="red";
													return false;
													
												}
											}

									
		}
		
			if( typeof(applicationform.Zip) == "object")
			{		
			
					
					
								checkZipType(applicationform.Zip,"");
								//Check for Canadian Zip Code
								if(zipType == "canada")
								{
		
										if (applicationform.Zip.value.length > 4 && applicationform.Zip.value.length < 7) {
											//alert("The zip code should be 6 alphanumerics zip."); 
											alert("The \"Current Zip Code\" should be 6 alphanumerics value.");
											applicationform.Zip.focus();
											applicationform.Zip.style.backgroundColor ="red";
											return false;
											}
										// if they put in even one number, assume they meant to put it in, but did it incorrectly.
										if (applicationform.Zip.value.length > 0 && applicationform.Zip.value.length < 7) {
											//alert("The zip code needs to have 6 alphanumerics.");
											alert("The \"Current Zip Code\" needs to have 6 alphanumerics value.");
											applicationform.Zip.focus();
											applicationform.Zip.style.backgroundColor ="red";
											return false;
											}		
								
								}
								
								//Check for US Zip Code
								if(zipType == "us")
								{				
	
										if (applicationform.Zip.value.length > 6 && applicationform.Zip.value.length < 10) {
												//alert("The zip code should be 5 numbers zip, or 5 numbers zip + 4."); 
												alert("The \"Current Zip Code\" should be numbers, or 5 numbers + 4.");
												applicationform.Zip.focus();
												applicationform.Zip.style.backgroundColor ="red";
												return false;
												}
							
										if (applicationform.Zip.value.length < 5) {
											//alert("The zip code needs to have 5 numbers.");
											alert("The \"Current Zip Code\" needs to have 5 numbers.");
											applicationform.Zip.focus();
											applicationform.Zip.style.backgroundColor ="red";
											return false;
											}
										
										// If length is exactly 5 numbers for zip, trim the length to 5, so no dash with it
										if (applicationform.Zip.value.length == 6)
										{
											str1= applicationform.Zip.value;
											str2 = str1.slice(0, 5);
											applicationform.Zip.value = str2;
										}
									
								}
															
						
		}
		
	}
	
	
			// validate email string to have the @, plus .
			function checkEmail(elm) { 				
				var TestVar = elm.value;
				
				// If blank, let it pass.
				if (TestVar == ""){ 
					return true; 
				  } 
				
				var pattern = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/;
				var flag = pattern.test(TestVar);
				
				if(!flag)
				{
				alert ("Please enter a valid email address");
				elm.focus();		
				elm.style.backgroundColor ="red";					
				return false;
				}
				elm.style.backgroundColor ="";	
				return true;
			}
		
	
	function checkChecked(sTemp) {
		bChecked = false;
		//We also need to make sure that at least one of the checkboxes has a value
		for (t=0;t<=sTemp.length-1;t++) {
			if (sTemp[t].checked==true && sTemp[t].value != '') { bChecked=true; break;}
		}
		
		return bChecked;
	}
	
	function checkChecked2(sTemp) {
		bChecked = false;
		if (sTemp.checked==true) { bChecked=true; }
		return bChecked;
	}
	
	function IsNumeric(sText) {
	   var ValidChars = "0123456789.";
	   var IsNumber=true;
	   var Char;
	
	 
	   for (i = 0; i < sText.length && IsNumber == true; i++) 
	      { 
	      Char = sText.charAt(i); 
	      if (ValidChars.indexOf(Char) == -1) 
	         {
	         IsNumber = false;
	         }
	      }
	   return IsNumber;
	   
	   }

	function isAlphanumeric(alphane)
	{
		var numaric = alphane;

		for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		  else	{
			 alert('Enter Alphanumeric only.');				 
			 return false;
		  }
		}
	 	return true;
	}	   

// -->
