$(document).ready( function() {
    /*$("#communication_post").each(function() {
		if ($(this).attr("checked") == true)
            {
                $('#communication_email').attr("checked", false);
                document.getElementById("communication_email").disabled = true;
            }
            $(this).click(function() 
            {
		       if ($(this).attr("checked") == true)
               {
                   $('#communication_email').attr("checked", false);
                   document.getElementById("communication_email").disabled = true;
               }
               else
               {
                   $('#communication_email').attr("checked", false);
                   document.getElementById("communication_email").disabled = false;
               }
           });
    });
        $("#communication_email").each(function() {
        // 3
		if ($(this).attr("checked") == true)
            {
                $('#communication_post').attr("checked", false);
                document.getElementById("communication_post").disabled = true;
            }
        $(this).click(function() 
            {
		       if ($(this).attr("checked") == true)
               {
                   $('#communication_post').attr("checked", false);
                   document.getElementById("communication_post").disabled = true;
               }
               else
               {
                   $('#communication_post').attr("checked", false);
                   document.getElementById("communication_post").disabled = false;
               }
           });
    });*/
    $(".checklist input").each(function() {
        // 3
		if( $(this).attr("id") == "cCavityWall")
        {
            if ($(this).attr("checked") == true)
            {
                $('#cInternalWall').attr("checked", false);
                $('#cExternalWall').attr("checked", false);
                document.getElementById("cInternalWall").disabled = true;
                document.getElementById("cExternalWall").disabled = true;
            }
            $(this).click(function() 
            {
		       if ($(this).attr("checked") == true)
               {
                   $('#cInternalWall').attr("checked", false);
                   $('#cExternalWall').attr("checked", false);
                   document.getElementById("cInternalWall").disabled = true;
                   document.getElementById("cExternalWall").disabled = true;
               }
               else
               {
                   $('#cInternalWall').attr("checked", false);
                   $('#cExternalWall').attr("checked", false);
                   document.getElementById("cInternalWall").disabled = false;
                   document.getElementById("cExternalWall").disabled = false;
               }
           });
        }
        // 7
        if( $(this).attr("id") == "cInternalWall")
        {
            if ($(this).attr("checked") == true)
            {
                $('#cCavityWall').attr("checked", false);
                document.getElementById("cCavityWall").disabled = true;
                $('#cExternalWall').attr("checked", false);
                document.getElementById("cExternalWall").disabled = true;
                
                
            }
            $(this).click(function() 
            {
		       if ($(this).attr("checked") == true)
               {
                   $('#cCavityWall').attr("checked", false);
                   document.getElementById("cCavityWall").disabled = true;
                   $('#cExternalWall').attr("checked", false);
                document.getElementById("cExternalWall").disabled = true;
               }
               else
               {
                   $('#cCavityWall').attr("checked", false);
                   document.getElementById("cCavityWall").disabled = false;
                   $('#cExternalWall').attr("checked", false);
                   document.getElementById("cExternalWall").disabled = false;
               }
           });
        }
        // 8
        if( $(this).attr("id") == "cExternalWall")
        {
            if ($(this).attr("checked") == true)
            {
                $('#cInternalWall').attr("checked", false);
                document.getElementById("cInternalWall").disabled = true;
                $('#cCavityWall').attr("checked", false);
                document.getElementById("cCavityWall").disabled = true;
                
                
            }
            $(this).click(function() 
            {
		       if ($(this).attr("checked") == true)
               {
                   $('#cInternalWall').attr("checked", false);
                   document.getElementById("cInternalWall").disabled = true;
                   $('#cCavityWall').attr("checked", false);
                document.getElementById("cCavityWall").disabled = true;
               }
               else
               {
                   $('#cInternalWall').attr("checked", false);
                   document.getElementById("cInternalWall").disabled = false;
                   $('#cCavityWall').attr("checked", false);
                   document.getElementById("cCavityWall").disabled = false;
               }
           });
        }
        if( $(this).attr("id") == "cLoft")
        {
            if ($(this).attr("checked") == true)
            {
                $('#cLoft50').attr("checked", false);
                document.getElementById("cLoft50").disabled = true;
            }
            $(this).click(function() 
            {
		       if ($(this).attr("checked") == true)
               {
                   $('#cLoft50').attr("checked", false);
                   document.getElementById("cLoft50").disabled = true;
               }
               else
               {
                   $('#cLoft50').attr("checked", false);
                   document.getElementById("cLoft50").disabled = false;
               }
           });
        }
        if( $(this).attr("id") == "cLoft50")
        {
            if ($(this).attr("checked") == true)
            {
                $('#cLoft').attr("checked", false);
                document.getElementById("cLoft").disabled = true;
            }
            $(this).click(function() 
            {
		       if ($(this).attr("checked") == true)
               {
                   $('#cLoft').attr("checked", false);
                   document.getElementById("cLoft").disabled = true;
               }
               else
               {
                   $('#cLoft').attr("checked", false);
                   document.getElementById("cLoft").disabled = false;
               }
           });
        }
        if( $(this).attr("id") == "cSimpleTipturnlightsoff")
        {
            if ($(this).attr("checked") == true)
            {
                $('#cLightbulbs').attr("checked", false);
                document.getElementById("cLightbulbs").disabled = true;
            }
            $(this).click(function() 
            {
		       if ($(this).attr("checked") == true)
               {
                   $('#cLightbulbs').attr("checked", false);
                   document.getElementById("cLightbulbs").disabled = true;
               }
               else
               {
                   $('#cLightbulbs').attr("checked", false);
                   document.getElementById("cLightbulbs").disabled = false;
               }
           });
        }
        if( $(this).attr("id") == "cLightbulbs")
        {
            if ($(this).attr("checked") == true)
            {
                $('#cSimpleTipturnlightsoff').attr("checked", false);
                document.getElementById("cSimpleTipturnlightsoff").disabled = true;
            }
            $(this).click(function() 
            {
		       if ($(this).attr("checked") == true)
               {
                   $('#cSimpleTipturnlightsoff').attr("checked", false);
                   document.getElementById("cSimpleTipturnlightsoff").disabled = true;
               }
               else
               {
                   $('#cSimpleTipturnlightsoff').attr("checked", false);
                   document.getElementById("cSimpleTipturnlightsoff").disabled = false;
               }
           });
        }
        if( $(this).attr("id") == "cCondensingheating")
        {
            if ($(this).attr("checked") == true)
            {
                $('#cCondensingboiler').attr("checked", false);
                document.getElementById("cCondensingboiler").disabled = true;
            }
            $(this).click(function() 
            {
		       if ($(this).attr("checked") == true)
               {
                   $('#cCondensingboiler').attr("checked", false);
                   document.getElementById("cCondensingboiler").disabled = true;
               }
               else
               {
                   $('#cCondensingboiler').attr("checked", false);
                   document.getElementById("cCondensingboiler").disabled = false;
               }
           });
        }
        if( $(this).attr("id") == "cCondensingboiler")
        {
            if ($(this).attr("checked") == true)
            {
                $('#cCondensingheating').attr("checked", false);
                document.getElementById("cCondensingheating").disabled = true;
            }
            $(this).click(function() 
            {
		       if ($(this).attr("checked") == true)
               {
                   $('#cCondensingheating').attr("checked", false);
                   document.getElementById("cCondensingheating").disabled = true;
               }
               else
               {
                   $('#cCondensingheating').attr("checked", false);
                   document.getElementById("cCondensingheating").disabled = false;
               }
           });
        }
	});
	
	$(".cutter-button").hover(
		function(){$(this).addClass("cutter-button-on"); },
		function(){$(this).removeClass("cutter-button-on"); }
	);
	
	//adds rollovers on form buttons
	$(".button-rollover input").each(function() {
		$(this).hover(
			function(){$(this).attr("src", $(this).attr("src").replace(".gif","-on.gif")); },
			function(){$(this).attr("src", $(this).attr("src").replace("-on.gif",".gif")); }
		);
	});
	$(".button-rollover img").each(function() {
		$(this).hover(
			function(){$(this).attr("src", $(this).attr("src").replace(".gif","-on.gif")); },
			function(){$(this).attr("src", $(this).attr("src").replace("-on.gif",".gif")); }
		);
	});
	
	$(".additional-question").hide();
	$("#property-type input").click(function() {
		var propType = $(this).attr("id");
		switch (propType) {
			 case "cFlat":
				$(".additional-question").hide("fast");
			break;
			case "cHouse":
				$(".additional-question").hide();
				$("#house-type").show("fast");
			break;
			 case "cMaisonette":
				$(".additional-question").hide("fast");
			break;
			case "cBungalow":
				$(".additional-question").hide();
				$("#bungalow-type").show("fast");
			break;
		}
	});
	$("#payment-type select[@name='BillPayments']").change(function() {
		var paymentType = $(this).attr("value");
		switch (paymentType) {
			 case "monthly":
				$(".additional-question").hide();
				$('#spendusage').empty();
                    $('#spendusage').append('What is your monthly spend/usage?');
				var selected=$('#cElectricityType').attr("value");
			 	$('#cElectricityType').empty();
			 	$('<option value="">Please select</option>').appendTo('#cElectricityType');
                if ( selected == "money" )
			 	   $('<option value="money" selected="selected">&pound;</option>').appendTo('#cElectricityType');
		 	    else
		 	        $('<option value="money">&pound;</option>').appendTo('#cElectricityType');
                if ( selected == "amount" )
		 	        $('<option value="amount" selected="selected">kWh</option>').appendTo('#cElectricityType');
	 	        else
	 	            $('<option value="amount">kWh</option>').appendTo('#cElectricityType');
				var selected=$('#cGasBillType').attr("value");
			 	$('#cGasBillType').empty();
			 	$('<option value="">Please select</option>').appendTo('#cGasBillType');
                if ( selected == "money" )
			 	   $('<option value="money" selected="selected">&pound;</option>').appendTo('#cGasBillType');
		 	    else
		 	        $('<option value="money">&pound;</option>').appendTo('#cGasBillType');
                if ( selected == "amount" )
		 	        $('<option value="amount" selected="selected">kWh</option>').appendTo('#cGasBillType');
	 	        else
	 	            $('<option value="amount">kWh</option>').appendTo('#cGasBillType');
			 	$("#payment-type").addClass("hrule");
				$("#bill-payment").show("fast");
			break;
			case "prepayment":
				$(".additional-question").hide();
				$('#spendusage').empty();
                    $('#spendusage').append('What is your monthly spend/usage?');
			 	$('#cElectricityType').empty();
		 	    $('<option value="money" selected="selected">&pound;</option>').appendTo('#cElectricityType');
		 	    
				$('#cGasBillType').empty();
                $('<option value="money" selected="selected">&pound;</option>').appendTo('#cGasBillType');
                
			 	$("#payment-type").addClass("hrule");
				$("#bill-payment").show("fast");
			break;
			case "quarterly":
				$('#spendusage').empty();
                $('#spendusage').append('What is your quarterly spend/usage?');
				var selected=$('#cElectricityType').attr("value");
			 	$('#cElectricityType').empty();
			 	$('<option value="">Please select</option>').appendTo('#cElectricityType');
                if ( selected == "money" )
			 	   $('<option value="money" selected="selected">&pound;</option>').appendTo('#cElectricityType');
		 	    else
		 	        $('<option value="money">&pound;</option>').appendTo('#cElectricityType');
                if ( selected == "amount" )
		 	        $('<option value="amount" selected="selected">kWh</option>').appendTo('#cElectricityType');
	 	        else
	 	            $('<option value="amount">kWh</option>').appendTo('#cElectricityType');
				var selected=$('#cGasBillType').attr("value");
			 	$('#cGasBillType').empty();
			 	$('<option value="">Please select</option>').appendTo('#cGasBillType');
                if ( selected == "money" )
			 	   $('<option value="money" selected="selected">&pound;</option>').appendTo('#cGasBillType');
		 	    else
		 	        $('<option value="money">&pound;</option>').appendTo('#cGasBillType');
                if ( selected == "amount" )
		 	        $('<option value="amount" selected="selected">kWh</option>').appendTo('#cGasBillType');
	 	        else
	 	            $('<option value="amount">kWh</option>').appendTo('#cGasBillType');
			 	$("#payment-type").addClass("hrule");
				$("#season").show("fast");
				if( $("#season select[@name='BillSeason']").attr("value") != null )
				    $("#bill-payment").show("fast");
			    $('#spendusage').hide();
			break;
			case "delivery":
				$(".additional-question").hide();
				$('#spendusage').empty();
                $('#spendusage').append('What is your delivery spend/usage?');
			 	$("#payment-type").addClass("hrule");
			 	var selected=$('#cElectricityType').attr("value");
			 	$('#cElectricityType').empty();
			 	$('<option value="">Please select</option>').appendTo('#cElectricityType');
                if ( selected == "money" )
			 	   $('<option value="money" selected="selected">&pound;</option>').appendTo('#cElectricityType');
		 	    else
		 	        $('<option value="money">&pound;</option>').appendTo('#cElectricityType');
                if ( selected == "amount" )
		 	        $('<option value="amount" selected="selected">kWh</option>').appendTo('#cElectricityType');
	 	        else
	 	            $('<option value="amount">kWh</option>').appendTo('#cElectricityType');
			 	var selected=$('#cGasBillType').attr("value");
			 	$('#cGasBillType').empty();
			 	$('<option value="">Please select</option>').appendTo('#cGasBillType');
                if ( selected == "money" )
			 	   $('<option value="money" selected="selected">&pound;</option>').appendTo('#cGasBillType');
		 	    else
		 	        $('<option value="money">&pound;</option>').appendTo('#cGasBillType');
                if ( selected == "amount" )
		 	        $('<option value="amount" selected="selected">kWh</option>').appendTo('#cGasBillType');
	 	        else
	 	            $('<option value="amount">kWh</option>').appendTo('#cGasBillType');
				$("#deliveries").show("fast");
			break;
			 case "yearly":
				$(".additional-question").hide();
				$('#spendusage').empty();
                $('#spendusage').append('What is your yearly spend/usage?');
			 	$("#payment-type").addClass("hrule");
			 	$('<option value="">Please select</option>').appendTo('#cElectricityType');
			 	var selected=$('#cElectricityType').attr("value");
			 	$('#cElectricityType').empty();
                if ( selected == "money" )
			 	   $('<option value="money" selected="selected">&pound;</option>').appendTo('#cElectricityType');
		 	    else
		 	        $('<option value="money">&pound;</option>').appendTo('#cElectricityType');
                if ( selected == "amount" )
		 	        $('<option value="amount" selected="selected">kWh</option>').appendTo('#cElectricityType');
	 	        else
	 	            $('<option value="amount">kWh</option>').appendTo('#cElectricityType');
			 	
			 	var selected=$('#cGasBillType').attr("value");
			 	$('#cGasBillType').empty();
			 	$('<option value="">Please select</option>').appendTo('#cGasBillType');
                if ( selected == "money" )
			 	   $('<option value="money" selected="selected">&pound;</option>').appendTo('#cGasBillType');
		 	    else
		 	        $('<option value="money">&pound;</option>').appendTo('#cGasBillType');
                if ( selected == "amount" )
		 	        $('<option value="amount" selected="selected">kWh</option>').appendTo('#cGasBillType');
	 	        else
	 	            $('<option value="amount">kWh</option>').appendTo('#cGasBillType');
	 	            
				$("#bill-payment").show("fast");
			break;
		}
	});

	
	$("#payment-type option").click(function() {
		var paymentType = $(this).attr("value");
		switch (paymentType) {
			 case "monthly":
				$(".additional-question").hide();
			 	$("#payment-type").addClass("hrule");
		            $('#spendusage').empty();
                    $('#spendusage').append('What is your monthly spend/usage?');
				$("#deliveries").hide();
				$("#bill-payment").show("fast");
			break;
			case "prepayment":
			    $("#deliveries").hide();
				$(".additional-question").hide();
			 	$("#payment-type").addClass("hrule");
			 	    $('#spendusage').empty();
                    $('#spendusage').append('What is your monthly spend/usage?');
				$("#bill-payment").show("fast");
			break;
			case "quarterly":
			    $("#deliveries").hide();
				$(".additional-question").hide();
			 	$("#payment-type").addClass("hrule");
			 	   $('#spendusage').empty();
                   $('#spendusage').append('What is your quarterly spend/usage?');
				$("#season").show("fast");
			break;
			case "delivery":
				$(".additional-question").hide();
			 	$("#payment-type").addClass("hrule");
	            $('#spendusage').empty();
                $('#spendusage').append('What is your delivery spend/usage?');
				$("#deliveries").show("fast");
			break;
			 case "yearly":
			    $("#deliveries").hide();
				$(".additional-question").hide();
			 	$("#payment-type").addClass("hrule");
			 	   $('#spendusage').empty();
                   $('#spendusage').append('What is your yearly spend/usage?');
				$("#bill-payment").show("fast");
			break;
		}
	});
		$(".form-row select").each(function() {
	        if( $(this).attr("name") == "BillPayments")
	        {
	               if( $(this).attr("value") == "delivery")
	               {
	                   $(".additional-question").hide();
			 	       $("#payment-type").addClass("hrule");
			 	       $("#deliveries").show("fast");
				       $("#deliveries").addClass("hrule");
				        $('#spendusage').empty();
                        $('#spendusage').append('What is your delivery spend/usage?');
		               $("#bill-payment").show("fast");
	               }
	               if( $(this).attr("value") == "quarterly")
	               {
	                   $('#spendusage').empty();
                       $('#spendusage').append('What is your quarterly spend/usage?');
	                   $(".additional-question").hide();
			 	       $("#payment-type").addClass("hrule");
				       $("#season").show("fast");
				       $("#season").addClass("hrule");
		               $("#bill-payment").show("fast");
	               }
	               if( $(this).attr("value") == "monthly")
	               {
	                   $('#spendusage').empty();
                        $('#spendusage').append('What is your monthly spend/usage?');
	                   $(".additional-question").hide();
			 	       $("#payment-type").addClass("hrule");
				       $("#bill-payment").show("fast");
	               }
	               if( $(this).attr("value") == "prepayment")
	               {
	                   $('#spendusage').empty();
                        $('#spendusage').append('What is your monthly spend/usage?');
	                   $(".additional-question").hide();
			 	       $("#payment-type").addClass("hrule");
			 	       $('#cElectricityType').empty();
                       $('<option value="money">&pound;</option>').appendTo('#cElectricityType');
			 	       $('#cGasBillType').empty();
                       $('<option value="money">&pound;</option>').appendTo('#cGasBillType');
				       $("#bill-payment").show("fast");
	               }
	               if( $(this).attr("value") == "yearly")
	               {
	                   $('#spendusage').empty();
                        $('#spendusage').append('What is your yearly spend/usage?');
	                   $(".additional-question").hide();
			 	       $("#payment-type").addClass("hrule");
				       $("#bill-payment").show("fast");
	               }
	        }
	});
	
	$(".form-row select").each(function() {
	        if( $(this).attr("id") == "cMainHeating")
	        {
	            if( $(this).attr("value") == "")
	            {
	                $("#cHouseType-detail").hide();
                   $("#cBedrooms-detail").hide();
	            }
	               $(this).change(function() 
	               {
				       if( $(this).attr("value") != "")
    	               {
    	                   $("#cHouseType-detail").show("fast");
    	                   if( $("#cHouseType").attr("value") != "")
        	               {
        	                   $("#cBedrooms-detail").show("fast");
        	                   if( $("#cBedrooms").attr("value") != "")
        	                   {
        	                       $("#checklist_form")[0].submit();
        	                   }
        	               }
    	               }
    	               else
    	               {
    	                   $("#cHouseType-detail").hide();
    	                   $("#cBedrooms-detail").hide();
    	               }
                   });
	        }
	        if( $(this).attr("id") == "cHouseType")
	        {
	            if( $(this).attr("value") == "")
	            {
                   $("#cBedrooms-detail").hide();
	            }
	            else
	            {
	                var preselectbed = $("#cBedrooms").attr("value");
	                if( $(this).attr("value") == "1" || $(this).attr("value") == "2")
    	                   {
    	                      $("#cBedrooms").empty();
                              $('<option value="">Please select</option>').appendTo($("#cBedrooms"));
                              $('<option value="1">1</option>').appendTo($("#cBedrooms"));
                              $('<option value="2">2</option>').appendTo($("#cBedrooms"));
                              $('<option value="3">3</option>').appendTo($("#cBedrooms"));
                              document.getElementById("cBedrooms")[preselectbed].selected = true;
                              
    	                   }
    	                   if( $(this).attr("value") == "3" || $(this).attr("value") == "4" ||  $(this).attr("value") == "5")
    	                   {
    	                      $("#cBedrooms").empty();
                              $('<option value="">Please select</option>').appendTo($("#cBedrooms"));
                              $('<option value="2">2</option>').appendTo($("#cBedrooms"));
                              $('<option value="3">3</option>').appendTo($("#cBedrooms"));
                              if( preselectbed != 1 || preselectbed != 4 )  
                                document.getElementById("cBedrooms")[preselectbed-1].selected = true;
                              else
                                document.getElementById("cBedrooms")[0].selected = true;

    	                   }
    	                   
    	                   if( $(this).attr("value") == "6" || $(this).attr("value") == "7" ||  $(this).attr("value") == "8")
    	                   {
    	                       $("#cBedrooms").empty();
                              $('<option value="">Please select</option>').appendTo($("#cBedrooms"));
                              $('<option value="2">2</option>').appendTo($("#cBedrooms"));
                              $('<option value="3">3</option>').appendTo($("#cBedrooms"));
                              $('<option value="4">4</option>').appendTo($("#cBedrooms"));
                              if( preselectbed != 1 )  
                                document.getElementById("cBedrooms")[preselectbed-1].selected = true;
                              else
                                document.getElementById("cBedrooms")[0].selected = true;
    	                   }
	                
	                
	            }
	               $(this).change(function() 
	               {
				       if( $(this).attr("value") != "")
    	               {
    	                   
    	                   if( $("#cBedrooms").attr("value") != "")
	                       {
	                           var preselectbed = $("#cBedrooms").attr("value");
	                       }
	                       else
	                       {
	                           var preselectbed = 0;
	                       }
    	                   if( $(this).attr("value") == "1" || $(this).attr("value") == "2")
    	                   {
    	                       $("#cBedrooms").empty();
    	                       if( preselectbed == 0 )
                                  $('<option value="" selected="selected">Please select</option>').appendTo($("#cBedrooms"));
                               else
                                  $('<option value="">Please select</option>').appendTo($("#cBedrooms"));
                               
                               if( preselectbed == 1 )
                                  $('<option value="1" selected="selected">1</option>').appendTo($("#cBedrooms"));
                               else
                                  $('<option value="1">1</option>').appendTo($("#cBedrooms"));
                                  
                               if( preselectbed == 2 )
                                  $('<option value="2" selected="selected">2</option>').appendTo($("#cBedrooms"));
                               else
                                  $('<option value="2">2</option>').appendTo($("#cBedrooms"));
                               
                              if( preselectbed == 3 )
                                  $('<option value="3" selected="selected">3</option>').appendTo($("#cBedrooms"));
                               else
                                  $('<option value="3">3</option>').appendTo($("#cBedrooms"));
                              document.getElementById("cBedrooms")[0].selected = true;
                              
    	                   }
    	                   if( $(this).attr("value") == "3" || $(this).attr("value") == "4" ||  $(this).attr("value") == "5")
    	                   {
    	                       $("#cBedrooms").empty();
    	                       if( preselectbed == 0 )
                                  $('<option value="" selected="selected">Please select</option>').appendTo($("#cBedrooms"));
                               else
                                  $('<option value="">Please select</option>').appendTo($("#cBedrooms"));
                                  
                               if( preselectbed == 2 )
                                  $('<option value="2" selected="selected">2</option>').appendTo($("#cBedrooms"));
                               else
                                  $('<option value="2">2</option>').appendTo($("#cBedrooms"));
                               
                               if( preselectbed == 3 )
                                  $('<option value="3" selected="selected">3</option>').appendTo($("#cBedrooms"));
                               else
                                  $('<option value="3">3</option>').appendTo($("#cBedrooms"));
                              document.getElementById("cBedrooms")[0].selected = true;

    	                   }
    	                   
    	                   if( $(this).attr("value") == "6" || $(this).attr("value") == "7" ||  $(this).attr("value") == "8")
    	                   {
    	                       $("#cBedrooms").empty();
    	                       if( preselectbed == 0 )
                                  $('<option value="" selected="selected">Please select</option>').appendTo($("#cBedrooms"));
                               else
                                  $('<option value="">Please select</option>').appendTo($("#cBedrooms"));
                                  
                               if( preselectbed == 2 )
                                  $('<option value="2" selected="selected">2</option>').appendTo($("#cBedrooms"));
                               else
                                  $('<option value="2">2</option>').appendTo($("#cBedrooms"));
                               
                               if( preselectbed == 3 )
                                  $('<option value="3" selected="selected">3</option>').appendTo($("#cBedrooms"));
                               else
                                  $('<option value="3">3</option>').appendTo($("#cBedrooms"));
                                  
                              if( preselectbed == 4 )
                                  $('<option value="4" selected="selected">4</option>').appendTo($("#cBedrooms"));
                               else
                                  $('<option value="4">4</option>').appendTo($("#cBedrooms"));
                            document.getElementById("cBedrooms")[0].selected = true;
    	                   }
    	                   
    	                   $("#cBedrooms-detail").show("fast");
    	                   if( $("#cBedrooms").attr("value") != "" && preselectbed != 0)
    	                   {
    	                       $("#checklist_form")[0].submit();
    	                   }
    	                       
    	               }
    	               else
    	               {
    	                   $("#cBedrooms-detail").hide();
    	               }
                   });
	        }
	        if( $(this).attr("id") == "cBedrooms")
	        {
	            if( $(this).attr("value") == "")
	            {
                   $("#checklist-content").hide();
	            }
	               $(this).change(function() 
	               {
				       if( $(this).attr("value") != "")
    	               {
    	                   $("#checklist_form")[0].submit();
    	                   
    	               }
    	               else
    	               {
    	                   $("#checklist-content").hide();
    	                   $("#checklist-content_button").hide();
    	               }
                   });
	        }
	        if( $(this).attr("name") == "fridge_age_1")
	        {
	               if( $(this).attr("value") == "over 12 years")
	               {
			 	       $("#c1_FridgeEnergyRating").hide();
	               }
	               $(this).change(function() 
	               {
				       if( $(this).attr("value") == "over 12 years")
    	               {
    			 	       $("#c1_FridgeEnergyRating").hide();
    	               }
    	               else
    	               {
    	                   $("#c1_FridgeEnergyRating").show("fast");
    	               }
                   });
	        }
	        if( $(this).attr("name") == "fridge_age_2")
	        {
	               if( $(this).attr("value") == "over 12 years")
	               {
			 	       $("#c2_FridgeEnergyRating").hide();
	               }
	               $(this).change(function() 
	               {
				       if( $(this).attr("value") == "over 12 years")
    	               {
    			 	       $("#c2_FridgeEnergyRating").hide();
    	               }
    	               else
    	               {
    	                   $("#c2_FridgeEnergyRating").show("fast");
    	               }
                   });
	        }
	        if( $(this).attr("name") == "fridge_age_3")
	        {
	               if( $(this).attr("value") == "over 12 years")
	               {
			 	       $("#c3_FridgeEnergyRating").hide();
	               }
	               $(this).change(function() 
	               {
				       if( $(this).attr("value") == "over 12 years")
    	               {
    			 	       $("#c3_FridgeEnergyRating").hide();
    	               }
    	               else
    	               {
    	                   $("#c3_FridgeEnergyRating").show("fast");
    	               }
                   });
	        }
	        if( $(this).attr("name") == "fridgefreezer_age_1")
	        {
	               if( $(this).attr("value") == "over 12 years")
	               {
			 	       $("#c1_FreezerEnergyRating").hide();
	               }
	               $(this).change(function() 
	               {
				       if( $(this).attr("value") == "over 12 years")
    	               {
    			 	       $("#c1_FreezerEnergyRating").hide();
    	               }
    	               else
    	               {
    	                   $("#c1_FreezerEnergyRating").show("fast");
    	               }
                   });
	        }
	        if( $(this).attr("name") == "fridgefreezer_age_2")
	        {
	               if( $(this).attr("value") == "over 12 years")
	               {
			 	       $("#c2_FreezerEnergyRating").hide();
	               }
	               $(this).change(function() 
	               {
				       if( $(this).attr("value") == "over 12 years")
    	               {
    			 	       $("#c2_FreezerEnergyRating").hide();
    	               }
    	               else
    	               {
    	                   $("#c2_FreezerEnergyRating").show("fast");
    	               }
                   });
	        }
	        if( $(this).attr("name") == "fridgefreezer_age_3")
	        {
	               if( $(this).attr("value") == "over 12 years")
	               {
			 	       $("#c3_FreezerEnergyRating").hide();
	               }
	               $(this).change(function() 
	               {
				       if( $(this).attr("value") == "over 12 years")
    	               {
    			 	       $("#c3_FreezerEnergyRating").hide();
    	               }
    	               else
    	               {
    	                   $("#c3_FreezerEnergyRating").show("fast");
    	               }
                   });
	        }
	        if( $(this).attr("name") == "upright_age_1")
	        {
	               if( $(this).attr("value") == "over 12 years")
	               {
			 	       $("#c1_UprightEnergyRating").hide();
	               }
	               $(this).change(function() 
	               {
				       if( $(this).attr("value") == "over 12 years")
    	               {
    			 	       $("#c1_UprightEnergyRating").hide();
    	               }
    	               else
    	               {
    	                   $("#c1_UprightEnergyRating").show("fast");
    	               }
                   });
	        }
	        if( $(this).attr("name") == "upright_age_2")
	        {
	               if( $(this).attr("value") == "over 12 years")
	               {
			 	       $("#c2_UprightEnergyRating").hide();
	               }
	               $(this).change(function() 
	               {
				       if( $(this).attr("value") == "over 12 years")
    	               {
    			 	       $("#c2_UprightEnergyRating").hide();
    	               }
    	               else
    	               {
    	                   $("#c2_UprightEnergyRating").show("fast");
    	               }
                   });
	        }
	        if( $(this).attr("name") == "upright_age_3")
	        {
	               if( $(this).attr("value") == "over 12 years")
	               {
			 	       $("#c3_UprightEnergyRating").hide();
	               }
	               $(this).change(function() 
	               {
				       if( $(this).attr("value") == "over 12 years")
    	               {
    			 	       $("#c3_UprightEnergyRating").hide();
    	               }
    	               else
    	               {
    	                   $("#c3_UprightEnergyRating").show("fast");
    	               }
                   });
	        }
	});
	
	
	$("#deliveries select").change(function() {
		$("#deliveries").addClass("hrule");
		$("#bill-payment").show("fast");
	});
	$("#season select").change(function() {
		$("#season").addClass("hrule");
		$("#bill-payment").show("fast");
	});
	
	$("#fridge-type input").click(function() {
		//$(".add-another").hide();
		var fridgeType = $(this).attr("id");
		switch (fridgeType) {
			 case "cFridge":
				if ($(this).attr("checked") == true) {$("#fridge-details").show("fast"); } else {$("#fridge-details").hide(); }
			break;
			case "cFridgeFreezer":
				if ($(this).attr("checked") == true) {$("#fridgefreezer-details").show("fast");} else {$("#fridgefreezer-details").hide(); }
			break;
			case "cChestUpright":
				if ($(this).attr("checked") == true) {$("#freezer-details").show("fast");} else {$("#freezer-details").hide(); }
			break;
			case "cFridgeNone":
				$(".additional-question").hide();
			break;
		}
	});
	
	$("#1_fridge-type input").click(function() {
		//$(".add-another").hide();
		var fridgeType = $(this).attr("id");
		switch (fridgeType) {
			 case "c1_Fridge":
				if ($(this).attr("checked") == true) {$("#1_fridge-details").show("fast"); } else {$("#1_fridge-details").hide(); }
			break;
			case "c1_FridgeFreezer":
				if ($(this).attr("checked") == true) {$("#1_fridgefreezer-details").show("fast");} else {$("#1_fridgefreezer-details").hide(); }
			break;
			case "c1_ChestUpright":
				if ($(this).attr("checked") == true) {$("#1_freezer-details").show("fast");} else {$("#1_freezer-details").hide(); }
			break;
			case "c1_FridgeNone":
				$(".additional-question").hide();
			break;
		}
	});
	
	$("#2_fridge-type input").click(function() {
		//$(".add-another").hide();
		var fridgeType = $(this).attr("id");
		switch (fridgeType) {
			 case "c2_Fridge":
				if ($(this).attr("checked") == true) {$("#2_fridge-details").show("fast"); } else {$("#2_fridge-details").hide(); }
			break;
			case "c2_FridgeFreezer":
				if ($(this).attr("checked") == true) {$("#2_fridgefreezer-details").show("fast");} else {$("#2_fridgefreezer-details").hide(); }
			break;
			case "c2_ChestUpright":
				if ($(this).attr("checked") == true) {$("#2_freezer-details").show("fast");} else {$("#2_freezer-details").hide(); }
			break;
			case "c2_FridgeNone":
				$(".additional-question").hide();
			break;
		}
	});
	
	$("#3_fridge-type input").click(function() {
		//$(".add-another").hide();
		var fridgeType = $(this).attr("id");
		switch (fridgeType) {
			 case "c3_Fridge":
				if ($(this).attr("checked") == true) {$("#3_fridge-details").show("fast"); } else {$("#3_fridge-details").hide(); }
			break;
			case "c3_FridgeFreezer":
				if ($(this).attr("checked") == true) {$("#3_fridgefreezer-details").show("fast");} else {$("#3_fridgefreezer-details").hide(); }
			break;
			case "c3_ChestUpright":
				if ($(this).attr("checked") == true) {$("#3_freezer-details").show("fast");} else {$("#3_freezer-details").hide(); }
			break;
			case "c3_FridgeNone":
				$(".additional-question").hide();
			break;
		}
	});
	$("#cTVYes").click(function() {
		$("#tv-details").show("fast");
	});
	$("#cTVNo").click(function() {
		$("#tv-details").hide();
	});
	$("#dishwasher input[@id='cDishwasherYes']").click(function() {
		$("#dishwasher-details").show("fast");
		$("#dishwasher-economy").show("fast");
		$("#dishwasher").removeClass("hrule");
	});
	$("#dishwasher input[@id='cDishwasherNo']").click(function() {
		$("#dishwasher-details").hide();
		$("#dishwasher-economy").hide();
		$("#dishwasher").addClass("hrule");
	});
	
	$("#washingmachine input[@id='cWashingMacineYes']").click(function() {
		$("#washingmachine-details").show("fast");
		$("#washingmachine-details2").show("fast");
		$("#washingmachine").removeClass("hrule");
		$("#washingmachine-details2").addClass("hrule");
	});
	$("#washingmachine input[@id='cWashingMacineNo']").click(function() {
		$("#washingmachine-details").hide();
		$("#washingmachine-details2").hide();
		$("#washingmachine").addClass("hrule");
	});
	
	$("#tumbledryer input[@id='cWasherDryerYes']").click(function() {
		$("#tumbledryer-details").show("fast");
		$("#tumbledryer").removeClass("hrule");
	});
	$("#tumbledryer input[@id='cWasherDryerNo']").click(function() {
		$("#tumbledryer-details").hide();
	});
	
	$("#satellite-type input").click(function() {
		var satelliteType = $(this).attr("id");
		switch (satelliteType) {
			 case "cSatellite":
				if ($(this).attr("checked") == true) {$("#satellite-details").show("fast"); } else {$("#satellite-details").hide(); }
			break;
			case "cCable":
				if ($(this).attr("checked") == true) {$("#cable-details").show("fast");} else {$("#cable-details").hide(); }
			break;
			case "cFreeview":
				if ($(this).attr("checked") == true) {$("#freeview-details").show("fast");} else {$("#freeview-details").hide(); }
			break;
			case "cSatelliteNone":
				$(".additional-question").hide();
			break;
		}
	});
	
	$("#dvd-type input").click(function() {
		var dvdType = $(this).attr("id");
		switch (dvdType) {
			 case "cDVD":
				if ($(this).attr("checked") == true) {$("#dvd-details").show("fast"); } else {$("#dvd-details").hide(); }
			break;
			case "cHDD":
				if ($(this).attr("checked") == true) {$("#hdd-details").show("fast");} else {$("#hdd-details").hide(); }
			break;
			case "cVideo":
				if ($(this).attr("checked") == true) {$("#video-details").show("fast");} else {$("#video-details").hide(); }
			break;
			case "cDvdNone":
				$(".additional-question").hide();
			break;
		}
	});
	
	$("#computer input").click(function() {
		var computerType = $(this).attr("id");
		switch (computerType) {
			 case "cLaptop":
				if ($(this).attr("checked") == true) {$("#laptop-details").show("fast"); } else {$("#laptop-details").hide(); }
			break;
			case "cDesktop":
				if ($(this).attr("checked") == true) {$("#pc-details").show("fast");} else {$("#pc-details").hide(); }
			break;
			case "cComputerNone":
				$(".additional-question").hide();
			break;
		}
	});
	$("#insulationpage1 input").click(function() {
		var computerType = $(this).attr("id");
		switch (computerType) {
			 case "cInsulationLoft":
				if ($(this).attr("checked") == true) {$("#loft-details").show("fast"); } else {$("#loft-details").hide(); }
			break;
		}
	});
	$("#insulationpage2 input").click(function() {
		var computerType = $(this).attr("id");
		switch (computerType) {
			case "cInsulationGlazing":
				if ($(this).attr("checked") == true) {$("#glazingdetails").show("fast");} else {$("#glazingdetails").hide(); }
			break;
			case "cInsulationNone":
				$(".additional-question").hide();
			break;
		}
	});
			 
	
	$("#1_vehicles select[@name='Car_1_Fuel']").change(function() {
		var engineType = $(this).attr("value");
		switch (engineType) {
			 case "Petrol":
				$("#1_vehicles select[@name='Car_1_Engine']").empty();
                $('<option value="">Please select</option>').appendTo("select[@name='Car_1_Engine']");
                $('<option value="small">Small: Less than 1.4 litres</option>').appendTo("select[@name='Car_1_Engine']");
                $('<option value="medium">Medium: Between 1.4 and 2 litres</option>').appendTo("select[@name='Car_1_Engine']");
                $('<option value="large">Large: More than 2 litres</option>').appendTo("select[@name='Car_1_Engine']");
			break;
			case "Diesel":
				$("#1_vehicles select[@name='Car_1_Engine']").empty();
				$('<option value="">Please select</option>').appendTo("select[@name='Car_1_Engine']");
                $('<option value="small">Small: Less than 1.7 litres</option>').appendTo("select[@name='Car_1_Engine']");
                $('<option value="medium">Medium: Between 1.7 and 2 litres</option>').appendTo("select[@name='Car_1_Engine']");
                $('<option value="large">Large: More than 2 litres</option>').appendTo("select[@name='Car_1_Engine']");
			break;
			case "Hybrid":
				$("#1_vehicles select[@name='Car_1_Engine']").empty();
				$('<option value="">Please select</option>').appendTo("select[@name='Car_1_Engine']");
                $('<option value="medium">Medium</option>').appendTo("select[@name='Car_1_Engine']");
                $('<option value="large">Large</option>').appendTo("select[@name='Car_1_Engine']");
			break;
			 
		}
	});
	$("#2_vehicles select[@name='Car_2_Fuel']").change(function() {
		var engineType = $(this).attr("value");
		switch (engineType) {
			 case "Petrol":
				$("#2_vehicles select[@name='Car_2_Engine']").empty();
                $('<option value="">Please select</option>').appendTo("select[@name='Car_2_Engine']");
                $('<option value="small">Small: Less than 1.4 litres</option>').appendTo("select[@name='Car_2_Engine']");
                $('<option value="medium">Medium: Between 1.4 and 2 litres</option>').appendTo("select[@name='Car_2_Engine']");
                $('<option value="large">Large: More than 2 litres</option>').appendTo("select[@name='Car_2_Engine']");
			break;
			case "Diesel":
				$("#2_vehicles select[@name='Car_2_Engine']").empty();
                $('<option value="">Please select</option>').appendTo("select[@name='Car_2_Engine']");
                $('<option value="small">Small: Less than 1.7 litres</option>').appendTo("select[@name='Car_2_Engine']");
                $('<option value="medium">Medium: Between 1.7 and 2 litres</option>').appendTo("select[@name='Car_2_Engine']");
                $('<option value="large">Large: More than 2 litres</option>').appendTo("select[@name='Car_2_Engine']");
			break;
			case "Hybrid":
				$("#2_vehicles select[@name='Car_2_Engine']").empty();
                $('<option value="">Please select</option>').appendTo("select[@name='Car_2_Engine']");
                $('<option value="medium">Medium</option>').appendTo("select[@name='Car_2_Engine']");
                $('<option value="large">Large</option>').appendTo("select[@name='Car_2_Engine']");
			break;
			 
		}
	});
	$("#3_vehicles select[@name='Car_3_Fuel']").change(function() {
		var engineType = $(this).attr("value");
		switch (engineType) {
			 case "Petrol":
				$("#3_vehicles select[@name='Car_3_Engine']").empty();
                $('<option value="">Please select</option>').appendTo("select[@name='Car_3_Engine']");
                $('<option value="small">Small: Less than 1.4 litres</option>').appendTo("select[@name='Car_3_Engine']");
                $('<option value="medium">Medium: Between 1.4 and 2 litres</option>').appendTo("select[@name='Car_3_Engine']");
                $('<option value="large">Large: More than 2 litres</option>').appendTo("select[@name='Car_3_Engine']");
			break;
			case "Diesel":
				$("#3_vehicles select[@name='Car_3_Engine']").empty();
                $('<option value="">Please select</option>').appendTo("select[@name='Car_3_Engine']");
                $('<option value="small">Small: Less than 1.7 litres</option>').appendTo("select[@name='Car_3_Engine']");
                $('<option value="medium">Medium: Between 1.7 and 2 litres</option>').appendTo("select[@name='Car_3_Engine']");
                $('<option value="large">Large: More than 2 litres</option>').appendTo("select[@name='Car_3_Engine']");
			break;
			case "Hybrid":
				$("#3_vehicles select[@name='Car_3_Engine']").empty();
                $('<option value="">Please select</option>').appendTo("select[@name='Car_3_Engine']");
                $('<option value="medium">Medium</option>').appendTo("select[@name='Car_3_Engine']");
                $('<option value="large">Large</option>').appendTo("select[@name='Car_3_Engine']");
			break;
			 
		}
	});
	
	$("#1_vehicles input").click(function() {
		var vehicleType = $(this).attr("id");
		switch (vehicleType) {
			 case "c1_Car":
				if ($(this).attr("checked") == true) {$("#1_car-details").show("fast"); } else {$("#1_car-details").hide(); }
			break;
			case "c1_Motorcycle":
				if ($(this).attr("checked") == true) {$("#1_motorbike-details").show("fast");} else {$("#1_motorbike-details").hide(); }
			break;
			
		}
	});
	
	$("#2_vehicles input").click(function() {
		var vehicleType = $(this).attr("id");
		switch (vehicleType) {
			 
			case "c2_Car":
				if ($(this).attr("checked") == true) {$("#2_car-details").show("fast"); } else {$("#2_car-details").hide(); }
			break;
			case "c2_Motorcycle":
				if ($(this).attr("checked") == true) {$("#2_motorbike-details").show("fast");} else {$("#2_motorbike-details").hide(); }
			break;
			
		}
	});
	
	$("#3_vehicles input").click(function() {
		var vehicleType = $(this).attr("id");
		switch (vehicleType) {
			case "c3_Car":
				if ($(this).attr("checked") == true) {$("#3_car-details").show("fast"); } else {$("#3_car-details").hide(); }
			break;
			case "c3_Motorcycle":
				if ($(this).attr("checked") == true) {$("#3_motorbike-details").show("fast");} else {$("#3_motorbike-details").hide(); }
			break;
			
		}
	});
		
	$("#aircon input[@id='cAirConYes']").click(function() {
		$("#aircon-details").show("fast");
		$("#aircon").removeClass("hrule");
		$("#aircon-details").addClass("hrule");
	});
	$("#aircon input[@id='cAirConNo']").click(function() {
		$("#aircon-details").hide();
		$("#aircon").addClass("hrule");
	});
	
	$("#flights input").click(function() {
		var flightType = $(this).attr("id");
		switch (flightType) {
			 case "cDomestic":
				if ($(this).attr("checked") == true) {$("#domestic-details").show("fast"); } else {$("#domestic-details").hide(); }
			break;
			case "cShortHaul":
				if ($(this).attr("checked") == true) {$("#shorthaul-details").show("fast");} else {$("#shorthaul-details").hide(); }
			break;
			case "cLongHaul":
				if ($(this).attr("checked") == true) {$("#longhaul-details").show("fast");} else {$("#longhaul-details").hide(); }
			break;
			case "cDontFly":
				$(".additional-question").hide();
			break;
		}
	});

	$(".form-row input").each(function() {
	    if($(this).hasClass("radio"))
	    {
	        if($(this).attr("checked") == true)
		    {
    	        if( $(this).attr("id") == "cDishwasherYes"){
    	            $("#dishwasher-details").show("fast");
		            $("#dishwasher-economy").show("fast");
		            $("#dishwasher").removeClass("hrule");
    	        }
    	        if( $(this).attr("id") == "cWashingMacineYes"){
    	            $("#washingmachine-details").show("fast");
		            $("#washingmachine-details2").show("fast");
		            $("#washingmachine").removeClass("hrule");
		            $("#washingmachine-details2").addClass("hrule");
    	        }
    	        if( $(this).attr("id") == "cWasherDryerYes"){
    	            $("#tumbledryer-details").show("fast");
		            $("#tumbledryer").removeClass("hrule");
    	        }
    	        if( $(this).attr("id") == "cAirConYes"){
    	           $("#aircon-details").show("fast");
            	   $("#aircon").removeClass("hrule");
            	   $("#aircon-details").addClass("hrule");
    	        }
    	        if( $(this).attr("id") == "cTVYes"){
    	            $("#tv-details").show("fast");
    	        }
		    }
		          
	    }
		if($(this).hasClass("hide")){
			var inputGroup = $(this).attr("name");
			var inputGroupLength = $("input[@name='" + inputGroup + "']").length;
			
			//wraps input and label with a div
			/*var $next = $(this).next("label");
			var $both = $(this).add($next);
			if ($both.length == 2) {
				$both.wrapAll("<div class=\"icon-replace\"></div>");
			}*/
			if($(this).attr("checked") == true)
		    {
		        if( $(this).attr("id") == "c1_Car")
		        {
		          $("#1_car-details").show("fast");
		          var value=$("select[@name='Car_1_Fuel']").attr("value");
		          var value_en=$("select[@name='Car_1_Engine']").attr("value");
		          switch (value) {
        			 case "Petrol":
        				$("#1_vehicles select[@name='Car_1_Engine']").empty();
        				$('<option value="">Please select</option>').appendTo("select[@name='Car_1_Engine']");
        				if(value_en == "small") {$('<option value="small" selected="selected">Small: Less than 1.4 litres</option>').appendTo("select[@name='Car_1_Engine']");}
                        else {$('<option value="small">Small: Less than 1.4 litres</option>').appendTo("select[@name='Car_1_Engine']");}
                        if(value_en == "medium") {$('<option value="medium" selected="selected">Medium: Between 1.4 and 2 litres</option>').appendTo("select[@name='Car_1_Engine']"); }
                        else {$('<option value="medium">Medium: Between 1.4 and 2 litres</option>').appendTo("select[@name='Car_1_Engine']");}
                        if(value_en == "large") {$('<option value="large" selected="selected">Large: More than 2 litres</option>').appendTo("select[@name='Car_1_Engine']");}
                        else{$('<option value="large">Large: More than 2 litres</option>').appendTo("select[@name='Car_1_Engine']");}
        			break;
        			case "Diesel":
        				$("#1_vehicles select[@name='Car_1_Engine']").empty();
        				$('<option value="">Please select</option>').appendTo("select[@name='Car_1_Engine']");
                        if(value_en == "small") {$('<option value="small" selected="selected">Small: Less than 1.7 litres</option>').appendTo("select[@name='Car_1_Engine']");}
                        else {$('<option value="small">Small: Less than 1.7 litres</option>').appendTo("select[@name='Car_1_Engine']");}
                        
                        if(value_en == "medium") {$('<option value="medium" selected="selected">Medium: Between 1.7 and 2 litres</option>').appendTo("select[@name='Car_1_Engine']");}
                        else {$('<option value="medium">Medium: Between 1.7 and 2 litres</option>').appendTo("select[@name='Car_1_Engine']");}
                        
                        if(value_en == "large") {$('<option value="large" selected="selected">Large: More than 2 litres</option>').appendTo("select[@name='Car_1_Engine']");}
                        else {$('<option value="large">Large: More than 2 litres</option>').appendTo("select[@name='Car_1_Engine']");}
        			break;
        			case "Hybrid":
        				$("#1_vehicles select[@name='Car_1_Engine']").empty();
        				$('<option value="">Please select</option>').appendTo("select[@name='Car_1_Engine']");
                        if(value_en == "medium"){$('<option value="medium" selected="selected">Medium</option>').appendTo("select[@name='Car_1_Engine']");}
                        else {$('<option value="medium">Medium</option>').appendTo("select[@name='Car_1_Engine']");}
                            
                        if(value_en == "large"){$('<option value="large" selected="selected">Large</option>').appendTo("select[@name='Car_1_Engine']");}
                        else {$('<option value="large">Large</option>').appendTo("select[@name='Car_1_Engine']");}
        			break;
		        }
		        } 
		          
		          
		          
		          
	            if( $(this).attr("id") == "c1_Motorcycle")
		          $("#1_motorbike-details").show("fast");
	            if( $(this).attr("id") == "c2_Car")
	            {
                    $("#2_car-details").show("fast");
		          var value=$("select[@name='Car_2_Fuel']").attr("value");
		          var value_en=$("select[@name='Car_2_Engine']").attr("value");
		          switch (value) {
        			 case "Petrol":
        				$("#2_vehicles select[@name='Car_2_Engine']").empty();
        				$('<option value="">Please select</option>').appendTo("select[@name='Car_2_Engine']");
        				if(value_en == "small") {$('<option value="small" selected="selected">Small: Less than 1.4 litres</option>').appendTo("select[@name='Car_2_Engine']");}
                        else {$('<option value="small">Small: Less than 1.4 litres</option>').appendTo("select[@name='Car_2_Engine']");}
                        if(value_en == "medium") {$('<option value="medium" selected="selected">Medium: Between 1.4 and 2 litres</option>').appendTo("select[@name='Car_2_Engine']"); }
                        else {$('<option value="medium">Medium: Between 1.4 and 2 litres</option>').appendTo("select[@name='Car_2_Engine']");}
                        if(value_en == "large") {$('<option value="large" selected="selected">Large: More than 2 litres</option>').appendTo("select[@name='Car_2_Engine']");}
                        else{$('<option value="large">Large: More than 2 litres</option>').appendTo("select[@name='Car_2_Engine']");}
        			break;
        			case "Diesel":
        				$("#2_vehicles select[@name='Car_2_Engine']").empty();
        				$('<option value="">Please select</option>').appendTo("select[@name='Car_2_Engine']");
                        if(value_en == "small") {$('<option value="small" selected="selected">Small: Less than 1.7 litres</option>').appendTo("select[@name='Car_2_Engine']");}
                        else {$('<option value="small">Small: Less than 1.7 litres</option>').appendTo("select[@name='Car_2_Engine']");}
                        
                        if(value_en == "medium") {$('<option value="medium" selected="selected">Medium: Between 1.7 and 2 litres</option>').appendTo("select[@name='Car_2_Engine']");}
                        else {$('<option value="medium">Medium: Between 1.7 and 2 litres</option>').appendTo("select[@name='Car_2_Engine']");}
                        
                        if(value_en == "large") {$('<option value="large" selected="selected">Large: More than 2 litres</option>').appendTo("select[@name='Car_2_Engine']");}
                        else {$('<option value="large">Large: More than 2 litres</option>').appendTo("select[@name='Car_2_Engine']");}
        			break;
        			case "Hybrid":
        				$("#2_vehicles select[@name='Car_2_Engine']").empty();
        				$('<option value="">Please select</option>').appendTo("select[@name='Car_2_Engine']");
                        if(value_en == "medium"){$('<option value="medium" selected="selected">Medium</option>').appendTo("select[@name='Car_2_Engine']");}
                        else {$('<option value="medium">Medium</option>').appendTo("select[@name='Car_2_Engine']");}
                            
                        if(value_en == "large"){$('<option value="large" selected="selected">Large</option>').appendTo("select[@name='Car_2_Engine']");}
                        else {$('<option value="large">Large</option>').appendTo("select[@name='Car_2_Engine']");}
        			break;
		        }
	            }
		         
	            if( $(this).attr("id") == "c2_Motorcycle")
		          $("#2_motorbike-details").show("fast");
		        if( $(this).attr("id") == "c3_Car")
		        {
		            $("#3_car-details").show("fast");
		            var value=$("select[@name='Car_3_Fuel']").attr("value");
		          var value_en=$("select[@name='Car_3_Engine']").attr("value");
		          switch (value) {
        			 case "Petrol":
        				$("#3_vehicles select[@name='Car_3_Engine']").empty();
        				$('<option value="">Please select</option>').appendTo("select[@name='Car_3_Engine']");
        				if(value_en == "small") {$('<option value="small" selected="selected">Small: Less than 1.4 litres</option>').appendTo("select[@name='Car_3_Engine']");}
                        else {$('<option value="small">Small: Less than 1.4 litres</option>').appendTo("select[@name='Car_3_Engine']");}
                        if(value_en == "medium") {$('<option value="medium" selected="selected">Medium: Between 1.4 and 2 litres</option>').appendTo("select[@name='Car_3_Engine']"); }
                        else {$('<option value="medium">Medium: Between 1.4 and 2 litres</option>').appendTo("select[@name='Car_3_Engine']");}
                        if(value_en == "large") {$('<option value="large" selected="selected">Large: More than 2 litres</option>').appendTo("select[@name='Car_3_Engine']");}
                        else{$('<option value="large">Large: More than 2 litres</option>').appendTo("select[@name='Car_3_Engine']");}
        			break;
        			case "Diesel":
        				$("#3_vehicles select[@name='Car_3_Engine']").empty();
        				$('<option value="">Please select</option>').appendTo("select[@name='Car_3_Engine']");
                        if(value_en == "small") {$('<option value="small" selected="selected">Small: Less than 1.7 litres</option>').appendTo("select[@name='Car_3_Engine']");}
                        else {$('<option value="small">Small: Less than 1.7 litres</option>').appendTo("select[@name='Car_3_Engine']");}
                        
                        if(value_en == "medium") {$('<option value="medium" selected="selected">Medium: Between 1.7 and 2 litres</option>').appendTo("select[@name='Car_3_Engine']");}
                        else {$('<option value="medium">Medium: Between 1.7 and 2 litres</option>').appendTo("select[@name='Car_3_Engine']");}
                        
                        if(value_en == "large") {$('<option value="large" selected="selected">Large: More than 2 litres</option>').appendTo("select[@name='Car_3_Engine']");}
                        else {$('<option value="large">Large: More than 2 litres</option>').appendTo("select[@name='Car_3_Engine']");}
        			break;
        			case "Hybrid":
        				$("#3_vehicles select[@name='Car_3_Engine']").empty();
        				$('<option value="">Please select</option>').appendTo("select[@name='Car_3_Engine']");
                        if(value_en == "medium"){$('<option value="medium" selected="selected">Medium</option>').appendTo("select[@name='Car_3_Engine']");}
                        else {$('<option value="medium">Medium</option>').appendTo("select[@name='Car_3_Engine']");}
                            
                        if(value_en == "large"){$('<option value="large" selected="selected">Large</option>').appendTo("select[@name='Car_3_Engine']");}
                        else {$('<option value="large">Large</option>').appendTo("select[@name='Car_3_Engine']");}
        			break;
		        }
		        }
	            if( $(this).attr("id") == "c3_Motorcycle")
		          $("#3_motorbike-details").show("fast");
		          
		        if( $(this).attr("id") == "cSatellite")
		          $("#satellite-details").show("fast");
	            if( $(this).attr("id") == "cCable")
		          $("#cable-details").show("fast");
		        if( $(this).attr("id") == "cFreeview")
		          $("#freeview-details").show("fast");
		          
		          
	            if( $(this).attr("id") == "cDVD")
		          $("#dvd-details").show("fast");
	            if( $(this).attr("id") == "cHDD")
		          $("#hdd-details").show("fast");
		        if( $(this).attr("id") == "cVideo")
		          $("#video-details").show("fast");
		          
		          
		        if( $(this).attr("id") == "cBungalow")
    			 $("#bungalow-type").show("fast");
			 
    			if( $(this).attr("id") == "cInsulationGlazing")
	             $("#glazingdetails").show("fast");
    	        if( $(this).attr("id") == "cInsulationLoft")
    	         $("#loft-details").show("fast"); 
    			 
    			if( $(this).attr("id") == "cLaptop")
	             $("#laptop-details").show("fast");
    	        if( $(this).attr("id") == "cDesktop")
    	         $("#pc-details").show("fast");
    	         
    	        if( $(this).attr("id") == "cDomestic")
	             $("#domestic-details").show("fast");
	            if( $(this).attr("id") == "cShortHaul")
	             $("#shorthaul-details").show("fast");
	            if( $(this).attr("id") == "cLongHaul")
	             $("#longhaul-details").show("fast");  
	             
    			if( $(this).attr("id") == "cHouse")
    		     $("#house-type").show("fast");
		        
    		    if( $(this).attr("id") == "c1_Fridge")
    			 $("#1_fridge-details").show("fast");
    			 
    			if( $(this).attr("id") == "c1_FridgeFreezer")
    			 $("#1_fridgefreezer-details").show("fast");
    			 
    			if( $(this).attr("id") == "c1_ChestUpright")
    			 $("#1_freezer-details").show("fast");
    			 
    			if( $(this).attr("id") == "c2_Fridge")
    			 $("#2_fridge-details").show("fast");
    			 
    			if( $(this).attr("id") == "c2_FridgeFreezer")
    			 $("#2_fridgefreezer-details").show("fast");
    			 
    			if( $(this).attr("id") == "c2_ChestUpright")
    			 $("#2_freezer-details").show("fast");
    			 
    			if( $(this).attr("id") == "c3_Fridge")
    			 $("#3_fridge-details").show("fast");
    			 
    			if( $(this).attr("id") == "c3_FridgeFreezer")
    			 $("#3_fridgefreezer-details").show("fast");
    			 
    			if( $(this).attr("id") == "c3_ChestUpright")
    			 $("#3_freezer-details").show("fast");  
    		        
			    $(this).parent().addClass($(this).attr("id")+" icon-replace-on "+$(this).attr("id")+"-on");
		    }
		    else
		    {
		        $(this).parent().addClass($(this).attr("id"));
		    }
			$(this).parent().addClass($(this).attr("id"));
			
			
			//adds class to specify width of icons/labels
			/*if (inputGroupLength % 3 == 0){
				$(this).parent().addClass("trio-item"); 
				if (inputGroupLength > 3){
					$(".icon-replace:eq(2)").addClass("last-item");
				}
			} 
			if (inputGroupLength % 4 == 0) {$(this).parent().addClass("quatro-item"); } 
			if (inputGroupLength == 7) {
				$(".icon-replace:eq(0)").addClass("quatro-item");
				$(".icon-replace:eq(1)").addClass("quatro-item");
				$(".icon-replace:eq(2)").addClass("quatro-item");
				$(".icon-replace:eq(3)").addClass("quatro-item last-item");
				$(".icon-replace:eq(4)").addClass("trio-item");
				$(".icon-replace:eq(5)").addClass("trio-item");
				$(".icon-replace:eq(6)").addClass("trio-item");
			}
			$("input[@name='" + inputGroup + "']:not(:last)").parent().addClass("margin-right");
			*/
			
			//hides radio buttons/checkboxes
			if ($(this).hasClass("hide")){$(this).css({ position:"relative", left:"-9999px" , display:"inline"}); }
			
			//adds hover functionality
			$(".icon-replace").hover(
				function(){
					if (!$(this).children("input").attr("checked")) { 
						$(this).addClass("icon-highlight").addClass($(this).children("input").attr("id") + "-hover");
					} 
				},
				function(){
					if(!$(this).children("input").attr("checked")){  
						$(this).removeClass("icon-highlight").removeClass($(this).children("input").attr("id") + "-hover");
					}
				}
			);
			
			//adds 'on' state for radio buttons
			$(":radio").click(function(){
				$(":radio[@name='" + $(this).attr("name") + "']").each(function() {
					$(this).parent().removeClass("icon-highlight").removeClass($(this).attr("id") + "-hover");
					$(this).parent().removeClass($(this).attr("id") + "-on").removeClass("icon-replace-on");
				});
				if($(this).parent().hasClass("icon-replace")){
					$(this).parent().addClass("icon-replace-on").addClass($(this).attr("id") + "-on");
				}
				
			});
				
			//adds 'on' state for checkboxes
			
			$(":checkbox").each(function() {
				var cbUncheck = $(".uncheckAll[@name='" + inputGroup + "']");
				var cbNormal = $(":checkbox[@name='" + inputGroup + "']").not(".uncheckAll"); 
				
				cbUncheck.click(function(){
					if (cbUncheck.attr("checked") == true) {
						cbNormal.each(function(){
							$(this).parent().removeClass($(this).attr("id") + "-on").removeClass("icon-replace-on");
						});
						cbNormal.attr("checked", false);
						$(this).parent().removeClass("icon-highlight").removeClass($(this).attr("id") + "-hover").addClass($(this).attr("id") + "-on").addClass("icon-replace-on");
					} else {
						$(this).parent().removeClass($(this).attr("id") + "-on").removeClass("icon-replace-on");
					}
				}); 
				cbNormal.click(function(){ 
					if ($(this).attr("checked") == true) { 
						cbUncheck.attr("checked", false);
						$(this).parent().removeClass("icon-highlight").removeClass($(this).attr("id") + "-hover").addClass($(this).attr("id") + "-on").addClass("icon-replace-on");
						cbUncheck.parent().removeClass(cbUncheck.attr("id") + "-on").removeClass("icon-replace-on");
					} else {
						$(this).parent().removeClass($(this).attr("id") + "-on").removeClass("icon-replace-on");
					}
				});
			});
		}
		
		
		
	});
	
	
$("#1_vehicles input[@id='c1_NoVehicle']").click(function() {
	    if ($(this).attr("checked") == true) {  $("#1_car-details").hide(); 
                                        	    $("#2_car-details").hide();
                                        	    $("#3_car-details").hide();
                                        	    $("#1_motorbike-details").hide();
                                        	    $("#2_motorbike-details").hide();
                                        	    $("#3_motorbike-details").hide();
	    }
	});
	
	
});
