﻿/*##############################################################################################
############ 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 URLSiteClub = '';
var oxyContenuDiv = '';
var indefini;
//Variable paramétrage service Oxylane
/*Pour corriger l'erreur du code de la sélection dans l'intégration LBU*/
var oxy_HauteurDisponible = '100';
var oxy_LargeurDisponible = '250';
var oxy_CouleurFiltre = 'Gray';
var isOxyCallWithSwitch='false';
/*fin correction*/

	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:250px;HEIGHT:100px;DISPLAY:none;Z-INDEX:9999;BACKGROUND:none transparent scroll repeat 0% 0%;BACKGROUND-COLOR:#FFFFFF;}');
	document.write('.oxyPositionFermer {POSITION:absolute;LEFT:225px;TOP:8px;width:14px;height:14px;PADDING:0px 0px 0px 0px;margin:0px 0px 0px 0px;border:#000000 0px solid;cursor:pointer;}');	
	document.write('--></style>');//left:37px;top:0px;
	document.write('<div id="oxyFiltreOxylane" onclick="Cacher_Oxylane();return false;"></div>');
	document.write('<div id="oxyServiceOxylane" class="popUp"></div>');

/*############################################################################################## */
// Remplit le cadre de l'iframe des services Oxylane
function RemplirContenuDiv()
{
	oxyContenuDiv = '#IFRAME#'
}
if(isOxyCallWithSwitch=='false') 
	loadBoutonOxylane(true)

function loadBoutonOxylane(isAffiche)
{
	if(isAffiche)
	{	
		RemplirContenuDiv();;
		/*############################################################################################## */
		// 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();PositionPopupOxylane('oxyServiceOxylane');}
}
/*############################################################################################## */
// Affiche le filtre d'opacite
function Affiche_Filtre(){   
    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(idDiv){
    Affiche_Filtre();
    //Est-ce que ce n'est pas la première fois que l'on charge
    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#',document.getElementById(idDiv).innerHTML);
    	
    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;
    }
}

function Affiche_Popup_AjouterContact(idDiv){
    
    Affiche_Filtre();
    //Est-ce que ce n'est pas la première fois que l'on charge
    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#',document.getElementById(idDiv).innerHTML);
    	
    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]-->');

