<!--

/***********************************************
* Required field(s) validation v1.10- By NavSurf
* Visit Nav Surf at http://navsurf.com
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function formCheck(formobj){ 
	// Enter name of mandatory fields
	var fieldRequired = Array( "EstimatedValue", "MortgageBalance1", "PurchasePrice", "Amount", "fico", "loanpurpose", "occupancy", "FirstName", "LastName", "PropertyCity", "PropertyState", "PropertyZip", "Email", "DayPhone");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array( "Estimated Value", "Mortgage Balance 1", "Purchase Price", "Amount", "fico", "Loan purpose", "Occupancy", "FirstName", "LastName", "Property City", "Property State", "Property Zip-Code", "Email", "Day Phone");
	// dialog message
	var alertMsg = "Please complete the following fields:\n"
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == "" || obj.options[obj.selectedIndex].text == "Select One"){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				obj.value=obj.value.replace(/,/g,'');//remove commas!
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}
	if ( document.appform.FirstName ){
	  if ( document.appform.PurchasePrice.value == "NA"){
		 var propValue = document.appform.EstimatedValue.value;
	  }else { var propValue = document.appform.PurchasePrice.value;
	  }
         //Redirect to 3rd party form after mail script
	  if ( //(document.appform.Amount.value/propValue) > .9 || 
      		document.appform.fico.value == "600-620" || 
	  		document.appform.fico.value == "Below+600" ||
	 		document.appform.Documentation.value == "NoDocs" ) { 
				var conditionmet="true";
				// alert( "pass" );	
	  }
	  if (	document.appform.PropertyState.value !== "NV" &&
			document.appform.PropertyState.value !== "AZ" &&
			document.appform.PropertyState.value !== "UT" &&
			document.appform.PropertyState.value !== "CO" &&
			document.appform.PropertyState.value !== "KS" &&
			document.appform.PropertyState.value !== "MO" &&
			document.appform.PropertyState.value !== "NM" &&
			document.appform.PropertyState.value !== "WA" &&
       		document.appform.PropertyState.value !== "CA"){
		  var conditionmet="true";
	  }
	  if (conditionmet=="true"){
		  document.appform.redirect.value = document.appform.cond1.value; 
	  }
	}
    
	//skip mail scrip if 
    if (document.appform.PropertyState ) {
	 if (document.appform.PropertyState.value !== "CA") {       
		//newAction = "http://" + document.appform.cond1.value;
		//newAction = unescape(newAction);
		//document.appform.target= "_top";
     }
	}
	if (alertMsg.length == l_Msg){
		document.appform.action = newAction;
              if (myAction){document.appform.action = myAction;}
		document.getElementById("required").innerHTML = "Please Wait, Data Processing!";
		document.getElementById("required").className = "red";
		document.getElementById("submit-btn").style.display = "none";
              //alert("newAction");
		return true;
		
	}else{
		//alert(alertMsg);
		document.getElementById("required").innerHTML = alertMsg;
		document.getElementById("required").className = "red";
		return false;
	}
}
// -->

