 ch=0;
	function change()
	{
		data = cha.innerHTML;
		ch=1;
		cha.innerHTML="";
	}

	function change1(){
		if (ch)
		{
			cha.innerHTML=data;
		}
	}
	

function search()
{
document.form1.method="POST"
document.form1.action="/cgi-bin/sitesearch.cgi"
document.form1.submit()
}

function Validate1(x)
 {
 

 var retValue=false;
 var invalidChars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%^&*(){}|\':;?/<>,.@-+=[]~`_ ";
 var i;
  
for(i=0;i<invalidChars.length;i++)
 {
  if(x.indexOf(invalidChars.charAt(i))>-1)
  {
     retValue=true;
     break;
   }
 }
 
return retValue;
 }


function Validate2(x)
 {
 

 var retValue=false;
 var invalidChars="0123456789!#$%^&*(){}|\':;?/<>";
 var i;
  
for(i=0;i<invalidChars.length;i++)
 {
  if(x.indexOf(invalidChars.charAt(i))>-1)
  {
     retValue=true;
     break;
   }
 }
 
return retValue;
 }


function Validate3(x)
 {
 

 var retValue=false;
 var invalidChars=".@";
 var i;
  
for(i=0;i<invalidChars.length;i++)
 {
  if(x.indexOf(invalidChars.charAt(i))>-1)
  {
     retValue=true;
     break;
   }
 }
 
return retValue;
}

function validate()
{
 if(document.form1.fname.value=="")
	{
		alert("Please Enter Your First Name. ");
		document.form1.fname.focus();
		document.form1.fname.select();
		return false;
	}
	if(!(document.form1.fname.value ==""))
	{
	if(!(isNaN(document.form1.fname.value)))
		{
		alert("Please Enter a Valid First Name");
		document.form1.fname.focus();
		document.form1.fname.select();
		return false;
		}
	}
if(document.form1.lname.value=="")
	{
		alert("Please Enter Your Last Name. ");
		document.form1.lname.focus();
		document.form1.lname.select();
		return false;
	}
	if(!(document.form1.lname.value ==""))
	{
	if(!(isNaN(document.form1.lname.value)))
		{
		alert("Please Enter a Valid Last Name");
		document.form1.lname.focus();
		document.form1.lname.select();
		return false;
		}
	}
		if(document.form1.email.value=="")
	{
		alert("Please Include Your E-mail Address. ");
		document.form1.email.focus();
		document.form1.email.select();
		return false;
	}
if(!(document.form1.email.value==""))
	{
	var evalue = document.form1.email.value;
      //var emailPat = /^(\".*\"|\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
	   var emailPat=/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
	  
	  var matchArray = evalue.match(emailPat);

		if(!emailPat.test(evalue))
		{
			alert("Please Enter a valid E-mail Address.");
			//alert(fv);
			document.form1.email.focus();
			document.form1.email.select();
  			return false;
	}
	}
	if( document.form1.h_phone.value == '' &&  document.form1.h_phone_1.value == '' && document.form1.h_phone_2.value == '' )
{
alert("Please Enter Your Phone Number");
document.form1.h_phone.select();
return false;
}
if ( Validate1(document.form1.h_phone.value) || document.form1.h_phone.value.length < 3)
		{
	alert("Please Enter Valid Phone Number");
        document.form1.h_phone.select();
		return false;
		}
	
if ( Validate1(document.form1.h_phone_1.value) || document.form1.h_phone_1.value.length < 3)
		{
	alert("Please Enter Valid Phone Number");
        document.form1.h_phone_1.select();
		return false;
		}
		
if ( Validate1(document.form1.h_phone_2.value) || document.form1.h_phone_2.value.length < 4)
		{
	alert("Please Enter Valid Phone Number");
        document.form1.h_phone_2.select();
		return false;
		}
	

document.getElementById('subimg').innerHTML="<img src='http://www.mortgages-expo.com/images/processing-short.gif'>&nbsp;&nbsp;<font size='2'><b>Processing..Please Wait..</b></font>";


document.form1.method="POST";
//document.form1.action="http://www.nymortgagedepo.com/test/form.php";
//document.form1.action="http://optionrefi.com/refinance-form.php";
document.form1.submit();
}
function PhoneMove(nLength, sMoveFrom, sMoveTo) {
	if (sMoveTo != '') {
		if (document.form1[sMoveFrom].value.length >= nLength) {
			document.form1[sMoveTo].focus();
		}

	}
}


