function goThere() {
	if (document.application.loanType.options[document.application.loanType.selectedIndex].value != "none") {
    location = document.application.loanType.options[document.application.loanType.selectedIndex].value
		}
	}

function checkFields() {
missinginfo = "";
if (document.form.firstName.value == "") {
missinginfo += "\n     -  First Name";
}
if (document.form.lastName.value == "") {
missinginfo += "\n     -  Last Name";
}
if (document.form.address.value == "") {
missinginfo += "\n     -  Address";
}
if (document.form.city.value == "") {
missinginfo += "\n     -  City";
}
if (document.form.state.value == "") {
missinginfo += "\n     -  State";
}
if (document.form.zip.value == "") {
missinginfo += "\n     -  Zip";
}
if (document.form.contactPhone.value == "") {
missinginfo += "\n     -  Contact Phone";
}
if (document.form.contactPhoneType.value == "") {
missinginfo += "\n     -  Contact Phone Location";
}
if ((document.form.email.value == "") || 
(document.form.email.value.indexOf('@') == -1) || 
(document.form.email.value.indexOf('.') == -1)) {
missinginfo += "\n     -  Email address";
}
if (document.form.loanAmount.value == "") {
missinginfo += "\n     -  Loan Amount";
}
if (document.form.loanPurpose.value == "") {
missinginfo += "\n     -  Loan Purpose";
}
if (document.form.propValue.value == "") {
missinginfo += "\n     -  Estimated Property Value";
}
if (document.form.credit.value == "") {
missinginfo += "\n     -  Credit Rating";
}

if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You failed to correctly fill in your:\n" +
missinginfo + "\n_____________________________" +
"\nPlease check the information and \nsubmit again!";
alert(missinginfo);
return false;
}
else return true;
}


function filterNum(str) {
re = /^\$|,/g;
// remove "$" and ","
return str.replace(re, "");
}

 function putFocus(formInst, elementInst) {
  if (document.forms.length > 0) {
   document.forms[formInst].elements[elementInst].focus();
  }
 }

function MM_validateForm() { //v2.0
  var i,objStr,field,theCheck,atPos,theNum,colonPos,min,max,errors='';
  for (i=0; i<(MM_validateForm.arguments.length-2); i+=3) {
    objStr = MM_validateForm.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.substring(0,objStr.lastIndexOf('.')).
                 lastIndexOf('.'),objStr.length);  //fix layer ref if not supp
    field = eval(objStr);
    field.name = (field.name)?field.name:objStr;
    theCheck = MM_validateForm.arguments[i+2];
    if (field.value) { //IF NOT EMPTY FIELD
      if (theCheck.indexOf('isEmail') != -1) { //CHECK EMAIL
        atPos = field.value.indexOf('@');
        if (atPos < 1 || atPos == (field.value.length - 1))
          errors += '- '+field.name+' must contain an e-mail address.\n';
      } else if (theCheck != 'R') { //START NUM CHECKS
        theNum = parseFloat(field.value);
        if (field.value != ''+theNum) errors += '- '+field.name+' must contain a number.\n';
        if (theCheck.indexOf('inRange') != -1) { //CHECK RANGE
          colonPos = theCheck.indexOf(':');
          min = theCheck.substring(8,colonPos);
          max = theCheck.substring(colonPos+1,theCheck.length);
          if (theNum < min || max < theNum) //bad range
            errors += '- '+field.name+' must contain a number between '+min+' and '+max+'.\n';
    } } }
    else if (theCheck.charAt(0) == 'R') errors += '- '+field.name+' is required.\n';
  }
  if (errors) alert('The following error(s) occurred:\n'+
                    errors);
  document.MM_returnValue = (errors == '')
}

function filterNum(str) {
re = /^\$|,/g;
// remove "$" and ","
return str.replace(re, "");
}

function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num);
}

function checkNumber(input, min, max, msg) {
msg = msg + " field has invalid data: " + input.value;
var str = input.value;
for (var i = 0; i < str.length; i++) {
var ch = str.substring(i, i + 1)
if ((ch < "0" || "9" < ch) && ch != '.') {
alert(msg);
return false;
      }
   }
var num = parseFloat(str)
if (num < min || max < num) {
alert(msg + " not in range [" + min + ".." + max + "]");
return false;
   }
input.value = str;
return true;
}
function computeField(input) {
if (input.value != null && input.value.length != 0)
input.value = "" + eval(input.value);
computeForm(input.form);
}
function computeForm(form) {
if ((form.payments.value == null || form.payments.value.length == 0) ||
(form.interest.value == null || form.interest.value.length == 0) ||
(form.principal.value == null || form.principal.value.length == 0)) {
return;
}
if (!checkNumber(form.payments, 1, 480, "# of payments") ||
!checkNumber(form.interest, .001, 99, "Interest") ||
!checkNumber(form.principal, 100, 10000000, "Principal")) {
form.payment.value = "Invalid";
return;
}
}