$(document).ready(function(){
    
$.fn.loadscripts = function(){

/* 
 * Navigation Spec
*/
    $("#nested ul li a span").each(function(){
        var navi = $(this);
        navi.html(navi.html().replace(/\/|-/ig, " "));
    });
    
    $("#headerInner #nested ul:first li:eq(10)").css({"margin-left" : "50px","margin-top" : "-13px"});
    $("#headerInner #nested ul:first li:eq(11)").css({"margin-top" : "-13px"});
    $("#headerInner #nested ul:first li:eq(12)").css({"margin-top" : "-13px"});
    $("#headerInner #nested ul:first li:eq(13)").css({"margin-top" : "-13px"});
    $("#headerInner #nested ul:first li:eq(14)").css({"margin-top" : "-13px"});
    $("#headerInner #nested ul:first li:eq(15)").css({"margin-top" : "-13px"});
    $("#headerInner #nested ul:first li:eq(16)").css({"margin-top" : "-13px"});
    $("#headerInner #nested ul:first li:eq(17)").css({"margin-top" : "-13px"});
    $("#headerInner #nested ul:first li:eq(18)").css({"margin-top" : "-13px"});
    
    if($("#headerInner #nested ul:first li").length > 10) {
        $(".widgetCatalogSearch").css({"margin-top" : "60px"});
        $(".widgetCart").css({"margin-top" : "77px"});
        $("#headerInner #nested").css({"height" : "60px"});
    }

/* 
 * Target Link auto _blank
*/

    $("a[href^='http://']").each(function(){
      var thehref = $(this).attr('href');
      if(!thehref.match(window.location.host))
          $(this).attr('target', '_blank').addClass('external_link');
    });
         
/* 
 * Ancre automatique
*/
    var uri = document.location.pathname;
    var indice = uri.lastIndexOf('.')+2;
    var current_page=uri.substring(indice,uri.length);
    if(current_page!=""){
        $('html').animate({scrollTop : 450}, 'slow');
    }
     
/* 
 * Box Product Spec
*/
    if(current_page!=""){
        $("#contentsInner .widgetProduct.best_sales .short_product:last").hide();
    }
    if($('#cart').length || $('.cart').length) {
        $("#contentsInner .widgetProduct.new_product").hide();
    }
    
/* 
 * Zoom Product Picture
*/
    $('#productPicture a').each(function() {
        // ajout de la class sur le lien pour la modalbox
        $(this).addClass("lightBox"); 
        // recuperation de la src Full
        var src = $(this).find("img").attr("src").replace("/thumbnails", "");            
        // fwd du src vers le href du lien
        $(this).attr({  
           href: src 
         });
     });

     $('#productPicture a').lightBox();

/* 
 * Zoom additionnal Product
*/
    $("#visuels_additionnels a").each(function() {
        // ajout de la class sur le lien pour la modalbox
        $(this).addClass("lightBox"); 
        // recupÃ©ration de la src Full
        var src = $(this).find("img").attr("src").replace("/thumbnails", "");            
        // fwd du src vers le href du lien
        $(this).attr({  
           href: src 
         });
    });

    $('#visuels_additionnels a').lightBox();

/* 
 * Hide Stock Zero
*/
    $('div.stockIcon img').parent().parent().hide();
 
/* 
 * Cart Spec
*/
    
    if($('#cart').length || $('.cart').length) {
        $('.widgetProduct.best_sales').hide();
    }
    
    $("#updatecartsubmit").hide();
    $("#cart input[name*=quantity]").change(function() {
            $('#updatecartsubmit').trigger('click');
    });

    $("#cart select.field").change(function() {
            $('#updatecartsubmit').trigger('click');
    });


} /* End Extension Jquery */

/* 
 * Active extension Jquery
*/

    $().loadscripts();
    
});

