$(document).ready(function(){
	//Menu déroulant
	$('ul.menu').menuBox({
		menuWi : '700'
	});
	
	//Lien pour nouvelle page
	$("a[class^='_blank']").click(function(){
		window.open(this.href, '_blank');
		return false;
    });
	
	if( $("a[rel^='prettyPhoto']").length ){
		$("a[rel^='prettyPhoto']").prettyPhoto({
			deeplinking : false,
			social_tools: ""
		});
	}
	
	if( $("a[class^='lightbox']").length ){
		$("a[class^='lightbox']").prettyPhoto({
			deeplinking : false,
			social_tools: ""
		});
	}

	 /*Debut diaporama accueil*/
	  
	 if ($("#slides").length){
		$("#slides").slides({
			 generatePagination  : false,
			 pagination : false,
			 play : 5000,
			 effect : 'fade',
			 fadeSpeed : 800, 
			 crossfade : true,
			 preload : true,
			 preloadImage : "/interface/img/loading.gif"
		});
		  
		var wid = $(window).width()/2;
		 
		if (wid*2 > 1400) {
			lef = (wid*2-1400)/2;
			$("#slides").css({'left' : lef+'px','width' : '1400px'});
			$(".slides_container").css({'width' : '1400px'});
			
			//$("#slides td").css({'margin-left' : '0px','width' : '1400px'});
		 } else {
			$("#slides").css({'left' : (wid-700)+'px','width' : ((wid*2)-(wid-700))+'px'});
			$(".slides_container").css({'width' :'1400px'});
		 }
		  
		 $(window).resize(function() {
		 var wid = $(window).width()/2;
		 if (wid*2 > 1400) {
				lef = (wid*2-1400)/2;
				$("#slides").css({'left' : lef+'px','width' : '1400px'});
				//$("#slides td").css({'margin-left' : '0px','width' : '1400px'});
				$(".slides_container").css({'width' : '1400px'});
			} else {
				$("#slides").css({'left' : (wid-700)+'px','width' : ((wid*2)-(wid-700))+'px'});
				$(".slides_container").css({'width' : '1400px'});
			}
		});
		  /*Fin diaporama accueil*/
	}
	  /*Debut diaporama fiche produit*/
	 if ($("#slider-one").length && $("#slider-one").is(':visible') ){
		 $('#slider-one').movingBoxes({
		    startPanel   : 1,      // start with this panel
		    width        : 990,    // overall width of movingBoxes (not including navigation arrows)
		    wrap         : true,   // if true, the panel will "wrap" (it really rewinds/fast forwards) at the ends
		    buildNav     : true,   // if true, navigation links will be added
		    fixedHeight	 : true,
		    panelType    : '> li', // selector to find the immediate ">" children "li" of "#slider-one" in this case
		    navFormatter : function(index, panel){ return '<img height="50" src="'+panel.find('img').attr('src')+'" class="diapos"/>';  } // function which returns the navigation text for each panel


		 });
	  //Code permettant la navigation grace aux miniatures
		 var i, t = '', len = $('#slider-one .mb-panel').length + 1;
		 for ( i=1; i<len; i++ ){
			 t += '<a href="#" rel="' + i + '">' + i + '</a> ';
		 }
		 $('.dlinks')
	    .find('span').html(t).end()
	    .find('a').click(function(){
	     $('#slider-one').data('movingBoxes').currentPanel( $(this).attr('rel') );
	     	return false;
	    });
	 }
	   /*Fin diaporama fiche produit*/
	   
	/*Debut diaporama historique*/
	 if ($("#slider-two").length && $("#slider-two").is(':visible') ){
		  $('#slider-two').movingBoxes({
			    startPanel   : 1,      // start with this panel
			    width        : 990,    // overall width of movingBoxes (not including navigation arrows)
			    wrap         : true,   // if true, the panel will "wrap" (it really rewinds/fast forwards) at the ends
			    buildNav     : true,   // if true, navigation links will be added
			    panelType    : '> li', // selector to find the immediate ">" children "li" of "#slider-one" in this case
			    navFormatter : function(index, panel){ return panel.find('img').attr('alt');  } // function which returns the navigation text for each panel
		   });
		  //Code permettant la navigation grace aux miniatures
		  var i, t = '', len = $('#slider-two .mb-panel').length + 1;
		   for ( i=1; i<len; i++ ){
		    t += '<a href="#" rel="' + i + '">' + i + '</a> ';
		   }
		   $('.dlinks')
		    .find('span').html(t).end()
		    .find('a').click(function(){
		     $('#slider-one').data('movingBoxes').currentPanel( $(this).attr('rel') );
		     return false;
		    });
	 }
		   /*Fin diaporama fiche produit*/
		   
   if ($("#formulaire").length){
	   //Google maps
	   initialize();
   }
  
 
});
