﻿function ShowNextPage(){
  var intAmount = document.getElementById('Amount').value;
  var strClassName = 'none';
  if(intAmount<1000){
     strClassName = '';
  }
  document.getElementById('EmployerNameRow').style.display = strClassName;
  document.getElementById('EmploymentDurationRow').style.display = strClassName;
  //document.getElementById('NationalInsuranceNoRow').style.display = strClassName;
  //document.getElementById('NationalInsuranceNoOptRow').style.display = strClassName;
  document.getElementById('IsDirectDepositRow').style.display = strClassName;
  document.getElementById('PayFrequencyRow').style.display = strClassName;
  document.getElementById('PayDate1Row').style.display = strClassName;
  document.getElementById('PayDate2Row').style.display = strClassName;
  document.getElementById('DebitCardTypeCodeRow').style.display = strClassName;
  document.getElementById('BankAccountNoRow').style.display = strClassName;
  document.getElementById('BankDetailsRow').style.display = strClassName;
  document.getElementById('BankSortCodeRow').style.display = strClassName;
  document.getElementById('Warning').style.display = strClassName;
  HideItem('Page1');
  ShowItem('Page2');
  document.getElementById('Employed_0').focus();
}

function ShowPreviousPage(){
  ShowItem('Page1');
  HideItem('Page2');
}

function HideProcessing() {
  HideItem('Processing');
}

function ShowForm(){
  ShowNextPage();
  ShowItem('Page1');
  ShowItem('Page2');
  HideItem('btnNext');
  HideItem('HouseNameTextRow');
  HideItem('FindAddressButton');
  HideItem('btnPrevious');
}

function ShowRepaymentPeriod(){
  var intAmount = document.getElementById('Amount').value;
  if(intAmount<1000){
    HideItem('RepaymentPeriodsRow');
    ShowItem('DayNumberRow');
  }else{
    ShowItem('RepaymentPeriodsRow');
    HideItem('DayNumberRow');
  }
}

function DisableSubmitButton(){
  document.getElementById('btnPrevious').disabled = 'true';
  document.getElementById('btnSubmit').value = 'Processing...   ';
  document.getElementById('btnSubmit').disabled = 'true';
  HideItem('MainPage');
  HideItem('MainFooter');
  ShowItem('Processing');
}

function HideFormControlsPDL(){
  HideItem('PurposeRow');
  HideItem('SalutationRow');
  HideItem('FirstNameRow');
  HideItem('SurnameRow');
  HideItem('DayNumberRow');
  HideItem('EveningNumberRow');
  HideItem('MobileNumberRow');
  HideItem('EmailAddressRow');
  HideItem('DoBRow');
  HideItem('AddressDetailsRow');
  HideItem('HouseNameTextRow');
  HideItem('HouseNumberRow');
  HideItem('HouseNameRow');
  HideItem('AddressField1');
  HideItem('AddressField2');
  HideItem('AddressField3');
  HideItem('PostcodeRow');
  HideItem('AddressButton');
  HideItem('ResidentialStatusRow');
  HideItem('AddressYearsRow');
  HideItem('NextButtonRow');
  HideItem('EmployedRow');
  HideItem('OccupationRow');
  HideItem('EmploymentStatusRow');
  HideItem('IncomeRow');
  HideItem('Warning');
  HideItem('btnPrevious');

  ShowItem('EmployerNameRow');
  ShowItem('EmploymentDurationRow');
  ShowItem('NationalInsuranceNoRow');
  ShowItem('NationalInsuranceNoOptRow');
  ShowItem('IsDirectDepositRow');
  ShowItem('PayFrequencyRow');
  ShowItem('PayDate1Row');
  ShowItem('PayDate2Row');
  ShowItem('DebitCardTypeCodeRow');
  ShowItem('BankAccountNoRow');
  ShowItem('BankSortCodeRow');
  ShowItem('Page2');
}

function HideFormControlsUL(){
  HideItem('PurposeRow');
  HideItem('YourDetailsRow');
  HideItem('SalutationRow');
  HideItem('FirstNameRow');
  HideItem('SurnameRow');
  HideItem('DayNumberRow');
  HideItem('EveningNumberRow');
  HideItem('MobileNumberRow');
  HideItem('EmailAddressRow');
  HideItem('DoBRow');
  HideItem('AddressDetailsRow');
  HideItem('HouseNameTextRow');
  HideItem('HouseNumberRow');
  HideItem('HouseNameRow');
  HideItem('AddressField1');
  HideItem('AddressField2');
  HideItem('AddressField3');
  HideItem('PostcodeRow');
  HideItem('AddressButton');
  HideItem('ResidentialStatusRow');
  HideItem('AddressYearsRow');
  HideItem('NextButtonRow');
  HideItem('EmployedRow');
  HideItem('OccupationRow');
  HideItem('EmploymentStatusRow');
  HideItem('IncomeRow');
  HideItem('EmploymentDetailsRow');
  HideItem('BankDetailsRow');
  HideItem('Warning');
  HideItem('btnPrevious');
  HideItem('EmployerNameRow');
  HideItem('EmploymentDurationRow');
  HideItem('NationalInsuranceNoRow');
  HideItem('NationalInsuranceNoOptRow');
  HideItem('IsDirectDepositRow');
  HideItem('PayFrequencyRow');
  HideItem('PayDate1Row');
  HideItem('PayDate2Row');
  HideItem('DebitCardTypeCodeRow');
  HideItem('BankAccountNoRow');
  HideItem('BankSortCodeRow');

  ShowItem('RepaymentPeriodsRow');
  ShowItem('Page2');
}
function HideFormControlsProvident(){
  HideItem('RepaymentPeriodsRow');
  HideItem('PurposeRow');
  HideItem('ResidentialStatusRow');
  HideItem('EmployedRow');
}
function HidePPI(){
  HideItem('AdditionalInformationRow');
  HideItem('PPIHasTakenLoanRow');
  HideItem('PPIInsuranceRow');
  HideItem('PPIAdviceRow');
}
function ShowPPIQuestions(Id){
  HideItem('PPIInsuranceRow');
  HideItem('PPIAdviceRow');
  switch(Id){
    case 1:
      ShowItem('PPIHasTakenLoanRow');
      break;
    case 2:
      var d = document.getElementById('PPIHasTakenLoan_0');
      if (d.checked) {
        ShowItem('PPIInsuranceRow');
      }
      break;
    case 3:
      ShowItem('PPIInsuranceRow');
      var d = document.getElementById('PPIInsurance_0');
      var e = document.getElementById('PPIInsurance_2');
      if (d.checked||e.checked) {
        ShowItem('PPIAdviceRow');
      }
      break;
  }
}
function ShowDayNumber() {
  ShowItem('DayNumberRow');
}
function ShowEveningNumber() {
  ShowItem('EveningNumberRow');
}
function ShowMobileNumber() {
  ShowItem('MobileNumberRow');
}
function HideYourDetailsRow() {
  HideItem('YourDetailsRow');
}

function HideItem(Id) {
  if(document.getElementById(Id)){ document.getElementById(Id).style.display = 'none'; }
}
function ShowItem(Id){
  if(document.getElementById(Id)){ document.getElementById(Id).style.display = ''; }
}
