// JavaScript Document
function ValidateCalcForm()
{
	var amount = document.CalcForm.amount;
	var name = document.CalcForm.name;
	var telno = document.CalcForm.telno;
    var email = document.CalcForm.email;
    var ValidChars = "0123456789.";
    var IsNumber=true;
    var Char;
    var BoxString = amount.value;


   for (i = 0; i < BoxString.length && IsNumber == true; i++) 
      { 
      Char = BoxString.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
		 window.alert("Please remove commas and dollar signs from amount.");
		 amount.focus();
		 return false;
         }
   }
 
	if (amount.value <= 0){
        window.alert("Please enter a loan amount greater than 0.");
        amount.focus();
        return false;
    }

    if (name.value == "")
    {
        window.alert("Please enter your name.");
        name.focus();
        return false;
    }
	
    if(telno.value.search(/\d{3}\-\d{3}\-\d{4}/)==-1)
   {
      alert("The phone number you entered is not valid.\r\nPlease enter a phone number with the format xxx-xxx-xxxx.");
        telno.focus();
      return false;
   }

   if (email.value == "")
    {
        window.alert("Please enter a valid e-mail address.");
        email.focus();
        return false;
    }
    if (email.value.indexOf("@", 0) < 0)
    {
        window.alert("Please enter a valid e-mail address.");
        email.focus();
        return false;
    }
    if (email.value.indexOf(".", 0) < 0)
    {
        window.alert("Please enter a valid e-mail address.");
        email.focus();
        return false;
    }





    return true;
}

document.write('<table width="94%" border="0" align="center"><tr align="center"><td>'+
'<form name="CalcForm" method="post" action="http://www.freequoterequest.com/loan-calculator/freequote/calc.php" onSubmit="return ValidateCalcForm();">'+
'<font color="#FFFFFF" style="font-size:12px">Loan Amount:</font> <input type="text" name="amount" size="12"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>'+
'<tr align="center"><td><font color="#FFFFFF" style="font-size:12px">&nbsp;&nbsp;&nbsp;Name: </font><input type="text" size="12" name="name" /></td></tr>'+
'<tr align="center"><td><font color="#FFFFFF" style="font-size:12px">Tel No#: </font><input type="text" size="12" name="telno" /></td></tr>'+
'<tr><td><font color="#FFFFFF" style="font-size:12px">Email Address:</font> '+
'<input type="text" size="12" name="email" /></td></tr><tr><td align="right">'+
'<input name="redirect" type="hidden" value="thankyou.php" >'+
'<input type="submit" name="submit" value="Calculate" />&nbsp;</form> </td> </tr> </table> ');
