

/******************************************************************************************************************************************/
//Fonction permettant d afficher des TG de facon aleatoire
function getAffichageTGHP(tab){
    if (tab.length>0){
          setBlocByHtml("titreTGHP","<span>"+titreHP+"</span>");
          if (tab.length >maxNbPrdHome)
            nbrRestants = maxNbPrdHome;
        else
            nbrRestants=tab.length ;
      
         for (i=0;i<nbrRestants ;i++){      
                showBloc(tab[i]);
         }
     }
     else{
        changeBlocClass("blocTGHP","encart-trois-tg-vide");
        setBlocByHtml("titreTGHP","<span> </span>");
     }
 }

/************************************************************************************************************************************/
//Fonction permettant d afficher des TG sur la page rayon
function getAffichageTGRayon(tab){
    if (tab.length>0){
        hideBloc("fleche-gauche");
        if (tab.length<=2){
            hideBloc("fleche-gauche");
            hideBloc("fleche-droite");
        }     
        for (i=0;i<tab.length ;i++){
            showBloc(tab[i]);
        }
        showBloc("tgRayon");       
        showBloc('ongletTG');
    }
    else if((tabTypeBoutique.length == 0 || !getSwitchSite('THEMATIC_SHOPS')) && !conseilouVideo) hideBloc('zoneOnglets'); // Pas de TG, si pas de MB ni de fiche conseil ou video, on cache la zone TG
}
 
 /******************************************************************************************************************************************/
//Fonction permettant d afficher des TG de facon aleatoire
function getAffichageTGBrandHP(tab){
    if (tab.length>0){
    vstyle=" 1px solid ";
    setBlocByHtml("titreTGHPBrand","<span>"+titreHPBrand+"</span><div/>");
      if (tab.length >maxNbPrdHome)
        nbrRestants = maxNbPrdHome;
    else
        nbrRestants=tab.length ;       
        for (i=0;i<nbrRestants ;i++){              
            Lemodele =  tab[i].substring(tab[i].indexOf("_")+1,tab[i].length);
            showBloc(tab[i]);
            changeBlocColor("promo_"+Lemodele,colorBrand);
            changeBlocColor("dates_"+Lemodele,colorBrand);
            changeBlocColor("apartirde_"+Lemodele,colorBrand);
            changeBlocColor("prix-promo_"+Lemodele,colorBrand);
            changeBlocColor("reductionPourcentage_"+Lemodele,colorBrand);
            changeBlocColor("reductionPrix_"+Lemodele,colorBrand);
            changeBlocColor("prix_"+Lemodele,colorBrand);
            changeBlocColor("marque_"+Lemodele,colorBrand);
            changeBlocColor("description_"+Lemodele,colorBrand);
            changeBlocColorBorder("prix_"+Lemodele,vstyle,colorBrand);
            changeBlocColorBorder("prix-promo_"+Lemodele,vstyle,colorBrand);     
     }
     }
     else{
        setBlocByHtml("titreTGHPBrand","<span> </span>");
     }
 }
 /*################################################################################################
############################## JS DES FONCTIONS POUR LE DEFILEMENT DES TG DE LA PAGERAYON  ###################
/*############################################################################################## */
/* Variables pour le defilement des TG sur la page rayon */
    // Deplacement en pixels entre chaque reaffichage
    var delta=10;
    // Position initiale du bandeau
    var posx=-259;
    // Position à atteindre au premier click (a drotie)
    var posp=2;
    // Coordonnees des 3 positions : 0 a gauche - 1 au milieu - 2 a droite
    var posxvaleur = new Array();
    posxvaleur[0]=0;
    posxvaleur[1]=-259;
    posxvaleur[2]=-518;

function defilg() {
    if (posp<2) posp=posp+1;
    defilgauche()
}

function defilgauche() {
    document.getElementById('bandeau-produits').style.left=posx+"px";
    posx=Math.round(posx-delta);
    if (delta>2) delta=delta*0.97;
    if (posx>posxvaleur[posp]) setTimeout("defilgauche()",20);
    else {
        delta=10;
        document.getElementById('bandeau-produits').style.left=posxvaleur[posp]+"px";
    }
    if (posp == 0) {
        hideBloc('fleche-gauche');
        showBloc('fleche-droite');
    }
    if (posp == 1) {
        showBloc('fleche-gauche');
        showBloc('fleche-droite');
    }
    if (posp == 2) {
        showBloc('fleche-gauche');
        hideBloc('fleche-droite');
    }
}

function defild() {
    if (posp>0) posp=posp-1;
    defildroite(posp)
}

function defildroite() {
    document.getElementById('bandeau-produits').style.left=posx+"px";
    posx=Math.round(posx+delta);
    if (delta>2) delta=delta*0.97;
    if (posx<posxvaleur[posp]) setTimeout("defildroite()",20);
    else {
        delta=10;
        document.getElementById('bandeau-produits').style.left=posxvaleur[posp]+"px";
    }
    if (posp == 0) hideBloc('fleche-gauche');
    if (posp == 1) {
        showBloc('fleche-gauche');
        showBloc('fleche-droite');
    }
    if (posp == 2) {
        showBloc('fleche-droite');
        hideBloc('fleche-gauche');
    }
}