$(document).ready(function(){	
    	 // Gestion taille titres
    	 $(".bestsales h3").each(function(){
    	   		var str = $(this).html();
    	   		$(this).html(str.substring(0,23)+'...');
    	 });
	 $("#produits_associes .short_product h3").each(function(){
    	   		var str = $(this).html();
    	   		$(this).html(str.substring(0,20)+'...');
    	 });
    	  
    	 // Gestion de la navigation 	
    	 $('.boxcatalogshortcut .box').each(function() {
      	 	$(this).hide();
      	 });
      	 $('.boxcatalogshortcut ul:first').addClass('topnav');
      	 $('.topnav ul').each(function() {
      	 	$(this).addClass('subnav');
      	 });
      	 $('.topnav ul.subnav li ul').each(function() {
      	 	$(this).removeClass('subnav');
      	 	$(this).addClass('thirdnav');
      	 	$(this).hide();
      	 });
      	 $("ul.subnav").parent().append("<span></span>");
		 $("ul.topnav li span").hover(function() {
			$(this).parent().find("ul.subnav").slideDown('fast').show();

			$(this).parent().hover(function() {
			}, function(){
				$(this).parent().find("ul.subnav").slideUp('slow');
			});

			}).hover(function() {
				$(this).addClass("subhover"); 
			}, function(){	
			$(this).removeClass("subhover");
		 });
		 
		 // Gestion alertance produits
		
	 	 $('.bestsales .short_product:nth-child(even)').each(function(el) {
      		$(this).addClass('white');
    	 });
    	 
    	 // Chargement des scripts externes 
    	 
    	 if ( $('.slider').length ){
			var script = document.createElement('script');
		    script.type = 'text/javascript';
			script.src = '/scripts/dragdealer.js';
			document.getElementsByTagName('head')[0].appendChild(script);
			
			var script = document.createElement('script');
		    script.type = 'text/javascript';
			script.src = '/scripts/dragdealer-main.js';
			document.getElementsByTagName('head')[0].appendChild(script);
    	 }
    	 
    	 // Gestion de l'affichage du details produit
    	 
    	 $("button").click(function () {
          $("#informations").toggle("slow");
          $("#produits_associes").css("display","none");
      	 });
      	 
      	 // Gestion du footer sur produit
      	
    	 if ( $('#product').length ){
		$('#baseline').css("display","none");
		$('#logo_fournisseurs').css("display","none");
		$('#signature').css("display","none");
		$('.bestsales').css("display","none");
    	 }
    	 
    	 // Gestion du rightbar sur produit
      	
    	 if ( $('#product').length ){
    	 	$('#rightbar').css("display","block");
    	 	$('#rightbar').css("float","right");
    	 	$('#rightbar').css("margin","120px 25px 0 0");
			$('#rightbar .infos').css("display","block");
    	 }
    	 if ( $('.familly').length ){
    	 	
    	 }

	// Gestion des produits associes
        
	if ( $('#product').length ){
		$("#produits_associes").addClass('catsales bestsales');
	}  

    	 // Gestion du zoom lightbox
        
         $(".gallery a").each(function() { 
         	var url =  $(this).find("img").attr("src");
         	var url2 = url.replace('thumbnails/','');  
            $(this).attr({  
              href: url2
            });
            $(this).lightBox();
         });

});
    
function close() {
             $('#informations').css("display","none");
             $('#produits_associes').css("display","block");
}

