﻿
$(document).ready(function () {
   // Initial hide
   $('#webform-component-if_yes_how_many_primary_school_children').hide();
   $('#webform-component-if_yes_how_many_high_school_children').hide();
   $('#webform-component-if_yes_what_was_their_taxable_income_for_the_year').hide();
   $('#webform-component-spouse_details').hide();
   $('#webform-component-spouse_name').hide();
   $('#webform-component-spouse_date_of_birth').hide();
   $('#webform-component-health_insurance_details').hide();
   $('#webform-component-if_yes_what_is_your_hecs_debt').hide();
   $('#webform-component-if_yes_provide_details').hide();
   
   $('#webform-component-car_travel_details').hide();
   $('#webform-component-additional_deductions').hide();
   $('#webform-component-tax_attachment1').hide();
   $('#webform-component-tax_information2').hide();
   $('#webform-component-tax_information3').hide();
   $('#webform-component-tax_information4').hide();
   $('#webform-component-tax_information5').hide();




   // Has primary school children check
  $('#edit-submitted-do-you-have-primary-school-children-No').click(function () {
    if ($('#edit-submitted-do-you-have-primary-school-children-No').attr('checked')) {
      $('#webform-component-if_yes_how_many_primary_school_children').hide();
    }
  });

  $('#edit-submitted-do-you-have-primary-school-children-Yes').click(function () {
    if ($('#edit-submitted-do-you-have-primary-school-children-Yes').attr('checked')) {
      $('#webform-component-if_yes_how_many_primary_school_children').show();
    }
  });

   // Has high school children check
  $('#edit-submitted-do-you-have-high-school-children-No').click(function () {
    if ($('#edit-submitted-do-you-have-high-school-children-No').attr('checked')) {
      $('#webform-component-if_yes_how_many_high_school_children').hide();
    }
  });

  $('#edit-submitted-do-you-have-high-school-children-Yes').click(function () {
    if ($('#edit-submitted-do-you-have-high-school-children-Yes').attr('checked')) {
      $('#webform-component-if_yes_how_many_high_school_children').show();
    }
  });

 // Have spouse
  $('#edit-submitted-do-you-have-spouse-No').click(function () {
    if ($('#edit-submitted-do-you-have-spouse-No').attr('checked')) {
      $('#webform-component-spouse_details').hide();
      $('#webform-component-if_yes_what_was_their_taxable_income_for_the_year').hide();
      $('#webform-component-spouse_name').hide();
      $('#webform-component-spouse_date_of_birth').hide();
    }
  });

  $('#edit-submitted-do-you-have-spouse-Yes').click(function () {
    if ($('#edit-submitted-do-you-have-spouse-Yes').attr('checked')) {
      $('#webform-component-spouse_details').show();
      $('#webform-component-if_yes_what_was_their_taxable_income_for_the_year').show();
      $('#webform-component-spouse_name').show();
      $('#webform-component-spouse_date_of_birth').show();

    }
  });

 // Have health insurance
 $('#edit-submitted-do-you-have-private-health-insurance-with-hospital--No').click(function () {
    if ($('#edit-submitted-do-you-have-private-health-insurance-with-hospital--No').attr('checked')) {
      $('#webform-component-health_insurance_details').hide();
    }
  });

  $('#edit-submitted-do-you-have-private-health-insurance-with-hospital--Yes').click(function () {
    if ($('#edit-submitted-do-you-have-private-health-insurance-with-hospital--Yes').attr('checked')) {
      $('#webform-component-health_insurance_details').show();
    }
  });

// Car Details
$('#edit-submitted-is-car-used-for-work-No').click(function () {
    if ($('#edit-submitted-is-car-used-for-work-No').attr('checked')) {
      $('#webform-component-car_travel_details').hide();
    }
  });

  $('#edit-submitted-is-car-used-for-work-Yes').click(function () {
    if ($('#edit-submitted-is-car-used-for-work-Yes').attr('checked')) {
      $('#webform-component-car_travel_details').show();
    }
  });
// Have Hecs
 $('#edit-submitted-do-you-have-hecs-No').click(function () {
    if ($('#edit-submitted-do-you-have-hecs-No').attr('checked')) {
      $('#webform-component-if_yes_what_is_your_hecs_debt').hide();
    }
  });

  $('#edit-submitted-do-you-have-hecs-Yes').click(function () {
    if ($('#edit-submitted-do-you-have-hecs-Yes').attr('checked')) {
      $('#webform-component-if_yes_what_is_your_hecs_debt').show();
    }
  });

// direct debit
 $('#edit-submitted-do-you-want-your-refund-to-be-direct-debited-No').click(function () {
    if ($('#edit-submitted-do-you-want-your-refund-to-be-direct-debited-No').attr('checked')) {
      $('#webform-component-if_yes_what_is_your_bsb_and_ac_number').hide();
    }
  });


// recieve income
 $('#edit-submitted-did-you-receive-any-income-during-the-year-in-addition-No').click(function () {
    if ($('#edit-submitted-did-you-receive-any-income-during-the-year-in-addition-No').attr('checked')) {
      $('#webform-component-if_yes_provide_details').hide();
    }
  });

  $('#edit-submitted-did-you-receive-any-income-during-the-year-in-addition-Yes').click(function () {
    if ($('#edit-submitted-did-you-receive-any-income-during-the-year-in-addition-Yes').attr('checked')) {
      $('#webform-component-if_yes_provide_details').show();
    }
  });

// deductions
 $('#edit-submitted-do-you-have-tax-deductions-No').click(function () {
    if ($('#edit-submitted-do-you-have-tax-deductions-No').attr('checked')) {
      $('#webform-component-additional_deductions').hide();
    }
  });

  $('#edit-submitted-do-you-have-tax-deductions-Yes').click(function () {
    if ($('#edit-submitted-do-you-have-tax-deductions-Yes').attr('checked')) {
      $('#webform-component-additional_deductions').show();
    }
  });

// attachments

$('#edit-submitted-did-you-earn-income-financial-year-No').click(function () {
    if ($('#edit-submitted-did-you-earn-income-financial-year-No').attr('checked')) {
         $('#edit-tax-attachment1').mandatory = false;
         $('#webform-component-tax_attachment1').hide();
  	 $('#webform-component-tax_information2').hide();
  	 $('#webform-component-tax_information3').hide();
  	 $('#webform-component-tax_information4').hide();
  	 $('#webform-component-tax_information5').hide();

    }
  });

  $('#edit-submitted-did-you-earn-income-financial-year-Yes').click(function () {
    if ($('#edit-submitted-did-you-earn-income-financial-year-Yes').attr('checked')) {
        $('#edit-tax-attachment1').mandatory = true;
        $('#webform-component-tax_attachment1').show();
   	$('#webform-component-tax_information2').show();
   	$('#webform-component-tax_information3').show();
   	$('#webform-component-tax_information4').show();
   	$('#webform-component-tax_information5').show();

    }
  });


});
