// JavaScript Document

function validate_quickcontact(thisform)
{
	
	with (thisform)
	{
		
	
	if (emptyvalidation(fname,"Woops! You Forgot to Fill in Your First Name")==false ){ 
			fname.focus();
			return false;	
			}
	if (fname.value =='First Name'){ 
			alert("Woops! You Forgot to Fill in Your First Name");
			fname.focus();
			return false;	
			}
	if (emptyvalidation(lname,"Woops! You Forgot to Fill in Your Last Name")==false ){ 
			lname.focus();
			return false;	
			}
	if (lname.value =='Last Name'){ 
			alert("Woops! You Forgot to Fill in Your Last Name");
			lname.focus();
			return false;	
			}
	if (emptyvalidation(address,"Woops! You Forgot to Fill in Your Address")==false ){ 
			address.focus();
			return false;	
			}
	if(address.value == 'Address'){
			alert("Woops! You Forgot to Fill in Your Address");
			address.focus();
			return false;	
			}
	if (emptyvalidation(city,"Woops! You Forgot to Fill in Your City")==false ){ 
			city.focus();
			return false;	
			}
	if (city.value =='City'){ 
			alert("Woops! You Forgot to Fill in Your City");
			city.focus();
			return false;	
			}
	var bstate= thisform.state.value;
	if (bstate=='0'){
			alert("Woops! You Forgot to Fill in State");
			state.focus();
			return false;	
			}
	if (emptyvalidation(zip,"Woops! You Forgot to Fill Zip code")==false ){ 
			zip.focus();
			return false;	
			}
	if (zip.value =='Zip'){ 
			alert("Woops! You Forgot to Fill Zip code");
			zip.focus();
			return false;	
			}
		
		if (emptyvalidation(email,"Woops! You Forgot to Fill in Your Email Address")==false){ 
			email.focus();
			return false;	
			}
		if(email.value == 'E-mail'){
			alert("Woops! You Forgot to Fill in Your Email Address");
			email.focus();
			return false;	
			}
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   		var address1 = thisform.email.value;
  
		if(reg.test(address1) == false){  
			  alert('Woops! You have Entered an Invalid Email Address');
			  email.focus();
			  email.select();
			  return false;
				}
		if ((emptyvalidation(homephone,"Woops! You Forgot to Fill in Phone Number")==false) || (emptyvalidation(homephone1,"Woops! You Forgot to Fill in Phone Number")==false) || emptyvalidation(homephone2,"Woops! You Forgot to Fill in Phone Number")==false){ 
			homephone.focus();
			return false;	
			}else
		if(IsNumeric(homephone.value)==false || IsNumeric(homephone1.value)==false || IsNumeric(homephone2.value)==false)
		{
			alert('Please Enter a Valid Phone Number');
			homephone.focus();
			homephone.select();
			return false;	
			}
		if(digitcountValidation(homephone.value,3,"Please Enter a Valid Phone Number")==false){
				homephone.focus();
				return false;					
				}
		if(digitcountValidation(homephone1.value,3,"Please Enter a Valid Phone Number")==false){
				homephone1.focus();
				return false;					
				}
		if(digitcountValidation(homephone2.value,4,"Please Enter a Valid Phone Number")==false){
				homephone2.focus();
				return false;					
				}
		if (mobile.value =='Mobile'){ 
			alert("Woops! You Forgot to Fill Your Mobile Number");
			mobile.focus();
			return false;	
			}
		
		
		if (emptyvalidation(mobile,"Woops! You Forgot to Fill Your Mobile Number")==false){ 
			mobile.focus();
			return false;	
			}
		if (IsNumeric(mobile.value)==false ){ 
			alert('Please Enter a Valid Mobile Number');
			mobile.focus();
			return false;	
			}
			if (ssn.value =='Work'){ 
			ssn.value='';
			}
		
	}
	thisform.submit();
}


function validate_signup(thisform)
{
	
	
	with (thisform)
	{
		
	
	if (emptyvalidation(fname,"Woops! You Forgot to Fill in Your First Name")==false ){ 
			fname.focus();
			return false;	
			}
	
	if (emptyvalidation(lname,"Woops! You Forgot to Fill in Your Last Name")==false ){ 
			lname.focus();
			return false;	
			}
	/*if (emptyvalidation(title,"Woops! You Forgot to Fill Title")==false ){ 
			title.focus();
			return false;	
			}*/
	if (emptyvalidation(email,"Woops! You Forgot to Fill in Your Email Address")==false){ 
			email.focus();
			return false;	
			}
	
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   		var address1 = thisform.email.value;
  
		if(reg.test(address1) == false) 
		{ 
		  alert('Woops! You have Entered an Invalid Email Address');
		  email.focus();
		  email.select();
		  return false;
	   	}		
	
	/*if ((emptyvalidation(ssn,"Woops! You Forgot to Fill Social Security Number")==false) || (emptyvalidation(ssn1,"Woops! You Forgot to Fill Social Security Number")==false) || emptyvalidation(ssn2,"Woops! You Forgot to Fill Social Security Number")==false){ 
			ssn.focus();
			return false;	
			}else
		if(IsNumeric(ssn.value)==false || IsNumeric(ssn1.value)==false || IsNumeric(ssn2.value)==false)
		{
			alert('Please Enter a Valid Social Security Number');
			ssn.focus();
			ssn.select();
			return false;	
		}*/
	
	if ((emptyvalidation(phone,"Woops! You Forgot to Fill in Phone Number")==false) || (emptyvalidation(phone1,"Woops! You Forgot to Fill in Phone Number")==false) || emptyvalidation(phone2,"Woops! You Forgot to Fill in Phone Number")==false){ 
			phone.focus();
			return false;	
			}else
		if(IsNumeric(phone.value)==false || IsNumeric(phone1.value)==false || IsNumeric(phone2.value)==false)
		{
			alert('Please Enter a Valid Phone Number');
			phone.focus();
			phone.select();
			return false;	
		}
	if(digitcountValidation(phone.value,3,"Please Enter a Valid Phone Number")==false){
			phone.focus();
			return false;					
			}
	if(digitcountValidation(phone1.value,3,"Please Enter a Valid Phone Number")==false){
			phone1.focus();
			return false;					
			}
	if(digitcountValidation(phone2.value,4,"Please Enter a Valid Phone Number")==false){
			phone2.focus();
			return false;					
			}
	/*if ((emptyvalidation(wphone,"Woops! You Forgot to Fill in Work Phone Number")==false) || (emptyvalidation(wphone1,"Woops! You Forgot to Fill in Work Phone Number")==false) || emptyvalidation(wphone2,"Woops! You Forgot to Fill in Work Phone Number")==false){ 
			wphone.focus();
			return false;	
			}else
		if(IsNumeric(wphone.value)==false || IsNumeric(wphone1.value)==false || IsNumeric(wphone2.value)==false)
		{
			alert('Please Enter a Valid Work Phone Number');
			wphone.focus();
			wphone.select();
			return false;	
		}*/
	
	var varmonth= thisform.bmonth.value;
	var varday= thisform.bday.value;
	var varyear= thisform.byear.value;
	
	if (varmonth == '0'){ 
			alert("Woops! You Forgot to Select Date of Birth");
			bmonth.focus();
			return false;	
			}
	if (varday == '0'){ 
			alert("Woops! You Forgot to Select Date of Birth");
			bday.focus();
			return false;	
			}
	if (varyear == '0'){ 
			alert("Woops! You Forgot to Select Date of Birth");
			byear.focus();
			return false;	
			}
	if (emptyvalidation(street1,"Woops! You Forgot to Fill in Your Street Address")==false){ 
			street1.focus();
			return false;	
			}
	if (emptyvalidation(city,"Woops! You Forgot to Fill in Your City")==false){ 
			city.focus();
			return false;	
			}
	var states= thisform.state.value;
	
	if (states == '0'){ 
			alert("Woops! You Forgot to Select a State");
			state.focus();
			return false;	
			}
	}
	thisform.submit();
}


function digitcountValidation(elmnt,num,alerttxt){
	if(elmnt.length < num){
		alert(alerttxt);
		return false;
		}
		else return true;
	}

function IsNumeric(strString)
{
   var strValidChars = "0123456789.()-";
   var strChar;
   var blnResult = true;
   //if ((strString.length == 0) || (strString.length > 16) )  return false;

   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1) 
	  blnResult = false;
      }
   return blnResult;
}

function emptyvalidation(entered, alertbox)
{
	with (entered)
	{
		while (value.charAt(0) == ' ')
			value = value.substring(1);
		while (value.charAt(value.length - 1) == ' ')
			value = value.substring(0, value.length - 1);
		if (value==null || value=="")
		{
			if (alertbox!="") alert(alertbox);
			return false;
		}
		else return true;
	}
}

