/*##############################################################################################
############ JS DES FONCTIONS DE GESTION D'AFFICHAGE DES + OXYLANE ######### 
/*############################################################################################## */

// Variable GLOBALE
var oxyDocRef;
var oxyAfficheFiltre = false;
var oxy_X_navigateur = navigator.appName.toLowerCase();
var oxy_X_Platform   = navigator.platform.toLowerCase();
var oxy_X_version    = navigator.appVersion.toLowerCase();
var oxyDocParentRef;

// Version de Internet Explorer
if(oxy_X_navigateur == 'microsoft internet explorer'){
	X_version_deb = oxy_X_version.indexOf('(') + 1;
	X_version_fin = oxy_X_version.indexOf(')');
	oxy_X_version     = oxy_X_version.substring(X_version_deb, X_version_fin);
	XtabTmp       = oxy_X_version.split(';');
	for(i in XtabTmp){
		if(XtabTmp[i].indexOf('msie') > -1){
			 oxy_X_version = parseInt(XtabTmp[i].replace('msie', ''));
			 break;
		}
	}
}
//Constantes Oxylane
var URLBalise = 'http://balise.oxylane.com/';
var oxyContenuDiv = '';
var indefini;
//Variable paramétrage service Oxylane
/*Pour corriger l'erreur du code de la sélection dans l'intégration LBU*/
if(oxy_TypeAppel == indefini) var oxy_TypeAppel = 0;
if(idPartenaire == indefini) var idPartenaire = oxy_idPartenaire;
if(oxy_HauteurDisponible == indefini) var oxy_HauteurDisponible = '460';
if(oxy_LargeurDisponible == indefini) var oxy_LargeurDisponible = '514';
if(oxy_CouleurFiltre == indefini) var oxy_CouleurFiltre = '#FA002C';
if(isOxyCallWithSwitch==indefini) var isOxyCallWithSwitch='false';
/*fin correction*/

if( oxy_TypeAppel != -1 )
{
	document.write('<style type="text/css"><!--');
	document.write('#oxyFiltreOxylane {POSITION:absolute;TOP:0px;LEFT:0px;WIDTH:auto;HEIGHT:auto;DISPLAY:none;Z-INDEX:9998;BACKGROUND-COLOR:'+oxy_CouleurFiltre+';}');
	document.write('#oxyServiceOxylane {POSITION: absolute;TOP:0px;LEFT:0px;WIDTH:700px;HEIGHT:500px;DISPLAY:none;Z-INDEX:9999;BACKGROUND:none transparent scroll repeat 0% 0%;BACKGROUND-COLOR:#FFFFFF;border:#000000 0px solid;}');
	document.write('#boutonOxylaneService {POSITION:relative;WIDTH:130px;HEIGHT:24px;BORDER:#000000 0px solid;}');
	if(idPartenaire != '36')
	{
		document.write('#oxyPositionPicto {POSITION:absolute;LEFT:0px;TOP:3px;width:22px;height:16px;border:#000000 0px solid;}');
		document.write('#oxyPositionBouton {POSITION:relative;width:130px;height:19px;PADDING:5px 0px 0px 23px;margin:0px 0px 0px 0px;border:#000000 0px solid;cursor:pointer;}');	
	}
	else
	{
		document.write('#oxyPositionPicto {POSITION:absolute;LEFT:100px;TOP:2px;width:22px;height:16px;border:#000000 0px solid;}');	
		document.write('#oxyLienDKT {FONT-WEIGHT: bold; FONT-SIZE: 10px; MARGIN: 0px 15px 0px 5px;PADDING: 0px 0px 0px 12px; WIDTH: 115px; COLOR: #fff; TEXT-DECORATION: none;BACKGROUND: url(http://www.decathlon.fr/FR/images/static/bg-puce03.gif) no-repeat 0px 3px;border:#000000 0px solid;}');	
		document.write('#oxyPositionBoutonDKT {POSITION:relative;width:115px;height:19px;PADDING:0px 0px 0px 0px;margin:2px 0px 0px 5px;border:#000000 0px solid;cursor:pointer;}');	
	}
	document.write('.oxyPositionFermer {POSITION:absolute;LEFT:675px;TOP:8px;width:14px;height:14px;PADDING:0px 0px 0px 0px;margin:0px 0px 0px 0px;border:#000000 0px solid;cursor:pointer;}');	
	document.write('.oxyCadreGrisHG{width:5px;height:5px;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px;background-position: top left;background-repeat:no-repeat;background-image:url('+URLBalise+'Charte/images/CadreService/coin_cadre_HG.gif);}');
	document.write('.oxyCadreGrisHC{height:5px;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px;background-position:top left;background-repeat:repeat;background-image:url('+URLBalise+'Charte/images/CadreService/coin_cadre_H_1px.gif);}');
	document.write('.oxyCadreGrisHD{width:5px;height:5px;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px;background-position:top left;background-repeat:no-repeat;background-image:url('+URLBalise+'Charte/images/CadreService/coin_cadre_HD.gif);}');
	document.write('.oxyCadreGrisBG{width:5px;height:5px;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px;background-position: top left;background-repeat:no-repeat;background-image:url('+URLBalise+'Charte/images/CadreService/coin_cadre_BG.gif);}');
	document.write('.oxyCadreGrisBC{height:5px;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px;background-position: top left;background-repeat:repeat;background-image:url('+URLBalise+'Charte/images/CadreService/coin_cadre_B_1px.gif);}');
	document.write('.oxyCadreGrisBD{width:5px;height:5px;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px;background-position: top left;background-repeat:no-repeat;background-image:url('+URLBalise+'Charte/images/CadreService/coin_cadre_BD.gif);}');
	document.write('.oxyCadreGrisG{width:5px;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px;background-position: top left;background-repeat:repeat;background-image:url('+URLBalise+'Charte/images/CadreService/coin_cadre_G_1px.gif);}');
	document.write('.oxyCadreGrisD{width:5px;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px;background-position: top left;background-repeat:repeat;background-image:url('+URLBalise+'Charte/images/CadreService/coin_cadre_D_1px.gif);}');
	document.write('.oxyBarreOrangeBC{height:14px;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px;font-size:9px;background-position: top left;background-repeat:repeat;background-image:url('+URLBalise+'Charte/images/CadreService/bandeorange_B_1px.gif);}');
	document.write('.oxyBarreOrangeBG{width:10px;height:14px;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px;background-position: top left;background-repeat:no-repeat;background-image:url('+URLBalise+'Charte/images/CadreService/bandeorange_BG_arrondi.gif);}');
	document.write('.oxyBarreOrangeBD{width:10px;height:14px;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px;background-position: top left;background-repeat:no-repeat;background-image:url('+URLBalise+'Charte/images/CadreService/bandeorange_BD_arrondi.gif);}');
	document.write('.oxyBarreOrangeHC{height:35px;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px;background-position: top left;background-repeat:repeat;background-image:url('+URLBalise+'Charte/images/CadreService/bandeorange_H_1px.gif);}');
	document.write('.oxyBarreOrangeHD{width:10px;height:35px;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px;background-position: top left;background-repeat:no-repeat;background-image:url('+URLBalise+'Charte/images/CadreService/bandeorange_HD_arrondi.gif);}');
	document.write('--></style>');//left:37px;top:0px;
}
if(oxy_TypeAppel!=2)
{
	var fPage = null;
}
if(oxy_TypeAppel==0) {
	try {
		fPage=window.parent.document.location.href;	
		fPage=escape(fPage);
	} catch (ex) {
		fPage=window.document.location.href;		
		fPage=escape(fPage);
	}
}
if(oxy_TypeAppel==2)
	fPage=escape(fPage);
	
document.write('<div id="oxyFiltreOxylane" onclick="Cacher_Oxylane();return false;"></div>');
document.write('<div id="oxyServiceOxylane"></div>');

/*############################################################################################## */
// Remplit le cadre de l'iframe des services Oxylane
function RemplirContenuDiv()
{
	oxyContenuDiv = '<table cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF" width="100%" height="100%"><tr><td class="oxyCadreGrisHG"></td><td class="oxyCadreGrisHC"></td><td class="oxyCadreGrisHD"></td></tr><tr><td class="oxyCadreGrisG"></td><td align="center" style="padding:15px 2px 2px 2px;" valign="top">';
	oxyContenuDiv += '<table cellpadding="0" cellspacing="0" border="0" width="100%" height="35"><tr><td width="110"><IMG SRC="'+URLBalise+'Charte/images/CadreService/logo.gif" width="96" height="35"></td><td class="oxyBarreOrangeHC">&nbsp;</td><td class="oxyBarreOrangeHD"></td></tr></table>';
	oxyContenuDiv += '<center>#IFRAME#</center>',
	oxyContenuDiv += '<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td class="oxyBarreOrangeBG"></td><td class="oxyBarreOrangeBC">&nbsp;</td><td class="oxyBarreOrangeBD"></td></tr></table></td><td class="oxyCadreGrisD"></td></tr>';
	oxyContenuDiv += '<tr><td class="oxyCadreGrisBG"></td><td class="oxyCadreGrisBC"></td><td class="oxyCadreGrisBD"></td></tr></table>';
}

/*############################################################################################## */
// Remplit le bouton contenant le texte "les + Oxylane" et la fonction d'ouverture
function RemplirBoutonOxylane()
{
	if(! (document.getElementById("boutonOxylaneService").innerHTML != null && document.getElementById("boutonOxylaneService").innerHTML.length > 0))
	{
		document.getElementById("boutonOxylaneService").innerHTML = '<div id="oxyPositionBouton" align="left" href="javascript:;" onClick="javascript:Affiche_Filtre_Oxylane();Affiche_Popup_Oxylane();return false;"><div id="oxyPositionPicto"><img src="'+URLBalise+'/Charte/images/Onglet/xypoinconpetit.png" width="22" height="16" border="0"></div>LES + SPORTIFS</div>';
		CorrectPNGOxylane();
	}	
}
function RemplirBoutonOxylaneDKT()
{
	if(! (document.getElementById("boutonOxylaneService").innerHTML != null && document.getElementById("boutonOxylaneService").innerHTML.length > 0))
	{
		document.getElementById("boutonOxylaneService").innerHTML = '<div id="oxyPositionBoutonDKT" align="left" href="javascript:;" onClick="javascript:Affiche_Filtre_Oxylane();Affiche_Popup_Oxylane();return false;"><span id="oxyLienDKT" onMouseOver="javascript:Souligner();" onMouseOut="javascript:DeSouligner();">Les + sportifs</span><div id="oxyPositionPicto"><img src="'+URLBalise+'/Charte/images/Onglet/xypoinconpetitbleu.gif" width="22" height="16" border="0"></div></div>';
		//CorrectPNGOxylane();
	}	
}
function Souligner()
{
	var object = parent.document.getElementById('oxyLienDKT');
	if(!object){return false;}
	else{object.style.textDecoration='underline';}
}
function DeSouligner()
{
	var object = parent.document.getElementById('oxyLienDKT');
	if(!object){return false;}
	else{object.style.textDecoration='none';}
}

if(isOxyCallWithSwitch=='false') 
	loadBoutonOxylane(true)

function loadBoutonOxylane(isAffiche)
{
	if(isAffiche)
	{	
		RemplirContenuDiv();
		if('#0#36#'.indexOf('#' + idPartenaire + '#') < 0) 
			RemplirBoutonOxylane();
		if('#0#36#'.indexOf('#' + idPartenaire + '#') > 0) 
			RemplirBoutonOxylaneDKT();	
		/*############################################################################################## */
		// Gestion du filtre au onresize et onscroll
		window.onscroll = window.onresize = function(){Gestion_Filtre_Oxylane();}
		/*############################################################################################## */
	}
}

/*############################################################################################## */
// Document référence en cours dans lequel les services Oxylane s'affichent
function MonDocumentRefOxylane(){
	if(oxyDocRef == null){
		if(parent.document.documentElement && parent.document.documentElement.clientWidth){
			oxyDocRef = parent.document.documentElement;
		}else{
			oxyDocRef = document.body;
		}
	}
}
/*############################################################################################## */
// Action de resize sur le filter
function Gestion_Filtre_Oxylane(){
   if(oxyAfficheFiltre){Affiche_Filtre_Oxylane();PositionPopupOxylane('oxyServiceOxylane');}
}
/*############################################################################################## */
// Affiche le filtre d'opacite
function Affiche_Filtre_Oxylane(){   
    var Filtre_Oxylane = parent.document.getElementById('oxyFiltreOxylane');		       
    if(Filtre_Oxylane){
        if(!oxyAfficheFiltre){Filtre_Oxylane.style.visibility = 'hidden';Filtre_Oxylane.style.display = 'block';}

        if(!oxyDocRef){MonDocumentRefOxylane();}
        X_largeur = parseInt(oxyDocRef.clientWidth) + parseInt(oxyDocRef.scrollLeft);
        X_hauteur = parseInt(oxyDocRef.clientHeight) + parseInt(oxyDocRef.scrollTop);
        
        Filtre_Oxylane.style.width = X_largeur + 'px';
        Filtre_Oxylane.style.height = X_hauteur + 'px';

        if(!oxyAfficheFiltre){
			// Affiche les SELECT si < IE7
			if(oxy_X_navigateur == 'microsoft internet explorer' && oxy_X_version < 7){              
				gestion_select('hidden');
			} 	
            //Change opacite
            ChangerOpaciteFiltreOxylane(70, 'oxyFiltreOxylane');
            //Filtre_Oxylane.innerHTML="<div id=\"waitBarStore\"/>";
            //Filtre_Oxylane.innerHTML="&nbsp;";
            Filtre_Oxylane.style.visibility = 'visible';
            oxyAfficheFiltre = true;
        }
    }
}
/*############################################################################################## */
//Change opacite du filtre Oxylane
function ChangerOpaciteFiltreOxylane(opacity, id){
	var object = parent.document.getElementById(id);
	if(!object){return false;}
	object = object.style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

/*############################################################################################## */
// Affiche l'Iframe des services Oxylane
function Affiche_Popup_Oxylane(){
	//Est-ce que ce n'est pas la première fois que l'on charge
	if (! (document.getElementById("oxyServiceOxylane").innerHTML != null && document.getElementById("oxyServiceOxylane").innerHTML.length > 0)) {
		document.getElementById("oxyServiceOxylane").innerHTML = '<DIV class="oxyPositionFermer" onclick="Cacher_Oxylane();return false;" href="javascript:void(0);"><img border="0" src="'+URLBalise+'Charte/images/CadreService/btn_fermer.gif" /></DIV>' + oxyContenuDiv.replace('#IFRAME#','<iframe id="oxyIframeServices" name="oxyIframeServices" src="'+URLBalise+'Services.aspx?hauteur='+oxy_HauteurDisponible+'&largeur='+oxy_LargeurDisponible+'&fPage='+fPage+'&idPartenaire='+idPartenaire+'" width="'+oxy_LargeurDisponible+'" height="'+oxy_HauteurDisponible+'" valign="top" align="top" Frameborder="0" Scrolling="no" framespacing="0" marginheight="0" border="0" marginwidth="0" HSPACE="0" vspace="0"></iframe>');
	}	
		
	var X_block = parent.document.getElementById('oxyServiceOxylane');
   
    if(X_block) {
		X_block.style.visibility = 'hidden';
    	X_block.style.display = 'block';
    	PositionPopupOxylane('oxyServiceOxylane');
    	X_block.style.visibility = 'visible';
    	var origiframe = null;
    	if (window.parent && window.parent.document.getElementById('oxyServiceOxylane')) {
    		origiframe = window.parent.document.getElementById('oxyServiceOxylane').offsetHeight;		
    	}
    } 
    else {
    	return false;
    }
}

/*############################################################################################## */
// Cache le Filtre et popup/iframe
function Cacher_Oxylane(){
	Cacher_PopupOxylane('oxyServiceOxylane');
	Cacher_FiltreOxylane('oxyFiltreOxylane');
}
/*############################################################################################## */
// Cache la popup/Iframe Oxylane
function Cacher_PopupOxylane(objName){   
	var X_block = parent.document.getElementById(objName);
    if(X_block){
        X_block.style.display = 'none';       
    } else {
    	return false;
    }
}
/*############################################################################################## */
// Cache le filtre d'opacite Oxylane
function Cacher_FiltreOxylane(objName){
    var X_block = parent.document.getElementById(objName);
    if(X_block){
		// Affiche les SELECT si < IE7
        if(oxy_X_navigateur == 'microsoft internet explorer' && oxy_X_version < 7){
			gestion_select('visible');
		}
        X_block.style.display = 'none';
        oxyAfficheFiltre = false;
    }
}
/*############################################################################################## */
// Calcule la position de la popup/iframe Oxylane
function PositionPopupOxylane(X_obj){
    var X_block = parent.document.getElementById(X_obj);
    if( !X_block ){return false;}
    if(!oxyDocRef){MonDocumentRefOxylane();}
    var X_blockTop = (parseInt(oxyDocRef.clientHeight) - parseInt(X_block.offsetHeight)) /2;
    X_block.style.top = parseInt(oxyDocRef.scrollTop) + parseInt(X_blockTop) + 'px';
    var X_blockLeft = (parseInt(oxyDocRef.clientWidth) - parseInt(X_block.offsetWidth)) /2;
    X_block.style.left = parseInt(oxyDocRef.scrollLeft) + parseInt(X_blockLeft) + 'px';
}

/*############################################################################################## */
// Affiche ou Cache les SELECT de la page
function gestion_select(X_option){
    var X_balises = document.getElementsByTagName('select');
    for(i=0; i<X_balises.length; i++){
       X_balises[i].style.visibility = X_option;
    }
    if (window.frames['basketContent']){
        var X_balisesFrame=window.frames['basketContent'].document.getElementsByTagName('select');
         for(i=0; i<X_balisesFrame.length; i++){
           X_balisesFrame[i].style.visibility = X_option;
        }
     }
    // Cela cache également les select de la popup recherche. 
    // Il faut donc réafficher ces select
    if (document.getElementById("popuprecherche")) {
        X_balises = document.getElementById("popuprecherche").getElementsByTagName('select');
        for(i=0; i<X_balises.length; i++){
            X_balises[i].style.visibility = 'visible';
        }
    }
    if (document.getElementById("localprice-resa")) {
      X_balises = document.getElementById("localprice-resa").getElementsByTagName('select');
        for(i=0; i<X_balises.length; i++){
            X_balises[i].style.visibility = 'visible';
        }
    }
}


//Corrige la transparence des png sous IE6
function CorrectPNGOxylane()
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
//document.write('<!--[if lt IE 7]><script language="JavaScript">CorrectPNGOxylane()</script><![endif]-->');

