// ***********************************************************************
// FONCTIONS AFFICHAGES DES FAQ
// ***********************************************************************
document.onmousedown=init_traine;
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onclick=getMouseXY;
document.onmouseup=stop_traine;

//var http = createRequestObject();
var nbquestions = 11;
function doRequestFaq(num_question) {
    // on mets tous les liens au style de off, sauf le lien de l'element selectionne
    for (i=1; i <= nbquestions; i++) {
        if (i == num_question) {
            document.getElementById('q' + i).className = "arial_11_225F22_bold";
            document.getElementById('faqResponse' + i).style.display = "block";
        }else{
            document.getElementById('q' + i).className = "arial_11_225F22";
            document.getElementById('faqResponse' + i).style.display = "none";			
        }
    }
}


// PARAMETRES
// PARAMETRES
var _dir_images = "/images/liste_produits/"; // repertoire de l'image a afficher
var _xlayer = 350; // position du bord gauche du layer relativement a la page
var _ylayer = 300; // position du bord haut du layer relativement a la page
var _couleur_fond = "#EEFAE4"; // couleur du fond
var _couleur_titre = "#FFD07D"; // couleur du titre
var _bordure_titre = "#707070"; // couleur de la bordure autour du titre (pas de bordure indiquer : "")
var _police = "Verdana,Arial,Helvetica,sans serif"; // police du texte
var _bouton_fermer = "/images/liste_produits/croix.gif"; // bouton fermer la fenetre en haut du layer
var _id_layer = "popup";
var _haut_titre = 25; // hauteur du titre en pixels (pour determiner la hauteur de la zone permettant le deplacement)   

// VARIABLES GLOBALES
var nn4 = (document.layers);
var dom = (document.getElementById);
var iex = (document.all);
var obj_layer = null;
var larg_image = 0; // largeur de l'image
var cache = true;
var X,Y,moveX,moveY,offsetX,offsetY;
var b_traine = false; // vrai, lorsqu'on est en train de deplacer le layer
var tempX = 400 ;
var tempY = 400;
// creation de l'objet obj_layer en fonction du navigateur :
// affecte le layer et lui donne son emplacement vertical
function init_layer() {
    if (dom && (document.getElementById(_id_layer))) {
        obj_layer = document.getElementById(_id_layer).style;
        X = iex ?  "event.clientX": "e.clientX";
        Y = iex ?  "event.clientY" : "e.clientY";
        offsetX = (iex) ? "document.body.scrollLeft" : "pageXOffset";
        offsetY = (iex) ? "document.body.scrollTop" : "pageYOffset";
    }
    else if (iex && (_id_layer)) {
        obj_layer = _id_layer.style;
        X="event.clientX";
        Y="event.clientY";
        offsetX="document.body.scrollLeft";
        offsetY="document.body.scrollTop";
    }
    else if (nn4 && (document.layers[_id_layer])) {
        obj_layer = document.layers[_id_layer];
        X="e.pageX";
        Y="e.pageY";
        offsetX="pageXOffset";
        offsetY="pageYOffset";
        document.captureEvents(Event.MOUSEDOWN|Event.MOUSEMOVE|Event.MOUSEUP);
    }
    if (obj_layer) {
        
        obj_layer.left = _xlayer;
        obj_layer.top = _ylayer;
    }
}


// ecrit le contenu dans le layer et le rend visible
function contenu_layerlist(contenu) {
    
    if (nn4) {
        obj_layer.document.write(contenu);
        obj_layer.document.close();
        obj_layer.visibility = "visible";
    }
    else if (dom) {
        document.getElementById(_id_layer).innerHTML = contenu;
        obj_layer.visibility = "visible";
    }
    else if (iex) {
        document.all[_id_layer].innerHTML = contenu;
        obj_layer.visibility = "visible";
    }
    
}

// cache le layer (seulement s'il est visible)
function fermer() {
    if (!cache) {
        resetEffect2();
        obj_layer.innerHTML = '';
        obj_layer.visibility = "hidden";
        cache = true;
        //initLayer('targetarea');
    }
}
var DocRef;    // Variable pour IE uniquement
function getMouseXY(e) {  
    //  alert("getMouseXYNew");
    // L'evenement est passee a la fonction
    // donc tous sauf IE.
    if( e){                    // Dans ce cas on obtient directement la position dans la page
        tempX= e.pageX;
        tempY = e.pageY;
    }
    else{                      // Dans ce cas on obtient la position relative a la fenetre d'affichage
        tempX = event.clientX;
        tempY = event.clientY;
        //-- Il faut traiter le CAS des DOCTYPE sous IE
        if( document.documentElement && document.documentElement.clientWidth) // Donc DOCTYPE
            DocRef = document.documentElement;   // Dans ce cas c'est documentElement qui est reference
        else
            DocRef = document.body;              // Dans ce cas c'est body qui est reference
        //-- On rajoute la position liee aux ScrollBars
        tempX += DocRef.scrollLeft;
        tempY += DocRef.scrollTop;
    }
    if(!IE) {
        if (tempY < 0){
            tempY = 0;
        }    
    }
    if ( (tempX + 400 )  > 1000){
        tempX = 600;
    }  
    return true;
}

// positionne correctement le layer si on a fait defile la page
function scroll_layerlist() {
    if (document.all) {
       //  alert("DocRef.scrollTop " +DocRef.scrollTop);
        obj_layer.left = parseInt(DocRef.scrollLeft + tempX - 200)+"px";        
        obj_layer.top = parseInt( tempY - 200)+"px";
    }
    else {
        obj_layer.left = parseInt(window.pageXOffset +  tempX -200 )+"px";
        obj_layer.top = parseInt(tempY - 200) +"px";
    }
}
function scroll_layerxml() {
    if (document.all) {
        obj_layer.left = parseInt(tempX - 600 )+"px";
        obj_layer.top = parseInt(tempY - 200 )+"px";
    }
    else {
        obj_layer.left = parseInt(tempX -600 )+"px";
        obj_layer.top = parseInt(tempY - 200  )+"px";
    }
}

// GESTION DE LA COULEUR
function startEffect2() {
    
    startTop   = $('masque').offsetTop;
    startLeft  = $('masque').offsetLeft; 
  //  $('masque').style.bgColor = '#000000';
    //$('masque').style.opacity = 0.10;
   // $('masque').style.visibility = "visible";	    
    //new Rico.Effect.FadeTo( 'masque', 0.4, 10, 4 );
    document.getElementById('masque').style.zIndex = 1;
    
}
function startEffect() {
    
    startTop   = $('masque').offsetTop;
    startLeft  = $('masque').offsetLeft; 
    //$('masque').style.bgColor = '#000000';
    //$('masque').style.opacity = 0.10;
    //$('masque').style.visibility = "visible";	    
    //new Rico.Effect.FadeTo( 'masque', 0.4, 10, 4 );
    document.getElementById('masque').style.zIndex = 1;
    
}

function resetEffect2() {
    //new Rico.Effect.FadeTo( 'masque', 0.1, 10, 4 ); 
    document.getElementById('masque').style.zIndex = -1;
    document.getElementById('masque').style.visibility = "hidden";	
}
function resetEffect() {
    //new Rico.Effect.FadeTo( 'masque', 0.1, 10, 4 ); 
    document.getElementById('masque').style.zIndex = -1;
    document.getElementById('masque').style.visibility = "hidden";	
}
function initLayer(mylayer) {
    document.getElementById(mylayer).innerHTML = '';
}

function showPopupdecoupe(libele,ident) {
    _id_layer = "popup";
    init_layer();
    if (obj_layer) {	
        cache = false;
        startEffect2('masque');
        var ch_texte = '';
        
        if(libele=='panier'){
            ch_texte+='<div id="contentPopup" class="pop">';
            ch_texte+='<div class="titre"><img src="/images/liste_produits/titre-panier.gif" alt="Produit ajout&eacute; &agrave; votre panier" /></div>';
            ch_texte+='<div class="floatLeft width50pc">';
            ch_texte+='<div class="produit">';
            ch_texte+='<div class="nouveau"></div>';
            ch_texte+='<img src="/images/liste_produits/visu3.jpg" alt="" class="border" />';
            ch_texte+='<p align="center"><a href="javascript:void(0);">Fiche detaillee</a></p></div>';
            ch_texte+='</div>';
            ch_texte+='<div class="floatRight width50pc">';
            ch_texte+='<p><div class="bold">Poignee de Porte \"Azur\".</div>Inox finition aluminium</p>';
            ch_texte+='<p class="pop-prix">Prix : 0,99 &euro;</p>';
            ch_texte+='<p>Existe en plusieurs modeles ou conditionnements</p>';
            ch_texte+='<a href="javascript:fermer();"><img src="/images/liste_produits/btn-poursuivre-achats.gif" alt="Poursuivre mes achats"></a><br><img src="/images/liste_produits/shim.gif" height="5" /><br />';
            ch_texte+='<a href="javascript:void(0);"><img src="/images/liste_produits/btn-acceder-panier.gif" border="0"></a>';
            ch_texte+='</div>	';
            ch_texte+='<div class="clearBoth"></div>';
            ch_texte+='</div>';
        }
        
        else if(libele=='liste'){
            ch_texte+='<div id="contentPopup" class="pop">';
            ch_texte+='<div class="titre"><img src="/images/liste_produits/titre-liste.gif" alt="Produit ajouter a votre liste" /></div>';
            ch_texte+='<div class="floatLeft width50pc">';
            ch_texte+='<div class="produit">';
            ch_texte+='<div class="nouveau"></div>';
            ch_texte+='<img src="/images/liste_produits/visu3.jpg" alt="" class="border" />';
            ch_texte+='<p align="center"><a href="javascript:void(0);">Fiche detaillee</a></p></div></div>';
            ch_texte+='<div class="floatRight width50pc">';
            ch_texte+='<p><div class="bold">Poignee de Porte \"Azur\".</div>Inox finition aluminium</p>';
            ch_texte+='<p class="pop-prix">Prix : 0,99 &euro;</p>';
            ch_texte+='<p>Existe en plusieurs modeles ou conditionnements</p>';
            ch_texte += '<a href="javascript:fermer();"><img src="/images/liste_produits/btn-poursuivre-achats.gif"></a><br><img src="/images/liste_produits/shim.gif" height="5" /><br />';
            ch_texte += '<a href="javascript:void(0);"><img src="/images/liste_produits/btn-acceder-liste.gif" border="0"></a></div>';	
            ch_texte+='<div class="clearBoth"></div></div>';
        }
        else{
            var panier="panier";
            var liste="liste";
            ch_texte+='<div id="contentPopup" class="pop_">';
            ch_texte+='<div class="fermer"><a href="javascript:fermer()"><img src="/images/liste_produits/btn-fermer_.gif" alt="fermer" /></a></div><div class="clearBoth"></div>';
            ch_texte+='<div class="floatLeft width50pc">';
            ch_texte+='<div class="produit">';
            ch_texte+='<div class="nouveau"></div>';
            ch_texte+='<img src="/images/liste_produits/visu3.jpg" alt="" class="border" />';
            ch_texte+='<p align="center"><a href="javascript:void(0);">Fiche detaillee</a></p></div></div>';
            ch_texte+='<div class="floatRight width50pc">';
            ch_texte+='<p><div class="bold">Poignee de Porte \"Azur\".</div>Inox finition aluminium</p>';
            ch_texte+='<p class="pop-prix">Prix : 0,99 &euro;</p>';
            ch_texte+='<p>Existe en plusieurs modeles ou conditionnements</p>';
            ch_texte += '<a href="javascript:fermer();loadeverything(\'panier\');"><img src="/images/liste_produits/btn-panier_.gif"></a><br><img src="/images/liste_produits/shim.gif" height="5" /><br />';
            ch_texte += '<a href="javascript:fermer();loadeverything(\'liste\');"><img src="/images/liste_produits/btn-liste_.gif" border="0"></a></div>';	
            ch_texte+='<div class="clearBoth"></div></div>';		
        }
        scroll_layerlist();
        contenu_layerlist(ch_texte);
    }
}


// DEPLACEMENT DU LAYER AVEC LA SOURIS

// initialisation lorsqu'on appuye sur le bouton de la souris (debut du deplacement)
// l'argument "e" est necessaire pour Netscape 4
function init_traine(e) {
    if (obj_layer && !cache) {
        var Xin = eval(X);
        var Yin = eval(Y);
        var L = parseFloat(obj_layer.left);
        var T = parseFloat(obj_layer.top);
        var offX = (nn4)? 0 : eval(offsetX);
        var offY = (nn4)? 0 : eval(offsetY);
        // determine si la souris est dans la zone superieure du layer
        if (Xin>(L-offX) && Xin<(L-offX+larg_image) && Yin>(T-offY) && Yin<(T-offY+_haut_titre)) {
            b_traine = true;
            moveX=Xin-L;
            moveY=Yin-T;
        }
        else b_traine = false;
    }
    else b_traine = false;
}

function stop_traine() {
    if (b_traine) {
        moveX = null;
        moveY = null;
        b_traine = false;
    }
}

function traine_layer(e) {
    if (b_traine) {
        var Xin = eval(X);
        var Yin = eval(Y);
        // deplacement
        obj_layer.top = Yin - moveY;
        obj_layer.left = Xin - moveX;
    }
}



/**** dynamique fonctions ****/

function showProduct(productid,libelle,modevente,nouveaute,pos) {
    _id_layer = "popup";    
    init_layer();
    if (obj_layer) {	
        cache = false;
        
        startEffect2();
        
        var ch_texte = '';
        if(libelle=='produit'){
            ch_texte +='<div id="contentPopup" class="pop_">';
            ch_texte +='<div class="fermer"><a href="javascript:fermer()"><img src="/images/liste_produits/btn-fermer_.gif" alt="fermer" /></a></div><div class="clearBoth"></div>';
            ch_texte +='<div class="floatLeft width50pc">';
            ch_texte +='<div class="produit">';
            if(nouveaute == 'oui'){
                ch_texte +='<img src="/images/liste_produits/nouveau.gif">';
            }
            ch_texte +=  document.getElementById(productid).value ;   
            if(document.getElementById('disponibilite_'+pos)){
            //alert('pos '+pos);    
            ch_texte +=  document.getElementById('disponibilite_'+pos).innerHTML ;
            }
            if(modevente == 'oui'){
                ch_texte +='<a href="javascript:void(0);" onMouseDown="BasketMgt.addProduct( '+productid+', 1, { callback:function(data) { refreshLightBasket(); showProduct('+productid+',\'panier\',\''+modevente+'\',\''+nouveaute+'\')}});"><img src="/images/liste_produits/btn-panier_.gif"></a><br><img src="/images/liste_produits/shim.gif" height="5" /><br />';
            }
            ch_texte +='<a href="javascript:void(0);" onMouseDown="ListCourseService.addProduct( '+productid+', 1, { callback:function(data) { refreshLightBasket(); showProduct('+productid+',\'liste\',\''+modevente+'\',\''+ nouveaute +'\')}});"><img src="/images/liste_produits/btn-liste_.gif" border="0"></a></div>';	
            ch_texte +='<div class="clearBoth"></div>';        
            ch_texte +=  '</div>';
        }
        else if(libelle=='panier'){
            ch_texte +='<div id="contentPopup" class="pop">';
            ch_texte +='<div class="titre"><img src="/images/liste_produits/titre-panier.gif" alt="Produit ajout&eacute; &agrave; votre panier" /></div>';
            ch_texte +='<div class="floatLeft width50pc">';
            ch_texte +='<div class="produit">';
            if(nouveaute == 'oui'){
                ch_texte +='<img src="/images/liste_produits/nouveau.gif">';
            }
            ch_texte +=  document.getElementById('ap-'+productid).value ;
            ch_texte +='<a href="javascript:fermer();"><img src="/images/liste_produits/btn-poursuivre-achats.gif" alt="Poursuivre mes achats"></a><br><img src="/images/liste_produits/shim.gif" height="5" /><br />';
            ch_texte +='<a href="pre?zone=zoneprocessachat&baskettodo=display&pageid=17"><img src="/images/liste_produits/btn-acceder-panier.gif" border="0"></a>';
            ch_texte +='</div>	';
            ch_texte +='<div class="clearBoth"></div>';        
            ch_texte +=  '</div>';
        }
        else if(libelle=='liste'){
            ch_texte +='<div id="contentPopup" class="pop">';
            ch_texte+='<div class="titre"><img src="/images/liste_produits/titre-liste.gif" alt="Produit ajout&eacute; &agrave; votre liste" /></div>';
            ch_texte +='<div class="floatLeft width50pc">';
            ch_texte +='<div class="produit">';
            if(nouveaute == 'oui'){
                ch_texte +='<img src="/images/liste_produits/nouveau.gif">';
            }
            ch_texte +=  document.getElementById(productid).value ;
            ch_texte +='<a href="javascript:fermer();"><img src="/images/liste_produits/btn-poursuivre-achats.gif" alt="Poursuivre mes achats"></a><br><img src="/images/liste_produits/shim.gif" height="5" /><br />';
            ch_texte +='<a href="pre?zone=zonelistecourse&srvname=srvlistecourse&action=showlistecourse&pageid=17"><img src="/images/liste_produits/btn-acceder-liste.gif" border="0"></a>';
            ch_texte +='</div>	';
            ch_texte +='<div class="clearBoth"></div>';        
            ch_texte +=  '</div>';
        }
        
        scroll_layerlist();
        contenu_layerlist(ch_texte);
    }
}

function showPopupTech(libele) {
    _id_layer = "popup";
    init_layer();
    if (obj_layer) {	
        cache = false;
        startEffect2('masque');
        var ch_texte = '';			
        if(libele=='panier'){
            ch_texte+='<div id="contentPopup" class="pop">';
            ch_texte+='<div class="titre"><img src="/images/liste_produits/titre-panier.gif" alt="Produit ajout&eacute; &agrave; votre panier" /></div>';
            ch_texte+='<div class="floatLeft width50pc">';
            ch_texte+='<div class="produit">';
            ch_texte+='<div class="nouveau"></div>';
            ch_texte+='';
            ch_texte+='</div>';
            ch_texte+='</div>';
            ch_texte+='<div class="floatRight width50pc">';
            ch_texte+='<a href="javascript:fermer();"><img src="/images/liste_produits/btn-poursuivre-achats.gif" alt="Poursuivre mes achats"></a><br><img src="/images/liste_produits/shim.gif" height="5" /><br />';
            ch_texte+='<a href="pre?zone=zoneprocessachat&baskettodo=display&pageid=17"><img src="/images/liste_produits/btn-acceder-panier.gif" border="0"></a>';
            ch_texte+='</div>	';
            ch_texte+='<div class="clearBoth"></div>';
            ch_texte+='</div>';
        }			
        else if(libele=='liste'){
            ch_texte+='<div id="contentPopup" class="pop">';
            ch_texte+='<div class="titre"><img src="/images/liste_produits/titre-liste.gif" alt="Produit ajouter a votre liste" /></div>';
            ch_texte+='<div class="floatLeft width50pc">';
            ch_texte+='<div class="produit">';
            ch_texte+='<div class="nouveau"></div>';
            ch_texte+='';
            ch_texte+='</div>';
            ch_texte+='</div>';
            ch_texte+='<div class="floatRight width50pc">';
            ch_texte += '<a href="javascript:fermer();"><img src="/images/liste_produits/btn-poursuivre-achats.gif"></a><br><img src="/images/liste_produits/shim.gif" height="5" /><br />';
            ch_texte += '<a href="pre?zone=zonelistecourse&srvname=srvlistecourse&action=showlistecourse&pageid=17"><img src="/images/liste_produits/btn-acceder-liste.gif" border="0"></a></div>';	
            ch_texte+='<div class="clearBoth"></div>';
            ch_texte+='</div>';
            
        } 
    }                        
    scroll_layerlist();
    contenu_layerlist(ch_texte);
}
function showPopupXML(libele,value) {
    _id_layer = "popupxml";
    init_layer();
    if (obj_layer) {	
        cache = false;
        startEffect2('masque');
        var ch_texte = '';			
        if(libele == 'popup:xml' ){
            ch_texte+='<div id="contentPopup" class="popxml">';
            ch_texte +='<div class="fermerxml"><a href="javascript:fermer()">Fermer <img src="/images/fiche-produit/icoFermerZoom.gif" alt="fermer" /></a></div><div class="clearBoth"></div>';
            ch_texte+='<div class="floatLeft" >';
            ch_texte+='<div class="produit">';
            ch_texte+='<div class="nouveau"></div>';
            ch_texte +=  document.getElementById("xml"+value).value;
            ch_texte +='</div>	';
            ch_texte +=  '</div>';  
            ch_texte +='<div class="clearBoth"></div>';        
            ch_texte +=  '</div>';  
        }  
    }                        
    scroll_layerxml();
    contenu_layerlist(ch_texte);
}

function checknumberselected(){
    if(document.multicriteriaQuerySet.getSelectedItems().size() > 3)
        alert("Vous devez selectionner 3 produits au maximum."); 
}


function doShowColDroite() {
    if(document.getElementById('colonnedroite')){
    obj = document.getElementById('colonnedroite');
    obj.style.display = 'block';
    }
    
}

function doHideColDroite() {
    if(document.getElementById('colonnedroite')){
    obj = document.getElementById('colonnedroite');
    obj.style.display = 'none';
    }
}
function doShowChoisissez() {
    if(document.getElementById('choisissez')){
    obj = document.getElementById('choisissez');
    obj.style.display = 'inline';
    }
}

function doHideChoisissez() {
    if(document.getElementById('choisissez')){
    obj = document.getElementById('choisissez');
    obj.style.display = 'none';
    }
}

function doCheckAndCompareEachOthers(){
    if(document.multicriteriaQuerySet.getSelectedItems().size() < 2) {
        alert("Vous devez selectionner au moins 2 produits.");
    }
    else{ 
        if(document.multicriteriaQuerySet.getSelectedItems().size() > 3)
            alert("Vous devez selectionner 3 produits au maximum."); 
        else {
            doHideColDroite();
            doHideChoisissez();
            doCompareEachOthers();
            if( typeof dhtmlHistory != 'undefined'){
            dhtmlHistory.add("compare","MQScompare");            
            }
        }
    }
}


function doHideDiv( name ) {
    if(document.getElementById(name)) {
        obj = document.getElementById(name);
        obj.style.display = 'none';
    }
}
function doShowDivBlock( name ) {
    if(document.getElementById(name)) {
        obj = document.getElementById(name);
        obj.style.display = 'block';
    }
}
function doShowDivInline( name ) {
    if(document.getElementById(name)) {
        obj = document.getElementById(name);
        obj.style.display = 'inline';
    }
}

function doShowHideCompare( numberofproduct ) {
    if( numberofproduct == 0 ) {
        doShowDivBlock('noitem');
        doHideDiv('orderby');
    }
    else {
        // doHideDiv('noitem');
        doShowDivBlock('orderby');
    }
    if( numberofproduct > 1 ) {
        // doShowDivBlock('comparetop');
        // doShowDivBlock('comparebottom');
        doShowDivInline('choisissezs');
    }
    else {
        // doHideDiv('comparetop');
        // doHideDiv('comparebottom');
        doHideDiv('choisissezs');
    }
    if( numberofproduct < 20 ) {
        doHideDiv('paginationmaintop');
        doHideDiv('pagination1top');
        doHideDiv('pagination2top');
        doHideDiv('pagination3top');
        doHideDiv('pagination4top');
        
        doHideDiv('paginationmainbottom');
        doHideDiv('pagination1bottom');
        doHideDiv('pagination2bottom');
        doHideDiv('pagination3bottom');
        doHideDiv('pagination4bottom');
    }
    if( numberofproduct >= 20 && numberofproduct < 40 ) {
        doShowDivInline('paginationmaintop');
        doShowDivInline('pagination1top');
        doHideDiv('pagination2top');
        doHideDiv('pagination3top');
        doShowDivInline('pagination4top');
        
        doShowDivInline('paginationmainbottom');
        doShowDivInline('pagination1bottom');
        doHideDiv('pagination2bottom');
        doHideDiv('pagination3bottom');
        doShowDivInline('pagination4bottom');
        
    }
    if( numberofproduct >= 40 && numberofproduct < 60 ) {
        doShowDivInline('paginationmaintop');
        doShowDivInline('pagination1top');
        doShowDivInline('pagination2top');
        doHideDiv('pagination3top');
        doShowDivInline('pagination4top');
        
        doShowDivInline('paginationmainbottom');
        doShowDivInline('pagination1bottom');
        doShowDivInline('pagination2bottom');
        doHideDiv('pagination3bottom');
        doShowDivInline('pagination4bottom');
    }
    if( numberofproduct >= 60 ) {
        doShowDivInline('paginationmaintop');
        doShowDivInline('pagination1top');
        doShowDivInline('pagination2top');
        doShowDivInline('pagination3top');
        doShowDivInline('pagination4top');
        
        doShowDivInline('paginationmainbottom');
        doShowDivInline('pagination1bottom');
        doShowDivInline('pagination2bottom');
        doShowDivInline('pagination3bottom');
        doShowDivInline('pagination4bottom');
    }
    
}


function showOnglet(libelle) {
    document.getElementById("infosAnnexeBlocid").innerHTML = document.getElementById(libelle).value;
    if(document.getElementById('bienchoisirclass')) {
        document.getElementById('bienchoisirclass').setAttribute('class','');
        document.getElementById('bienchoisirclass').setAttribute('className','');
    }
    if(document.getElementById('faiteslevousmemeclass')) {
        document.getElementById('faiteslevousmemeclass').setAttribute('class','');
        document.getElementById('faiteslevousmemeclass').setAttribute('className','');
    }
    if(document.getElementById('lsoptionclass')) {
        document.getElementById('lsoptionclass').setAttribute('class','');
        document.getElementById('lsoptionclass').setAttribute('className','');      
    }
    if(document.getElementById('lsoptiontype1class')) {
        document.getElementById('lsoptiontype1class').setAttribute('class','');
        document.getElementById('lsoptiontype1class').setAttribute('className','');      
    }
    if(document.getElementById('lsoptiontype2class')) {
        document.getElementById('lsoptiontype2class').setAttribute('class','');
        document.getElementById('lsoptiontype2class').setAttribute('className','');      
    }
    if(document.getElementById('avisclass')) {
        document.getElementById('avisclass').setAttribute('class','');
        document.getElementById('avisclass').setAttribute('className','');      
    }
    document.getElementById(libelle+'class').setAttribute('class','on');
    document.getElementById(libelle+'class').setAttribute('className','on');
}    

function checkQteArt(action, object) {
    qte = Number(document.calcultotal['nop-0'].value);
    if (isNaN(qte)){
        alert("La valeur saisie est incorrect");
        document.calcultotal['nop-0'].value = 1;			
        calcul();		
    }else if (qte < 0){
        alert("Vous ne pouvez pas saisir de quantit\u00e9 n\u00e9gative.");
        document.calcultotal['nop-0'].value = 1;			
        calcul();
    }else if (qte > 9999){
        alert("La quantit\u00e9 saisie ne doit pas d\u00e9passer 9999.");
        document.calcultotal['nop-0'].value = 9999;			
        calcul();
    }else if (qte == 0){
        alert("La quantit\u00e9 saisie doit etre sup\u00e9rieure a 0.");
        document.calcultotal['nop-0'].value = 1;			
        calcul();	
    }else{
        if (action == 'increment'){
            incrementPanier(1, object);
            calcul();
        }else if (action == 'decrement'){
            incrementPanier(-1, object);
            calcul();
        }else if (action == 'qte'){
            document.calcultotal['nop-0'].value = qte;	
            calcul();
        }else if (action == 'add'){
            BasketMgt.addProduct( document.calcultotal.eiid.value, document.calcultotal['nop-0'].value, { callback:function(data) {     refreshLightBasket();showPopup('panier');}});
        }
    }
    
} 


function showPopup(libele) {
    _id_layer = "popup";    
    init_layer();
    
    if (obj_layer) {	
        cache = false;
        
        startEffect2('masque');
        var ch_texte = '<div id="contentPopup" >';
        
        if(libele=='panier'){
            ch_texte += '<h1 class="produits">L\'article a bien &eacute;t&eacute; ajout&eacute; au panier</h1><br>';
            ch_texte += '<div id="targetarea" class="arial_12_000000" style="margin-top: 5px; margin-bottom: 10px;">&nbsp;</div>';
            ch_texte += '<a href="pre?zone=zoneprocessachat&baskettodo=display&pageid=17"><img src="/images/fiche-produit/accederAupanierVert.gif" border="0"></a><br>';
            ch_texte += '<a href=javascript:fermer()><img src="/images/fiche-produit/btnPoursuivreAchatsVert.gif" border="0"></a></div>';
        }
        
        if(libele=='liste'){
            ch_texte += '<h1 class="produits">L\'article a bien &eacute;t&eacute; ajout&eacute; &agrave; ma liste</h1><br>';
            ch_texte += '<div id="targetarea" class="arial_12_000000" style="margin-top: 5px; margin-bottom: 10px;">&nbsp;</div>';
            ch_texte += '<a href="pre?zone=zonelistecourse&srvname=srvlistecourse&action=showlistecourse&pageid=17"><img src="/images/fiche-produit/accederAmalisteVert.gif" border="0"></a><br>';
            ch_texte += '<a href=javascript:fermer()><img src="/images/fiche-produit/btnPoursuivreAchatsVert.gif" border="0"></a></div>';
            
        }
        
        if(libele=='nf'){
            ch_texte += '<div class="fermer"><a href="javascript:fermer()">Fermer <img src="/images/fiche-produit/icoFermerZoom.gif" alt="fermer" /></a></div>';
            ch_texte += '<h1 class="produits">Norme Fran&ccedil;aise</h1><br>';
            ch_texte += '<div id="targetarea" class="arial_12_000000" style="margin-top: 5px; margin-bottom: 5px;">&nbsp;</div>';
            ch_texte += '<table cellspacing="2"><tr><td valign="top"><img src="/images/fiche-produit/logoQualite2.gif" alt="" /></td><td>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla pretium, eros a dapibus ultrices, ligula arcu aliquam justo, congue gravida quam tortor eu metus. Etiam lacinia risus id sem. Pellentesque tellus. Aliquam ac erat vel ligula viverra lobortis. In hac habitasse platea dictumst. Duis accumsan. Nullam eget libero. Aliquam erat volutpat. Sed lectus lorem, commodo ut, elementum quis, molestie nec, tortor. Donec est massa, sollicitudin eget, aliquet sagittis, bibendum sed, libero. Nullam libero mi, dignissim in, vulputate sit amet, pharetra at, orci. Praesent pretium pulvinar risus.</td></tr></table>';
            ch_texte += '</div>';
        }
        
        if(libele=='composition'){
            ch_texte += '<div class="fermer"><a href="javascript:fermer()">Fermer <img src="/images/fiche-produit/icoFermerZoom.gif" alt="fermer" /></a></div>';
            ch_texte += '<h1 class="produits">Composition</h1><br>';
            ch_texte += '<div id="targetarea" class="arial_12_000000" style="margin-top: 5px; margin-bottom: 5px;">&nbsp;</div>';
            ch_texte += '<b>Image composee de 3 les de papier peint intisse</b><br><br>';
            ch_texte += 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla pretium, eros a dapibus ultrices, ligula arcu aliquam justo, congue gravida quam tortor eu metus. Etiam lacinia risus id sem. Pellentesque tellus. Aliquam ac erat vel ligula viverra lobortis. In hac habitasse platea dictumst. Duis accumsan. Nullam eget libero. Aliquam erat volutpat. Sed lectus lorem, commodo ut, elementum quis, molestie nec, tortor. Donec est massa, sollicitudin eget, aliquet sagittis, bibendum sed, libero. Nullam libero mi, dignissim in, vulputate sit amet, pharetra at, orci. Praesent pretium pulvinar risus.';
            ch_texte += '</div>';
        }
        
        if(libele == 'popup:schemas'){
            
            ch_texte += '<div class="fermer"><a href="javascript:fermer()">Fermer <img src="/images/fiche-produit/icoFermerZoom.gif" alt="fermer" /></a></div>';
            ch_texte +=  '<h1 class="produits">Schemas</h1><br>';
            ch_texte +=  document.getElementById("schema").value;
            ch_texte +=  '</div>';
            
        }
        if(libele == 'popup:plusphotos' ){
            
            ch_texte += '<div class="fermer"><a href="javascript:fermer()">Fermer <img src="/images/fiche-produit/icoFermerZoom.gif" alt="fermer" /></a></div>';
            ch_texte +=  '<h1 class="produits">Plus de photos</h1><br>';
            ch_texte +=  document.getElementById("plusphotos").value;
            ch_texte +=  '</div>';
            
        }
        if(libele == 'popup:ensavoirplus'){
            
            ch_texte += '<div class="fermer"><a href="javascript:fermer()">Fermer <img src="/images/fiche-produit/icoFermerZoom.gif" alt="fermer" /></a></div>';
            ch_texte +=  '<h1 class="produits">En savoir plus</h1><br>';
            ch_texte +=  document.getElementById("ensavoirplus").value;
            ch_texte +=  '</div>';
            
        }
        
        if(libele=='archiveAddOk'){
            ch_texte += '<img src="/images/compte/popup_title.gif" width="129" height="16"><br>';
            ch_texte += '<div id="targetarea" class="arial_12_000000" style="margin-top: 5px; margin-bottom: 10px;">&nbsp;</div>';
            ch_texte += '<a href="/mpng2-front/pre?zone=zoneespaceperso&srvname=srvuserarchivemngt&pageid=28"><img src="/images/compte/popup_btn1.gif" width="203" height="21" border="0"></a><br>';
            ch_texte += '<a href=javascript:fermer()><img src="/images/compte/popup_btn2.gif" width="276" height="21" border="0"></a></div>';
        }
        
        if(libele=='errorinaddress'){
            ch_texte += '<img src="/images/liste-panier/msgErreur.gif" alt="erreur" /><br/>';
            ch_texte += '<div id="targetarea" style="margin-top: 5px; margin-bottom: 10px;"><strong>Veuilllez corriger ou renseigner les champs <br />en contour rouge.</strong></div>';
            ch_texte += '<a href=javascript:fermer()><img src="/images/liste-panier/btnFermerErreur.gif" alt="fermer" /></a></div>';
        }
        
        scroll_layerlist();
        contenu_layerlist(ch_texte);
        
    }
    
}
function showZoom() {
    if(document.getElementById("calqueZoom").getElementsByTagName("img")[1].src != window.location) {
        if(document.getElementById("calqueZoom").getElementsByTagName("img")[1].src.indexOf("popup:")==-1) {
            if ( document.getElementById("calqueZoom").style.visibility != "visible" ) {
                document.getElementById("calqueZoom").style.visibility = "visible";
            }
        }
        else {
            // alert(document.getElementById("calqueZoom").getElementsByTagName("img")[1].src);
            var winl = (screen.width - 800) / 2;
            var wint = (screen.height - 600) / 2;
            var lien = 'pre?zone=zonecatalogue&idEIPub='+window.document.calcultotal.eiid.value+'&mdpid=1175778426&eipublicationtype=EI&zonetmp=zoneimpressionsl&06-impression-render=off';
            // window.open(lien,'popup',"height="+ 400 + ",width="+ 400 +",top=" + wint + ",left=" + winl + ",resizable=yes,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1").focus();
            showPopup(document.getElementById("calqueZoom").getElementsByTagName("img")[1].src);
        }
    }
}
function hiddeZoom() {
    if(document.getElementById("calqueZoom")) {
        document.getElementById("calqueZoom").style.visibility = "hidden";
    }
    else {
        fermer();
    }
}

comptZoom = 0;
comptFirst = 0;
function changeZoom(indent) {
    comptZoom = comptZoom + indent;
    if ( comptZoom == -1 ) comptZoom = 0;
    else if ( comptZoom == listeVisuels.length ) comptZoom = listeVisuels.length-1;
    document.getElementById("visuZoom").src = listeVisuels[comptZoom][0];
    document.getElementById("calqueZoom").getElementsByTagName("img")[1].src = listeVisuels[comptZoom][1];
    if(listeVisuels[comptZoom][1]!='') {
        document.getElementById("initzoom").style.visibility = "visible";
        document.getElementById("visuZoom").setAttribute("onclick","showZoom();");
        document.getElementById("visuZoom").onclick = function() {showZoom();};
    }
    else {
        document.getElementById("initzoom").style.visibility = "hidden";
        document.getElementById("visuZoom").setAttribute("onclick","#");
        document.getElementById("visuZoom").onclick = function() {};
    }        
    for ( var i=0; i<document.getElementById("visuZoomVignettes").getElementsByTagName("img").length; i++ ) {
        if ( (listeVisuels.length - comptZoom) > 2 ) {
            if(i==0) comptFirst = comptZoom+i;
            document.getElementById("visuZoomVignettes").getElementsByTagName("img")[i].src = listeVisuels[comptZoom+i][2];
        }
    }
    
}
function changeZoomPos(pos) { 
    comptZoom = comptFirst+pos;
    if ( comptZoom == -1 ) comptZoom = 0;
    else if ( comptZoom == listeVisuels.length ) comptZoom = listeVisuels.length-1;
    document.getElementById("visuZoom").src = listeVisuels[comptZoom][0];
    document.getElementById("calqueZoom").getElementsByTagName("img")[1].src = listeVisuels[comptZoom][1];
    if(listeVisuels[comptZoom][1]!='') {
        document.getElementById("initzoom").style.visibility = "visible";
        document.getElementById("visuZoom").setAttribute("onclick","showZoom();");
        document.getElementById("visuZoom").onclick = function() {showZoom();};
    }
    else {
        document.getElementById("initzoom").style.visibility = "hidden";
        document.getElementById("visuZoom").setAttribute("onclick","#");
        document.getElementById("visuZoom").onclick = function() {};
    }        
    for ( var i=0; i<document.getElementById("visuZoomVignettes").getElementsByTagName("img").length; i++ ) {
        if ( (listeVisuels.length - comptZoom) > 2 ){
            if(i==0) comptFirst = comptZoom+i;
            document.getElementById("visuZoomVignettes").getElementsByTagName("img")[i].src = listeVisuels[comptZoom+i][2];
        }
    }
    
}
var nboption=0;    
    function initnboption()
    {
    nboption=0;
    posv1=0;
    posv2=0;
    do
    {
    nboption = nboption+1;
    }
    while(document.getElementById('li'+nboption));
    if(nboption > 2 )
    {    
    posv2 = posv1+1;
    document.getElementById('navid2').style.display = "block";
    document.getElementById('navid2').style.visibility = "visible";    
    }
    else
    {
    document.getElementById('navid2').style.display = "none";
    document.getElementById('navid2').style.visibility = "hidden";    
    }
    document.getElementById('navid1').style.display = "none";
    document.getElementById('navid1').style.visibility = "hidden";    
    
    //alert('nboption ='+nboption);
    }

function schowNext() {
    
    if( nboption > 1 && posv2 < (nboption-1)) {
        var ndinv = 0;
        do {
            document.getElementById('li'+ndinv).style.display = "none";
            document.getElementById('li'+ndinv).style.visibility = "hidden";    
            ndinv = ndinv + 1;
        }
        while(document.getElementById('li'+ndinv));
        
        posv1=posv1+1;
        posv2=posv2+1;
        //alert('posv1 ='+posv1+ 'posv2 ='+posv2);
        document.getElementById('li'+posv1).style.display = "block";
        document.getElementById('li'+posv1).style.visibility = "visible";
        document.getElementById('li'+posv2).style.display = "block";
        document.getElementById('li'+posv2).style.visibility = "visible";
        if(document.getElementById('navid1'))
        {
        if(posv1 >0) {
            document.getElementById('navid1').style.display = "block";
            document.getElementById('navid1').style.visibility = "visible";        
        }   
        else {
            document.getElementById('navid1').style.display = "none";
            document.getElementById('navid1').style.visibility = "hidden";        
        }
        }
        if(document.getElementById('navid2'))
        {
        if(posv2 == (nboption-1)) {
            document.getElementById('navid2').style.display = "none";
            document.getElementById('navid2').style.visibility = "hidden";        
        }
        else {
            document.getElementById('navid2').style.display = "block";
            document.getElementById('navid2').style.visibility = "visible";        
        }
        }
    }
    
}

function schowPreview() {
    if(nboption > 1 && posv1 > 0 ) {
        var ndinv = 0;
        do {
            document.getElementById('li'+ndinv).style.display = "none";
            document.getElementById('li'+ndinv).style.visibility = "hidden";    
            ndinv = ndinv+1;
        }
        while(document.getElementById('li'+ndinv));
        
        
        posv1=posv1-1;
        posv2=posv2-1;
        // alert('posv1 ='+posv1+ 'posv2 ='+posv2);
        document.getElementById('li'+posv1).style.display = "block";
        document.getElementById('li'+posv1).style.visibility = "visible";
        document.getElementById('li'+posv2).style.display = "block";
        document.getElementById('li'+posv2).style.visibility = "visible";
        if(document.getElementById('navid1'))
        {
        if(posv1 >0) {
            document.getElementById('navid1').style.display = "block";
            document.getElementById('navid1').style.visibility = "visible";        
        }   
        else {
            document.getElementById('navid1').style.display = "none";
            document.getElementById('navid1').style.visibility = "hidden";        
        }
        }
        if(document.getElementById('navid2'))
        {
        if(posv2 == (nboption-1)) {
            document.getElementById('navid2').style.display = "none";
            document.getElementById('navid2').style.visibility = "hidden";        
        }
        else {
            document.getElementById('navid2').style.display = "block";
            document.getElementById('navid2').style.visibility = "visible";        
        }
        }
    }
}

dwr.engine._allowGetForSafariButMakeForgeryEasier = true;





