$(document).ready(function(){

	onAjaxLoad(function() {
		// Appel class active sur les liens	
		var rubrique = $("#position span").html();
		$("#collectionfoot li").removeClass();
		
		$("#collectionfoot a").each(function(){
			var name = $(this).html();
			if(name == rubrique) {
				$(this).parent("li").addClass("active");
			}
		});
		
		// Check Slider
		if ($("#minislider img").length == 0) {
	    	$("#google").hide();
	    }
		
		// Gestion des slides 
		$('#minislider').nivoSlider({
	        effect:'fade',
	        slices:16
	    });
	    
	    // Gestion du slider 
	    $('#slider').nivoSlider({
	        //effect:'fade',
	        slices:16
	    });
		
		// Gestion des collections
		$("#collectionchoise a.next").click(function(){
			$("#collectionfoot ol li.active").next("li").find("a").trigger('click');
		});
		$("#collectionchoise a.prev").click(function(){
			$("#collectionfoot ol li.active").prev("li").find("a").trigger('click');
		});
		
		// Form Specif Ajax
		$('.error').hide()
		$("#taratatashop .button").click(function() {  
			 // Check input
		     var email = $("input#email").val();  
	         if (email == "") {  
		       $("label#email_error").show();  
		       $("input#email").focus();  
		       return false;  
		     }
		     var region = $("select#region option:selected").val(); 
		     // alert("region "+region);
		     // Send form
		       var dataString = 'region='+ region + '&email=' + email;
			   $.ajax({  
			      type: "POST",  
			      url: "squelettes/sendform.php",
			      data: dataString,  
			      success: function() {  
			        $('#taratatashop').html("<div id='message'></div>");  
			        $('#message').html("<h3>Merci !</h3><p>Nous vous avons envoy&eacute; par email la liste des magasins revendeurs (Taratata Bijoux) de votre r&eacute;gion.</p></h3>"); 
			      }  
			   });  
			   return false;  
	   	});
		
	});

});
