/* ***************** */
/*  Fenêtres popup   */
/* ***************** */

function Pop(url,nom,largeur,hauteur) {
	var midWidth=(((window.top.screen.width)/2)-largeur/2);
	var midHeight=(((window.top.screen.height)/2)-hauteur/2);
	var win_param=("left=" + midWidth + ",top=" + midHeight +",toolbar=no,location=no,directories=no,status=yes,alwaysRaised=yes,dependant=no,menubar=no,scrollbars=yes,resizable=yes,width=" + largeur + ",height=" + hauteur + "");
		window.open(url, nom, win_param);
}

//-------------------------------------------------------------
//  Nom Document : GFBULLE.JS
//-------------------------------------------------------------
//  Mise à Jour  : 29.05.2006
//  Objet        : Compatibilité IE6 et DOCTYPE
//  -----------------------------------------------------------
var DOM = (document.getElementById ? true : false);
var IE  = (document.all && !DOM ? true : false);
var NS4 = (document.layers ? true : false);
var NAV_OK   = ( DOM || IE || NS4);
var NETSCAPE = (navigator.appName == "Netscape");
var Mouse_X;        // Position X en Cours de la Mouse
var Mouse_Y;        // Position Y en Cours de la Mouse
var TopIndex = 1;   // Z-Index interne
var Decal_X  = -30;   // Décalage X entre Pointeur Mouse et Bulle
var Decal_Y  = 12;   // Décalage Y entre Pointeur Mouse et Bulle
var bBulle= false;  // Flag Affichage de la Bulle
//---------------------
function GetObjet(div_){
  if( DOM) return document.getElementById(div_);
  if( IE)  return document.all[div_];
  if( NS4) return document.layers[div_];
}
//---------------------
function GetStyle(div_){
  return (NS4 ? GetObjet(div_) : GetObjet(div_).style);
}
//---------------------
function ObjHide( div_){
  var Obj = null;
  if( div_){
    Obj = GetStyle( div_);
    if( Obj){
      Obj.visibility= "hidden";
    }
  }
  return(true);
}
//-------------------------
function ObjShow( div_, z_){
  var Obj = null;
  if( div_){
    Obj = GetStyle( div_);
    if( Obj){
      Obj.visibility = "visible";
      if( arguments[1] != null)
        Obj.zIndex = z_;
      else
        Obj.zIndex = TopIndex++;
    }
  }
  return(true);
}
//-----------------------------
function ObjWrite( div_, html_){
  var Obj;
  Obj = GetObjet( div_);
  if( Obj) with( Obj){
    if( !NS4){
      innerHTML = html_;
    }
    else{
      document.open();
      document.write( html_);
      document.close();
    }
  }
}
//-------------------------------
function ObjMoveTo( div_, x_, y_){
  var Obj = null;
  var Arg = arguments;
  if( div_){
    Obj = GetStyle( div_);
    if( Obj){
      if( Arg[1] != null) Obj.left = x_ +"px";
      if( Arg[2] != null) Obj.top  = y_ +"px";
    }
  }
}
//------------------------------------
//  Mise à Jour  : 29.05.2006
//------------------------------------
function ObjShowAll( div_, x_, y_, z_){
  var Obj = GetObjet( div_);
  var DocRef;
  var MaxX, MaxY;
  var Top,  Left;
  var Haut, Larg;
  var SavY = y_;

  if( Obj){
    //-- Récup. dimension fenêtre et DIV
    if( NETSCAPE){
      with( window){
        Left = pageXOffset;
        Top  = pageYOffset;
        MaxX = innerWidth;
        MaxY = innerHeight;
        if( MaxX > document.width)  MaxX = document.width;
        if( MaxY > document.height) MaxY = document.height;
        MaxX += Left;
        MaxY += Top;
      }
      if( NS4){
        Larg = Obj.clip.width;
        Haut = Obj.clip.height;
      }
      else{
        Larg = Obj.offsetWidth;
        Haut = Obj.offsetHeight;
      }
    }
    else{
      if( document.documentElement && document.documentElement.clientWidth)
        DocRef = document.documentElement;
      else
        DocRef = document.body;

      with( DocRef){
        Left = scrollLeft;
        Top  = scrollTop;
        MaxX = Left + clientWidth;
        MaxY = Top  + clientHeight;
      }

      Larg = Obj.scrollWidth;
      Haut = Obj.scrollHeight;
    }
    //-- Réajuste dimension fenêtre
    MaxX -= Larg;
    MaxY -= Haut;

    //-- Application Bornage
    if( x_ > MaxX) x_ = MaxX;
    if( x_ < Left) x_ = Left;
    if( y_ > MaxY) y_ = MaxY;
    if( y_ < Top)  y_ = Top;

    //-- si en bas On réajuste
    //-- pour que la bulle ne prenne pas le focus
    if( y_== MaxY){
      var DeltaY = MaxY -SavY;
      y_ = MaxY - DeltaY -Haut -2*Decal_Y;
    }

    //-- On place la Bulle
    ObjMoveTo( div_, x_, y_);
    ObjShow( div_, z_);
  }
}
//------------------------
function BulleWriteCartouche( titre_, txt_, pathUrl){
 var Obj;
 var Html;
 Obj = GetObjet('Bulle');
 if( Obj){
    Html = '<div style="width: 188px; display: block; font-family: Arial,sans-serif; background: transparent url(' + pathUrl + 'cartouche/popinfo-haut.png) no-repeat left top; padding-top: 6px;">';
	Html += '<h4 style="text-align: center; color: #000; width: auto; font-size: 12px; background: #e5e5e5 url(' + pathUrl + 'cartouche/popinfo-fond.png) no-repeat right top; margin: 0; padding: 0 0 4px 0; border-left: solid 1px #7d7d7d; border-right: solid 1px #7d7d7d;">';
	Html += titre_;
	Html += '</h4>';
	Html += '<div style="background: #FFF url(' + pathUrl + 'cartouche/popinfo-fondcorps.png) no-repeat right top; border-left: solid 1px #7d7d7d; border-right: solid 1px #7d7d7d;">';
	Html += '<div style="margin: 0; padding: 0.5em; text-align: left">';
	Html += txt_;

    //-- Rajout pour la démo
    //Html += "<BR><HR>Position <B>onMouseOver</B><BR>Mouse : X= " +Mouse_X +" Y= " +Mouse_Y;

    Html += '</div>';
	Html += '</div>';
	Html += '</div>';
	Html += '<div style="width: 188px; display: block; background: transparent url(' + pathUrl + 'cartouche/popinfo-bas.png) no-repeat left top; padding-top: 6px;"&nbsp;</div>';
  ObjWrite  ('Bulle', Html);
  ObjShowAll('Bulle', Mouse_X +Decal_X, Mouse_Y +Decal_Y, 1000);
  bBulle= true;
  return( true);
 }
 return(false);
}
//------------------
function BulleHide(){
  ObjWrite ('Bulle', "&nbsp;");
  ObjHide  ('Bulle');
  ObjMoveTo('Bulle', 0, 0);
  bBulle= false;
  return(true);
}

//------------------------------------
//  Mise à Jour  : 29.05.2006
//------------------------------------
function WhereMouse(e){
  var DocRef;

  if( NETSCAPE){
    Mouse_X = e.pageX;
    Mouse_Y = e.pageY;
  }
  else{
    if( document.documentElement && document.documentElement.clientWidth)
      DocRef = document.documentElement;
    else
      DocRef = document.body;

    Mouse_X = event.clientX +DocRef.scrollLeft;
    Mouse_Y = event.clientY +DocRef.scrollTop;
  }
  //-- La bulle est affichée on la MOVE
  if( bBulle)
    ObjShowAll('Bulle', Mouse_X +Decal_X, Mouse_Y +Decal_Y, 1000);
}
//== INITIALISATION ==================================
//-- Capture Souris events ---------------------------
if( NETSCAPE)
  window.captureEvents( Event.MOUSEMOVE);
document.onmousemove = WhereMouse;

//-- Création STYLE Bulle et DIV----------------------
// Nota : pour NS4 le DIV doit faire parti du document
var Html;
  //-- On met du style pour la bulle
  Html  = '<STYLE TYPE="text/css">';
  Html += '.Bulle{color:#000000;font-size:13px;font-family:Verdana;}';
  Html += '</STYLE>';
  document.write( Html);

  //-- Création du DIV Bulle
  if( !NS4){
    Html ='<div id="Bulle" style="position:absolute; left:auto; top:auto; width:auto; height:auto; z-index:0; visibility:hidden"></div>';
    document.write( Html);
  }

/*
 * Fenêtres popup
 */
function Pop(url,nom,largeur,hauteur) {
	var midWidth=(((window.top.screen.width)/2)-largeur/2);
	var midHeight=(((window.top.screen.height)/2)-hauteur/2);
	var win_param=("left=" + midWidth + ",top=" + midHeight +",toolbar=no,location=no,directories=no,status=yes,alwaysRaised=yes,dependant=no,menubar=no,scrollbars=yes,resizable=yes,width=" + largeur + ",height=" + hauteur + "");
		window.open(url, nom, win_param);
 }
 
/*
** popup virtuels, afficher et masquer alternativement un div
*/

function switchMyDiv(id) {
	var conteneur =  document.getElementById(id);

	isIE = (document.all)
	isGek = (!isIE) && (document.getElementById)

	if (isIE) conteneur = document.all[id];
	if (isGek) conteneur = document.getElementById(id);

	if (conteneur.style.display == "none") {
	  conteneur.style.display = "block";
	}
	else {
	  conteneur.style.display = "none";
	}
 }
/*
** Renvoi avec alerte vers la page d'accueil pour la recherche
*/

function Reload() { 
	if(document.all) { 
		document.all['GHpopDetailMasque'].style.display='none';
		document.all['GHpopDetailOmbre'].style.display='none';
		document.all['GHpopDetail'].style.display='none';
	} else {
		document.getElementById('GHpopDetailMasque').style.display= 'none';
		document.getElementById('GHpopDetailOmbre').style.display= 'none';
		document.getElementById('GHpopDetail').style.display= 'none';
	}
	
	window.location.href='http://www.pierreetvacances.com/';
}
function Timer() {
	setTimeout("Reload()",5000); /*  */
}

/*
** popup virtuels, afficher et masquer alternativement un div
*/

function switchMyDiv(id) {
	var conteneur =  document.getElementById(id);

	isIE = (document.all)
	isGek = (!isIE) && (document.getElementById)

	if (isIE) conteneur = document.all[id];
	if (isGek) conteneur = document.getElementById(id);

	if (conteneur.style.display == "none") {
	conteneur.style.display = "block";
	}
	else {
	conteneur.style.display = "none";
	}
 }

/* ********************************* */
/*        "trimer" une chaine        */
/* ********************************* */

function trim (myString)
{
return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
} 


/* ********************************* */
/* Contourner le bug de la librairie */
/* effect.js sur des divs flottants  */
/* ********************************* */

function toggleOrSwitch(id,methode,duree) {
	var browser = navigator.appName;
	var version = navigator.appVersion;
	
	if( (browser == 'Opera') || (version.indexOf('Safari') != -1 ) || (version.indexOf('Chrome') != -1 ) ) {
		//alert('navigateur : '+browser+' ! Moteur : '+version.indexOf('Chrome'));
		switchMyDiv(id);
	}
	else {
		//alert('pas Opera : '+browser+' ! Moteur : '+version);
		Effect.toggle(id, methode, {duration:duree}); /* necessite prototype.js, scriptaculous.js et effect.js */
	}
}

/* ********************************* */
/*      intégration Google maps      */
/* ********************************* */

function initializeGM(num,Latitude,Longitude) { // initialisation de la carte Google Maps
	//var WordingMap = 'Voir sur la carte';
	//var WordingCloseMap = 'Refermer la carte';
	var isLoaded = (document.getElementById('mapOffre-'+num).innerHTML.length == 0 ) ? false : true;
	
  if ( isLoaded == false ) { 
	  if ( GBrowserIsCompatible() ) { 
		var map = new GMap2( document.getElementById('mapOffre-'+num),{ size: new GSize(745,180) } );
		map.enableDoubleClickZoom();
		var point = new GLatLng( Latitude , Longitude );
		map.addControl(new GMapTypeControl());
		map.addControl(new GSmallZoomControl3D);					
				
		/* définition d'une classe d'icône */
		var icon = new GIcon();
		icon.image = gmapIcon;//'img/cartouche/Gmap-icon.png';
		icon.shadow = gmapIconShadow;//'img/cartouche/Gmap-iconshadow.png';
		icon.iconSize = new GSize(32, 32);
		icon.shadowSize = new GSize(32, 32);
		icon.iconAnchor = new GPoint(13, 29);
		icon.infoWindowAnchor = new GPoint(13, 10);
		
		//map.addControl(new GOverviewMapControl(new GSize(140,140)));  
		map.setCenter(point, 8);
		var marker = new GMarker(point, icon, {clickable:false} );
		map.addOverlay(marker);
	  } 
  }
  
  if ( document.getElementById('piloteGmap-'+num).innerHTML == WordingMap ) {
		document.getElementById('piloteGmap-'+num).innerHTML = WordingCloseMap;
	} else {
		document.getElementById('piloteGmap-'+num).innerHTML = WordingMap;
	}
}
