function validatemail()
{
	if((document.form.email.value=='')||(document.form.email.value=='Email Address'))
	{
		alert("Please enter your mail address");
		document.form.email.focus();
		return false;
	}
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    var address = document.form.email.value;
  
	if(reg.test(address) == false) 
	{ 
      alert('Woops! You have entered an invalid Email Address');
	  document.form.email.focus();
	  document.form.email.select();
      return false;
   }
   document.form.submit();
}
function validate_quickcontact(thisform)
{

	with (thisform)
	{
	//	if(fname.value=="Name")fname.value="";	
	if (emptyvalidation(q_name,"Woops! You Forgot to Fill in Your Name")==false) 
		{
		q_name.focus();
		return false;	
		}
		if (emptyvalidation(q_email,"Woops! You Forgot to Fill in Your Email Address")==false) 
		{
		q_email.focus();
		return false;	
		}	
  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = thisform.q_email.value;
  
	if(reg.test(address) == false) 
	{ 
      alert('Woops! You have Entered an Invalid Email Address');
	  q_email.focus();
	  q_email.select();
      return false;
   }
		if (emptyvalidation(q_phone,"Woops! You Forgot to Fill in Your Phone Number")==false) 
		{
		q_phone.focus();
		return false;	
		}
		
	var ph = thisform.q_phone.value;
		var res=IsPhoneNumber(ph);
		if(res==false)
		{
			//count.value=parseInt(count.value)+1;
			alert("Please enter a valid Phone Number");
			q_phone.focus();
			q_phone.select();
			return false;		
		}
		
	/*if(email.value=="Email")email.value=""; */	
	if (emptyvalidation(q_comments,"Woops! You Forgot to Fill in Your Comments")==false) 
		{
		q_comments.focus();
		return false;	
		
		}
	
	
	}
	
	thisform.submit();
	
}
function validate_login(thisform)
{
	
	thisform.submit();
}
function IsPhoneNumber(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.- []()";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
		 //alert("Enter a phone number");
         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;
	}
}

function validate_contact(thisform)
{
	with (thisform)
	{

	if (emptyvalidation(q_name,"Woops! You Forgot to Fill in Your Name")==false) 
		{
		q_name.focus();
		return false;	
		}
		
		if (emptyvalidation(q_mail,"Woops! You Forgot to Fill in Your Email Address")==false) 
		{
		q_mail.focus();
		return false;	
		}	
  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = thisform.q_mail.value;
  
	if(reg.test(address) == false) 
	{ 
      alert('Woops! You have Entered an Invalid Email Address');
	  q_mail.focus();
	  q_mail.select();
      return false;
   }
		if (emptyvalidation(q_phone,"Woops! You Forgot to Fill in Your Phone Number")==false) 
		{
		q_phone.focus();
		return false;	
		}
		
	var ph = thisform.q_phone.value;
		var res=IsPhoneNumber(ph);
		if(res==false)
		{
			//count.value=parseInt(count.value)+1;
			alert("Please enter a valid Phone Number");
			q_phone.focus();
			q_phone.select();
			return false;		
		}
		
	/*if(email.value=="Email")email.value=""; */	
	if (emptyvalidation(gross_monthly_income,"Woops! You Forgot to Fill in Your Gross Monthly Income")==false) 
		{
		gross_monthly_income.focus();
		return false;	
		
		}
		if (emptyvalidation(tot_mon_mortage,"Woops! You Forgot to Fill in Your Total Monthly Mortgage Payment ")==false) 
		{
		tot_mon_mortage.focus();
		return false;	
		
		}
		if (emptyvalidation(loan_balance,"Woops! You Forgot to Fill in Your Loan Balance")==false) 
		{
		loan_balance.focus();
		return false;	
		
		}
	
	
	}
	document.contactform.submit();
	
	
}

