/*!
 * js accueil 
 * 
 
 
 */

$(document).ready(function () {
							
	$("select#m").change(function(){
		$("#attente").addClass("ui-autocomplete-loading");
		id = $("select#m").val();
		$.getJSON("/parcourir/modeleliste", "marque=" + id, function(data) {
			var options = '<option value="0"  >Mod&Egrave;le</option>';
			$.each(data, function(key, val) {
				options += '<option value="' + key + '">' + val + '</option>';
			});
			$("select#mo").html(options);
			rajCompteur();
			$("#attente").delay(2000).removeClass("ui-autocomplete-loading");
			
		});
	 });
	
	
	$("select#mo").change(function(){
		rajCompteur();
	});	
		
	 $('input[name=c]').change(function(){
	 
		rajCompteur();
	 });	
			
	 $("#min_amount").change(function(){
		rajCompteur();
	 });	
			
			$( ".search-form #amount-range" ).slider({
   				change: function(event, ui) {  rajCompteur() }
			});
		$("#reset").click
		
		
			
 
});
 
function rajCompteur(){
	 
	 $('#ajax-results').html('<img src="http://static.autosphere.fr/images/loader/loading.gif" width="16" height="16" alt="Chargement en cours ...">');  
 	// <strong>400 annonces</strong> correspondant à votre recherche
 	 $("#ajax-results").animate({
    					opacity: 0.1
						}, 200); 
	 var carr = $('input[name=c]:checked', '#main-search').val();
	 if(carr == undefined) {
		carr = 0;	 
	 }
	 
	 
	 $.post("/parcourir/compte",  
			  	"m=" + $("select#m").val() 
				+ "&mo=" + $("select#mo").val()
				+ "&c=" + carr 
				+ "&pxmin=" + $('#min_amount').val()
				+ "&pxmax=" + $('#max_amount').val()
		 		
				
				, function(data) {
					
					 
					$("#ajax-results").html(data);
					$("#ajax-results").animate({
    					opacity: 1
						}, 200); 
				});
	
}
