
function  get_options(parent_id,select_name,id,select_id,select_mode)
{

	   $.ajax({
		type: "POST" ,
		url: '/scripts/menu_car.php',
		data: {parent_id:parent_id,name:select_name,id:id,select_id:select_id,mode:select_mode},

		success:

		function(response)
		{
			try
			{
				eval(response);
			}
			catch(e) 
			{ 
			    //alert(e+response);
			}
		}



	  }) ;
}

function  select_box( )
{
    	$('div[id^=select_box] select.makes').each( 
		   function ( )
		   {
		       var select_id=$(this).attr('default');
			   if( select_id == undefined ) select_id=-1;

			   var parent_id=$(this).parents("div[id^=select_box]").attr('id');

//     		   alert(parent_id+' '+select_id);
		       get_options(parent_id,'makes',0,select_id,0);

		   }
	   );


	   $('div[id^=select_box] select.makes').change( 
		   function ( )
		   {

		       var parent_id=$(this).parents("div[id^=select_box]").attr('id');


		       get_options(parent_id,'models',$('option:selected',this).val(),-1,0);

			   $('#'+parent_id+' select.engines').html('').attr('disabled',true);
        	   $('#'+parent_id+' select.generations').html('').attr('disabled',true);
			   $('#'+parent_id+' select.bodys').html('').attr('disabled',true);

		   }
	   );

	   $('div[id^=select_box] select.models').change( 
		   function ( )
		   {

		       var parent_id=$(this).parents("div[id^=select_box]").attr('id');


		       get_options(parent_id,'generations',$('option:selected',this).val(),-1,0);
		       //get_options(parent_id,'bodys',$('option:selected',this).val(),-1,1); 

		       $('#'+parent_id+' select.engines').html('').attr('disabled',true);
        	   $('#'+parent_id+' select.generations').html('').attr('disabled',true);
			   $('#'+parent_id+' select.bodys').html('').attr('disabled',true);

		   }
	   );

	   $('div[id^=select_box] select.generations').change( 
		   function ( )
		   {
		       var parent_id=$(this).parents("div[id^=select_box]").attr('id');

		       get_options(parent_id,'bodys',$('option:selected',this).val(),-1,0); 
		  
			   $('#'+parent_id+' select.engines').html('').attr('disabled',true);
			   $('#'+parent_id+' select.bodys').html('').attr('disabled',true);


		   }
	   );

       $('div[id^=select_box] select.bodys').change( 
		   function ( )
		   {
		       var parent_id=$(this).parents("div[id^=select_box]").attr('id');

		       get_options(parent_id,'engines',$('option:selected',this).val(),-1,0); 
		   }
	   );


	   $('div[id^=select_box] select.engines').change( 
		   function ( )
		   {
		       var parent_id=$(this).parents("div[id^=select_box]").attr('id');

		       get_options(parent_id,'transmissions_drives_years',$('option:selected',this).val(),-1,0); 
		   }
	   );


}


$( function ( ) {

try { select_box()

}catch(err){}

});

