var leBody;
var pageRevendeur;
var depRevendeur;
var regRevendeur = "Alsace";
var paysRevendeur;
var langue;



$(function(){
  
  //redimensions des images aux différentes tailles
  //redimensionImages('ev2_taille1', 408, 320);
	//redimensionImages('ev2_taille2', 60, 60);
	//redimensionImages('ev2_taille3', 154, 110);
	//redimensionImages('ev2_taille4', 130, 90);
	//redimensionImages('ev2_taille5', 140, 105);
	$(".ev2_taille1 img").aeImageResize({height: 320, width: 408});
	$(".ev2_taille2 img").aeImageResize({height: 60, width: 60});
	$(".ev2_taille3 img").aeImageResize({height: 105, width: 154});
	$(".ev2_taille4 img").aeImageResize({height: 90, width: 130});
	$(".ev2_taille5 img").aeImageResize({height: 105, width: 140});
  
  //rends les images visibles
  $('.activer').each(function () {
    $(this).css("visibility","visible");
  });
  
  //quelques variables
  var urlCourant = document.location.href;// l'url de la page
  var TabUrlCourant = urlCourant.split('/');// l'url coupé via les "/"
  var url = '';//
	leBody = $('body');//l'élement body
	//langue -> par default français
	langue = TabUrlCourant[3];
	if(langue !== 'en' && langue !== 'es' && langue !== 'it'){ langue = 'fr'; }
	
	
	
	/////////////////POUR TOUS - HEADER///////////////////
	
  //fonction qui met l'image de accueil dans le menu
  imgMenu();
  //fonction communauté médialibs
  var i = 1;
	$('.ev2_lightbox img').each (function(){
    url = $(this).attr("src");
    url = url.replace('thumbnails/','');
    $(this).parent().attr("href",url);
    if(i==1){
      $('#ev2_zoom2').attr("href",url);
    }
    i = 0;
  });
  //fonction qui active les lightbox
  $('.ev2_lightbox').lightBox();
  
  
  
  //////////////////CATALOG/////////////////////////////
  //rend visible la rightbar 
	$(".catalog").each(function(){
     $("#rightbar").css("display","block");
  });
  //si la box promotion existe on cache la deuxieme box nouveaute
  if(leBody.hasClass("produits")){
    $('.box_promotion').each (function(){
       $('.box_nouveaute2').css('display', 'none');
    });
  }
	//on rend visible la box chaine YouTube pour l'index du catalog
  if(leBody.hasClass('produits')){
	  $('.box_chaineYoutube').css("display", "block");
	}
	//panier -> supprssion de commentaire quand il est vide
	if(leBody.hasClass('panier')){
	  //customer message
    $('#customer_message').each(function(){
      //
      if($(this).find("textarea").size() == 0){
        if($(this).text().length < 60){
          $(this).css("display", "none");
        }
      }
      
    });
  }
	
	
	//////////////COMPTE/////////////////////
  
	
	//met en rouge les états des commandes 'En attente de validation'
  if(leBody.hasClass('comptes_clients')){
  
    $("#code_clientid").attr("readonly", "readonly");
    $("#account_modify #socitid").attr("readonly", "readonly");
    $("#code_clientid").css("color", "grey");
    $("#account_modify #socitid").css("color", "grey");
	
	
   /*
	 $("#account_pending_orders td").each(function(){
	   //français || anglais || espagnol
	   if($(this).text() == 'En attente de validation' || $(this).text() == 'Pending' || $(this).text() == 'En espera'){
	     $(this).css("color", "red");
     }
   });
   */
    //commande en cours dans la page mon compte/vos commandes
    $("#boxcart .viewcart").each(function(){
      var js_panier = $(this).find(".value").html();
      if(js_panier == null){
        //fr
        if(langue == 'fr'){
          $(".js_panier").append('<p>Aucune commande n\'est en cours</p>');
        }
        if(langue == 'en'){
          $(".js_panier").append('<p>No pending order</p>');
        }
        if(langue == 'es'){
          $(".js_panier").append('<p>Sin orden actual</p>');
        }
        if(langue == 'it'){
          $(".js_panier").append('<p>Nessun ordine corrente</p>');
        }
      }else{
        //pour récupérer le nombres d'articles en cours de commandes
        js_panier = js_panier.replace("(", "");
        js_panier = js_panier.replace(")", "");
        //fr
        if(langue == 'fr'){
          $(".js_panier").append('<p>Vous avez ' + js_panier + ' article(s) dans le panier en attente de validation.<a href="/produits/panier/viewcart.html">Acc&eacute;dez au panier</a></p>');
        }
        if(langue == 'en'){
          $(".js_panier").append('<p>You have ' + js_panier + ' item(s) in the shopping cart waiting for validation.<a href="/produits/panier/viewcart.html">Acc&eacute;dez au panier</a></p>');
        }
        if(langue == 'es'){
          $(".js_panier").append('<p>Ten&eacute;is ' + js_panier + ' producto(s) en el carrito en espera de aprobaci&oacute;n.<a href="/produits/panier/viewcart.html">Acc&eacute;dez au panier</a></p>');
        }
        if(langue == 'it'){
          $(".js_panier").append('<p>Voi ' + js_panier + ' prodotti nel carrello in attesa di approvazione.<a href="/produits/panier/viewcart.html">Acc&eacute;dez au panier</a></p>');
        }
      }
      //?? autres langues
    });
    
    //supprimer les boutons endant les formaulaires
    $("#form").each(function(){
      $(".btnCompte").css("display", "none");
    });
       
  }
  
if(leBody.hasClass('panier')){
  
    $("#code_clientid").attr("readonly", "readonly");
    //$("#socitid").attr("readonly", "readonly");
    $("#code_clientid").css("color", "grey");
    //$("#socitid").css("color", "grey");
	
	};
  
   //formulaire de création de nouvelle adresse
  $("#account_address #code_clientid").parent().parent().css("display", "none");

  //$("#account_address #socitid").parent().parent().css("display", "none");
  
  $("#account_address #prenomid").parent().parent().css("display", "none");
  
  $("#account_address #nomid").parent().parent().css("display", "none");
  
  $("#account_address #mailid").parent().parent().css("display", "none");
  
  //$("#account_address #telid").parent().parent().css("display", "none");
  
  $("#account_address #mobileid").parent().parent().css("display", "none");
  
  $("#account_address #faxid").parent().parent().css("display", "none");
  
  $("#account_address #webid").parent().parent().css("display", "none");
  
  
  $("#account_address #adr1id").parent().parent().find("label").replaceWith('<label for="adr1id">Adresse &nbsp; <span class="obligatory">*</span> :</label>');
  if(langue == 'en'){
       $("#account_address #adr1id").parent().parent().find("label").replaceWith('<label for="adr1id">Address &nbsp; <span class="obligatory">*</span> :</label>');
   }
   if(langue == 'es'){
       $("#account_address #adr1id").parent().parent().find("label").replaceWith('<label for="adr1id">Direcci&oacute;n &nbsp; <span class="obligatory">*</span> :</label>');
   }
   if(langue == 'it'){
       $("#account_address #adr1id").parent().parent().find("label").replaceWith('<label for="adr1id">Indirizzo &nbsp; <span class="obligatory">*</span> :</label>');
	   $("#account_address #libadresseid").parent().parent().find("label").replaceWith('<label for="libadresseid">Formulazione dell indirizzo &nbsp;<span class="obligatory">* </span>:</label>');
   }
   
  
  //formulaire de création d'adresse dans le panier
  $("#manage_address #code_clientid").parent().parent().css("display", "none");

  //$("#manage_address #socitid").parent().parent().css("display", "none");
  
  $("#manage_address #prenomid").parent().parent().css("display", "none");
  
  $("#manage_address #nomid").parent().parent().css("display", "none");
  
  $("#manage_address #mailid").parent().parent().css("display", "none");
  
  //$("#manage_address #telid").parent().parent().css("display", "none");
  
  $("#manage_address #mobileid").parent().parent().css("display", "none");
  
  $("#manage_address #faxid").parent().parent().css("display", "none");
  
  $("#manage_address #webid").parent().parent().css("display", "none");
  
  $("#manage_address #adr1id").parent().parent().find("label").replaceWith('<label for="adr1id">Adresse &nbsp; <span class="obligatory">*</span> :</label>');
 
  if(langue == 'en'){
       $("#manage_address #adr1id").parent().parent().find("label").replaceWith('<label for="adr1id">Address &nbsp; <span class="obligatory">*</span> :</label>');
	  
   }
   if(langue == 'es'){
       $("#manage_address #adr1id").parent().parent().find("label").replaceWith('<label for="adr1id">Direcci&oacute;n &nbsp; <span class="obligatory">*</span> :</label>');
	   
   }
   if(langue == 'it'){
       $("#manage_address #adr1id").parent().parent().find("label").replaceWith('<label for="adr1id">Indirizzo &nbsp; <span class="obligatory">*</span> :</label>');
	
   }
   
    //formulaire de password
   if(langue == 'it'){
       $("#account_change_password #ancien").parent().parent().find("label").replaceWith('<label for="ancien">Vecchia password &nbsp;<span class="obligatory">* </span>:</label>');
	    $("#account_change_password #nouveau").parent().parent().find("label").replaceWith('<label for="nouveau">Nuova password &nbsp;<span class="obligatory">* </span>:</label>');
		 $("#account_change_password #verify").parent().parent().find("label").replaceWith('<label for="verify">Verifica password &nbsp;<span class="obligatory">* </span>:</label>');
   }
  
  
  

	
	
	//////////////////////FICHE PRODUIT////////////////////
	//liens de la fiche produits
  
  //en anglais
  if(langue=='en'){
    $('#ev2_vue_eclate a').contents().replaceWith('<span>Download exploded view</span>');
    $('#ev2_notice a').contents().replaceWith('<span>Download instructions</span>');
    $('.ev2_catalogue a').contents().replaceWith('<span>e-catalogue</span>');
  }
  //en espagnol
  if(langue=='es'){
    $('#ev2_vue_eclate a').contents().replaceWith('<span>descargar la vista explosionada</span>');
    $('#ev2_notice a').contents().replaceWith('<span>descargar el manual de uso</span>');
    $('.ev2_catalogue a').contents().replaceWith('<span>e-catalogue</span>');
  }
  //en italien
  if(langue=='it'){
    $('#ev2_vue_eclate a').contents().replaceWith('<span>Scaricare l’immagine esplosa</span>');
    $('#ev2_notice a').contents().replaceWith('<span>Scaricare le istruzioni</span>');
    $('.ev2_catalogue a').contents().replaceWith('<span>e-catalogue</span>');
  }
  //en français
  if(langue=='fr'){
    $('#ev2_vue_eclate a').contents().replaceWith('<span>T&eacute;l&eacute;charger la vue &eacute;clat&eacute;e</span>');
    $('#ev2_notice a').contents().replaceWith('<span>T&eacute;l&eacute;charger la notice</span>');
    $('.ev2_catalogue a').contents().replaceWith('<span>e-catalogue</span>');
  }
  //target blank sur le lien pdf
  $('.ev2_catalogue a').attr('target', '_blank');
	
	
	
	var laDivProduct = $('#product');
  
  
  
  if(TabUrlCourant[4]=='nouveautes'){
     installationNouveaute();
  }
  
  
  //var machin = $('#ev2_vue_eclate a').clone();
  
  

  $('#disparition img').each (function(){
    url = $(this).attr("src");
    $('#ev2_photo_hd a').attr("href",url);
  });
  
  $('#cart_footer .ev2_valida').each(function(){
    $('#cart_detail').css('display', 'none');
    $('.les_adresses').css('display', 'none');
  });
  
  $('#nested .videos a').each(function(){
    $(this).attr("target", "_blank");
  });
  
  
  
  
  $('.js_wallpaper').each(function(){
    url = $(this).find(".js_vignette img").attr("src");
    url = url.replace("thumbnails/", "");
    $(this).find(".js_bouton").attr("href",url);
  });
  
  
    
    	
	
	
  
	  
	
	
	
	
  
  
	/////////////PRODUITS///////////////
	if(leBody.hasClass('redirection')){
    //installationPager();
    suppressionAjoutPanier();
    installationVideo();
    installationStock();
    
    
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $("#formproductversion").attr("OnSubmit", "return false;");
    
    $(".ev2_quantite").keydown(function(event){
      event = (event?event:window.event);
      if(event.keyCode == 13){ $("#ev2_ajout_panier").click(); clear(); }
    });
    //onKeyPress(function(){  }
    
    
    
    
    //au cas ou il y a une réduction, je change un peu des css
    $('.special_rate').each(function(){
      $('.prix').css("top", "68px");
      $('.total_price').css("display", "block");
    });
    
  }
  
  if(leBody.hasClass('recherche')){
    //installationPager2();
  }
  
  if(leBody.hasClass('revendeurs')){
    $('.specif_revendeur_detail').each(function(){
      $('.boxlastelements').css("display", "block");
    });
  }
  
  
  
  
  $('#cart_payment_confirmation').each(function(){
    var urlCourant = document.location.href;
    var TabUrlCourant = urlCourant.split('/');
    
    var TabUrlCourant1 = TabUrlCourant[5].split('-');
    
    
    //$('.js_chargement').load(function(){
    
      if(TabUrlCourant1.length == 3){
        $(this).css('display', 'none');
        document.location.href = urlCourant + "-response";
      }
      else{
        $('.js_chargement').css('display', 'none');
      }
    //});
  });
  
  
   
	/*
	/////////////CONTACT///////////////
	//redirection vers la page contact pour les revendeurs
	if(leBody.hasClass("contact")){
	  //si connecté alors ...
    $('.box_login_username').each (function(){
      //si anglais alors ...
      if(langue=='en'){
        //redirection vers cette adresse
        document.location.href= "/en/about-us/retailer-contact/";
      }
      if(langue=='fr'){
        //redirection vers cette adresse (français)
        document.location.href= "/infos-societe/contact-revendeur/";
      }
      if(langue=='es'){
        document.location.href= "/es/nuestra-empresa/contacto-profesional/";
      }
      if(langue=='it'){
        document.location.href= "/it/societa/contatti-rivenditore/";
      }
    });
  }
  */
  
  
  

});






/*--------------------------------------------------------------*/
/*------------------REDIMENSIONNEMENT D'IMAGES------------------*/
/*--------------------------------------------------------------*/
function redimensionImages(classe, wMax, hMax){
  
  $('.' + classe + ' img').each(function() {
  
    var maxWidth = wMax; // Max width for the image
    var maxHeight = hMax;    // Max height for the image
    var ratio = 0;  // Used for aspect ratio
    var width = $(this).attr("width");    // Current image width
    var height = $(this).attr("height");  // Current image height

    //alert($(this).get(0).offsetWidth);
    alert($(this).get(0).offsetWidth);
    alert($(this).attr("src"));
    

    // Check if the current width is larger than the max
    if(width > maxWidth){
      ratio = maxWidth / width;   // get ratio for scaling image
      $(this).css("width", maxWidth); // Set new width
      $(this).css("height", height * ratio);  // Scale height based on ratio
      height = height * ratio;    // Reset height to match scaled image
      width = width * ratio;    // Reset width to match scaled image
    }

    // Check if current height is larger than max
    if(height > maxHeight){
      ratio = maxHeight / height; // get ratio for scaling image
      $(this).css("height", maxHeight);   // Set new height
      $(this).css("width", width * ratio);    // Scale width based on ratio
      width = width * ratio;    // Reset width to match scaled image
    }
  
  });
  
}






/*--------------------------------------------------------------*/
/*-------------AJOUTE L'IMAGE ACCUEIL DANS LE MENU--------------*/
/*--------------------------------------------------------------*/
function imgMenu(){

	//reste à éviter que au moment ou il est la classe est égal à "active accueil" html1 soi undefined
	var html1 = "<a href='" + $("#nested li[class='defaultmenu accueil'] a").attr("href") + "'><img id='ev2_img_accueil' src='/images/tr.gif' width='36' height='26' style='border:0px; display:block'/></a>";
	
	//suppression du texte ACCUEIL et remplacement par une image
	$("#nested li[class='active accueil']").empty();
	$("#nested li[class='defaultmenu accueil']").empty();
	$("#nested li[class='active accueil']").append(html1);
	$("#nested li[class='defaultmenu accueil']").append(html1);
}






/*--------------------------------------------------------------*/
/*--------------------INSTALLATION DU PAGER---------------------*/
/*--------------------------------------------------------------*/
function installationPager(){
    var test = 1;
    var varA;
    var html1;
    for(varA = 1; test == varA; varA++){
      $("#line" + varA).each(function(){
         test++;
      });
    }
    
    var NbPage = Math.ceil((test-1)/3);
    for(varA=1; varA <= NbPage; varA++){
      if(varA==1){
          html1 += "<option value='" + varA + "' selected='selected'>" + varA + "</option>";
      }else{
          html1 += "<option value='" + varA + "'>" + varA + "</option>";
      }
    }
    $("#ev2_selectPager").html(html1);
    
    $("#ev2_selectPager").change(function(){
       $('.line').css("display","none");
       var ligneMax = $("#ev2_selectPager").val()*3;
       var ligneMin = ligneMax-2;
       for(varA=ligneMin; varA<=ligneMax; varA++){
           $('#line' + varA).css("display","block");
       }
    });
}






/*--------------------------------------------------------------*/
/*--------------------INSTALLATION DU PAGER---------------------*/
/*--------------------------------------------------------------*/
function installationPager2(){
    var test = 1;
    var varA;
    var html1;
    for(varA = 1; test == varA; varA++){
      $("#row" + varA).each(function(){
         test++;
      });
    }
    
    var NbPage = Math.ceil((test-1)/3);
    for(varA=1; varA <= NbPage; varA++){
      if(varA==1){
          html1 += "<option value='" + varA + "' selected='selected'>" + varA + "</option>";
      }else{
          html1 += "<option value='" + varA + "'>" + varA + "</option>";
      }
    }
    $("#ev2_selectPager").html(html1);
    
    $("#ev2_selectPager").change(function(){
       $('.rowbis').css("display","none");
       var ligneMax = $("#ev2_selectPager").val()*3;
       var ligneMin = ligneMax-2;
       for(varA=ligneMin; varA<=ligneMax; varA++){
           $('#row' + varA).css("display","block");
       }
    });
}






/*--------------------------------------------------------------*/
/*--------------------INSTALLATION DU STOCK---------------------*/
/*--------------------------------------------------------------*/
function installationStock(){
  
  
  $("#stock_detail").each(function(){
    //je récupére le nombre de produits disponible
    var nbStock = $(this).text();
    //par defaut, le Stock est disponible
    //if(nbStock == ""){ nbStock = 51; }
    
    //si en français
    if(langue == 'fr'){
      if(nbStock < 1){
        $("#stock_icon img").attr("src", "/images/stock/produitRouge.jpg");
        $("#stock_icon img").attr("alt", "Indisponible");
      }
      if(nbStock > 1 && nbStock < 50){
        $("#stock_icon img").attr("src", "/images/stock/produitOrange.jpg");
        $("#stock_icon img").attr("alt", "Stock limit&eacute;");
      }
      if(nbStock > 50){
        $("#stock_icon img").attr("src", "/images/stock/produitVert.jpg");
        $("#stock_icon img").attr("alt", "Disponible");
      }
    }
    if(langue == 'en'){
      if(nbStock < 1){
        $("#stock_icon img").attr("src", "/images/stock/produitRougeEN.jpg");
        $("#stock_icon img").attr("alt", "Available");
      }
      if(nbStock > 1 && nbStock < 50){
        $("#stock_icon img").attr("src", "/images/stock/produitOrangeEN.jpg");
        $("#stock_icon img").attr("alt", "Limited supply");
      }
      if(nbStock > 50){
        $("#stock_icon img").attr("src", "/images/stock/produitVertEN.jpg");
        $("#stock_icon img").attr("alt", "Unavailable");
      }
    }
    if(langue == 'es'){
      if(nbStock < 1){
        $("#stock_icon img").attr("src", "/images/stock/produitRougeES.jpg");
        $("#stock_icon img").attr("alt", "Available");
      }
      if(nbStock > 1 && nbStock < 50){
        $("#stock_icon img").attr("src", "/images/stock/produitOrangeES.jpg");
        $("#stock_icon img").attr("alt", "Limited supply");
      }
      if(nbStock > 50){
        $("#stock_icon img").attr("src", "/images/stock/produitVertES.jpg");
        $("#stock_icon img").attr("alt", "Unavailable");
      }
    }
    if(langue == 'it'){
      if(nbStock < 1){
        $("#stock_icon img").attr("src", "/images/stock/produitRougeIT.jpg");
        $("#stock_icon img").attr("alt", "Available");
      }
      if(nbStock > 1 && nbStock < 50){
        $("#stock_icon img").attr("src", "/images/stock/produitOrangeIT.jpg");
        $("#stock_icon img").attr("alt", "Limited supply");
      }
      if(nbStock > 50){
        $("#stock_icon img").attr("src", "/images/stock/produitVertIT.jpg");
        $("#stock_icon img").attr("alt", "Unavailable");
      }
    }
    
    $("#stock_icon img").css("display", "block");
    
  });
}






/*--------------------------------------------------------------*/
/*-----------------INSTALLATION DES NOUVEAUTES------------------*/
/*--------------------------------------------------------------*/
function installationNouveaute(){
    var clone;
    var test;
    var line = 1;
    var col = 1;
    
    $('.ev2_prod_original .short_product').each(function(){
          
        if($(this).hasClass('new_product')){
          if($(this).parent().hasClass('col1')){
            $(this).parent().removeClass('col1');
          }
          if($(this).parent().hasClass('col2')){
            $(this).parent().removeClass('col2');
          }
          if($(this).parent().hasClass('col3')){
            $(this).parent().removeClass('col3');
          }
          if($(this).parent().hasClass('col4')){
            $(this).parent().removeClass('col4');
          }
          if($(this).parent().hasClass('col5')){
            $(this).parent().removeClass('col5');
          }
          
          clone = $(this).parent().clone();
          $(this).parent().css('display', 'none');

          clone.addClass('col'+col);
          if(col==1){
            $('.ev2_prod_nouveaute').append("<div id='line"+line+"' class='line'></div>");
          }
          $('.ev2_prod_nouveaute #line' + line).append(clone);
          
          col++;
          
          if(col==6){
            $('.ev2_prod_nouveaute #line'+line).append("<div style='clear:both'></div>");
            line++;
            col=1;
          }

        }
        else{
          if($(this).parent().hasClass('col1')){
            test = 'col1';
          }
          if($(this).parent().hasClass('col2')){
            test = 'col2';
          }
          if($(this).parent().hasClass('col3')){
            test = 'col3';
          }
          if($(this).parent().hasClass('col4')){
            test = 'col4';
          }
          if($(this).parent().hasClass('col5')){
            test = 'col5';
          }
          $(this).parent().css('display', 'none');
        }
        
        
        //var sp = $(this).find('.short_product');
        //alert(sp.length);
        
    });
    
    $('.ev2_prod_nouveaute #line'+line).append("<div style='clear:both'></div>");
    
    $('.ev2_prod_original').empty();
}





/*--------------------------------------------------------------*/
/*----------------INSTALLATION DES COMMENTAIRES-----------------*/
/*--------------------------------------------------------------*/
function installationCommentaire(){
  
  //si il y à un message d'erreur c'est que le message à déjà été envoyé et qu'il fo afficher la boite d'ajout de commentaire
  if($.trim($("#add_comment .error").text())!==""){
    $("#add_comment").attr({style: "display:block;"});
  }
  
  $("#add_comment .ev2_fermer").click(function(){
    //fermer la boite d'ajout commentaire
    $("#add_comment").attr({style: "display:none;"});
  });
  
  $(".ev2_ecrireavis").click(function(){
    //ouvrir la  boite d'ajout de commentaire
    $("#add_comment").attr({style: "display:block;"});
  });
  
  $("#comments_list .ev2_fermer").click(function(){
    //fermer la boite d'ajout commentaire
    $("#comments_list").attr({style: "display:none;"});
  });
  
  $(".ev2_voiravisbis").click(function(){
    //ouvrir la  boite d'ajout de commentaire
    $("#comments_list").attr({style: "display:block;"});
  });
  
  var string1 = Math.round(parseFloat($("#ev2_mbEtoile").text().replace(",", ".")));
  
  for(var i=1; i<=string1; i++){
    $("#note"+i).attr({src: "/images/etoile-active.jpg"});
  }
  
}






/*--------------------------------------------------------------*/
/*---------------------CENTRAGE DES IMAGES----------------------*/
/*--------------------------------------------------------------*/
function imgCentrer(classe){

	$('.' + classe).each(function () {
	   
     if($(this).parent().innerHeight() !== 0){
		      
          var nbParent = $(this).innerHeight();
          var Enfant = $(this).find("img");
          var nbEnfant = $(this).find("img").first().innerHeight();
		      if(nbEnfant!==0){
  		      var nbNew = Math.round((nbParent - nbEnfant)/2)-1;
  		      Enfant.css("padding-top", nbNew + "px");
  		    }
		      
      }
  });
  
}



/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function installationVideo(){
  
  $(".ev2_video").click(function(){
    $(".video").css("display","block");
    var laW = document.body.offsetWidth;
    var laH = document.body.offsetHeight;
    $("#brouillage").css("width",laW);
    $("#brouillage").css("height",laH);
    $("#brouillage").css("display","block");
  });
  
  $("#brouillage").click(function(){
    $(".video").css("display","none");
    $("#brouillage").css("display","none");
  });
  
}




//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function suppressionAjoutPanier(){
  //enleve le bouton d'ajout si le prix est non communiqué
  if($('.ev2_encart_prix_detail .prix span').html() == 'NC'){
    $('.ev2_encart_prix_detail #formproductversion').css("display","none");
    $('.ev2_encart_prix_detail #stock_icon').css("display","none");
  }
  //enleve le bouton d'ajout si la personne n'est pas connecté
  if($('#boxcart').size() == 0){
     $('.ev2_encart_prix_detail #formproductversion').css("display","none");
     $('.ev2_encart_prix_detail #stock_icon').css("display","none");
  }
  else{
    if(langue == "fr"){
      $('.ev2_encart_prix_detail .ev2_prix_public_1').contents().replaceWith('<span>Prix HT constat&eacute; :</span>');
    }
    if(langue == "en"){
      $('.ev2_encart_prix_detail .ev2_prix_public_1').contents().replaceWith('<span>duty-free price :</span>');
    }
  }
}

/*
function deplacerEncartEnBas(boxClass){
	var clone = $('.' + boxClass).clone();
	$('.' + boxClass).remove();
	$('#encart_bas').append(clone);
}
*/

