$(function(){
	
        
        $('#made').change(function (){
            valmade = $(this).attr('value');            
            $("#year").load("index.php",{block:"aj_prop", type:"year", made:valmade},function(){
                //alert($('#year').parent().children('.newListSelected').html(''));
                $("#year").parent().children('.newListSelected').remove();
                $(this).sSelect();                
                $(this).parent().children('.newListSelected ').toggleClass('Red');
            });
            
        });

        $('#year').change(function (){
            valmade = $('#made').attr('value')
            valyear = $(this).attr('value');
            $(this).parent().children('.newListSelected ').removeClass('Red');
            $("#model").load("index.php",{block:"aj_prop", type:"model", made:valmade, year:valyear},function(){
                //alert($('#year').parent().children('.newListSelected').html(''));
                $("#model").parent().children('.newListSelected').remove();
                $('#model').sSelect();
                $(this).parent().children('.newListSelected ').toggleClass('Red');
            });

        });

        $('#model').change(function (){
            valmade = $('#made').attr('value')
            valyear = $('#year').attr('value');
            valmodel = $(this).attr('value');
            $(this).parent().children('.newListSelected ').removeClass('Red');
            $("#type").load("index.php",{block:"aj_prop", type:"type", made:valmade, year:valyear, model:valmodel},function(){
                //alert($('#year').parent().children('.newListSelected').html(''));
                $("#type").parent().children('.newListSelected').remove();
                $('#type').sSelect();
                $(this).parent().children('.newListSelected ').toggleClass('Red');
            });
        });

        $('#type').change(function (){
            valmade = $('#made').attr('value')
            valyear = $('#year').attr('value');                        
            valmodel= $('#model').attr('value');
            valtype = $(this).attr('value');

            $aelem = $('#a_search');            
            $("#div_search").show("slow");
            $(this).parent().children('.newListSelected ').removeClass('Red');
            $aelem.bind('click',function(){                
                var url = "?cinfo=res&made="+valmade+"&year="+valyear+"&type="+valtype+"&model="+valmodel;
                $(location).attr('href',url);
            });
        });
});
