var imgToResize = new Array();
/** #########################################
* Permet de redimensionner une image
*/
function redimImage(idImg, inMW, inMH)
{
  // Cette function recoit 3 parametres
  // inImg : Chemin relatif de l'image
  // inMW  : Largeur maximale
  // inMH   : Hauteur maximale
  var maxWidth = inMW;
  var maxHeight = inMH;
  // Rcupration de l'lment image
  var oImg = new Image()
  var nImg = document.getElementById(idImg)
  oImg.src = nImg.src;

  // On recupere les tailles reelles
  var h = dH = oImg.height;
  var w = dW = oImg.width;
  // Si la largeur ou la hauteur depasse la taille maximale
  if ((h >= maxHeight) || (w >= maxWidth)) {
    // Si la largeur et la hauteur depasse la taille maximale
    if ((h >= maxHeight) && (w >= maxWidth)) {
      // On cherche la plus grande valeur
      if (h > w) {      
        dW = maxWidth 
        // On recalcule la taille proportionnellement
        dH = parseInt((h * dW) / w, 10);
        dW = parseInt((w * dH) / h, 10);
      } else {
        dH = maxHeight 
        // On recalcule la taille proportionnellement
        dW = parseInt((w * dH) / h, 10);        
        dH = parseInt((h * dW) / w, 10);
      }
    } else if ((h > maxHeight) && (w < maxWidth)) {
      // Si la hauteur depasse la taille maximale
      dH = maxHeight;
        // On recalcule la taille proportionnellement
      dW = parseInt((w * dH) / h, 10);
    } else if ((h < maxHeight) && (w > maxWidth)) {
      // Si la largeur depasse la taille maximale
      dW = maxWidth;
        // On recalcule la taille proportionnellement
      dH = parseInt((h * dW) / w, 10);
    }
  // On mets  jour les dimensions de l'image dans le document    
  nImg.height = dH
  nImg.width = dW
  }
}

/** #########################################
* Permet de redimensionner les images des BU
*/
function resizeAll(listImgToResize, inMW, inMH){    
    if(listImgToResize.length > 0){
        for(i=0;i<listImgToResize.length; i++){
            redimImage(listImgToResize[i], inMW, inMH);
        }
    }    
}

/*
* Permet de charger une nouvelle image principal
*/
function changeMainPicture(idPicture, newUrl){
    imgObject = document.getElementById(idPicture);
    imgObject.src = newUrl;
}

/** #########################################
* Permet de cacher les onglets
*/
function hideOnglet(node){
    var firstNode = null ;
    if(node){
        parentNode = node.parentNode;
        if(parentNode.id != "product-details"){
            parentNode = parentNode.parentNode ;
        }
    }
    else{
        parentNode = document.getElementById("product-details") ;
    }
    if(parentNode != null){
        allH4 = parentNode.getElementsByTagName('h4');
        allDL = parentNode.getElementsByTagName('dl');
        for(i in allH4){
            if(firstNode == null){
                firstNode = allH4[i].id ;
            }
            allH4[i].className = '';
        }
        for(j=0 ; j<allDL.length ; j++){
            allDL[j].className = 'hidden';            
        }
        return firstNode ;
    }
}

/** #########################################
* Permet de slectionner un onglet
*/
function selectOnglet(node, current){
    var firstNode = hideOnglet(node) ;
    if(node == null){        
        node = document.getElementById(firstNode) ;
    }
    node.className = 'selectionne';
    
    if(document.getElementById(node.id+"-contenu")){
        document.getElementById(node.id+"-contenu").className = "" ;
    }
    else if(parent.document.getElementById(node.id+"-contenu")){
        parent.document.getElementById(node.id+"-contenu").className = "" ;    
    }
}

/** #########################################
* Permet d'ouvrir un zoom produit
*/
function ouvrirZoom(imageName){
    window.open(imageName , "", "top=screen.height,left=0,width=420, height=430, location=0, titlebar=0, status=0,menubar=0" );         
}

/** #########################################
* Permet de changer la photo principale par la photo choisie par l'internaute
*/
function changeMainPicture(idImage, idZoomImage, urlImage, urlZoomImage){
    document.getElementById(idImage).src = urlImage ;   
    urlZoomImg =  urlZoomImage;
    document.getElementById(idImage).onclick = function onclick(event){ouvrirZoom(urlZoomImg);return false;};      
    initZoom(idImage, idZoomImage);
}

/** #########################################
* Permet d'initialiser l'image zoom en fonction de l'image principale
*/
function initZoom(idImage, idZoomImage){
    if(document.getElementById(idZoomImage)){
        document.getElementById(idZoomImage).onclick = document.getElementById(idImage).onclick;
    }
}

/** #########################################
* Permet d'initialiser le premier onglet
*/
function initOnglet(){
    /*if(document.getElementById("prixTab")){
        document.getElementById("prixTab").className = "selectionne" ;
        selectOnglet(document.getElementById("prixTab"), 0) ;
    }    
    else*/
    if(parent.document.getElementById('beneficesTab')){
        document.getElementById("beneficesTab").className = "selectionne" ;
        selectOnglet(document.getElementById("beneficesTab"), 0) ;
    }
    else if(parent.document.getElementById('infoPlusTab')){
        document.getElementById("infoPlusTab").className = "selectionne" ;
        selectOnglet(document.getElementById("infoPlusTab"), 0) ;
    }
    else if(parent.document.getElementById('tailleEtColorisTab')){
        document.getElementById("tailleEtColorisTab").className = "selectionne" ;
        selectOnglet(document.getElementById("tailleEtColorisTab"), 0) ;
    }
    /*else if(parent.document.getElementById('oxylaneAvisTab')){
        selectOnglet(parent.document.getElementById('oxylaneAvisTab'), 5);        
    }*/
    else if(parent.document.getElementById('oxylaneTab')){
        document.getElementById("oxylaneTab").className = "selectionne" ;
        selectOnglet(document.getElementById("oxylaneTab"), 0) ;
    }            
}

/** #########################################
* Permet d'ouvrir une popup
*/
function openPopup(url, largeur, hauteur){
    var timestamp = Math.floor((new Date()).getTime() / 1000) ;
    window.open(url, 'nw'+timestamp, 'top=screen.height,left=0,width='+largeur+',height='+hauteur+',menubar=no,toolbar=no, scrollbars=yes,location=no,resizable=yes') ;
}

/** #########################################
* Permet d'ouvrir une popup
* fonction 2
*/
function openPopup2(url){
    largeur=1000;
    hauteur=600;
    var timestamp = Math.floor((new Date()).getTime() / 1000) ;
    window.open(url, 'nw'+timestamp, 'top=screen.height,left=0,width='+largeur+',height='+hauteur+',menubar=no,toolbar=no, scrollbars=yes,location=no,resizable=yes') ;
}

/** #########################################
* Permet de rediriger l'internaute vers la page famille si le produit n'est plus dispo
*/
function redirectProduit(modele, urlPathFamille){
    if(urlPathFamille != ""){                
        var locationProduit = document.location.href ;
        document.location.href = urlPathFamille + "?nondispo=true" ;        
    }    
}

/** #########################################
* Permet d'ouvrir une vido
*/
function openPlayer(urlVideo, width, height){
    if(width == ''){
        width = "800" ;
    }
    if(height == ""){
        height = "600" ;
    }
    var target = "" ;
    if(urlVideo.indexOf(".flv") > -1){
        target = "_blank" ;
    }
    else if(urlVideo.indexOf(".wmv") > -1){
        target = "_top" ;
    }
    else{
        target = "_blank" ;
    }
    
    window.open(urlVideo, target, "width="+width+",height="+height+",location=no,toolbar=no,resizable=yes,menubar=no") ;
}

/** #########################################
* Permet d'ouvrir une vido
*/
function openPlayer2(){
    var timestamp = Math.floor((new Date()).getTime() / 1000) ;        
    window.open("infoPlus.html", 'player'+timestamp, "width=800,height=700,location=no,toolbar=no,resizable=yes,menubar=no") ;
}

/** #########################################
* Permet de rcuprer le path du rayon
*/
function getPathRayon(genereDecouvrirPlus, rootPath, urlPathFamille, labelAccueil, libelleProduit, refProduit, libelleDecouvrez, rubTg, id, listeRayon, listeRayonArbo){
    var xhr = getXhr();
    
    xhr.onreadystatechange = function(){
        if(xhr.readyState == 4 && xhr.status == 200){         
            
            var propertiesDivObjSr = document.getElementById("content-famille-path");
            var propertiesAdviceDivObjSr = document.getElementById("advice");
            var propertiesTreeDivObjSr = document.getElementById("content-famille-arbo");
            var propertiesTgDivObjSr = document.getElementById("zone-tg");
            var propertiesBackDivObjSr = document.getElementById("back-picture");
            
            responseAjax = xhr.responseXML ;
            var rayonTag = responseAjax.getElementsByTagName("Rayon")[0] ;
            var rayonName = "" ;
            var rayonUrl = "" ;
            var rayonCss = "" ;            
            var rayonImageConseil = "" ;
            var rayonAltImgConseil = "" ;
            var rayonLibelleConseil = "" ;
            var rayonMultiName = "" ;
            for (i=0; i<rayonTag.childNodes.length; i++){
                if (rayonTag.childNodes[i].nodeName=="title"){
                    rayonName = rayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (rayonTag.childNodes[i].nodeName=="body2"){
                    rayonName = rayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (rayonTag.childNodes[i].nodeName=="userTitle"){
                    rayonName = rayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (rayonTag.childNodes[i].nodeName=="url"){
                    rayonUrl = rootPath+rayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (rayonTag.childNodes[i].nodeName=="color"){
                    rayonCss = rayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (rayonTag.childNodes[i].nodeName=="name_image1"){
                    rayonImageConseil = rayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (rayonTag.childNodes[i].nodeName=="description1"){
                    rayonAltImgConseil = rayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (rayonTag.childNodes[i].nodeName=="body1"){
                    rayonLibelleConseil = rayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (rayonTag.childNodes[i].nodeName=="multilingualCategoryName"){
                    rayonMultiName = rayonTag.childNodes[i].firstChild.nodeValue ;
                    
                     //on va dplier le sous menu
                    expandSubMenuWithURL(id, listeRayon, listeRayonArbo, rayonMultiName) ;
                }                    
            }
            
            //on va d'abord tester si le rayon est dispo (n'a t-il pas t dpublier ??)
            isRayonExiste = verifRayonPublie(rayonUrl) ;
            var sousRayonTag = responseAjax.getElementsByTagName("SousRayon")[0] ;
            var sousRayonName = "" ;
            var sousRayonUrl = "" ;
            var sousRayonMultiName = "" ;
            for (i=0; i<sousRayonTag.childNodes.length; i++){
                if (sousRayonTag.childNodes[i].nodeName=="title"){
                    sousRayonName = sousRayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (sousRayonTag.childNodes[i].nodeName=="url"){
                    sousRayonUrl = rootPath+sousRayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (sousRayonTag.childNodes[i].nodeName=="multilingualCategoryName"){
                    sousRayonMultiName = sousRayonTag.childNodes[i].firstChild.nodeValue ;                
                }           
            }
            
            var familleTag = responseAjax.getElementsByTagName("Famille")[0] ;
            var familleName = "" ;
            var familleUrl = "" ;
            var familleMultiName = "" ;
            for (i=0; i<familleTag.childNodes.length; i++){
                if (familleTag.childNodes[i].nodeName=="title"){
                    familleName = familleTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (familleTag.childNodes[i].nodeName=="url"){
                    familleUrl = rootPath+familleTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (familleTag.childNodes[i].nodeName=="multilingualCategoryName"){
                    familleMultiName = familleTag.childNodes[i].firstChild.nodeValue ;                
                }
                
                if(familleTag.childNodes[i].nodeName=="userTitle"){                    
                    if(familleTag.childNodes[i].firstChild.nodeValue != ""){
                        familleName = familleTag.childNodes[i].firstChild.nodeValue ;
                    }
                }                
            }              
            var intitulerTagGAR='/'+_language+'/chemin de fer/'+rayonName;
          var reg=new RegExp("'", "g");
          intitulerTagGAR=intitulerTagGAR.replace(reg,"&apos;");
           var tagGAR='if(hasGoogleAnalytic)pageTracker._trackPageview("'+intitulerTagGAR+'");';
           
            var intitulerTagGAF='/'+_language+'/chemin de fer/'+familleName;
          var reg=new RegExp("'", "g");
          intitulerTagGAF=intitulerTagGAF.replace(reg,"&apos;");
          
           var intitulerTagGAFR=_tagPageGoogleAnalytic+'/'+familleName;
          var reg=new RegExp("'", "g");
          intitulerTagGAFR=intitulerTagGAFR.replace(reg,"&apos;");
          
           var tagGAF='if(hasGoogleAnalytic)pageTracker._trackPageview("'+intitulerTagGAF+'");';
           var tagGAFR="if(hasGoogleAnalytic)pageTracker._trackPageview('"+intitulerTagGAFR+"');";
           
            if(rayonName != "" && rayonUrl != "" && sousRayonName != "" && sousRayonUrl != "" && familleName != "" && familleUrl != ""){                
                var zonePath = "<div id='content-famille-path'>"+
                    "<a href='"+rootPath+"'>"+labelAccueil+ "</a> "+
                    "&gt; <a href='"+rayonUrl+"' onclick='"+tagGAR+"'>"+rayonName+"</a> "+
                    "&gt; "+sousRayonName+
                    "&gt; <a id='lienFamillePath' href='"+familleUrl+"' target='_top' onclick='"+tagGAF+"'>"+familleName+"</a>"+
                    " &gt; "+ libelleProduit +
                    "</div>" ;                   
                
                var zoneBack = '<a href="'+familleUrl+'" onclick="'+tagGAFR+'"><img alt="" align="absmiddle" src="../images/static/retour.gif"></a>' ;                
                var zoneTree = "<iframe id='iframe-arbo' src='"+rayonUrl+"tree.html?sousrayon="+sousRayonMultiName+"&famille="+familleMultiName+"' frameborder='0' scrolling='no' style='display:none;'></iframe>" ;
                var zoneTg = "<iframe id='iframe-tg' src='"+rubTg+"index.html?nomRayon="+rayonMultiName+"&rayonCss="+rayonCss+"' scrolling='no' frameborder='0'></iframe>" ; 

                if(rayonCss){
                    var styleSpec = document.getElementById("specStyle") ;
                    styleSpec.href = rootPath+"/css/"+rayonCss+".css" ;
                }
                
                if(rayonImageConseil && rayonLibelleConseil){
                    var zoneAdvice = "<img src='"+rootPath+"/images/assets/"+rayonImageConseil+"' ";
                    if(rayonAltImgConseil){
                        zoneAdvice = zoneAdvice + "alt='"+rayonAltImgConseil+"' >" ;
                    }
                    else{
                        zoneAdvice = zoneAdvice + "alt='"+rayonName+"' >" ;
                    }                           
                    var intitulerTagGACo=_tagPageGoogleAnalytic+'/'+rayonLibelleConseil;
                    var reg=new RegExp("'", "g");
                    intitulerTagGACo=intitulerTagGACo.replace(reg,"&apos;");
                    var tagGAFR='if(hasGoogleAnalytic)pageTracker._trackPageview("'+intitulerTagGACo+'");';
                    zoneAdvice = zoneAdvice + "<a href='"+rayonUrl+"conseil.shtml' onclick='"+tagGAFR+"'>";
                    if(rayonLibelleConseil){
                        zoneAdvice = zoneAdvice + rayonLibelleConseil ;
                    }
                    else{
                        zoneAdvice = zoneAdvice + rayonName ;
                    }         
                    zoneAdvice = zoneAdvice + "</a>" ;
                    propertiesAdviceDivObjSr.innerHTML = zoneAdvice ;
                }       
                
                document.getElementById("titreRayon").innerHTML = rayonName ;
                propertiesDivObjSr.innerHTML = zonePath ;
                propertiesTreeDivObjSr.innerHTML = zoneTree ;
                if(propertiesTgDivObjSr){
                    propertiesTgDivObjSr.innerHTML = zoneTg ;
                }
                
                propertiesBackDivObjSr.innerHTML = zoneBack ;
                
                if(genereDecouvrirPlus == "true"){
                    var urlProduit = document.location.href ;
                    var urlProduitTab = urlProduit.split('/') ;
                    //Recuperation au format /FR/produit-xxx-123456/
                    if(urlProduitTab[3] && urlProduitTab[4]){
                        urlProduit = "/"+urlProduitTab[3]+"/"+urlProduitTab[4]+"/" ;
                        refProduit = "/"+urlProduitTab[4]+"/" ;
                    }
                    else{
                        urlProduit = "" ;
                        refProduit = "" ;
                    }                    
                    getTreeRayon(rootPath, rayonUrl+"tree.html", refProduit, sousRayonMultiName, libelleDecouvrez, rayonUrl, familleUrl, urlProduit) ;
                }
            }
        }
    }
    
    xhr.open("GET", urlPathFamille, true);
    xhr.setRequestHeader('Content-Type','text/xml');
    xhr.send(null);
}

/** #########################################
* Permet de vrifier si le rayon existe bien
*/
function verifRayonPublie(urlRayon){
    var xhr = getXhr();
    xhr.onreadystatechange = function(){
        if(xhr.readyState == 4 && xhr.status == 200){
            return true ;
        }
        else if(xhr.readyState == 4 && xhr.status == 404){
            document.location.href="../index.shtml" ;
            return false ;
        }
    }
    xhr.open("GET", urlRayon, true);
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xhr.send(null);
}

/** #########################################
* Permet de rcuprer le tree du rayon
*/
function getTreeRayon(rootPath, urlTree, refProduit, nomSousRayon, libelleDecouvrez, urlRayon, urlFamille, urlProduit){
    var xhr = getXhr();
    
    xhr.onreadystatechange = function(){
        if(xhr.readyState == 4 && xhr.status == 200){
            responseAjax = xhr.responseText ;
            spanArray = responseAjax.split('<span id="')  ;
            var nbFamille = 0 ;
            
            for(var k=1 ; k<spanArray.length ; k++){                
                var sousRayonCourant = spanArray[k].split('"')[0] ;
                if(sousRayonCourant == nomSousRayon+"-nb-famille"){
                    nbFamille = spanArray[k].split('">')[1].split("</span>")[0] ;
                    break;
                }
            }
            if(nbFamille > 0){
                var idsFamille = "" ;
                
                //On va rcuprer le nombre famille disponible pour ce sous rayon
                var nbFamilleFound = 0 ; //le nb de famille trouv
                //Si le nb de famille est strictement suprieur  4, on va chercher  afficher 4 produit en plus du produit principal
                if(nbFamille > nbProduitVraimentAAfficher){
                    while(nbFamilleFound<nbProduitVraimentAAfficher){                           
                        //Gnre une famille au hasard
                        randomIdFamille = Math.ceil(Math.random()*nbFamille) ;
                        var idFamille = nomSousRayon+"-famille-"+randomIdFamille ; //identifiant famille dans tree.html                   
                
                        //Si la famille n'a pas encore t choisi, on slectionne cette famille
                        if(idsFamille.indexOf(idFamille, 0) == -1 && randomIdFamille > 0){
                            nbFamilleFound++ ; //on incrmente le nb de famille trouve                      
                            idsFamille = idsFamille + idFamille + ";" ;                              
                        }                   
                    }
                }
                //Sinon si le nb de famille est infrieur ou gal  4, on va chercher  afficher le maximum de produit possible mais 4 produits au maximum
                else if(nbFamille <= nbProduitVraimentAAfficher){
                    for(var t=0 ; t<nbFamille ; t++){
                        //Gnre une famille au hasard
                        var idFamille = nomSousRayon+"-famille-"+(t+1) ;
                        idsFamille = idsFamille + idFamille + ";" ;
                    }                           
                }   
                
                //Suppression du dernier ";"
                if(idsFamille.lastIndexOf(";") == idsFamille.length-1){
                    idsFamille = idsFamille.substring(0, idsFamille.length-1) ;
                }
                var arrayIdFamille = idsFamille.split(";") ; //Tableau contenant la liste des familles
                var arrayParamFamille = new Array() ;
                
                for(var m=0 ; m<arrayIdFamille.length ; m++){
                    var currentIdFamille = arrayIdFamille[m]  ;
                    
                    nomFamille = responseAjax.split(currentIdFamille)[1].split('class="')[1].split('"')[0] ;
                    currentUrlFamille = responseAjax.split(currentIdFamille)[1].split('href="')[1].split('"')[0] ;
                    arrayParamFamille[m] = nomFamille+"___"+currentUrlFamille ;
                }            
                getDecouvrirPlus(rootPath, nomSousRayon, refProduit, libelleDecouvrez, nbFamille, arrayParamFamille, urlRayon, urlFamille, urlProduit);
            }
        }
    }
    xhr.open("GET", urlTree, true);
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xhr.send(null);
}

/** #########################################
* Permet de charger l'image principale dans la popup photoplus
*/
function chargeMainPicture(idImage, urlImage){
    var currentPhoto = document.getElementById(idImage).src ;    
    if(currentPhoto.indexOf(urlImage) == -1){
        document.getElementById(idImage).src = urlImage ;
    }
}

/** #########################################
* Permet de charger une image directe dans la popup photoplus
*/
function chargeDirectPhoto(idImage){
    var params = getParameters() ;
    if(params[0][1] && params[0][1] != ""){
        var urlImage = decodeURI(params[0][1]) ;
        chargeMainPicture(idImage, urlImage) ;
    }
}

/** #########################################
* Permet d'ouvrir la popup photoplus
*/
function openPhotoPlus(imgObj, url){
    var imgSrc = imgObj.src ;
    if(imgSrc){
        imgSrc = imgSrc.replace("gd-asset", "asset") ;
        if(imgSrc.indexOf("my-asset") == -1){
            openPopup(url+'?image='+imgSrc, '500', '750') ;
        }
	else{
	    openPopup(url, '500', '750') ;
	}
    }
}

/** #########################################
* Permet de cacher tous les concupour de la page famille
*/
function hideAllConcuPour(){
    var divTags = document.getElementById("content-products") ;
    var divChildTags = divTags.getElementsByTagName("div") ;
    
    for(var k=0 ; k<divChildTags.length ; k++){
        if((divChildTags[k].id).indexOf("infoplus-produit-") > -1){
            divChildTags[k].style.display = "none" ;
        }
    }
}

/** #########################################
* Permet de rcuprer les info plus produit
*/
function getInfoPlusProduitV1(refModele) {
    showall = document.getElementById('all-pages');

    if(!showall || (showall && showall.style.visibility != 'hidden')){
        //hideAllConcuPour() ;
        var propertiesDivObjSr = document.getElementById("infoplus-produit-"+refModele);
        if(propertiesDivObjSr){
            propertiesDivObjSr.style.display = "block" ;
        }
    }
}

/** #########################################
* Permet de mettre  jour le bloc info plus produit
*/
function getInfoPlusProduitV2(rootPath, refProduit, libProduit, imgProduit, concupour, accroche, lienProduit, libconcupour, libEnsavoirplus, libAjouterFavoris) {    
    var propertiesDivObjSr = document.getElementById("previsu-produit");
    if(propertiesDivObjSr){
        var libProduitTmp = libProduit.replace("'", "\\'") ;
        var result = "<div id='libproduit'><a href='"+lienProduit+"' target='_top'>"+libProduit+"</a></div>" +        
            "<a href='"+lienProduit+"' target='_top'><img alt='"+libProduit+"' id='previsu' src='"+imgProduit+"'></a>" +
            "<div id='info'>"+
                "<div id='concupour'><strong>"+libconcupour+"</strong>"+concupour+"</div>" +
                getAccrocheProduit(rootPath, accroche) +
            "</div>" ;

        propertiesDivObjSr.innerHTML = result ;
        propertiesDivObjSr.style.display ="block";

        moveContainer();
        
    }
}

/** #########################################
* Permet de rcuprer l'accroche produit
*/
function getAccrocheProduit(rootPath, accroche){
    if(accroche != ""){
	return "<div id='accroche'><img src='/"+rootPath+"/images/static/070627-int-picto-savoir.gif' align='absmiddle'>&nbsp;"+accroche+"</div>" ;
    }
    else{
	return "" ;     
    }
}
/** #########################################
* Code pour xiti
*/
function getRayon(urlPathFamille){
    var xhr = getXhr();
    
    xhr.onreadystatechange = function(){
        if(xhr.readyState == 4 && xhr.status == 200){         
            
            var propertiesDivObjSr = document.getElementById("content-famille-path");
            var propertiesAdviceDivObjSr = document.getElementById("advice");
            var propertiesTreeDivObjSr = document.getElementById("content-famille-arbo");
            var propertiesTgDivObjSr = document.getElementById("zone-tg");
            var propertiesBackDivObjSr = document.getElementById("back-picture");
            
            responseAjax = xhr.responseXML ;
            var rayonTag = responseAjax.getElementsByTagName("Rayon")[0] ;
            var rayonName = "" ;
            var rayonUrl = "" ;
            var rayonCss = "" ;            
            var rayonImageConseil = "" ;
            var rayonAltImgConseil = "" ;
            var rayonLibelleConseil = "" ;
            var rayonMultiName = "" ;
            for (i=0; i<rayonTag.childNodes.length; i++){
                if (rayonTag.childNodes[i].nodeName=="title"){
                    rayonName = rayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (rayonTag.childNodes[i].nodeName=="body2"){
                    rayonName = rayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (rayonTag.childNodes[i].nodeName=="userTitle"){
                    rayonName = rayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (rayonTag.childNodes[i].nodeName=="url"){
                    rayonUrl = rootPath+rayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (rayonTag.childNodes[i].nodeName=="color"){
                    rayonCss = rayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (rayonTag.childNodes[i].nodeName=="name_image1"){
                    rayonImageConseil = rayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (rayonTag.childNodes[i].nodeName=="description1"){
                    rayonAltImgConseil = rayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (rayonTag.childNodes[i].nodeName=="body1"){
                    rayonLibelleConseil = rayonTag.childNodes[i].firstChild.nodeValue ;                
                }
                if (rayonTag.childNodes[i].nodeName=="multilingualCategoryName"){
                    rayonMultiName = rayonTag.childNodes[i].firstChild.nodeValue ;
                    
                }                    
            }
            
            //on va d'abord tester si le rayon est dispo (n'a t-il pas t dpublier ??)
            isRayonExiste = verifRayonPublie(rayonUrl) ;
            }

      }
           xhr.open("GET", urlPathFamille, true);
        xhr.setRequestHeader('Content-Type','text/xml');
        xhr.send(null);
}



