// JavaScript Document
   

function loadVehicles()
{

	//document.getElementById("second_select").value=$("#second_select").val();

   
	
	
    $.ajax({
           url: "vehicleselector/index.php/dropdown/vehicles",
           global: false,
           type: "POST",
           async: true,
           dataType: "html",
           data: "test=1", //the name of the $_POST variable and its value
           success:    function (response) //'response' is the output provided by the controller method prova()
                       {
                       //counts the number of dynamically generated options
                       var dynamic_options = $("*").index( $('.dynamic3')[0] );
                    //removes previously dynamically generated options if they exists (not equal to 0)
                       if ( dynamic_options != (-1)) $(".dynamic3").remove();
                    $("#first_select").append(response);
					 $(".sausage").attr({selected: ' selected'});
					

					
                   }
                   
          });
    
          return false
	
}

function test()
{
    var valore = $("#first_select").val();
    $.ajax({
           url: "vehicleselector/index.php/dropdown/models",
           global: false,
           type: "POST",
           async: false,
           dataType: "html",
           data: "first_select="+ valore, //the name of the $_POST variable and its value
           success: function (response) //'response' is the output provided by the controller method prova()
                       {
                       //counts the number of dynamically generated options
                       var dynamic_options = $("*").index( $('.dynamic')[0] );
                    //removes previously dynamically generated options if they exists (not equal to 0)
                       if ( dynamic_options != (-1)) $(".dynamic").remove();
                    $("#second_select").append(response);
                    $(".first").attr({selected: ' selected'});
                   }
                   
          });
    
          return false
	
}

function wheelsize()
{

	//document.getElementById("second_select").value=$("#second_select").val();

    var valore = $("#second_select").val();
	var valone = $("#first_select").val();
	
	
	
    $.ajax({
           url: "vehicleselector/index.php/dropdown/size",
           global: false,
           type: "POST",
           async: true,
           dataType: "html",
           data: "second_select="+ valore+"&first_select="+ valone, //the name of the $_POST variable and its value
           success:    function (response) //'response' is the output provided by the controller method prova()
                       {
                       //counts the number of dynamically generated options
                       var dynamic_options = $("*").index( $('.dynamic2')[0] );
                    //removes previously dynamically generated options if they exists (not equal to 0)
                       if ( dynamic_options != (-1)) $(".dynamic2").remove();
                    $("#third_select").append(response);
					 $(".second").attr({selected: ' selected'});
					

					
                   }
                   
          });
    
          return false
	
}