function layout() {
        var x=750; var y=550
        resizeTo(x,y)
        moveTo((screen.width-x)/2,(screen.height-y)/2)
    }


function ValidateFields(theForm)
{
 if (document.ApplyHomeLoan.TypeCredit[0].checked == false && document.ApplyHomeLoan.TypeCredit[1].checked == false && document.ApplyHomeLoan.TypeCredit[2].checked == false && document.ApplyHomeLoan.TypeCredit[3].checked == false && document.ApplyHomeLoan.TypeCredit[4].checked == false)
  {
   alert("Please select Type of Credit Requested.");
   document.ApplyHomeLoan.LoanAmount.focus();
   return (false);
  }
 if (document.ApplyHomeLoan.AppFirstName.value == "")
  {
   alert("Please enter a value for the \"Applicant First Name\" field.");
    document.ApplyHomeLoan.AppFirstName.focus();
    return (false);
  }
 if (document.ApplyHomeLoan.AppLastName.value == "")
  {
   alert("Please enter a value for the \"Applicant Last Name\" field.");
    document.ApplyHomeLoan.AppLastName.focus();
    return (false);
  }
 if (document.ApplyHomeLoan.AppAddress.value == "") 
  {
   alert("Please enter a value for the \"Address\" field.");
    document.ApplyHomeLoan.AppAddress.focus();
    return (false);
  }
  if (document.ApplyHomeLoan.AppCity.value == "") 
  {
   alert("Please enter a value for the \"City\" field.");
    document.ApplyHomeLoan.AppCity.focus();
    return (false);
  }
  if (document.ApplyHomeLoan.AppState.value == "") 
  {
   alert("Please enter a value for the \"State\" field.");
    document.ApplyHomeLoan.AppState.focus();
    return (false);
  }
  if (document.ApplyHomeLoan.AppZip.value == "") 
  {
   alert("Please enter a value for the \"Zip\" field.");
    document.ApplyHomeLoan.AppZip.focus();
    return (false);
  }
  if (document.ApplyHomeLoan.AppSSN1.value == "") 
  {
   alert("Please enter a value for the \"Social Security Number\" field.");
    document.ApplyHomeLoan.AppSSN1.focus();
    return (false);
  }
  if (document.ApplyHomeLoan.AppSSN2.value == "") 
  {
   alert("Please enter a value for the \"Social Security Number\" field.");
    document.ApplyHomeLoan.AppSSN2.focus();
    return (false);
  }
 if (document.ApplyHomeLoan.AppSSN3.value == "") 
  {
   alert("Please enter a value for the \"Social Security Number\" field.");
    document.ApplyHomeLoan.AppSSN3.focus();
    return (false);
  }
 if (document.ApplyHomeLoan.AppDateOfBirth.value == "") 
  {
   alert("Please enter a value for the \"Date of Birth\" field.");
    document.ApplyHomeLoan.AppDateOfBirth.focus();
    return (false);
  }
  if (document.ApplyHomeLoan.AppDriverLicNum.value == "") 
  {
   alert("Please enter a value for the \"Driver License Number\" field.");
    document.ApplyHomeLoan.AppDriverLicNum.focus();
    return (false);
  }
 
   //Co-App last Name
 if (document.ApplyHomeLoan.CoAppLastName.value == "" && document.ApplyHomeLoan.CoAppFirstName.value != "") 
  {
   alert("Please enter a value for the \"Last Name\" field.");
    document.ApplyHomeLoan.CoAppLastName.focus();
    return (false);
  }

 //Co-App Address
 if (document.ApplyHomeLoan.CoAppAddress.value == "" && document.ApplyHomeLoan.CoAppFirstName.value != "") 
  {
   alert("Please enter a value for the \"Address\" field.");
    document.ApplyHomeLoan.CoAppAddress.focus();
    return (false);
  }
  //Co-App City
 if (document.ApplyHomeLoan.CoAppCity.value == "" && document.ApplyHomeLoan.CoAppFirstName.value != "") 
  {
   alert("Please enter a value for the \"City\" field.");
    document.ApplyHomeLoan.CoAppCity.focus();
    return (false);
  }
  //Co-App State
 if (document.ApplyHomeLoan.CoAppState.value == "" && document.ApplyHomeLoan.CoAppFirstName.value != "") 
  {
   alert("Please enter a value for the \"State\" field.");
    document.ApplyHomeLoan.CoAppState.focus();
    return (false);
  }
  //Co-App Zip
 if (document.ApplyHomeLoan.CoAppZip.value == "" && document.ApplyHomeLoan.CoAppFirstName.value != "") 
  {
   alert("Please enter a value for the \"Zip\" field.");
    document.ApplyHomeLoan.CoAppZip.focus();
    return (false);
  }
 //Co-APP SSN 
  if (document.ApplyHomeLoan.CoAppSSN1.value == "" && document.ApplyHomeLoan.CoAppFirstName.value != "") 
  {
   alert("Please enter a value for the \"Social Security Number\" field.");
    document.ApplyHomeLoan.CoAppSSN1.focus();
    return (false);
  }
  if (document.ApplyHomeLoan.CoAppSSN2.value == "" && document.ApplyHomeLoan.CoAppFirstName.value != "") 
  {
   alert("Please enter a value for the \"Social Security Number\" field.");
    document.ApplyHomeLoan.CoAppSSN2.focus();
    return (false);
  }
 if (document.ApplyHomeLoan.CoAppSSN3.value == "" && document.ApplyHomeLoan.CoAppFirstName.value != "") 
  {
   alert("Please enter a value for the \"Social Security Number\" field.");
    document.ApplyHomeLoan.CoAppSSN3.focus();
    return (false);
  }
 //Co-App Date of Birth
 if (document.ApplyHomeLoan.CoAppDateOfBirth.value == "" && document.ApplyHomeLoan.CoAppFirstName.value != "") 
  {
   alert("Please enter a value for the \"date of birth\" field.");
    document.ApplyHomeLoan.CoAppDateOfBirth.focus();
    return (false);
  }
//Co-APP Drivers License
 if (document.ApplyHomeLoan.CoDriverLicNum.value == "" && document.ApplyHomeLoan.CoAppFirstName.value != "") 
  {
   alert("Please enter a value for the \"Driver License\" field.");
    document.ApplyHomeLoan.CoDriverLicNum.focus();
    return (false);
  }
 
 //Applicant Home Phone verification
 if (document.ApplyHomeLoan.AppHomePhoneNum.value != " ")
 {
  var CheckNumPhone = "0123456789-.,() ";
  var checkstrPhone = document.ApplyHomeLoan.AppHomePhoneNum.value;

  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkstrPhone.length;  i++)
  {
    ch = checkstrPhone.charAt(i);
    for (j = 0;  j < CheckNumPhone.length;  j++)
      if (ch == CheckNumPhone.charAt(j))
        break;
    if (j == CheckNumPhone.length)
    {
      allValid = false;
      break;
    }   
   }
  if (!allValid)
  {
    alert("Please enter only digit characters in the applicant home \"Phone\" field.");
     document.ApplyHomeLoan.AppHomePhoneNum.select();
     document.ApplyHomeLoan.AppHomePhoneNum.focus();
    return (false);
  }
 }
//Co-Applicant Home Phone verification
 if (document.ApplyHomeLoan.CoAppHomePhoneNum.value != " ")
 {
  var CheckNumPhone = "0123456789-.,() ";
  var checkstrPhone = document.ApplyHomeLoan.CoAppHomePhoneNum.value;

  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkstrPhone.length;  i++)
  {
    ch = checkstrPhone.charAt(i);
    for (j = 0;  j < CheckNumPhone.length;  j++)
      if (ch == CheckNumPhone.charAt(j))
        break;
    if (j == CheckNumPhone.length)
    {
      allValid = false;
      break;
    }   
   } 
  if (!allValid)
  {
    alert("Please enter only digit characters in the co-applicant home \"Phone\" field.");
     document.ApplyHomeLoan.CoAppHomePhoneNum.select();
     document.ApplyHomeLoan.CoAppHomePhoneNum.focus();
    return (false);
  }
 }
 //Applicant Work Phone verification
 if (document.ApplyHomeLoan.AppEmplyPhoneNum.value != " ")
 {
  var CheckNumPhone = "0123456789-.,() ";
  var checkstrPhone = document.ApplyHomeLoan.AppEmplyPhoneNum.value;

  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkstrPhone.length;  i++)
  {
    ch = checkstrPhone.charAt(i);
    for (j = 0;  j < CheckNumPhone.length;  j++)
      if (ch == CheckNumPhone.charAt(j))
        break;
    if (j == CheckNumPhone.length)
    {
      allValid = false;
      break;
    }   
   } 
  if (!allValid)
  {
    alert("Please enter only digit characters in the applicant work \"Phone\" field.");
     document.ApplyHomeLoan.AppEmplyPhoneNum.select();
     document.ApplyHomeLoan.AppEmplyPhoneNum.focus();
    return (false);
  }
 }
//Co-Applicant Work Phone verification
 if (document.ApplyHomeLoan.CoAppEmplyPhoneNum.value != " ")
 {
  var CheckNumPhone = "0123456789-.,() ";
  var checkstrPhone = document.ApplyHomeLoan.CoAppEmplyPhoneNum.value;

  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkstrPhone.length;  i++)
  {
    ch = checkstrPhone.charAt(i);
    for (j = 0;  j < CheckNumPhone.length;  j++)
      if (ch == CheckNumPhone.charAt(j))
        break;
    if (j == CheckNumPhone.length)
    {
      allValid = false;
      break;
    }   
   } 
  if (!allValid)
  {
    alert("Please enter only digit characters in the applicant work \"Phone\" field.");
     document.ApplyHomeLoan.CoAppEmplyPhoneNum.select();
     document.ApplyHomeLoan.CoAppEmplyPhoneNum.foFacus();
    return (false);
  }
 } 
/////////////
 //Applicant Work Fax Phone verification
 if (document.ApplyHomeLoan.AppEmplyFaxNum.value != " ")
 {
  var CheckNumPhone = "0123456789-.,() ";
  var checkstrPhone = document.ApplyHomeLoan.AppEmplyFaxNum.value;

  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkstrPhone.length;  i++)
  {
    ch = checkstrPhone.charAt(i);
    for (j = 0;  j < CheckNumPhone.length;  j++)
      if (ch == CheckNumPhone.charAt(j))
        break;
    if (j == CheckNumPhone.length)
    {
      allValid = false;
      break;
    }   
   } 
  if (!allValid)
  {
    alert("Please enter only digit characters in the applicant work \"Fax\" field.");
     document.ApplyHomeLoan.AppEmplyFaxNum.select();
     document.ApplyHomeLoan.AppEmplyFaxNum.focus();
    return (false);
  }
 }
//Co-Applicant Work Fax verification
 if (document.ApplyHomeLoan.CoAppEmplyFaxNum.value != " ")
 {
  var CheckNumPhone = "0123456789-.,() ";
  var checkstrPhone = document.ApplyHomeLoan.CoAppEmplyFaxNum.value;

  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkstrPhone.length;  i++)
  {
    ch = checkstrPhone.charAt(i);
    for (j = 0;  j < CheckNumPhone.length;  j++)
      if (ch == CheckNumPhone.charAt(j))
        break;
    if (j == CheckNumPhone.length)
    {
      allValid = false;
      break;
    }   
   } 
  if (!allValid)
  {
    alert("Please enter only digit characters in the applicant work \"Fax\" field.");
     document.ApplyHomeLoan.CoAppEmplyFaxNum.select();
     document.ApplyHomeLoan.CoAppEmplyFaxNum.focus();
    return (false);
  }
 } 
//Applicant Zip code verification
if (document.ApplyHomeLoan.AppZip.value != " ")
{
  var CheckNumZip = "0123456789-.,";
  var checkstrZip = document.ApplyHomeLoan.AppZip.value;
  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkstrZip.length;  i++)
  {
    ch = checkstrZip.charAt(i);
    for (j = 0;  j < CheckNumZip.length;  j++)
      if (ch == CheckNumZip.charAt(j))
        break;
    if (j == CheckNumZip.length)
    {
      allValid = false;
      break;
    }    
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the applicant \"Zip Code\" field.");
    document.ApplyHomeLoan.AppZip.select();
    document.ApplyHomeLoan.AppZip.focus();
    return (false);
  }
 }
//Co-Applicant Zip code verification

if (document.ApplyHomeLoan.CoAppZip.value != " ")
{
  var CheckNumZip = "0123456789-.,";
  var checkstrZip = document.ApplyHomeLoan.CoAppZip.value;
  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkstrZip.length;  i++)
  {
    ch = checkstrZip.charAt(i);
    for (j = 0;  j < CheckNumZip.length;  j++)
      if (ch == CheckNumZip.charAt(j))
        break;
    if (j == CheckNumZip.length)
    {
      allValid = false;
      break;
    }    
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the co-applicant \"Zip Code\" field.");
    document.ApplyHomeLoan.CoAppZip.select();
    document.ApplyHomeLoan.CoAppZip.focus();
    return (false);
  }
 }

//Applicant Zip code verification
if (document.ApplyHomeLoan.AppEmplyZip.value != " ")
{
  var CheckNumZip = "0123456789-.,";
  var checkstrZip = document.ApplyHomeLoan.AppEmplyZip.value;
  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkstrZip.length;  i++)
  {
    ch = checkstrZip.charAt(i);
    for (j = 0;  j < CheckNumZip.length;  j++)
      if (ch == CheckNumZip.charAt(j))
        break;
    if (j == CheckNumZip.length)
    {
      allValid = false;
      break;
    }    
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the applicant \"Zip Code\" field.");
    document.ApplyHomeLoan.AppEmplyZip.select();
    document.ApplyHomeLoan.AppEmplyZip.focus();
    return (false);
  }
 }
//Co-Applicant Zip code verification

if (document.ApplyHomeLoan.CoAppEmplyZip.value != " ")
{
  var CheckNumZip = "0123456789-.,";
  var checkstrZip = document.ApplyHomeLoan.CoAppEmplyZip.value;
  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkstrZip.length;  i++)
  {
    ch = checkstrZip.charAt(i);
    for (j = 0;  j < CheckNumZip.length;  j++)
      if (ch == CheckNumZip.charAt(j))
        break;
    if (j == CheckNumZip.length)
    {
      allValid = false;
      break;
    }    
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the co-applicant \"Zip Code\" field.");
    document.ApplyHomeLoan.CoAppEmplyZip.select();
    document.ApplyHomeLoan.CoAppEmplyZip.focus();
    return (false);
  }
 }
 
//Applicant SSN1 verification
if (document.ApplyHomeLoan.AppSSN1.value != " ")
{
  var CheckNumSSN1 = "0123456789-";
  var checkstrSSN1 = document.ApplyHomeLoan.AppSSN1.value;
  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkstrSSN1.length;  i++)
  {
    ch = checkstrSSN1.charAt(i);
    for (j = 0;  j < CheckNumSSN1.length;  j++)
      if (ch == CheckNumSSN1.charAt(j))
        break;
    if (j == CheckNumSSN1.length)
    {
      allValid = false;
      break;
    }    
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the applicant \"SSN1\" field.");
    document.ApplyHomeLoan.AppSSN1.select();
    document.ApplyHomeLoan.AppSSN1.focus();
    return (false);
  }
 }
 
 //Applicant SSN2 verification
if (document.ApplyHomeLoan.AppSSN2.value != " ")
{
  var CheckNumSSN2 = "0123456789-";
  var checkstrSSN2 = document.ApplyHomeLoan.AppSSN2.value;
  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkstrSSN2.length;  i++)
  {
    ch = checkstrSSN2.charAt(i);
    for (j = 0;  j < CheckNumSSN2.length;  j++)
      if (ch == CheckNumSSN2.charAt(j))
        break;
    if (j == CheckNumSSN2.length)
    {
      allValid = false;
      break;
    }    
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the applicant \"SSN2\" field.");
    document.ApplyHomeLoan.AppSSN2.select();
    document.ApplyHomeLoan.AppSSN2.focus();
    return (false);
  }
 }
 
 //Applicant SSN3 verification
if (document.ApplyHomeLoan.AppSSN3.value != " ")
{
  var CheckNumSSN3 = "0123456789-";
  var checkstrSSN3 = document.ApplyHomeLoan.AppSSN3.value;
  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkstrSSN3.length;  i++)
  {
    ch = checkstrSSN3.charAt(i);
    for (j = 0;  j < CheckNumSSN3.length;  j++)
      if (ch == CheckNumSSN3.charAt(j))
        break;
    if (j == CheckNumSSN3.length)
    {
      allValid = false;
      break;
    }    
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the applicant \"SSN3\" field.");
    document.ApplyHomeLoan.AppSSN3.select();
    document.ApplyHomeLoan.AppSSN3.focus();
    return (false);
  }
 }
 
//Co-Applicant SSN1 verification
if (document.ApplyHomeLoan.CoAppSSN1.value != " ")
{
  var CheckNumSSN1 = "0123456789-";
  var checkstrSSN1 = document.ApplyHomeLoan.CoAppSSN1.value;
  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkstrSSN1.length;  i++)
  {
    ch = checkstrSSN1.charAt(i);
    for (j = 0;  j < CheckNumSSN1.length;  j++)
      if (ch == CheckNumSSN1.charAt(j))
        break;
    if (j == CheckNumSSN1.length)
    {
      allValid = false;
      break;
    }    
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the Co-Applicant \"SSN1\" field.");
    document.ApplyHomeLoan.CoAppSSN1.select();
    document.ApplyHomeLoan.CoAppSSN1.focus();
    return (false);
  }
 }
 
 //Co-Applicant SSN2 verification
if (document.ApplyHomeLoan.CoAppSSN2.value != " ")
{
  var CheckNumSSN2 = "0123456789-";
  var checkstrSSN2 = document.ApplyHomeLoan.CoAppSSN2.value;
  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkstrSSN2.length;  i++)
  {
    ch = checkstrSSN2.charAt(i);
    for (j = 0;  j < CheckNumSSN2.length;  j++)
      if (ch == CheckNumSSN2.charAt(j))
        break;
    if (j == CheckNumSSN2.length)
    {
      allValid = false;
      break;
    }    
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the Co-Applicant \"SSN2\" field.");
    document.ApplyHomeLoan.CoAppSSN2.select();
    document.ApplyHomeLoan.CoAppSSN2.focus();
    return (false);
  }
 }
 
 //Co-Applicant SSN3 verification
if (document.ApplyHomeLoan.CoAppSSN3.value != " ")
{
  var CheckNumSSN3 = "0123456789-";
  var checkstrSSN3 = document.ApplyHomeLoan.CoAppSSN3.value;
  var allValid = true;
  var allNum = "";
  
  for (i = 0;  i < checkstrSSN3.length;  i++)
  {
    ch = checkstrSSN3.charAt(i);
    for (j = 0;  j < CheckNumSSN3.length;  j++)
      if (ch == CheckNumSSN3.charAt(j))
        break;
    if (j == CheckNumSSN3.length)
    {
      allValid = false;
      break;
    }    
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the Co-Applicant \"SSN3\" field.");
    document.ApplyHomeLoan.CoAppSSN3.select();
    document.ApplyHomeLoan.CoAppSSN3.focus();
    return (false);
  }
 }
if (document.ApplyHomeLoan.AppDateOfBirth.value != "")
{ 
//Applicant Date Of Birth Field value
// Checks for the following valid date formats:
// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
// Also separates date into month, day, and year variables

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

// To require a 4 digit year entry, use this line instead:
// var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
var matchArray = document.ApplyHomeLoan.AppDateOfBirth.value.match(datePat); // is the format ok?
if (matchArray == null) {
alert("Date is not in a valid format.");
document.ApplyHomeLoan.AppDateOfBirth.select();
document.ApplyHomeLoan.AppDateOfBirth.focus();
return false;
}
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.");
document.ApplyHomeLoan.AppDateOfBirth.select();
document.ApplyHomeLoan.AppDateOfBirth.focus();
return false;
}
if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.");
document.ApplyHomeLoan.AppDateOfBirth.select();
document.ApplyHomeLoan.AppDateOfBirth.focus();
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
 switch(month)
 {
  case "4":
  alert("April doesn't have 31 days");
  document.ApplyHomeLoan.AppDateOfBirth.select();
  document.ApplyHomeLoan.AppDateOfBirth.focus();
  return false
  break;
  case "04":
  alert("April doesn't have 31 days");
  document.ApplyHomeLoan.AppDateOfBirth.select();
  document.ApplyHomeLoan.AppDateOfBirth.focus();
  return false
  break;
  case "6":
  alert("June doesn't have 31 days");
  document.ApplyHomeLoan.AppDateOfBirth.select();
  document.ApplyHomeLoan.AppDateOfBirth.focus();
  return false
  break;
  case "06":
  alert("June doesn't have 31 days");
  document.ApplyHomeLoan.AppDateOfBirth.select();
  document.ApplyHomeLoan.AppDateOfBirth.focus();
  return false
  break;
  case "9":
  alert("September doesn't have 31 days");
  document.ApplyHomeLoan.AppDateOfBirth.select();
  document.ApplyHomeLoan.AppDateOfBirth.focus();
  return false
  break;
  case "09":
  alert("September doesn't have 31 days");
  document.ApplyHomeLoan.AppDateOfBirth.select();
  document.ApplyHomeLoan.AppDateOfBirth.focus();
  return false
  break;
  case "11":
  alert("November doesn't have 31 days");
  document.ApplyHomeLoan.AppDateOfBirth.select();
  document.ApplyHomeLoan.AppDateOfBirth.focus();
  return false
  break;
  default:
  alert("Month "+month+" doesn't have 31 days!");
  document.ApplyHomeLoan.AppDateOfBirth.select();
  document.ApplyHomeLoan.AppDateOfBirth.focus();
return false
}
 }
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
alert("February " + year + " doesn't have " + day + " days!");
document.ApplyHomeLoan.AppDateOfBirth.select();
document.ApplyHomeLoan.AppDateOfBirth.focus();
return false;
   }
 } 
 
if (document.ApplyHomeLoan.CoAppDateOfBirth.value != "")
{ 
// Co-Applicant Date Of Birth Field value
// Checks for the following valid date formats:
// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
// Also separates date into month, day, and year variables

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

// To require a 4 digit year entry, use this line instead:
// var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
var matchArray = document.ApplyHomeLoan.CoAppDateOfBirth.value.match(datePat); // is the format ok?
if (matchArray == null) {
alert("Date is not in a valid format.");
document.ApplyHomeLoan.CoAppDateOfBirth.select();
document.ApplyHomeLoan.CoAppDateOfBirth.focus();
return false;
}
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.");
document.ApplyHomeLoan.CoAppDateOfBirth.select();
document.ApplyHomeLoan.CoAppDateOfBirth.focus();
return false;
}
if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.");
document.ApplyHomeLoan.CoAppDateOfBirth.select();
document.ApplyHomeLoan.CoAppDateOfBirth.focus();
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
 switch(month)
 {
  case "4":
  alert("April doesn't have 31 days");
  document.ApplyHomeLoan.CoAppDateOfBirth.select();
  document.ApplyHomeLoan.CoAppDateOfBirth.focus();
  return false
  break;
  case "04":
  alert("April doesn't have 31 days");
  document.ApplyHomeLoan.CoAppDateOfBirth.select();
  document.ApplyHomeLoan.CoAppDateOfBirth.focus();
  return false
  break;
  case "6":
  alert("June doesn't have 31 days");
  document.ApplyHomeLoan.CoAppDateOfBirth.select();
  document.ApplyHomeLoan.CoAppDateOfBirth.focus();
  return false
  break;
  case "06":
  alert("June doesn't have 31 days");
  document.ApplyHomeLoan.CoAppDateOfBirth.select();
  document.ApplyHomeLoan.CoAppDateOfBirth.focus();
  return false
  break;
  case "9":
  alert("September doesn't have 31 days");
  document.ApplyHomeLoan.CoAppDateOfBirth.select();
  document.ApplyHomeLoan.CoAppDateOfBirth.focus();
  return false
  break;
  case "09":
  alert("September doesn't have 31 days");
  document.ApplyHomeLoan.CoAppDateOfBirth.select();
  document.ApplyHomeLoan.CoAppDateOfBirth.focus();
  return false
  break;
  case "11":
  alert("November doesn't have 31 days");
  document.ApplyHomeLoan.CoAppDateOfBirth.select();
  document.ApplyHomeLoan.CoAppDateOfBirth.focus();
  return false
  break;
  default:
  alert("Month "+month+" doesn't have 31 days!");
  document.ApplyHomeLoan.CoAppDateOfBirth.select();
  document.ApplyHomeLoan.CoAppDateOfBirth.focus();
return false
}
 }
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
alert("February " + year + " doesn't have " + day + " days!");
document.ApplyHomeLoan.CoAppDateOfBirth.select();
document.ApplyHomeLoan.CoAppDateOfBirth.focus();
return false;
   }
  }  
 }
}
if (document.ApplyHomeLoan.AppEmplyStartDate.value != "")
{ 
//Applicant Start Date Value
// Checks for the following valid date formats:
// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
// Also separates date into month, day, and year variables

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

// To require a 4 digit year entry, use this line instead:
// var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
var matchArray = document.ApplyHomeLoan.AppEmplyStartDate.value.match(datePat); // is the format ok?
if (matchArray == null) {
alert("Date is not in a valid format.");
document.ApplyHomeLoan.AppEmplyStartDate.select();
document.ApplyHomeLoan.AppEmplyStartDate.focus();
return false;
}
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.");
document.ApplyHomeLoan.AppEmplyStartDate.select();
document.ApplyHomeLoan.AppEmplyStartDate.focus();
return false;
}
if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.");
document.ApplyHomeLoan.AppEmplyStartDate.select();
document.ApplyHomeLoan.AppEmplyStartDate.focus();
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
 switch(month)
 {
  case "4":
  alert("April doesn't have 31 days");
  document.ApplyHomeLoan.AppEmplyStartDate.select();
  document.ApplyHomeLoan.AppEmplyStartDate.focus();
  return false
  break;
  case "04":
  alert("April doesn't have 31 days");
  document.ApplyHomeLoan.AppEmplyStartDate.select();
  document.ApplyHomeLoan.AppEmplyStartDate.focus();
  return false
  break;
  case "6":
  alert("June doesn't have 31 days");
  document.ApplyHomeLoan.AppEmplyStartDate.select();
  document.ApplyHomeLoan.AppEmplyStartDate.focus();
  return false
  break;
  case "06":
  alert("June doesn't have 31 days");
  document.ApplyHomeLoan.AppEmplyStartDate.select();
  document.ApplyHomeLoan.AppEmplyStartDate.focus();
  return false
  break;
  case "9":
  alert("September doesn't have 31 days");
  document.ApplyHomeLoan.AppEmplyStartDate.select();
  document.ApplyHomeLoan.AppEmplyStartDate.focus();
  return false
  break;
  case "09":
  alert("September doesn't have 31 days");
  document.ApplyHomeLoan.AppEmplyStartDate.select();
  document.ApplyHomeLoan.AppEmplyStartDate.focus();
  return false
  break;
  case "11":
  alert("November doesn't have 31 days");
  document.ApplyHomeLoan.AppEmplyStartDate.select();
  document.ApplyHomeLoan.AppEmplyStartDate.focus();
  return false
  break;
  default:
  alert("Month "+month+" doesn't have 31 days!");
  document.ApplyHomeLoan.AppEmplyStartDate.select();
  document.ApplyHomeLoan.AppEmplyStartDate.focus();
return false
}
 }
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
alert("February " + year + " doesn't have " + day + " days!");
document.ApplyHomeLoan.AppEmplyStartDate.select();
document.ApplyHomeLoan.AppEmplyStartDate.focus();
return false;
   }
 } 
 
if (document.ApplyHomeLoan.CoAppEmplyStartDate.value != "")
{ 
// Co-Applicant Start Date value
// Checks for the following valid date formats:
// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
// Also separates date into month, day, and year variables

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

// To require a 4 digit year entry, use this line instead:
// var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
var matchArray = document.ApplyHomeLoan.CoAppEmplyStartDate.value.match(datePat); // is the format ok?
if (matchArray == null) {
alert("Date is not in a valid format.");
document.ApplyHomeLoan.CoAppEmplyStartDate.select();
document.ApplyHomeLoan.CoAppEmplyStartDate.focus();
return false;
}
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.");
document.ApplyHomeLoan.CoAppEmplyStartDate.select();
document.ApplyHomeLoan.CoAppEmplyStartDate.focus();
return false;
}
if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.");
document.ApplyHomeLoan.CoAppEmplyStartDate.select();
document.ApplyHomeLoan.CoAppEmplyStartDate.focus();
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
 switch(month)
 {
  case "4":
  alert("April doesn't have 31 days");
  document.ApplyHomeLoan.CoAppEmplyStartDate.select();
  document.ApplyHomeLoan.CoAppEmplyStartDate.focus();
  return false
  break;
  case "04":
  alert("April doesn't have 31 days");
  document.ApplyHomeLoan.CoAppEmplyStartDate.select();
  document.ApplyHomeLoan.CoAppEmplyStartDate.focus();
  return false
  break;
  case "6":
  alert("June doesn't have 31 days");
  document.ApplyHomeLoan.CoAppEmplyStartDate.select();
  document.ApplyHomeLoan.CoAppEmplyStartDate.focus();
  return false
  break;
  case "06":
  alert("June doesn't have 31 days");
  document.ApplyHomeLoan.CoAppEmplyStartDate.select();
  document.ApplyHomeLoan.CoAppEmplyStartDate.focus();
  return false
  break;
  case "9":
  alert("September doesn't have 31 days");
  document.ApplyHomeLoan.CoAppEmplyStartDate.select();
  document.ApplyHomeLoan.CoAppEmplyStartDate.focus();
  return false
  break;
  case "09":
  alert("September doesn't have 31 days");
  document.ApplyHomeLoan.CoAppEmplyStartDate.select();
  document.ApplyHomeLoan.CoAppEmplyStartDate.focus();
  return false
  break;
  case "11":
  alert("November doesn't have 31 days");
  document.ApplyHomeLoan.CoAppEmplyStartDate.select();
  document.ApplyHomeLoan.CoAppEmplyStartDate.focus();
  return false
  break;
  default:
  alert("Month "+month+" doesn't have 31 days!");
  document.ApplyHomeLoan.CoAppEmplyStartDate.select();
  document.ApplyHomeLoan.CoAppEmplyStartDate.focus();
return false
}
 }
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
alert("February " + year + " doesn't have " + day + " days!");
document.ApplyHomeLoan.CoAppEmplyStartDate.select();
document.ApplyHomeLoan.CoAppEmplyStartDate.focus();
return false;
   }
  }  
 }
 }
}

function SSN1()
  { 
    intLengthSSN1 = document.ApplyHomeLoan.AppSSN1.value.length;
 	if (intLengthSSN1 == 3)
	{
	  document.ApplyHomeLoan.AppSSN2.focus()
	}
  }
 	
  function SSN2()
  { 					  
    intLengthSSN2 = document.ApplyHomeLoan.AppSSN2.value.length;
 	if (intLengthSSN2 == 2)
 	{
	  document.ApplyHomeLoan.AppSSN3.focus()
	}		
  }
 
 function COSSN1()
   {
     intLengthCOSSN1 = document.ApplyHomeLoan.CoAppSSN1.value.length;
  	if (intLengthCOSSN1 == 3)
 	{
 	  document.ApplyHomeLoan.CoAppSSN2.focus()
 	}
   }
  	
  function COSSN1()
   {
     intLengthCOSSN1 = window.document.ApplyHomeLoan.CoAppSSN1.value.length;
  	if (intLengthCOSSN1 == 3)
 	{
 	  document.ApplyHomeLoan.CoAppSSN2.focus()
 	}
   }
  	
   function COSSN2()
   { 					  
     intLengthCOSSN2 = document.ApplyHomeLoan.CoAppSSN2.value.length;
  	if (intLengthCOSSN2 == 2)
  	{
 	  document.ApplyHomeLoan.CoAppSSN3.focus()
 	}		

}
