var Timer;
var contexteclick="";
var QueryFromUrl=null;
var SelectedCriteriaStack=new Array(0);
var isProductHome=false;
var isJSBackHistory=false;
var isNewsLetter=false;


var tiSiteID = 589;
var tiComplement = "";

var enableMovingBasket=true;
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 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)
{
	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;
   xhr.open("GET", "XMLHttpProxy/AvailIntelligenceService.aspx?"+strQuery,  true); 
   xhr.send(null);
	

}
function AddViewedProductColorId(productColorId)
{
   var xhr=getXhr();     
   var strQuery="Service=AddViewedProduct&ProductColorId="+productColorId;
   xhr.open("POST", "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
    {
        
        if ( ReadCookie("NewUser")=="true")
        {
            EURECA_newcustomer('sarenza');
            WriteCookie("NewUser","");
        }
        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("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 !="") 
    {
        isFullTextSearch=true;
        //window.location ="Search.aspx?Ftq=" + txtMotCle.value;
        window.open("Search.aspx?Ftq=" + txtMotCle.value,'_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 ="InscriptionPage.aspx?Email="+getElement_By_Id("mailnewsletter").value+"&LangCode=fr";
        }
        else 
        {
            window.location ="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 ="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) {

    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: 20px 20px 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;    

    var r = serviceGET("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;  

    var r = serviceGET("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("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(nom) {
  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 ""
  }

//---------------------------------------------------------------///

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=""
   //     return;
    ProductURL = window.location.toString();
    var Prd = new Array(4);
    for (var i=1; i<4; i++) {
       Prd[i] = ReadCookie("LastPrd" + i);
    }
    if (Prd[1] == ProductName +"|" + BrandName + "|" + ProductURL)
        return;
    
     for (var i=3; i>=2; i--) {
       Prd[i] = Prd[i-1];
    }
    Prd[1] = ProductName +"|" + BrandName + "|" + ProductURL;
    for (var i=1; i<4; i++) {
        WriteCookie("LastPrd" + i, Prd[i]);
    }
}

function DisplayLastViewedProduct() {
    if (getElement_By_Id("divLastView") == null)
        return;
    
    var Prd = new Array(4);
    var PrdName;
    var BrdName;
    var PrdUrl;
    for (var i=1; i<4; i++) {
       Prd[i] = ReadCookie("LastPrd" + i);
       if (Prd[i] !=null && Prd[i] !="") {
            PrdName = Prd[i].split('|')[0];
            BrdName = Prd[i].split('|')[1];
            PrdUrl = Prd[i].split('|')[2];
            getElement_By_Id("liPrd" + i ).innerHTML = '<a href="' +PrdUrl + '">'+ BrdName +' <span>' + PrdName+ '</span></a>';
            getElement_By_Id("liPrd" + i ).style.display="block";
       }
       else 
            getElement_By_Id("liPrd" + i ).style.display="none";// ="";
    }
}


////////////////////////////////////////////////////////////////////////////////////
// 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"));
    
    if (ReadCookie("ContexteClick") == "/HomeBrand.aspx" || ReadCookie("ContexteClick") == "/Search.aspx" || ReadCookie("ContexteClick") == "/HomeType.aspx" || ReadCookie("ContexteClick") == "/HomeVentePrivee.aspx" || ReadCookie("ContexteClick") == "/HomeTrend.aspx" || ReadCookie("ContexteClick") == "/PageRessource.aspx" ) {
        window.history.back(-1);
        return;
        }
    
    var s=ReadCookie("ContexteClick");
    window.open(s.substr(1,s.length),'_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=="" && QueryFromUrl!=null)
    {
        contexteclick=QueryFromUrl;
              
    }



    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","");
    }    
    if (SelectedCriteriaStack!=null )
    {
        if ( SelectedCriteriaStack.length!=0 && contexteclick.indexOf("&CriteriaStack="+SelectedCriteriaStack.toString())==-1)
            contexteclick+="&CriteriaStack="+SelectedCriteriaStack.toString();
    }
    if (QueryFromUrl!=null)
    {
        while(QueryFromUrl.indexOf('&')!=-1)
                QueryFromUrl=QueryFromUrl.replace('&','#');
        if (contexteclick.indexOf("&QueryFromUrl="+QueryFromUrl)==-1)
            contexteclick+="&QueryFromUrl="+QueryFromUrl;  
    }

    if (isProductHome==true && isinHref == false && isJSBackHistory==false && isFullTextSearch==false && isNewsLetter==false) {
        if (ReadCookie("ContexteClick") == "/HomeBrand.aspx" || ReadCookie("ContexteClick") == "/Search.aspx" || ReadCookie("ContexteClick") == "/HomeType.aspx" || ReadCookie("ContexteClick") == "/HomeVentePrivee.aspx" || ReadCookie("ContexteClick") == "/HomeTrend.aspx" || ReadCookie("ContexteClick") == "/PageRessource.aspx" || ReadCookie("ContexteClick").indexOf("landing") != -1 ) {
            return;
            }
           
        window.open(ReadCookie("ContexteClick"),"_self");
        }
    else 
    {
        if (isProductHome==false){
        
            expires = new Date();
            expires.setDate(expires.getDate() +1);
            WriteCookie("ContexteClick", contexteclick,expires,"/");
        }
    }
}


function RedirectToNewsletters(langCode)
{
    var email  = getElement_By_Id("mailnewsletter").value;  
    var toto = getElement_By_Id("trendId");
    
    if (toto == null)
    {
        window.open("InscriptionPage.aspx?Email="+email+"&LangCode="+langCode, "_self");
    }
    else
    {
        window.open("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("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("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;
        }
    }
}