<!-- Hide

function AutoTab( hItem, maxLength, linkItem ){
var vKeyCode,oItem
oItem = eval(linkItem);
vKeyCode = window.event.keyCode
if(vKeyCode==9 && window.event.shiftKey){ return; }
switch(window.event.keyCode){
case 37 : return;
case 39 : return;
case 16 : return;
case 46 : return;
}
if (window.event.keyCode != 9 ){
if( typeof(oItem) == "object" ){
if( (String(oItem.value).length == 0) && (String(hItem.value).length == maxLength) ){
oItem.focus()
}
}
}
}

function displayInlineError(sField, sErrMsg){
var itop;
var ileft;
var size;
var sName;
var oItem;

oItem = sField;
if(typeof(oItem)!="object")
return;

itop = 0;
ileft = 0;

itop = oItem.offsetHeight;
while (oItem.tagName != "BODY" ){
itop  += oItem.offsetTop;
ileft += oItem.offsetLeft;
oItem = oItem.offsetParent;
}

divError.style.left = ileft +"px";
divError.style.top  = itop +"px";
divError.innerText = sErrMsg;

divError.style.display = "inline";
}

function ClearError(){
Form1.first_name.style.visibility = 'visible';
divError.style.display = 'none';
}
function CharValidate(Field,ValidValues){

var isValid = true;
var i = 0;
var j;

while ((i < Field.length) & (isValid)){
isValid = false;
j = 0;
while ( (j<=ValidValues.length) & (!isValid) ){
if (Field.charAt(i) == ValidValues.charAt(j)){
isValid = true;
}
j++;

}
i++;
}
return isValid;
}

function ValidateData(){

// validate Area Code
if ( String(Form1.phoneareacode.value).length < 3 ) {
displayInlineError(Form1.phoneareacode, "Please type your area code");
Form1.phoneareacode.focus();
return false;
}

if (!CharValidate(Form1.phoneareacode.value,"0123456789")){
displayInlineError(Form1.phoneareacode, "Please enter numbers only for your area code");
Form1.phoneareacode.focus();
return false;
}

// validate Prefix
if ( String(Form1.phoneprefix.value).length < 3 ) {
displayInlineError(Form1.phoneprefix, "Please type your phone number");
Form1.phoneprefix.focus();
return false;
}
if (!CharValidate(Form1.phoneprefix.value,"0123456789")){
displayInlineError(Form1.phoneprefix, "Please enter numbers only for your phone number");
Form1.phoneprefix.focus();
return false;
}
// validate Last4
if ( String(Form1.phonelast.value).length < 4 ) {
displayInlineError(Form1.phonelast, "Please type your phone number");
Form1.phonelast.focus();
return false;
}
if (!CharValidate(Form1.phonelast.value,"0123456789")){
displayInlineError(Form1.phonelast, "");
Form1.phonelast.focus();
return false;
}

// validate fax1 Area Code
if ( String(Form1.fax1.value).length < 3 ) {
displayInlineError(Form1.fax1, "Please type your area code");
Form1.fax1.focus();
return false;
}

if (!CharValidate(Form1.fax1.value,"0123456789")){
displayInlineError(Form1.fax1, "Please enter numbers only for your area code");
Form1.fax1.focus();
return false;
}

// validate fax2 Prefix
if ( String(Form1.fax2.value).length < 3 ) {
displayInlineError(Form1.fax2, "Please type your phone number");
Form1.fax2.focus();
return false;
}
if (!CharValidate(Form1.fax2.value,"0123456789")){
displayInlineError(Form1.fax2, "Please enter numbers only for your phone number");
Form1.fax2.focus();
return false;
}
// validate fax3 Last4
if ( String(Form1.fax3.value).length < 4 ) {
displayInlineError(Form1.fax3, "Please type your phone number");
Form1.fax3.focus();
return false;
}
if (!CharValidate(Form1.fax3.value,"0123456789")){
displayInlineError(Form1.fax3, "");
Form1.fax3.focus();
return false;
}

return true;
} // end auto_tab functions


function validate() {

if (document.Form1.first_name.value == "") {
alert("We would like to know your first name.");
document.Form1.first_name.focus();
return false;
}

if (document.Form1.last_name.value == "") {
alert("We would like to know your last name.");
document.Form1.last_name.focus();
return false;
}

if (document.Form1.address.value == "") {
alert("Please Enter Your Address.");
document.Form1.address.focus();
return false;
}

if (document.Form1.city.value == "") {
alert("Please Enter Your City.");
document.Form1.city.focus();
return false;
}

if (document.Form1.state.value == "--") {
alert("Please Select Your State.");
document.Form1.state.focus();
return false;
}

if (document.Form1.zip.value == "") {
alert("Please Enter Your Zip Code.");
document.Form1.zip.focus();
return false;
}

if (document.Form1.phoneareacode.value == "") {
alert("Phone Number Section Is Missing Some Data.");
document.Form1.phoneareacode.focus();
return false;
}

if (document.Form1.phoneprefix.value == "") {
alert("Phone Number Section Is Missing Some Data.");
document.Form1.phoneprefix.focus();
return false;
}

if (document.Form1.phonelast.value == "") {
alert("Phone Number Section Is Missing Some Data.");
document.Form1.phonelast.focus();
return false;
}

if (!emailCheck(document.Form1.user_email.value)) {
document.Form1.user_email.focus();
return false;
}

for (var i=0; i < document.Form1.LoanType.length; i++)
   {
   if (document.Form1.LoanType[i].checked)
      {
      var rad_val = document.Form1.LoanType[i].value;
      }
   }

if (rad_val == "LoanTypePurchase") {
   if (document.Form1.PurchasePrice.value == "" || document.Form1.PurchasePrice.value < 1) {
   alert("Sales Price value cannot be left blank, AND must be greater than 0.");
   document.Form1.PurchasePrice.focus();
   return false;
   }
}

if (rad_val == "LoanTypeRefinance") {
   if (document.Form1.EstPropertyValue.value == "" || document.Form1.EstPropertyValue.value < 1) {
   alert("Estimated property value cannot be left blank, AND must be greater than 0.");
   document.Form1.EstPropertyValue.focus();
   return false;
   }
}

if (document.Form1.LoanAmount.value == "" || document.Form1.LoanAmount.value < 1) {
alert("Loan amount value cannot be left blank, AND must be greater than 0. Fill out at least 1 of the above 4 fields.");
document.Form1.LoanAmount.focus();
return false;
}

if (document.Form1.Income.value == "" || document.Form1.Income.value < 1) {
alert("Gross Monthly Income cannot be left blank, AND must be greater than 0.");
document.Form1.Income.focus();
return false;
}

var c_credit = document.Form1.ApproxCreditScore.selectedIndex
var v8 = document.Form1.ApproxCreditScore.options[c_credit].text
if (v8 == "I know my credit score") {

   if (document.Form1.ExactCreditScore.value == "") {
   alert("Your exact credit score cannot be left blank.");
   document.Form1.ExactCreditScore.focus();
   return false;
   }
}

return true;
}

function emailCheck (emailStr) {
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


/* Finally, let's start trying to figure out if the supplied address is
   valid. */

/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	alert("Email address seems incorrect (check @ and .'s)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    alert("The Email username doesn't seem to be valid.")
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The email domain name doesn't seem to be valid.")
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   alert("The address must end in a three-letter domain, or two letter country.")
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}

// If we've gotten this far, everything's valid!
return true;
}

-->
