<!--
// filename: clearview-zap_check.js -->

		function checkOnSubmit(contact) {
			
			for (i=0; i<contact.length; i++)
			{
				contact[i].style.backgroundColor = "";
			}			

			if (contact.CFirstName.value == "") {
				alert("You must enter your first name to continue.");
				contact.CFirstName.focus();
				contact.CFirstName.style.backgroundColor ="red";			
				return false;
			}	
		
			else if (contact.CLastName.value == "") {
				alert("You must enter your last name to continue.");
				contact.CLastName.focus();
				contact.CLastName.style.backgroundColor ="red";
				return false;
			}	
		
			else if (contact.CZip.value == "") {
				alert("You must enter your zip code to continue.");
				contact.CZip.focus();
				contact.CZip.style.backgroundColor ="red";
				return false;
			}
		
			else if(contact.CZip.value.length > 0){
				checkZipType(contact.CZip,"");
				//Check for Canadian Zip Code
				if(zipType == "canada")
				{
		
						if (contact.CZip.value.length > 4 && contact.CZip.value.length < 7) { 
							alert("The ZIP Code should be 6 alphanumerics value.");
							contact.CZip.focus();
							contact.CZip.style.backgroundColor ="red";
							return false;
							}
						// if they put in even one number, assume they meant to put it in, but did it incorrectly.
						if (contact.CZip.value.length > 0 && contact.CZip.value.length < 7) {
							alert("The ZIP Code needs to have 6 alphanumerics value.");
							contact.CZip.focus();
							contact.CZip.style.backgroundColor ="red";
							return false;
							}						
				}
				
				//Check for US Zip Code
				else if(zipType == "us")
				{				
						if (contact.CZip.value.length > 6 && contact.CZip.value.length < 10) { 
								alert("The ZIP Code should be numbers, or 5 numbers + 4.");
								contact.CZip.focus();
								contact.CZip.style.backgroundColor ="red";
								return false;
								}
			
						if (contact.CZip.value.length < 5) {
							alert("The ZIP Code needs to have 5 numbers.");
							contact.CZip.focus();
							contact.CZip.style.backgroundColor ="red";
							return false;
							}
						
						// If length is exactly 5 numbers for zip, trim the length to 5, so no dash with it
						if (contact.CZip.value.length == 6)
						{
							str1= contact.CZip.value;
							str2 = str1.slice(0, 5);
							contact.CZip.value = str2;
						}
					
				}	
			}	

			if(contact.CState.value == 0) {
				alert("You must enter your state to continue.");
				contact.CState.focus();			
				return false;
			}	
			else if (contact.DisciplineID.value == "") {
				alert("You must select a Discipline to continue.");
				contact.DisciplineID.focus();
				return false;
			}				
				
			
			// validate email string to have the @, plus the period
			var TestVar = contact.CEmail.value;			
			if(TestVar !="")
			{
				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");
					contact.CEmail.focus();
					contact.CEmail.style.backgroundColor ="red";
					return false;
				}
			}
			
			
			if (contact.CPhone.value == "") {
				alert("You must enter your telephone number to continue.");
				contact.CPhone.focus();
				contact.CPhone.style.backgroundColor ="red";
				
				return false;
			}
		
		}
		
		function checkChecked(sTemp) {
		bChecked = false;
		
		for (t=0;t<=sTemp.length-1;t++) {
			if (sTemp[t].checked==true) { bChecked=true; }
		}
		return bChecked;
		}
		

		
		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;
			}
		
		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;
		}// end of phone, zip, ssn checking
		
		
		
		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;
		}

// -->
