/*################################################################################
  #
  # FICHIER: zone.js
  #
  # MODULE:  RESERVIT/MANAGER/FORMS
  #
  # OBJET:   Contient des fonctions utilitaires concernant la page zone 
  #          et plus particulierement l'affichage de la popup lors du
  #          passage de la souris sur la carte.
  #         
  # AUTEURS: Stephane Michel    smichel@it.marseille-innov.org
  #          (C) Copyright 1999 Interface Technologies,
  #
  ################################################################################
  #     HISTORIQUE
  ################################################################################
  # CHG DD/MM/YYYY INIT            DESCRIPTION
  # --- ---------- ---- ---------------------------------------------------------
  # 001 05/05/2003  SM  Creation (DEV-#225)
  ################################################################################*/



// Couleur de fond principale (la plus grande partie)
var fcolor = "#FFFFFF";
	
// Couleur de la bordure ainsi que celle de la barre des titres
var backcolor = "#FF9900";
	
// Couleur du texte
var textcolor = "#000000";
	
// Couleur de la barre icones 
var capcolor = "#CCFF66";

// Largeur de la fenetre ( pop-up) en pixels
 var width = "225";
	
// Largeur pour la bordure ?
var border = "1";
		
// D�calage en pixels, � droite du curseur, utilis� pour l'affichage de la popup
var offsetx = 20;
	
// D�calage en pixels, en dessous du curseur, utilis� pour l'affichage de la popup
var offsety = -50;

// Compatibilit� du browser: Netscape? IE? ...
bNetscape4 = false;
bMozilla   = false;
bIE4       = false;

bNetscape4 = (document.layers)? true:false;
if (!bNetscape4)
{
  bIE4 = (document.all)? true:false;
  
  if (!bIE4)
    {
      bMozilla = (document.getElementById)?true:false;
    }
}

// Tests compl�mentaires pour IE
if (bIE4) {
  if (navigator.userAgent.indexOf('MSIE 5')>0) {
    bIE5 = true;
  } else {
    bIE5 = false; }
} else {
  bIE5 = false;
}

// D�finition de quelques variables locales
var x = 0;
var y = 0;
var snow = 0;
var sw = 0;
var cnt = 0;
var dir = 1;

// Clears popups if appropriate
function nd() {
	if ( cnt >= 1 ) { sw = 0 };
	if ( (bNetscape4) || (bIE4) || (bMozilla)) {
		if ( sw == 0 ) {
			snow = 0;
			hideObject(over);
		} else {
			cnt++;
		}
	}
}

// ================================================================
// DisplayPopup: Fonction permettant d'afficher une popup lors du
//               passage de la souris sur un icone.
// => La fenetre contient les infos relatives aux hotels presents
// dans la ville: nom de l'hotel, de la ville, classification ..
// ================================================================ 
function DisplayPopup(id, title, 
		      text, image,
		      width_windows,
		      bgcolor, txtcolor, bordercolor, titlecolor, titleclass) 
{
  if (bgcolor == "") { bgcolor = fcolor; }
  if (txtcolor == "") { txtcolor = textcolor }
  if (bordercolor == "") { bordercolor = backcolor; }
  if (titlecolor == "") { titlecolor = capcolor; }
  if (width_windows == "" || width_windows == 0) { width_windows = width; }

  switch (id)
    {
    case "59":
      txt  = "<div id=\"popup\">\n";
      txt += "  <div id=\"popup_header\">"+title+"</div>\n";
      txt += "  <div id=\"popup_text\">"+text+"</div>\n";
      txt += "</div>\n";
      break;
    default:
	  txt  = "<div id=\"popup\">\n";
      txt += "  <div id=\"popup_header\">"+title+"</div>\n";
      txt += "  <div id=\"popup_text\">"+text+"</div>\n";
      txt += "</div>\n";
	/*
      txt  = "<TABLE WIDTH=\""+width_windows+"\" BORDER=\"0\" CELLPADDING=\""+border+"\" CELLSPACING=\"0\" BGCOLOR=\""+bordercolor+"\">\n";
      txt = txt+"<TR>\n";
      txt = txt+"  <TD>\n";
      txt = txt+"     <TABLE WIDTH=\"100%\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">\n";
      txt = txt+"     <TR>\n";
      txt = txt+"       <TD ALIGN=\"center\">\n";
      txt = txt+"         <SPAN ID=\"PTT\"><FONT COLOR=\""+titlecolor+"\" class=\""+titleclass+"\" style=\"font-size: 7pt;\"><B>"+title+"</B></FONT></SPAN><BR>";
      txt = txt+"       </TD>";
      txt = txt+"     </TR>";
      txt = txt+"     </TABLE>";
      txt = txt+"     <TABLE WIDTH=\"100%\" BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"0\" BGCOLOR=\""+bgcolor+"\">";
      txt = txt+"     <TR>\n";
      
      if (image != "")
	{
	  txt = txt+"       <TD>\n";
	  txt = txt+"         <IMG SRC=\""+image+"\">";
	  txt = txt+"       </TD>";
	}
      
      txt = txt+"       <TD VALIGN=\"top\" CLASS=\"textopacht\">\n";
      txt = txt+"         <SPAN ID=\"PST\">\n";
      txt = txt+"         <FONT SIZE=\"1\">"+text+"</FONT>";
      txt = txt+"         <SPAN>";
      txt = txt+"       </TD>";
      txt = txt+"     </TR>";
      txt = txt+"     </TABLE>";
      txt = txt+"  </TD>";
      txt = txt+"</TR>";
      txt = txt+"</TABLE>";
	 */
      break;
    }

  layerWrite(txt);
  dir = 1;
  display();
}

// ================================================================
// display: Fonction g�n�rale d'affichage
// ================================================================ 
function display() {
  if ( (bNetscape4) || (bIE4) )
{
  if (bNetscape4)
  {
  	over = document.overDiv;
  }
  if (bIE4) 
  {
  	over = overDiv.style; 
  	document.onmousemove = mouseMove;
  }
  if (bNetscape4)
  { 
  document.captureEvents(Event.MOUSEMOVE);
  }  
}

if (bMozilla) {
	
  over = document.getElementById("overDiv");
  document.onmousemove = mouseMove;
}

	
  if ( (bNetscape4) || (bIE4) || (bMozilla)) {
    if (snow == 0) 	{
      if (dir == 2) { // Center
	moveTo(over,x+offsetx-(width/2),y+offsety);
      }
      if (dir == 1) { // Right
	moveTo(over,x+offsetx,y+offsety);
      }
      if (dir == 0) { // Left
	moveTo(over,x-offsetx-width,y+offsety);
      }
      showObject(over);
      snow = 1;
    }
  }
}

// ================================================================
// mouseMove: Fonction permettant le d�placement de la fenetre popup
// ================================================================ 
function mouseMove(e) {
  if (bNetscape4) {x=e.pageX; y=e.pageY;}
  if (bIE4) {x=event.x; y=event.y;}
  if (bIE5) {x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;}

  if (bMozilla) { x=e.pageX; y=e.pageY; }
  if (snow) {
    if (dir == 2) { // Center
      moveTo(over,x+offsetx-(width/2),y+offsety);
    }
    if (dir == 1) { // Right
      moveTo(over,x+offsetx,y+offsety);
    }
    if (dir == 0) { // Left
      moveTo(over,x-offsetx-width,y+offsety);
    }
  }
}

// ================================================================
// layerWrite: Fonction permettant d'�crire dans la fenetre popup
// ================================================================ 
function layerWrite(txt) {
  if (bNetscape4) 
    {
      var lyr = document.overDiv.document;
      lyr.write(txt);
      lyr.close();
    }
  else 
    {
      if (bIE4) 
	document.all["overDiv"].innerHTML = txt;
      else if (bMozilla)
	{
	  document.getElementById("overDiv").innerHTML = txt;
	}
    }
}

// ================================================================
// showObject: Fonction rendant visible l'objet
// ================================================================ 
function showObject(obj) {
  if (bNetscape4) 
    obj.visibility = "show";
  else 
    if (bIE4) obj.visibility = "visible";
    else if (bMozilla)
     {
	obj.style.visibility = "visible";
     }
}

// ================================================================
// showObject: Fonction cachant l'objet � l'ecran
// ================================================================ 
function hideObject(obj) {
  if (obj != null && typeof(obj) != 'undefined')
    {
      if (bNetscape4) 
	obj.visibility = "hide";
      else 
	if (bIE4) obj.visibility = "hidden";
	else if (bMozilla)
	  {
	    obj.style.visibility = "hidden";
	  }
    }
}

// ================================================================
// moveTo: Fonction de d�placement du layer
// ================================================================ 
function moveTo(obj,xL,yL) 
{
  	var toon_xL = parseInt(xL);
	var toon_yL = parseInt(yL);
  
  if (bMozilla)
    {

	obj.style.marginLeft = toon_xL + "px";
	obj.style.marginTop = toon_yL + "px";
    }
  else
    {
       obj.left = toon_xL;
       obj.top = toon_yL;
    }
}