$(document).ready(function() {
		 $('a[rel*=facebox]').facebox({
        	loadingImage : './scripts/src/loading.gif',
        	closeImage   : './scripts/src/closelabel.png'
      	})
		//
		
			
			var hh=$("#navigation").css("height");
			var dispo=true;
			$("#navigation").hover(				
					function(){
						if(dispo==true) {
							dispo=false;
							$(this).animate({height:"+=75"},250,function() {dispo=true}).find("ul").fadeIn("slow");}
						}					 ,
 				function(){
 					$(this).find("ul").fadeOut("fast").parent().css("height",hh);
  					 
 				});
				
				// slider
				
				$("#slider_navigation a").eq(0).addClass("selected");
				
				var imageWidth = $("#slider").width();
				
				var imageSum = $("#slider ul li").size();
				
				var imageReelWidth = imageWidth * imageSum;
				
				
				$("#slider ul").css({'width' : imageReelWidth});
				
				
				$("#slider_navigation a").click(function() {
				    $active = $(this); //Activate the clicked paging
				   
				  
				    clearInterval(play); 
				    rotate(); 
				    rotateSwitch(); 
				    return false; 
				    
				});
				
				$("#slider ul li a").hover(function() {
					    clearInterval(play); 
					}, function() {
					    rotateSwitch(); 
					});	

				
				rotate = function(){			
				
				    var triggerID = $active.attr("rel") - 1; 
				    var image_reelPosition = triggerID * imageWidth; 
				
				    $("#slider_navigation a").removeClass("selected");
				    $active.addClass("selected");
	
				   
				    $("#slider ul").animate({
				        left: -image_reelPosition
				    }, 500 );
				
				}; 
				
				
				rotateSwitch = function(){
				    play = setInterval(function(){ 
				   
				        $active = $("#slider_navigation a.selected").next();
				       
				        if ( $active.length === 0) { 
				      
				      
				            $active = $("#slider_navigation a").eq(0); 
				        }
				        rotate();
				    }, 5000); 
				};
				
				rotateSwitch();
				
				
							
				$("#connexion").toggle(
                   function()
                   {
                     $("#login").animate({height:85},500)
    					$(".loginBloc").fadeIn("slow")
                   },
                   function()
                   {
                   		$(".loginBloc").fadeOut("fast")
                     $("#login").animate({height:0},500)
                   });


					$("#suiviCommande").toggle(
                   function()
                   {
                     $("#conteneurCommande").animate({height:50},200)
    					$("#conteneurCommande form").fadeIn("slow")
    					$("#conteneurCommande #conteneurProgressBar").fadeIn("slow")
    					
                   },
                   function()
                   {
                   		$("#conteneurCommande form").fadeOut("fast")
                   		$("#conteneurCommande #conteneurProgressBar").fadeOut("slow")
                     $("#conteneurCommande").animate({height:0},200)
                   });
				
								
				$("#suiviComm").submit(function() {				       
				
				        var fem = $(this).serialize();
						
						$("#conteneurProgressBar").html('');
				        
				        $.ajax({
				            type: "POST",
				            url: baseurl+"suiviCommande.php",
				            data: fem,
				            success: function(msg) {
				            
				            	if(msg=="error"){
				            		$("#conteneurProgressBar").fadeIn("slow").html('<b>Désolé, cette commande n\'existe pas.</b>');
				            	} else {
				            		$("#conteneurProgressBar").html('finalisée à : <span class="progressBar" id="pb1">'+msg+'%</span>');
									$("#pb1").progressBar();
									
								}
							}
				        });
				
				        return false;
				    });

				
				
				
				});			
				

