document.observe("dom:loaded", function() {

  if ($('pv_rebate_household_income_current_year')) {
  	Event.observe('pv_rebate_household_income_current_year', 'change', function(e){
  		if (this.options[this.selectedIndex].value == '>$100,000') {
  			$('inform').appear().highlight();
  		} else {
  			$('inform').fade();
  		}
  	});
  };

  if ($('pv_rebate_govt_rebate_choice')) {
  	Event.observe('pv_rebate_govt_rebate_choice', 'change', function(e) {
  	  if (this.options[this.selectedIndex].value == 'true') {
  	    $('taxable_income').appear().highlight();
  	  } else {
  	    $('taxable_income').fade();
  	  };
  	});
  };

  if ($('solar_thermal_rebate_permanent_place_of_residence')) {
  	Event.observe('solar_thermal_rebate_permanent_place_of_residence', 'change', function(e) {
  	  if (this.options[this.selectedIndex].value == 'false') {
  	    $('inform_perm_residence_ineligibility').appear().highlight();
  	  } else {
  	    $('inform_perm_residence_ineligibility').fade();
  	  };
  	});
  };

  if ($('solar_thermal_rebate_new_home')) {
  	Event.observe('solar_thermal_rebate_new_home', 'change', function(e) {
  	  if (this.options[this.selectedIndex].value == 'true') {
  	    $('inform_new_home_ineligibility').appear().highlight();
  	  } else {
  	    $('inform_new_home_ineligibility').fade();
  	  };
  	});
  };

  if ($('solar_thermal_rebate_insulation_rebate_application')) {
  	Event.observe('solar_thermal_rebate_insulation_rebate_application', 'change', function(e) {
  	  if (this.options[this.selectedIndex].value == 'true') {
  	    $('inform_insulation_ineligibility').appear().highlight();
  	  } else {
  	    $('inform_insulation_ineligibility').fade();
  	  };
  	});
  };

  if ($('solar_thermal_rebate_residency_status')) {
  	Event.observe('solar_thermal_rebate_residency_status', 'change', function(e) {
  	  if (this.options[this.selectedIndex].value == 'Tenant') {
  	    $('inform_tenancy_permission').appear().highlight();
  	  } else {
  	    $('inform_tenancy_permission').fade();
  	  };
  	});
  };

  if ($('user_marketing_choice_id')) {
  	Event.observe('user_marketing_choice_id', 'change', function(e) {
  	  if (this.options[this.selectedIndex].text == 'Referred by a friend') {
  	    $('referrer_prompt').appear().highlight();
  	  } else {
  	    $('referrer_prompt').fade();
  	  };
  	});
  };

  if ($('solar_thermal_rebate_permission_sought')) {
  	Event.observe('solar_thermal_rebate_permission_sought', 'change', function(e) {
  	  if (this.options[this.selectedIndex].value == 'true') {
  	    $('inform_positive_permission').fade();
  	  } else {
  	    $('inform_positive_permission').appear().highlight();
  	  };
  	});
  };

  if ($('solar_thermal_rebate_type_of_system_replaced')) {
  	Event.observe('solar_thermal_rebate_type_of_system_replaced', 'change', function(e) {
  	  if (this.options[this.selectedIndex].value == 'Other') {
  			$('insulation_question').fade();
  	    $('other_system_to_be_replaced_text_box').appear().highlight();
  		} else if (this.options[this.selectedIndex].value == 'Electric') {
  			$('insulation_question').appear().highlight();
  			$('other_system_to_be_replaced_text_box').fade();
  	  } else {
  	    $('other_system_to_be_replaced_text_box').fade();
  				// need to fix this to not check if the neighbourhood is a regional one
  			$('insulation_question').fade();
  	  };
  	});
  };

  if ($('property_detail_property_type_id')) {
  	Event.observe('property_detail_property_type_id', 'change', function(e) {
  	  property_type = this.options[this.selectedIndex].text.toLowerCase()
  	  if (property_type == 'house') {
  	    $('apartment').blindUp();
  	    $('house').blindDown().highlight();
  	  } else if (property_type == 'apartment' || property_type == 'townhouse') {
  	      if ($('apartment').style.display == "none") {
  	        $('house').blindUp();
  	        $('apartment').blindDown()
          }
          $('apartment').highlight();
  	  }else{
  	    $('apartment').blindUp();
  	    $('house').blindUp();	      
  	  };
  	});
  };

  if ($('same_address')) {
  	Event.observe('same_address', 'change', function(e) {
  	  if (!this.checked) {
  	    $('postal_details').appear().highlight();
  	  } else {
  	    $('postal_details').fade();
  	  }
  	});
  };

  if ($('property_business')) {
  	Event.observe('property_business', 'change', function(e) {
  	  if (this.checked) {
  	    $('business_details').appear().highlight();
  	  } else {
  	    $('business_details').fade();
  	  }
  	});
  };


});


