// Validate initial section
function s1() {

   var check;
   var check2;

   check=document.getElementById('cheque').value;
//      check=document.form.cheque.value;

   if (check=="") {

      alert('Please tell us who the cheque should be made payable to');
      document.form.cheque.focus();
      return false;}

   check=document.getElementById('amount').value;
   if (check=="") {
      alert('Please tell us how much you wish to borrow');
      document.form.amount.focus();
      return false;}

   check=document.getElementById('purpose').value;
   if (check=="") {
      alert('Please tell us the main purpose of the loan');
      document.form.purpose.focus();
      return false;}

   check=document.getElementById('length').value;
   if (check=="") {
      alert('Please tell us how long you would like the loan to last');
      document.form.length.focus();
      return false;}


  document.getElementById('s1').style.visibility = 'visible';
  document.getElementById("s1").style.display="block";
  document.getElementById('startshow').style.visibility = 'hidden';
  document.form.status.focus();
  return false;
}




// Validate section 1 + Show section 2
function s2() {

   var check;
   var check2;

   check=document.getElementById('status').value;
   if (check=="") {
      alert('Please check the residential status box');
      document.form.status.focus();
      return false;}


   check=document.getElementById('dobdd').value;
   if (check=="") {
      alert('Please tell us the day of the month, for your date of birth');
      document.form.dobdd.focus();
      return false;}
   check=document.getElementById('dobmm').value;
   if (check=="") {
      alert('Please tell us the month, for your date of birth');
      document.form.dobmm.focus();
      return false;}
   check=document.getElementById('dobyy').value;
   if (check=="") {
      alert('Please tell us the year, of your date of birth');
      document.form.dobyy.focus();
      return false;}

   check=document.getElementById('marital').value;
   if (check=="") {
      alert('Please tell us your marital status');
      document.form.marital.focus();
      return false;}

   check=document.getElementById('bank').value;
   if (check=="") {
      alert('Please tell us how long you have been with your bank');
      document.form.bank.focus();
      return false;}

   check=document.getElementById('employment').value;
   if (check=="") {
      alert('Please tell us about your employment');
      document.form.employment.focus();
      return false;}

   check=document.getElementById('yearsinjob').value;
   if (check=="") {
      alert('Please tell us how long you have been employed');
      document.form.yearsinjob.focus();
      return false;}

   check=document.getElementById('additional').value;
   if (check=="") {
      alert('Please tell us whether you have additional income');
      document.form.additional.focus();
      return false;}

   check2=document.getElementById('addincome').value;
   if (check2==""&&check=="Yes") {
      alert('Please tell us how much you earn from your additional employment');
      document.form.addincome.focus();
      return false;}

   check2=document.getElementById('addsource').value;
   if (check2==""&&check=="Yes") {
      alert('Please tell us what your occupation is for additional income');
      document.form.addsource.focus();
      return false;}

   check=document.getElementById('reside').value;
   if (check=="") {
      alert('Please tell us whether you permanent rights to reside in the UK');
      document.form.reside.focus();
      return false;}



  document.getElementById('s2').style.visibility = 'visible';
  document.getElementById("s2").style.display="block";
  document.getElementById('s1show').style.visibility = 'hidden';
  document.form.sal.focus();
  return false;
}



// Validate section 2 + Show section 3
function s3() {

   var check;
   var check2;

   check=document.getElementById('sal').value;
   if (check=="") {
      alert('Please choose your title');
      document.form.sal.focus();
      return false;}

   check=document.getElementById('first').value;
   if (check=="") {
      alert('Please tell us your first name');
      document.form.first.focus();
      return false;}

   check=document.getElementById('surname').value;
   if (check=="") {
      alert('Please tell us your surname');
      document.form.surname.focus();
      return false;}

   check=document.getElementById('maiden').value;
   check2=document.getElementById('sal').value;
   if (check==""&&check2=="Mrs") {
      alert('Please tell us your maiden name');
      document.form.maiden.focus();
      return false;}

   check=document.getElementById('mothermaiden').value;
   if (check=="") {
      alert('Please tell us your mothers maiden name');
      document.form.mothermaiden.focus();
      return false;}


   check=document.getElementById('address').value;
   if (check=="") {
      alert('Please tell us your address');
      document.form.address.focus();
      return false;}

   check=document.getElementById('postcode').value;
   if (check=="") {
      alert('Please tell us your postcode');
      document.form.postcode.focus();
      return false;}

   check=document.getElementById('phone').value;
   if (check=="") {
      alert('Please tell us your phone number');
      document.form.phone.focus();
      return false;}

   check=document.getElementById('when').value;
   if (check=="") {
      alert('Please tell us the best day to call you');
      document.form.when.focus();
      return false;}

   check=document.getElementById('calltime').value;
   if (check=="") {
      alert('Please tell us the best time to call you');
      document.form.calltime.focus();
      return false;}

  document.getElementById('s3').style.visibility = 'visible';
  document.getElementById("s3").style.display="block";
  document.getElementById('s2show').style.visibility = 'hidden';
  document.form.title2.focus();

  return false;
}



// Validate section 3 + Show section 4
function s4() {

   var check;
   var check2;
   var yourStatus=document.getElementById('marital').value;

   if (yourStatus=="Married") {

   check=document.getElementById('title2').value;
   if (check=="") {
      alert('Please choose your partners title');
      document.form.title2.focus();
      return false;}

   check=document.getElementById('first2').value;
   if (check=="") {
      alert('Please tell us your partners first name');
      document.form.first2.focus();
      return false;}

   check=document.getElementById('surname2').value;
   if (check=="") {
      alert('Please tell us your partners surname');
      document.form.surname2.focus();
      return false;}

   check=document.getElementById('dobdd2').value;
   if (check=="") {
      alert('Please tell us the day of the month, for your partners date of birth');
      document.form.dobdd2.focus();
      return false;}
   check=document.getElementById('dobmm2').value;
   if (check=="") {
      alert('Please tell us the month, for your partners date of birth');
      document.form.dobmm2.focus();
      return false;}
   check=document.getElementById('dobyy2').value;
   if (check=="") {
      alert('Please tell us the year, of your partners date of birth');
      document.form.dobyy2.focus();
      return false;}

   check=document.getElementById('marital2').value;
   if (check=="") {
      alert('Please tell us your partners marital status');
      document.form.marital2.focus();
      return false;}

   check=document.getElementById('bank2').value;
   if (check=="") {
      alert('Please tell us how long your partner has been with their bank');
      document.form.bank2.focus();
      return false;}


   check=document.getElementById('employment2').value;
   if (check=="") {
      alert('Please tell us about your partners employment');
      document.form.employment2.focus();
      return false;}

   check=document.getElementById('yearsinjob2').value;
   if (check=="") {
      alert('Please tell us how long your partner has been employed');
      document.form.yearsinjob2.focus();
      return false;}


   check=document.getElementById('maiden2').value;
   check2=document.getElementById('title2').value;
   if (check==""&&check2=="Mrs") {
      alert('Please tell us your partners maiden name');
      document.form.maiden2.focus();
      return false;}

   check=document.getElementById('mothermaiden2').value;
   if (check=="") {
      alert('Please tell us your partners mothers maiden name');
      document.form.mothermaiden2.focus();
      return false;}


   check=document.getElementById('address2').value;
   if (check=="") {
      alert('Please tell us your partners address');
      document.form.address2.focus();
      return false;}

   check=document.getElementById('postcode2').value;
   if (check=="") {
      alert('Please tell us your partners postcode');
      document.form.postcode2.focus();
      return false;}

   check=document.getElementById('phone2').value;
   if (check=="") {
      alert('Please tell us your partners phone number');
      document.form.phone2.focus();
      return false;}

   check=document.getElementById('reside2').value;
   if (check=="") {
      alert('Please tell us whether your partner has permanent rights to reside in the UK');
      document.form.reside2.focus();
      return false;}


//   check=document.getElementById('when2').value;
//   if (check=="") {
//      alert('Please tell us the best day to call your partner');
//      document.form.when2.focus();
//      return false;}

//   check=document.getElementById('calltime2').value;
//   if (check=="") {
//      alert('Please tell us the best time to call your partner');
//      document.form.calltime2.focus();
//      return false;}

} // married


  document.getElementById('s4').style.visibility = 'visible';
  document.getElementById("s4").style.display="block";
  document.getElementById('s3show').style.visibility = 'hidden';
  document.form.propertyvalue.focus();
  return false;
}



// Validate section 4 + Show section 5
function s5() {

   var check;
   var check2;

   check=document.getElementById('propertyvalue').value;
   if (check=="") {
      alert('Please tell us the value of your property');
      document.form.propertyvalue.focus();
      return false;}

   check=document.getElementById('bedrooms').value;
   if (check=="") {
      alert('Please tell us how many bedrooms your property has');
      document.form.bedrooms.focus();
      return false;}

   check=document.getElementById('yearbuilt').value;
   if (check=="") {
      alert('Please tell us the year your property was built');
      document.form.yearbuilt.focus();
      return false;}

   check=document.getElementById('purchaseprice').value;
   if (check=="") {
      alert('Please tell us the amount you paid for your property');
      document.form.purchaseprice.focus();
      return false;}

   check=document.getElementById('purchasedate').value;
   if (check=="") {
      alert('Please tell us the date you purchased the property');
      document.form.purchasedate.focus();
      return false;}

   check=document.getElementById('propertytype').value;
   if (check=="") {
      alert('Please tell us about the type of property');
      document.form.propertytype.focus();
      return false;}


   check2=document.getElementById('floors').value;
   if (check2==""&&check=="Flat") {
      alert('Please tell us how many storeys are in your apartment block');
      document.form.floors.focus();
      return false;}

   check=document.getElementById('construction').value;
   if (check=="") {
      alert('Please tell us the construction of your property');
      document.form.construction.focus();
      return false;}


   check=document.getElementById('excouncil').value;

   if (check=="") {
      alert('Please tell us whether your home was purchased from the local authority');
      document.form.excouncil.focus();
      return false;}

   check2=document.getElementById('sittingtenant').value;
   if (check2==""&&check=="Yes") {
      alert('Please tell us if you purchased your home as a sitting tenant');
      document.form.sittingtenant.focus();
      return false;}

   check2=document.getElementById('councilvalue').value;
   if (check2==""&&check=="Yes") {
      alert('Please tell us the amount the council valued your your');
      document.form.councilvalue.focus();
      return false;}

   check2=document.getElementById('councildiscount').value;
   if (check2==""&&check=="Yes") {
      alert('Please tell us the amount the council gave you as a discount');
      document.form.councildiscount.focus();
      return false;}



  document.getElementById('s5').style.visibility = 'visible';
  document.getElementById("s5").style.display="block";
  document.getElementById('s4show').style.visibility = 'hidden';
  document.form.mortcompany.focus();
  return false;
}




// Validate section 5
function s6() {

   var check;
   var check2;



   check=document.getElementById('mortcompany').value;
   if (check=="") {
      alert('Please tell us who your mortgage is with');
      document.form.mortcompany.focus();
      return false;}

   check=document.getElementById('prevmort').value;
   if (check=="") {
      alert('Please tell us whether you have had a previous mortgage');
      document.form.prevmort.focus();
      return false;}

   check=document.getElementById('mortbal').value;
   if (check=="") {
      alert('Please tell us the outstanding balance of your mortgage');
      document.form.mortbal.focus();
      return false;}

   check=document.getElementById('monthly').value;
   if (check=="") {
      alert('Please tell us your monthly mortgage repayments');
      document.form.monthly.focus();
      return false;}

   check=document.getElementById('term').value;
   if (check=="") {
      alert('Please tell us the remaining time you have on your mortgage');
      document.form.term.focus();
      return false;}

   check=document.getElementById('morttype').value;
   if (check=="") {
      alert('Please tell us the type of mortgage you have');
      document.form.morttype.focus();
      return false;}

   check=document.getElementById('otherloan').value;
   if (check=="") {
      alert('Please tell us if you have any other loan secured on your home');
      document.form.otherloan.focus();
      return false;}


   check2=document.getElementById('othercompany').value;
   if (check=="Yes"&&check2=="") {
      alert('Please tell us the name of the company this loan is with');
      document.form.othercompany.focus();
      return false;}


   check2=document.getElementById('otheramount').value;
   if (check=="Yes"&&check2=="") {
      alert('Please tell us the amount of the loan secured on your home');
      document.form.otheramount.focus();
      return false;}

   check=document.form.accept;
   if (check.checked!==true) {
      alert('Please accept the terms and conditions');
//      document.form.otheramount.focus();
      return false;}

   document.form.submit();


}

// show 1st section
function FormSections() {
   document.getElementById('s1').style.visibility = 'hidden';
   document.getElementById('s2').style.visibility = 'hidden';
   document.getElementById('s3').style.visibility = 'hidden';
   document.getElementById('s4').style.visibility = 'hidden';
   document.getElementById('s5').style.visibility = 'hidden';

   document.getElementById("s1").style.display="none";
   document.getElementById("s2").style.display="none";
   document.getElementById("s3").style.display="none";
   document.getElementById("s4").style.display="none";
   document.getElementById("s5").style.display="none";


}

function tc() {
  tcwin=window.open('tc.shtml','TC', 'width=400,height=200,status=no,resizable=no,scrollbars=yes,top=200,left=200,dependent=yes,alwaysRaised=yes');
  tcwin.focus();
  }


window.onload = FormSections;


