$("document").ready(function(){
	
	$("#carte .country").click(function(){
		
		$("#zip-form #country").attr("value",$(this).html());
		
		$("#result .this").css("display","none");
		$("#result .hebe").css("display","none");
		
		if($("#zip-form #zip").attr("value")==$("#zip-form #zip_default").attr("value"))
			zip="";
		else
			zip=$("#zip-form #zip").attr("value");
		
		country=$("#zip-form #country").attr("value");
		
		Fiche.find( "LM", zip, country);
		Fiche.find( "!LM", zip, country);
	
	});
	
	$("#zip-form").attr("action","javascript:;");
	
	var Fiche ={
	find :	function(mark, zip, country){
				
			var data="marks="+mark+"&zip="+zip+"&country="+country;
			//alert(data);
			$.ajax({
				type: "GET",
				url: "ajax-page/fiche/fiche-search",
				data: data,
				success: function(msg){
					
					//alert(msg);
					if(msg!="")
					{
						if(mark.search("!")==-1)
						{
							$("#search .this").css("display","block");
							$("#search .this").html("<p><strong>Les centres Lady Moving de votre département :</strong></p><p>"+msg+"</p>");
						}
						else
						{
							$("#search .hebe").css("display","block");
							$("#search .hebe").html("<p><strong>Les autres centres de fitness de notre réseau :</strong></p><p>"+msg+"</p>");
						}
					}
					else if(mark.search("!")==-1)
					{
						$("#search .this").css("display","block");
						$("#search .this").html("<p>Il n'y a pas de centres Lady Moving sur le département sélectionné</p>")
						$("#search .hebe").css("display","none");
					}
						
				}
			});
		}
	}
	
	$("#zip-form .submit").click(function(){	
		
		$("#result .this").css("display","none");
		$("#result .hebe").css("display","none");
		
		zip=$("#zip-form #zip").attr("value");
		country=$("#zip-form #country").attr("value");
		
		Fiche.find( "LM", zip, country);
		Fiche.find( "!LM", zip, country);

	});
	
	$("#result .this").css("display","none");
	$("#result .hebe").css("display","none");
	
	zip=$("#zip-form #zip").attr("value");
	country=$("#zip-form #country").attr("value");
	
	Fiche.find( "LM", zip, country);
	Fiche.find( "!LM", zip, country);

});

