var Timer;
var contexteclick = "";
var LuxeEnv = false;
var SelectedCriteriaStack = new Array(0);
//Variables utilisees pour le tag du Moteur de selection
var nbSearch = parseInt(0);
var provenance;
var provenanceTemp;
var isFinalTag = false;
var isTagSortie = false;
var toProduct = false;
var SelectedCriteriaList = new Array(0);
var fromProductToMoteur = false;

var isProductHome = false;
var isJSBackHistory = false;
var isNewsLetter = false;

var isCalledEulerian = false; //Variable pour détecter si c'est un premier appel du tag eulerian

var tiSiteID = 589;
var tiComplement = "";

var enableMovingBasket = true;
var loadHeader = true;
var updatedHeaderBasket = true; //Variable pour tester si on doit recharger le contenu du résumé du basket dans le header ou non
function getCurrency() {
    return document.getElementById('Currency').value;
}
function FormatCurrency(montant) {
    return document.getElementById('Currency').value.replace('{0}', montant);

}
function InitMesPreferes() {
    var eltNbMesPreferes = getElement_By_Id("NbMesPreferes");
    if (eltNbMesPreferes != null) {
        //SHA Nouvelle Gestion du Cookie
        var isAuth = "0";
        isAuth = getCookieMultiValue("SarUserContext", "srIsAuthen");
        ////if (ReadCookie("IsAuthenticated") != "True") {
        if (isAuth != "1") {
            //var expires = new Date();
            //expires.setDate(expires.getDate() +7);
            //WriteCookie("NbMesPreferes","",expires,'/');
        }
        else {
            if (getCookieMultiValue("sarServices2", "NbMesPreferes") != "") {
                eltNbMesPreferes.innerHTML = "(" + getCookieMultiValue("sarServices2", "NbMesPreferes") + ")";
            }
        }
    }
}

function ChangeContext2DefaultAndRedirect() {
    var expires = new Date();
    expires.setDate(expires.getDate() + 1000);
    setCookieMultiValue("sarServices2", "Context", "Default", expires);
    //alert(getCookieMultiValue("sarServices2", "Context"));
    //document.location = "/"
}
function ChangeContext2LuxeAndRedirect() {
    var expires = new Date();
    expires.setDate(expires.getDate() + 1000);
    setCookieMultiValue("SarServices2", "Context", "Luxe", expires);

}
function UpdateMesBonsAchatDisplay(value) {
    var eltNbBonsAchat = getElement_By_Id("NbBonsAchat");
    eltNbBonsAchat.innerHTML = "(" + FormatCurrency(value.toString().replace(",00", "")) + ")";
}
function InitMesBonsAchat() {
    var eltNbBonsAchat = getElement_By_Id("NbBonsAchat");
    if (eltNbBonsAchat != null) {
        //SHA Nouvelle Gestion du Cookie
        var isAuth = "0";
        isAuth = getCookieMultiValue("SarUserContext", "srIsAuthen");
        /////if (ReadCookie("IsAuthenticated") != "True") {
        if (isAuth != "1") {
            //var expires = new Date();
            //expires.setDate(expires.getDate() +7);
            //WriteCookie("eltNbBonsAchat","",expires,'/');
        }
        else {
            if (getCookieMultiValue("sarServices2", "NbBonsAchat") != "") {
                UpdateMesBonsAchatDisplay(getCookieMultiValue("sarServices2", "NbBonsAchat"));

            }
        }
    }
}
function SetNewsLetterPrivateSaleCanal(elt) {
    //SHA Nouvelle Gestion du Cookie
    var isAuth = "0";
    isAuth = getCookieMultiValue("SarUserContext", "srIsAuthen");
    if (isAuth != "1")
    //Utilisateur connecte
    ////if(ReadCookie("IsAuthenticated") == "True")
    {
        //appel au service de mise a jour du compte EMS
        var retSvc = servicePOST(getsiteurl() + "/XMLHttpProxy/NewsLetterServices.aspx", "Action=updateprivatesalecanal", true);
        if (retSvc != undefined && retSvc != null && retSvc.rtCode == "OK") {
            if (retSvc.msg != null && retSvc.msg != "") {
                //SHA 02/04/2010 :: Nouvelle page
                ////window.open("HomeVentePrivee.aspx?VPLabel=" + retSvc.msg, '_self');
                window.open(getsiteurl() + "/PrivateSaleHome.aspx?VPId=" + retSvc.msg, '_self');
                return false;
            }

        }
    }
    else {

        return hs.htmlExpand(elt, { objectType: 'iframe', outlineType: 'rounded-white', wrapperClassName: 'highslide-wrapper drag-header', outlineWhileAnimating: true, preserveContent: false, width: 775, height: 590, align: 'center', dimmingOpacity: 0.5, src: getsiteurl() + '/XMLHttpProxy/CompteLight.aspx?From=vente-privee&Action=updateprivatesalecanal&DestinationPage=' + escape(elt.href) });
    }
}
function IsNavigator() {


    agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns = ((agent.indexOf('mozilla') != -1) &&
    (agent.indexOf('spoofer') == -1) &&
    (agent.indexOf('compatible') == -1) &&
    (agent.indexOf('opera') == -1) &&
    (agent.indexOf('webtv') == -1) &&
    (agent.indexOf('hotjava') == -1));
    this.ns2 = (this.ns && (this.major == 2));
    this.ns3 = (this.ns && (this.major == 3));
    this.ns4 = (this.ns && (this.major == 4));
    this.ns6 = (this.ns && (this.major >= 5));
    this.ie = ((agent.indexOf("msie") != -1) &&
    (agent.indexOf("opera") == -1));
    this.ie3 = (this.ie && (this.major < 4));
    this.ie4 = (this.ie && (this.major == 4) &&
    (agent.indexOf("msie 4") != -1));
    this.ie5 = (this.ie && (this.major == 4) &&
    (agent.indexOf("msie 5.") != -1) &&
    (agent.indexOf("msie 5.5") == -1) &&
    (agent.indexOf("mac") == -1));
    this.iem5 = (this.ie && (this.major == 4) &&
    (agent.indexOf("msie 5.") != -1) &&
    (agent.indexOf("mac") != -1));
    this.ie55 = (this.ie && (this.major == 4) &&
    (agent.indexOf("msie 5.5") != -1));
    this.ie6 = (this.ie && (this.major == 4) &&
    (agent.indexOf("msie 6.") != -1));
    this.ie7 = (this.ie && (this.major == 4) &&
    (agent.indexOf("msie 7.0") != -1));
    this.nsdom = (this.ns4 || this.ns6);
    this.ie5dom = (this.ie5 || this.iem5 || this.ie55);
    this.iedom = (this.ie4 || this.ie5dom || this.ie6);
    this.w3dom = (this.ns6 || this.ie6 || this.ie7);
}

var isNavigator = new IsNavigator();

function setStyleForHeaderMenu() {
    if (isNavigator.ie6) {
        var _menu = document.getElementsByName("HeaderGenderLink");
        if (_menu && _menu.length) {
            for (var i = 0; i < _menu.length; i++) {
                if (i == 0 || i == 1)
                    _menu[i].style.marginRight = "1px";
                else
                    _menu[i].style.marginRight = "2px"
            }
        }
    }

}
function JSPourPageMariage() {
    document.write(unescape("%3Cscript src=" + getsiteurl() + "'jsv4/library/jquery/jquery.js' type='text/javascript'%3E%3C/script%3E"));
    document.write(unescape("%3Cscript src=" + getsiteurl() + "'jsv4/library/jquery/plugins/history/history.js' type='text/javascript'%3E%3C/script%3E"));
    document.write(unescape("%3Cscript src=" + getsiteurl() + "'jsv4/library/jquery/plugins/Cycle/jquery.cycle.all.js' type='text/javascript'%3E%3C/script%3E"));

}
function InitPageMariage() {
    jQuery.noConflict();
    var $j = jQuery;

    function pageload(hash) {
        // hash doesn't contain the first # character.
        if (hash) {
            SetTabVisible(hash);
        }
    }

    jQuery(document).ready(function () {
        // Initialize history plugin.
        // The callback is called at once by present location.hash. 


        jQuery(".tablinks").each(function (i) {

            this.id = "tabLinks_" + i;

        });
        jQuery("div.divTabContent").each(function (i) {

            this.id = "divTabContent_" + i;

        });



        jQuery.historyInit(pageload);

        jQuery(".tablinks").click(function () {

            var hash = this.href;
            hash = hash.replace(/^.*#/, '');

            jQuery.historyLoad(hash);

            return true;
        });
    });

    function SetTabVisible(hash) {

        jQuery(".tablinks").each(function (i) {

            var imgLink = this.getElementsByTagName("img")[0];
            if (imgLink) {
                var src = imgLink.src;
                var shash = this.href;
                var idTabLink = this.id.replace("tabLinks_", "");
                shash = shash.replace(/^.*#/, '');
                if (shash == hash) {
                    imgLink.src = src.replace("_on.png", ".png").replace(".png", "_on.png");

                    jQuery("#divTabContent_" + idTabLink).css("display", "block");

                    jQuery('#PushTrend' + idTabLink).cycle({
                        fx: 'fade',
                        next: '#PushTrendNext' + idTabLink,
                        prev: '#PushTrendPrev' + idTabLink,
                        pause: true

                    });

                }
                else {
                    imgLink.src = src.replace("_on.png", ".png");
                    jQuery("#divTabContent_" + idTabLink).css("display", "none");
                    jQuery('#PushTrend' + idTabLink).cycle('pause');

                }
            }


        });




    }
}

function move_mybasket_left(interval) {
    var elt = getElement_By_Id("divMyBasketProducts");
    if (elt != null && enableMovingBasket && (elt.scrollLeft - interval) >= 0) {
        enableMovingBasket = false;
        scroll_myBasket((elt.scrollLeft - interval), 50, (-1));
    }
}
function scroll_myBasket(finalposition, speed, direction) {

    var elt = getElement_By_Id("divMyBasketProducts");
    if (elt != null) {
        if (((direction) * elt.scrollLeft) < ((direction) * finalposition)) {
            var tmpscrollLeft = elt.scrollLeft;
            elt.scrollLeft = elt.scrollLeft + ((direction) * 10);
            if (tmpscrollLeft == elt.scrollLeft) {
                enableMovingBasket = true;
                return;
            }
            window.setTimeout("scroll_myBasket(" + finalposition + "," + speed + ",(" + direction + "))", speed);
        }
        else
            enableMovingBasket = true;

    }
}
function move_mybasket_right(interval) {
    var elt = getElement_By_Id("divMyBasketProducts");
    if (elt != null && enableMovingBasket) {
        enableMovingBasket = false;
        scroll_myBasket((elt.scrollLeft + interval), 50, 1);
    }

}

function posAvailIntelligencePush(divName, templateName, useUserContext, productColorId, rules) {
    var xhr = getXhr();

    xhr.onreadystatechange = function () {
        var divElement = getElement_By_Id(divName);
        if (divElement != null) {

            if (xhr.readyState == 4) {
                if (xhr.status == 200) {

                    if (xhr.responseText.length <= 5) {
                        divElement.parentNode.style.display = "none";
                    }
                    else {
                        divElement.innerHTML = xhr.responseText;
                        divElement.parentNode.style.display = "block";
                    }

                }
                else {
                    divElement.parentNode.style.display = "none";
                }


            }
            else {
                divElement.parentNode.style.display = "none";
            }
        }
    };
    var strQuery = "Service=GetPush&TemplateName=" + templateName;
    if (useUserContext && useUserContext != null)
        strQuery += "&UserContext=" + useUserContext.toString();
    if (productColorId && productColorId != null)
        strQuery += "&ProductColorId=" + productColorId;
    if (rules && rules != null)
        strQuery += "&Rules=" + rules;
    xhr.open("GET", getsiteurl() + "/XMLHttpProxy/AvailIntelligenceService.aspx?" + strQuery, true);
    xhr.send(null);


}
function AddViewedProductColorId(productColorId) {
    var xhr = getXhr();
    var strQuery = "Service=AddViewedProduct&ProductColorId=" + productColorId;
    xhr.open("POST", getsiteurl() + "/XMLHttpProxy/AvailIntelligenceService.aspx?" + strQuery, true);
    xhr.send(null);


}




function showAltTabForBrand() {
    for (i = 3; i >= 0; i--) {
        try {
            if (getElement_By_Id('tabAlt' + i + 'Cont') != null) {
                showAltTab(i);
                break;
            }
        }
        catch (ex)
		 { }

    }
}

window.onunload = function () {
    AddProduct();
    AddContexteClick();


}
////////////////////////////////////////////////////////////////////
// Récupération d'une valeur de conf !!!! A sécuriser
function GetWebConfigValue(key) {
    var hidField = getElement_By_Id("Config_" + key);
    if (hidField != null)
        return hidField.value;
    else
        return "";
}


/////////////////////////////////////////////////////////////////////
// InitPage 
// Récupérer la sélection et le panier
// intialiser le moteur de recherche
var IndxDiapo = 0;
var nbMaxDiapo = -1;
var diapoTimer;
var diapoSpeed;

function NextDiapo() {
    // if (diapoTimer)
    //    diapoTimer = null;
    var NextIndxDiapo = IndxDiapo + 1;
    if (NextIndxDiapo >= nbMaxDiapo)
        NextIndxDiapo = 0;
    var divOldDiapo = getElement_By_Id('diapo' + IndxDiapo);
    var divNextDiapo = getElement_By_Id('diapo' + NextIndxDiapo);
    if (nbMaxDiapo != null && divOldDiapo != null && divNextDiapo != null) {
        divOldDiapo.style.display = "none";
        divNextDiapo.style.display = "inline";
        IndxDiapo = NextIndxDiapo;
        diapoTimer = setTimeout('NextDiapo();', diapoSpeed);
    }

}



function AfterInitPage() {
    try {

        var EurecaTagMode_Soldes = jQuery("#SoldesTagDisable_Eulerian").val();
        if (EurecaTagMode_Soldes == "true") {
            if (ReadCookie("isCalledEulerian") != "true") {
                WriteCookie("isCalledEulerian", "false");
                if (getCookieMultiValue("SarUserContext", "srNewUser") == "true") {
                    EA_collector(['newcustomer', '1', 'email', getCookieMultiValue("SarServices1", "UserMail")]);
                    //isCalledEulerian = true;
                    WriteCookie("isCalledEulerian", "true");
                    setCookieMultiValue("SarUserContext", "srNewUser", "");
                }
            }
        }
        else {
            if (getCookieMultiValue("SarUserContext", "srNewUser") == "true") {

                EA_collector(['newcustomer', '1', 'email', getCookieMultiValue("SarServices1", "UserMail")]);
                isCalledEulerian = true;
                setCookieMultiValue("SarUserContext", "srNewUser", "");
            }
        }


        if (!detectFlash(8) && ReadCookie("doDetectFlash") == "") {
            var boolValue = confirm("A fin de profiter pleinement des fonctionnalites de notre site, il est recommande d''installer la derniere version du FlashPlayer sur www.adobe.com. Installer maintenant ?");
            expires = new Date();
            expires.setDate(expires.getDate() + 1);
            WriteCookie("doDetectFlash", "false", expires, '/');
            if (boolValue)
                window.open("http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash&Lang=French", "_self");

        }
        LoadImages();


        if (typeof (InitGlobalMembers) == "function")
            InitGlobalMembers();
        if (typeof (DisplayLastViewedProduct) == "function")
            DisplayLastViewedProduct();

        if (typeof (bCaroussel) != 'undefined' && bCaroussel == true) {
            window.setTimeout("sCaroussel();", 1000);
        }
        if (getElement_By_Id("scrollBasketPrev") != null)
            getElement_By_Id("scrollBasketPrev").style.visibility = "hidden";
        if (getElement_By_Id("scrollBasketNext") != null)
            getElement_By_Id("scrollBasketNext").style.visibility = "hidden";

        /// Gestion des diapo
        if ($$('div', 'diapo').length > 0) {
            nbMaxDiapo = $$('div', 'diapo').length
            var divsDiapo = $$('div', 'diapo');
            for (i = 0; i < divsDiapo.length; i++) {
                divsDiapo[i].id = 'diapo' + i;
            }
            divsDiapo[0].style.display = 'inline';
            diapoSpeed = divsDiapo[0].getAttribute("speed").value;
            if (diapoSpeed == undefined || diapoSpeed == null)
                diapoSpeed = 3500;
            diapoTimer = setTimeout('NextDiapo();', diapoSpeed);
        }
        else
            nbMaxDiapo = null;
    }
    catch (ex) { }
}

function hidesubscribe() {
    getElement_By_Id("notifySubscribe").style.visibility = "hidden";
}
///Control mail
function checkMail(mail) {

    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (filter.test(mail)) return true;
    else return false;
}

////////////BigSize Events /////////////////////////////////////////
function HandleBigSizeInputMailNotifKeyPress(wEvent) {
    var keyCode = null;
    if (wEvent.which) {
        keyCode = wEvent.which;
    }
    else if (wEvent.keyCode) {
        keyCode = wEvent.keyCode;
    }
    if (13 == keyCode) {
        BigSizeNewsSubscribe();
    }
    return false;
}

function BigSizeNewsSubscribe() {
    var sMail = getElement_By_Id("mail").value;
    getElement_By_Id("mail").value = '';
    if (checkMail(sMail)) {
        result = servicePOST(getsiteurl() + "/XMLHttpProxy/ManageNotification.aspx", "Action=BigSizeNotification&Mail=" + sMail, true);
        if (result.rtCode != "NOK") {
            getElement_By_Id("notifySubscribe").style.visibility = "visible";
        }
    } else {
        alert('Adresse incorrect');
        getElement_By_Id("mail").focus();
    }
}





////////////////////////////////////////////////////////////////////
// Recherche full texte
var isFullTextSearch = false;
function Rechercher() {
    var txtMotCle = getElement_By_Id("txtMots");
    if (txtMotCle != null && txtMotCle.value != "" && txtMotCle.value != "Recherche" && txtMotCle.value != "Search") {
        isFullTextSearch = true;
        //window.location ="Search.aspx?Ftq=" + txtMotCle.value;
        window.open(getsiteurl() + "/Search.aspx?Ftq=" + txtMotCle.value, '_self');
    }
    //    else
    //    {
    //        isFullTextSearch = true;
    //        window.open("Search.aspx?Ftq=", '_self');
    //    }
    return false;
}
function mailnewsletterkeypress(wEvent) {
    var keyCode = null;
    if (wEvent.which) {
        keyCode = wEvent.which;
    }
    else if (wEvent.keyCode) {
        keyCode = wEvent.keyCode;
    }
    if (13 == keyCode) {
        isNewsLetter = true;
        var toto = getElement_By_Id("trendId");
        if (toto == null) {
            window.location = getsiteurl() + "/InscriptionPage.aspx?Email=" + getElement_By_Id("mailnewsletter").value + "&LangCode=fr";
        }
        else {
            window.location = getsiteurl() + "/InscriptionPage.aspx?Email=" + getElement_By_Id("mailnewsletter").value + "&TrendId=" + toto.value + "&LangCode=fr";
        }
    }
    return false;
}
function mailnewsletterpushkeypress(wEvent, promocode, populationid) {
    var keyCode = null;
    if (wEvent.which) {
        keyCode = wEvent.which;
    }
    else if (wEvent.keyCode) {
        keyCode = wEvent.keyCode;
    }
    if (13 == keyCode) {
        window.location = getsiteurl() + "/InscriptionPage.aspx?Email=" + getElement_By_Id("mailnewsletterpush").value + "&LangCode=fr&Canal=PushNews" + (promocode ? "&promo=" + promocode : "") + (populationid ? "&populationid=" + populationid : "");
    }
    return false;
}


function HandleTxtMotsKeyPress(wEvent) {
    var keyCode = null;
    if (wEvent.which) {
        keyCode = wEvent.which;
    }
    else if (wEvent.keyCode) {
        keyCode = wEvent.keyCode;
    }
    if (13 == keyCode) {
        Rechercher();

    }
    return false;

}

var isinHref = false;

//////////////////////////////////////////////////////////////////////////////////
// Fonctions générique pour la page
function HandleMouseOver(wEvent) {
    var srcElt = getSrcElement(wEvent);

    if (srcElt.getAttribute("type") == "vig") {
        var doctitle = document.title;
        ZoomVig(srcElt, wEvent);

        if (document.title != doctitle) {
            document.title = doctitle;
        }
    }
    else if (srcElt.id == "mon_panier") {
        ShowBasketDetail();
    }
    else if (srcElt.id == "hrefBrand")
        ShowLogoBrand(srcElt, wEvent);

    if (srcElt.tagName == "A" && srcElt.getAttribute("hrref") == null && srcElt.getAttribute("id") != null && (srcElt.getAttribute("id").indexOf("TY_") != -1 || srcElt.getAttribute("id").indexOf("ProductTypeForGender") != -1)) {
        srcElt.setAttribute('hrref', srcElt.getAttribute('href'));
        srcElt.setAttribute('href', '#0');
    }




}
function HandleMouseOut(wEvent) {

    var srcElt = getSrcElement(wEvent);
    if (srcElt.getAttribute("type") == "vig") {
        HideZoom();
    }
    else {
        //if (srcElt.id== "divDetailBasket")
        //   HideBasketDetail();
    }

}
function HandleMouseDown(mEvent) {

    var srcElt1 = getSrcElement(mEvent);

    if (srcElt1.getAttribute("href") != null || srcElt1.parentNode.getAttribute("href") != null) {
        isinHref = true;

    }
    else
        isinHref = false;

    if (srcElt1.getAttribute("id") != null && srcElt1.getAttribute("id") == "JSBackHistory")
        isJSBackHistory = true;
    else
        isJSBackHistory = false;
}
function isEltInDiv(elt, idDiv) {
    if (elt.TagName == "BODY")
        return false
    else if (elt.id == idDiv)
        return true;
    else
        return isEltInDiv(elt.parentNode, idDiv);
}
//////////////////////////////////////////////////////////////////////////////////
// Gestion des vingettes (Zoom avant et gestion des vues)
//var large_images     = new Array();
var currZoomedPrd = null;
var offx;  // GLOBAL VARS pour la position d'un element après avoir appeler getAbsPositon
var offy; // GLOBAL VARS pour la position d'un element après avoir appeler getAbsPositon
function ZoomVig(srcImg, wEvent) {//Commenté par OHA pour désactiver le zoom vignette
    /*
    var urlZoom = srcImg.getAttribute("urlZoom");
    var divZoom = getElement_By_Id("divZoomVig"); 
    if(divZoom==null)
    return;
    var divVig = srcImg.parentNode.parentNode.parentNode;
    
  
  
    // stop;
    if (currZoomedPrd ==null || currZoomedPrd != urlZoom ) {
    currZoomedPrd = urlZoom
    getAbsPosition(divVig);
    var moffx=offx;
    var moffy=offy;
        
    var versbas=1;
    var versdroite=1;
    if (wEvent.screenX>600)
    versdroite=0;
    if (wEvent.screenY>400) 
    versbas=0;
    if (versbas==1 && versdroite==1) {
    moffx = moffx +100;
    moffy = moffy +80;
    }
    if (versbas==0 && versdroite==1) {
    moffx = moffx + 100;
    moffy = moffy - 240;
    }
    if (versbas==1 && versdroite==0) {
    moffx = moffx - 240;
    moffy = moffy + 80;
    }
    if (versbas==0 && versdroite==0) {
    moffx = moffx - 240;
    moffy = moffy - 240;
    }
        
  
    divZoom.style.top = moffy + 'px';// wEvent.y + "px";
    divZoom.style.left = moffx + 'px';// wEvent.x + "px";
    divZoom.style.display="inline";
    var objFlash = getElement_By_Id("divZoomVig");

    if(objFlash!=null){
    var myFlashObject = new FlashObject('',  urlZoom,coeffZoom, 8,true);
    if(srcImg.getAttribute("zoomMarketingField")!="")

    divZoom.innerHTML = "<div style=\"width:100%; POSITION: relative; TOP: 0px! important; HEIGHT: 1px\"><img style=\"FLOAT: right; MARGIN: 10px 10px 0px 0px\"   src=\"http://cache.sarenza.com/V4/" + srcImg.getAttribute("zoomMarketingField") + "\" alt=\"ZoomMarketing\" /></div><div class=\"clear\"></div>" + myFlashObject.getHTML();
    else
    myFlashObject.write("divZoomVig");
    }
    //getElement_By_Id("ProductImage").src = GetWebConfigValue("ProductPhotosPath") + urlZoom;
    }
    */
}

function HideZoom() {
    if (getElement_By_Id("divZoomVig") != null)
        getElement_By_Id("divZoomVig").style.display = "none";
    currZoomedPrd = null;
}


////////////////////////////////////////////////////////////////////////////
// Récupère le html d'une vignette
function GetVignetteHTML(productId, supplierColorId, displayMode) {

    var strQuery = "ProductId=" + productId;
    if (supplierColorId != undefined)
        strQuery += "&ColorId=" + supplierColorId;
    if (displayMode != undefined)
        strQuery += "&DisplayMode=" + displayMode;

    if (LuxeEnv != undefined)
        strQuery += "&LuxeEnv=" + LuxeEnv;

    var r = serviceGET(getsiteurl() + "/XMLHttpProxy/GetVignette.aspx", strQuery, false);
    if (r != null) {
        return r.text;
    }
}
function GetVignetteHTMLByVariant(variantId, displayMode) {
    var strQuery = "VariantId=" + variantId;
    if (displayMode != undefined)
        strQuery += "&DisplayMode=" + displayMode;
    if (LuxeEnv != undefined)
        strQuery += "&LuxeEnv=" + LuxeEnv;
    var r = serviceGET(getsiteurl() + "/XMLHttpProxy/GetVignette.aspx", strQuery, false);
    if (r != null) {
        return r.text;
    }
}

function GetVignetteHTMLByVariantToPrefere(variantId, displayMode) {
    var strQuery = "VariantId=" + variantId + "&Prefere=true";
    if (displayMode != undefined)
        strQuery += "&DisplayMode=" + displayMode;

    var r = serviceGET(getsiteurl() + "/XMLHttpProxy/GetVignette.aspx", strQuery, false);
    if (r != null) {
        return r.text;
    }
}

/////////////////////////////////////////////////////////
//mettre une valeur dans le cookie en spécifiant son nom
///////////////////////////////////////
function WriteCookie(key, value, expires, path, domain, secure) {
    secure = (secure == undefined || secure == null) ? false : true;
    document.cookie = key + "=" + escape(value) +
    ((expires == undefined || expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == undefined || path == null) ? "" : ("; path=" + path)) +
    ((domain == undefined || domain == null) ? "" : ("; domain=" + domain)) +
    ((secure) ? "; secure" : "");

}
////////////////////////////////////////////////////////////////////
function ReadCookie(name) {
    /*  var deb,fin
    deb = document.cookie.indexOf(nom + "=")
    if (deb >= 0) {
    deb += nom.length + 1
    fin = document.cookie.indexOf(";",deb)
    if (fin < 0) fin = document.cookie.length
    return unescape(document.cookie.substring(deb,fin))
    }
    return ""
    */
    // Escape regexp special characters (thanks kangax!)
    name = name.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');

    var regex = new RegExp('(?:^|;)\\s?' + name + '=(.*?)(?:;|$)', 'i'),
        match = document.cookie.match(regex);

    var ret = match && unescape(match[1]);
    if (ret == null)
        return "";
    else
        return ret;


}
///
function DeleteCookie(nom) {
    /*var sPos = document.cookie.indexOf(nom + "=");
    if(sPos == -1){
    return true;
    }
    else
    {
    var expires = new Date();
    expires.setDate(expires.getDate()-30);
    WriteCookie(nom,"",expires,'/');
    return true;
    } 
    */
    var val = ReadCookie(nom);
    if (val != null && val.length > 0) {
        var expires = new Date();
        expires.setDate(expires.getDate() - 30);
        WriteCookie(nom, "", expires, '/');
        return true;
    }
    return true;
    r
}
function getCookieMultiValue(cookiename, cookiekey) {
    var cookievalue = ReadCookie(cookiename);
    if (cookievalue == "")
        return "";
    var cookievaluesep = cookievalue.split("&");

    for (c = 0; c < cookievaluesep.length; c++) {
        cookienamevalue = cookievaluesep[c].split("=");
        if (cookienamevalue.length > 1) //it has multi valued cookie
        {
            if (cookienamevalue[0] == cookiekey)
                return cookienamevalue[1].toString();
        }
        /* debut **
        else		
        return "";	
        ** fin */
    }

    return "";

}
function trim(string) {
    return string.replace(/(^\s*)|(\s*$)/g, '');
}
function setCookieMultiValue(cookiename, cookiekey, cookiekeyvalue, expires) {
    //cookiename=key1=value1&key2=value2...
    var cookievalue = ReadCookie(cookiename);
    var newCookieValue = trim(cookievalue);
    if (newCookieValue == "") {
        //WriteCookie(cookiename,cookiekey+"="+cookiekeyvalue,expires);
        document.cookie = cookiename + "=" + cookiekey + "=" + cookiekeyvalue + ((expires == undefined || expires == null) ? "" : ("; expires=" + expires.toGMTString()));
        return;
    }

    //verifier si la cle existe dans le cookie cookiename
    var getcookiekeyvalue = getCookieMultiValue(cookiename, cookiekey);

    if (getcookiekeyvalue == "")	//cle n'existe pas		
        newCookieValue += "&" + cookiekey + "=" + cookiekeyvalue;
    else {
        newCookieValue = newCookieValue.replace(cookiekey + "=" + getcookiekeyvalue, cookiekey + "=" + cookiekeyvalue);
    }
    //WriteCookie(cookiename,newCookieValue,expires);
    document.cookie = cookiename + "=" + newCookieValue + ((expires == undefined || expires == null) ? "" : ("; expires=" + expires.toGMTString()));
    return;
}

function getsiteurl() {
    try {
        return getElement_By_Id("Config_UrlSite").value.toString()
    }
    catch (ex) {
        return "";
    }

}


//---------------------------------------------------------------///

function getLocation() {
    try {
        return getElement_By_Id("locationname").value.toString()
    }
    catch (ex) {
        return window.location.toString();
    }
}

//-----------------------------------------------------------//
//recuperer un element de la page par son Id
function getElement_By_Id(param) {
    var elt = null;
    if (window.document.getElementById)
        elt = window.document.getElementById(param);
    else
        elt = window.document.all(param);
    return elt;

}

function getSrcElement(mEvent) {
    if (mEvent.srcElement) {
        elt = mEvent.srcElement;
    }
    else if (mEvent.target) {
        elt = mEvent.target;
    }
    return elt;
}

function getAbsPosition(elt) {
    offx = 0;
    offy = 0;

    var ndObject = elt;
    if (ndObject != null) {
        while (ndObject != null && ndObject.nodeName != "BODY") {
            offx += ndObject.offsetLeft;
            offy += ndObject.offsetTop;
            ndObject = ndObject.offsetParent;
        }
    }
}


function NavigBrand() {

}

///////////////////////////////////////////////////////////////////////////////////////
// gestion des derniers vus
function AddProduct() {
    var ProductName;
    var BrandName;
    var ProductURL;
    if (getElement_By_Id("HiddenDetailsNomModele") != null)
        ProductName = getElement_By_Id("HiddenDetailsNomModele").value;
    else
        return;
    if (getElement_By_Id("ImgBrandName") != null)
        BrandName = getElement_By_Id("ImgBrandName").alt;
    else
        BrandName = ""

    // le producId sera utilise pour construire le push avail. a ne pas modifier. position=3
    //le productcolorId sera utiliser pour construire
    var eltreference = getElement_By_Id("reference");
    var productId = null;
    var photoUrl = null;
    if (eltreference != null) {
        productId = eltreference.getAttribute("productId");
        photoUrl = eltreference.getAttribute("photo10Url");
    }

    ProductURL = window.location.toString();
    while (ProductURL.indexOf("#") != -1) {
        ProductURL = ProductURL.replace("#", "");
    }

    var Prd = new Array(6);
    //if(ReadCookie("LastPrd")!="")
    DeleteCookie("LastPrd");

    var Prd = unescape(getCookieMultiValue("SarServices1", "LastPrd")).split('#');
    if (Prd.length > 0 && Prd[0] == "")
        Prd.splice(0, 1);
    if (Prd.length > 0 && Prd[0] == (ProductName + "|" + BrandName + "|" + ProductURL + "|" + productId + "|" + photoUrl))
        return;

    for (var i = Prd.length; i >= 1; i--) {
        Prd[i] = Prd[i - 1];
    }
    if (Prd.length > 6) {
        Prd.splice(6, Prd.length - 1);
    }
    Prd[0] = ProductName + "|" + BrandName + "|" + ProductURL + "|" + productId + "|" + photoUrl;
    var lstPrd = "";
    for (var i = 0; i < Prd.length; i++) {
        if (i != Prd.length - 1)
            lstPrd += Prd[i] + "#";
        else
            lstPrd += Prd[i];
    }
    var expires = new Date();
    expires.setDate(expires.getDate() + 1000);
    setCookieMultiValue("SarServices1", "LastPrd", escape(lstPrd), expires);

}

function DisplayLastViewedProduct() {


    if (getElement_By_Id("divLastView") == null)
        return;



    var Prd = new Array(6);
    var PrdName;
    var BrdName;
    var PrdUrl;
    var productId;
    var photoUrl;
    var Prd = unescape(getCookieMultiValue("SarServices1", "LastPrd")).split('#')

    var HasElement = 0;


    for (var i = 0; i < Prd.length; i++) {
        if (Prd[i] != null && Prd[i] != "") {
            PrdName = Prd[i].split('|')[0];
            BrdName = Prd[i].split('|')[1];
            PrdUrl = Prd[i].split('|')[2];
            productId = Prd[i].split('|')[3];
            photoUrl = Prd[i].split('|')[4];

            if (photoUrl != "null" && productId != "null" && photoUrl != null && productId != null) {

                HasElement = HasElement + 1;
                //getElement_By_Id("liPrd" + (i+1) ).innerHTML = '<a href="' +PrdUrl + '">'+ BrdName +' <span>' + PrdName+ '</span></a>';
                getElement_By_Id("liPrd" + (i + 1)).innerHTML = '<a href="' + PrdUrl + '"><img src="http://cache.sarenza.com/_img/productsV4/' + photoUrl.split('_')[0] + '/' + photoUrl + '"/></a>';

                getElement_By_Id("liPrd" + (i + 1)).style.display = "block";
            }
            else {
                getElement_By_Id("liPrd" + (i + 1)).style.display = "none";
            }
        }
        else
            getElement_By_Id("liPrd" + (i + 1)).style.display = "none"; // ="";
    }


    if (HasElement == 0) {
        getElement_By_Id("divLastView").style.display = "none";
    }
    for (var i = Prd.length; i <= 6; i++) {
        try {
            if (getElement_By_Id("liPrd" + (i + 1)) != null)
                getElement_By_Id("liPrd" + (i + 1)).style.display = "none";
        }
        catch (ex) { }
    }
}


////////////////////////////////////////////////////////////////////////////////////
// Gestion de l'historique d'appel
//function AddVisitedPage(urlPage, statusPage) {
//    var iNiveau=0;
//    if (ReadCookie("Niveau").length!=0)
//       iNiveau=parseInt(ReadCookie("Niveau"));
//    WriteCookie("Histo"+iNiveau, urlPage + "|" + statusPage);
//    
//    WriteCookie("Niveau" ,iNiveau+1);
//// TO METTRE DANS UNE PILE 
//}

//function backHistory() {
//    var lastPage = ReadCookie("Histo1");
//    var url = lastPage.split('|')[0];
//    var status = lastPage.split('|')[1];
//    
//    
//    //FindProductID(status);
//}

function backHistoryV1() {
    //window.location.replace= ReadCookie('ContexteClick');
    //alert("aee");
    //alert(ReadCookie("ContexteClick"));
    var readCookieContexteClick = ReadCookie("ContexteClick");
    var tabtemp = readCookieContexteClick.split("&");
    var tabtempfinal = new Array();
    var i = 0;
    var j = 0;
    for (i = 0; i < tabtemp.length; i++) {
        if (tabtemp[i].search("NbSearch") == -1) {
            tabtempfinal[j] = tabtemp[i];
            j++;
        }
    }
    readCookieContexteClick = tabtempfinal.join("&");
    if (readCookieContexteClick.toLowerCase().indexOf("/homebrand.aspx") == 0 || readCookieContexteClick.toLowerCase().indexOf("/pagemarket.aspx") == 0 || readCookieContexteClick.toLowerCase().indexOf("/search.aspx") == 0 || readCookieContexteClick.toLowerCase().indexOf("/hometype.aspx") == 0 || readCookieContexteClick.toLowerCase().indexOf("/privatesalehome.aspx") == 0 || readCookieContexteClick.toLowerCase().indexOf("/hometrend.aspx") == 0 || readCookieContexteClick.toLowerCase().indexOf("/pageressource.aspx") == 0) {
        window.history.back(-1);
        return;
    }
    var s = readCookieContexteClick;
    //OHA 28-04-2010: Si l'url contient "HTTP:" on ne supprime pas le premier caractère "/"
    //Bug non reproductible. Seulement pour blinder le fonctionnement.
    if (s.indexOf('http:') == -1)
        window.open(s.substr(1, s.length), '_self');
    else
        window.open(s, '_self');

}

function InitDivFilterAction() {
    if ($('divFilterTools').offsetHeight > 10) {
        $S('add', $('divFilterAction'), 'advanceHidden');
        unFold($('divFilterTools'), $('divFilterTools', 'div', 0));
    } else {
        $S('del', $('divFilterAction'), 'advanceHidden');
        fold($('divFilterTools'), $('divFilterTools', 'div', 0));
    }
}
/////////////////////////////////////////////////////////////////////////////////////
// OVERRIDE DES FONCTIONS FOURNIS PAS PI
/***** 70 - Product View *****/

function viewProduct(id) {
    var viewerId = id.split('Thumb')[0]
    var thumbIndex = id.split('Thumb')[1]

    var productId = '';
    try {
        coeffZoom = getElement_By_Id("ViewInfos_CoeffZoom").value;
        productId = getElement_By_Id("ViewInfos_ProductId").value;
    }
    catch (ex)
	{ }

    $('AZoomProduct').href = $(viewerId + 'Thumb' + thumbIndex).src.replace('PI_', 'HD_');
    var objFlash = getElement_By_Id("productFlash");

    if (objFlash != null) {
        //var myFlashObject = new FlashObject(productId, $(viewerId+'Thumb'+thumbIndex).src.replace('/thumbs/','/big/'),coeffZoom, 8,false);
        var myFlashObject = new FlashObject(productId, $(viewerId + 'Thumb' + thumbIndex).src.replace('/thumbs/', '/big/').replace('PI_', ''), coeffZoom, 8, false);
        myFlashObject.write("productFlash");
    }
    //$(viewerId+'View','img',0).src = $(viewerId+'Thumb'+thumbIndex).src.replace('/thumbs/','/big/');
    //$('divLoupe','img',0).src=$(viewerId+'Thumb'+thumbIndex).src.replace('/thumbs/','/big/');

}
function ScrollPressRight() {
    Timer = setInterval("document.getElementById('DivPressScroll').scrollLeft -= 2", 15);
}
function ScrollPressLeft() {
    Timer = setInterval("document.getElementById('DivPressScroll').scrollLeft -= 2", 15);
}

function AddContexteClick() {
    if (contexteclick.indexOf('http') == -1) {
        if (contexteclick.indexOf('.aspx?') != -1 || contexteclick.indexOf('.html?') != -1)
            contexteclick = contexteclick.split('?')[1];
        if (contexteclick.substr(0, 1) == "&")
            contexteclick = (getLocation().replace('#0', '')).split("?")[0] + '?' + contexteclick.substr(1, contexteclick.length);
        else
            contexteclick = (getLocation().replace('#0', '')).split("?")[0] + '?' + contexteclick;
    }

    if (contexteclick.indexOf('FromUser') == -1) {
        contexteclick += "&FromUser=true";
        contexteclick = contexteclick.replace("?&FromUser=true", "");
    }


    //add ScrollPosition 
    //BMN 04/05/2010 :: Repositionnement du scroll vertical + horizontal
    if (contexteclick != "/HomeBrand.aspx" && contexteclick != "/PageMarket.aspx" && contexteclick != "/Search.aspx" && contexteclick != "/HomeType.aspx" && contexteclick != "/PrivateSaleHome.aspx" && contexteclick != "/HomeTrend.aspx" && contexteclick != "/PageRessource.aspx" && contexteclick.indexOf("landing") == -1) {

        var hscroll = (document.all ? document.scrollLeft : window.pageXOffset);
        var vscroll = (document.all ? document.scrollTop : window.pageYOffset);

        if (hscroll != 0 || vscroll != 0) {
            if (contexteclick.indexOf("?") != -1)
                contexteclick += "&";
            else
                contexteclick += "?";

            contexteclick += "hscroll=" + hscroll + "&vscroll=" + vscroll;
        }
    }
    //BMN 04/05/2010


    if (getLocation().indexOf("Product.aspx") != -1 || getLocation().indexOf("ProductV2.aspx") != -1) {
        if (SelectedCriteriaStack.length != 0 && contexteclick.indexOf("&CriteriaStack=" + SelectedCriteriaStack.toString()) == -1) {
            contexteclick += "&CriteriaStack=" + SelectedCriteriaStack.toString();
        }

        if (!isFinalTag && getCookieMultiValue("ContexteClick", "CriteriaStack") != "" && isJSBackHistory == false) {
            FinalTag();
            nbSearch = parseInt(nbSearch) + 1;
        }
    }
    else {
        if (SelectedCriteriaStack != null) {
            if (SelectedCriteriaStack.length != 0 && contexteclick.indexOf("&CriteriaStack=" + SelectedCriteriaStack.toString()) == -1) {
                contexteclick += "&CriteriaStack=" + SelectedCriteriaStack.toString();
                /* incrémentation du compteur de cycle */
                if (!isFinalTag && toProduct == false) {
                    FinalTag();
                    nbSearch = parseInt(nbSearch) + 1;
                }
            }
        }
    }
    /* ajout de NbSearch au ContexteClick */
    if (getCookieMultiValue("ContexteClick", "NbSearch") != "" && parseInt(getCookieMultiValue("ContexteClick", "NbSearch")) != null) {
        var oldNbSearch = getCookieMultiValue("ContexteClick", "NbSearch");
        var parseOldNbSearch = parseInt(oldNbSearch);
        nbSearchTmp = parseInt(nbSearch) + parseOldNbSearch;
        contexteclick += "&NbSearch=" + nbSearchTmp;
    }

    /* ajout du CriteriaList au ContexteClick */
    if (SelectedCriteriaList != null) {
        if (SelectedCriteriaList.length != 0 && contexteclick.indexOf("&CriteriaList=" + SelectedCriteriaList.toString()) == -1) {
            contexteclick += "&CriteriaList=" + SelectedCriteriaList.toString();




        }
    }

    /* ajout de la provenance au ContexteClick */
    if (provenance != null && provenance != "") {
        contexteclick += "&Provenance=" + provenance;
    }

    if (!isFinalTag && !toProduct && SelectedCriteriaStack.length != 0 && !isJSBackHistory && (getLocation().indexOf("Product.aspx") == -1 && getLocation().indexOf("ProductV2.aspx") == -1)) {
        FinalTag();
    }

    if (!isFinalTag && (getLocation().indexOf("Product.aspx") != -1 || getLocation().indexOf("ProductV2.aspx") != -1) && getCookieMultiValue("ContexteClick", "CriteriaStack") != "" && !isJSBackHistory) {
        FinalTag();
    }

    //Tag des actions suivant la première utilisation du moteur de recherche

    //fiche produit

    //fiche produit
    if (!isTagSortie && !isJSBackHistory && parseInt(getCookieMultiValue("ContexteClick", "NbSearch")) == 0 && (getLocation().indexOf("Product.aspx") != -1 || getLocation().indexOf("ProductV2.aspx") != -1) && getCookieMultiValue("ContexteClick", "CriteriaStack") != "") {
        SortieTag("/Product");
    }


    //autre page 
    if (!isTagSortie && parseInt(getCookieMultiValue("ContexteClick", "NbSearch")) == 1 && getCookieMultiValue("ContexteClick", "CriteriaStack") != "" && SelectedCriteriaStack.length == 0 && (getLocation().indexOf("Product.aspx") == -1 || getLocation().indexOf("ProductV2.aspx") == -1)) {
        SortieTag("/OtherPage");
    }




    if (isProductHome == true && isinHref == false && isJSBackHistory == false && isFullTextSearch == false && isNewsLetter == false && getLocation().indexOf("ProductV2.aspx") == -1) {
        var readCookieContexteClick = ReadCookie("ContexteClick");
        var tabtemp = readCookieContexteClick.split("&");
        var tabtempfinal = new Array();
        var i = 0;
        var j = 0;
        for (i = 0; i < tabtemp.length; i++) {
            if (tabtemp[i].search("NbSearch") == -1) {
                tabtempfinal[j] = tabtemp[i];
                j++;
            }
        }
        readCookieContexteClick = tabtempfinal.join("&");

        if (readCookieContexteClick == "/HomeBrand.aspx" || readCookieContexteClick == "/PageMarket.aspx" || readCookieContexteClick == "/Search.aspx" || readCookieContexteClick == "/HomeType.aspx" || readCookieContexteClick == "/PrivateSaleHome.aspx" || readCookieContexteClick == "/HomeTrend.aspx" || readCookieContexteClick == "/PageRessource.aspx" || readCookieContexteClick.indexOf("landing") != -1) {
            return;
        }

        window.open(readCookieContexteClick, "_self");


    }
    else {
        if (isJSBackHistory == false) {
            expires = new Date();
            expires.setDate(expires.getDate() + 1);
            WriteCookie("ContexteClick", contexteclick, expires, "/");
        }
    }
}

function SortieTag(url) {
    //Tag GA
    var pageTracker = _gat._getTracker("UA-1858805-6");
    pageTracker._trackPageview(url);
    isTagSortie = true;
}

function FinalTag() {
    try {
        if (getCookieMultiValue("ContexteClick", "NbSearch") != "" && parseInt(getCookieMultiValue("ContexteClick", "NbSearch")) != null) {
            var oldNbSearch = getCookieMultiValue("ContexteClick", "NbSearch");
            var parseOldNbSearch = parseInt(oldNbSearch);
            var parseNbSearch = parseInt(nbSearch);
            isFinalTag = true;
            var nbSearchTemp = parseNbSearch + parseOldNbSearch;
            if (nbSearchTemp < 1) {

                //création de l'URL finale
                var myFinalURL = CreateFinalURL();
                //Tag GA
                var pageTracker = _gat._getTracker("UA-1858805-6");
                pageTracker._setDomainName("none");
                pageTracker._setAllowLinker(true);
                pageTracker._setAllowHash(false);
                pageTracker._trackPageview(myFinalURL);

            }
        }
    } catch (err) { }
}

function CreateFinalURL() {
    //premier noeud de l'URL: Final
    var myURL = "/Final";

    //deuxième noeud de l'URL: Genre
    switch (parseInt(Gender)) {
        case 1:
            myURL += "/Woman";
            break;
        case 2:
            myURL += "/Man";
            break;
        case 3:
            myURL += "/Child";
            break;
        case 4:
            myURL += "/BagAndAccessories";
            break;
        case 5:
            myURL += "/Child";
            break;
        case 6:
            myURL += "/Child";
            break;
        case 7:
            myURL += "/Child";
            break;
        case 8:
            myURL += "/Entretien";
            break;
        case 9:
            myURL += "/BagAndAccessories";
            break;
        case 10:
            myURL += "/BagAndAccessories";
            break;
    }

    //troisième noeud de l'URL: Catégorie
    if (contexteclick.indexOf("Luxe=true") != -1) {
        myURL += "/Luxe";
    }
    else {
        if (contexteclick.indexOf("Filter=2") != -1) {
            myURL += "/Promo";
        }
        else {
            myURL += "/Standard";
        }
    }

    //quatrième noeud de l'URL: Provenance
    if (provenance != null) {
        myURL += provenance;
    }
    else {
        myURL += "/HomeGenre";
    }

    //ajout des critères sélectionnés
    if (SelectedCriteriaList.length != 0) {
        for (var i = 0; i < SelectedCriteriaList.length; i++) {
            myURL += "/" + SelectedCriteriaList[i];
        }
    }
    else {
        var sCriteriaListTemp = getCookieMultiValue("ContexteClick", "CriteriaList");
        var SelectedCriteriaListTemp = sCriteriaListTemp.split(",");
        for (var i = 0; i < SelectedCriteriaListTemp.length; i++) {
            myURL += "/" + SelectedCriteriaListTemp[i];
        }
    }
    return myURL;
}

function RedirectToNewsletters(langCode) {
    var email = getElement_By_Id("mailnewsletter").value;
    var toto = getElement_By_Id("trendId");

    if (toto == null) {
        window.open(getsiteurl() + "/InscriptionPage.aspx?Email=" + email + "&LangCode=" + langCode, "_self");
    }
    else {
        window.open(getsiteurl() + "/InscriptionPage.aspx?Email=" + email + "&TrendId=" + toto.value + "&LangCode=" + langCode + sCanal, "_self");
    }
}
function RedirectToNewslettersFromPush(langCode, promocode, populationid) {
    var email = getElement_By_Id("mailnewsletterpush").value;
    window.open(getsiteurl() + "/InscriptionPage.aspx?Email=" + email + "&LangCode=" + langCode + "&Canal=PushNews" + (promocode ? "&promo=" + promocode : "") + (populationid ? "&populationid=" + populationid : ""), "_self");
}


function LoadSelectedAllBrands() {
    var selCatBrands = getElement_By_Id("selBrands");
    var selValue;
    if (selCatBrands.selectedIndex != -1) {
        selValue = selCatBrands.options[selCatBrands.selectedIndex].value;
        window.open(getsiteurl() + "/AllBrands.aspx?" + selValue, "_self");
    }

}

function ShowLogoBrand(srcElt, wEvent) {
    var urlLogo = srcElt.getAttribute("logo");
    var imgLogo = getElement_By_Id("imgLogoBrand");
    var divLogo = getElement_By_Id("divImgBrand");
    imgLogo.src = GetWebConfigValue("BrandPhotosPath") + urlLogo;
    getAbsPosition(srcElt);

    divLogo.style.top = (offy - 20) + 'px';
    if (document.all) {
        divLogo.style.left = (offx + srcElt.innerText.length * 6) + 'px';
    } else {
        divLogo.style.left = (offx + srcElt.textContent.length * 1.5) + 'px';

    }

    divLogo.style.display = "inline";



}

function LoadImages() {
    aLoadImages();
}

function aLoadImages() {
    var imgs = window.document.images;
    var t = 0;
    for (var i = 0; i < imgs.length; i++) {
        if (imgs[i].getAttribute("asrc") != null) {
            imgs[i].setAttribute("src", imgs[i].getAttribute("asrc"));
            t = t + 1;
        }
    }
}
function OpenCompteLight(displayMode, urlSortie) {
    var lien = getsiteurl() + "/XMLHttpProxy/CompteLight.aspx?From=" + displayMode + "&DestinationPage=" + urlSortie;
    return hs.htmlExpand(this, { objectType: 'iframe', outlineType: 'rounded-white', wrapperClassName: 'highslide-wrapper drag-header', outlineWhileAnimating: true, preserveContent: false, width: 775, height: 590, align: 'center', dimmingOpacity: 0.5, src: getsiteurl() + '/XMLHttpProxy/CompteLight.aspx?From=' + escape(displayMode) + '&DestinationPage=' + escape(urlSortie) });
}
function OpenCompteLight(displayMode, urlSortie, elem) {
    var lien = getsiteurl() + "/XMLHttpProxy/CompteLight.aspx?From=" + displayMode + "&DestinationPage=" + urlSortie;
    return hs.htmlExpand(elem, { objectType: 'iframe', outlineType: 'rounded-white', wrapperClassName: 'highslide-wrapper drag-header', outlineWhileAnimating: true, preserveContent: false, width: 775, height: 590, align: 'center', dimmingOpacity: 0.5, src: getsiteurl() + '/XMLHttpProxy/CompteLight.aspx?From=' + escape(displayMode) + '&DestinationPage=' + escape(urlSortie) });
}

function ShowErrorRE(msg) {
    jQuery("#MsgErreurGlobal").html(msg);
    setTimeout("window.location='" + getsiteurl() + "/MyAccountV4.aspx?Zone=MyOrders&Filter=2'", 500);
}