/*
CE FICHIER CONSTITUE UNE PARTIE DU LOGICIEL Vitamine CMS.
* Le Logiciel Initial "Vitamine CMS" (non modifié par une contribution) est distribuée
	par la Société STUDIO VITAMINE S.A.R.L dont le siège est Hôtel TIC - 1, rue Alexander Fleming – 17000 La Rochelle - France.
	(Site Internet : www.studiovitamine.com - Téléphone 05 46 07 23 16)
* Tous les éléments constitutifs du logiciel Vitamine CMS
	sont la création de Fabien Guy BRANCHUT, l'Auteur de logiciel, né en France le 11 mars 1974 à Angoulême (16).
	(Site Internet : www.fabien-branchut.fr - Téléphone : 06 60 80 26 02)
*/
var global_infoBulle_DOM = (document.getElementById ? true : false);
var global_infoBulle_IE  = (document.all && !global_infoBulle_DOM ? true : false);
var global_infoBulle_NS4 = (document.layers ? true : false);
var global_infoBulle_NETSCAPE = (navigator.appName == "Netscape");
var global_infoBulle_Mouse_X;        // Position X en Cours de la Mouse
var global_infoBulle_Mouse_Y;        // Position Y en Cours de la Mouse
var global_infoBulle_TopIndex = 1;   // Z-Index interne
var global_infoBulle_Decal_X  = 5;   // Décalage X entre Pointeur Mouse et Bulle
var global_infoBulle_Decal_Y  = 5;   // Décalage Y entre Pointeur Mouse et Bulle
var global_infoBulle_bBulle= false;  // Flag Affichage de la Bulle
//---------------------
function infoBulle_GetObjet(div_){
  if( global_infoBulle_DOM) return document.getElementById(div_);
  if( global_infoBulle_IE)  return document.all[div_];
  if( global_infoBulle_NS4) return document.layers[div_];
}
//---------------------
function infoBulle_GetStyle(div_){
  return (global_infoBulle_NS4 ? infoBulle_GetObjet(div_) : infoBulle_GetObjet(div_).style);
}
//---------------------
function infoBulle_ObjHide( div_){
  var Obj = null;
  if( div_){
    Obj = infoBulle_GetStyle( div_);
    if( Obj){
      Obj.visibility= "hidden";
    }
  }
  return(true);
}
//-------------------------
function infoBulle_ObjShow( div_, z_){
  var Obj = null;
  if( div_){
    Obj = infoBulle_GetStyle( div_);
    if( Obj){
      Obj.visibility = "visible";
      if( arguments[1] != null)
        Obj.zIndex = z_;
      else
        Obj.zIndex = global_infoBulle_TopIndex++;
    }
  }
  return(true);
}
//-----------------------------
function infoBulle_ObjWrite( div_, html_){
  var Obj;
  Obj = infoBulle_GetObjet( div_);
  if( Obj) with( Obj){
    if( !global_infoBulle_NS4){
      innerHTML = html_;
    }
    else{
      document.open();
      document.write( html_);
      document.close();
    }
  }
}
//-------------------------------
function infoBulle_ObjMoveTo( div_, x_, y_){
  var Obj = null;
  var Arg = arguments;
  if( div_){
    Obj = infoBulle_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 infoBulle_ObjShowAll( div_, x_, y_, z_){
  var Obj = infoBulle_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( global_infoBulle_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( global_infoBulle_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*global_infoBulle_Decal_Y;
    }

    //-- On place la Bulle
    infoBulle_ObjMoveTo( div_, x_, y_);
    infoBulle_ObjShow( div_, z_);
  }
}
//------------------------
function infoBulle_BulleWrite( txt_){
 var Obj;
 var Html;
 Obj = infoBulle_GetObjet( 'Bulle');
 if( Obj && txt_!=""){
 	txt_ = txt_.replace(/###apostrophe###/g,"'");
 	txt_ = txt_.replace(/###guillemet###/g,'"');
 	
	Html = "";
	Html += "<TABLE id='tableInfoBulle' CELLSPACING=0>";
	Html += "<TR>";
	Html += "<TD>";
	Html += "<TABLE CELLSPACING=0 CELLPADDING=4 WIDTH='100%'>";
	//Html += "<TR><TD><BR><HR>Position <B>onMouseOver</B><BR>Mouse : X= " +global_infoBulle_Mouse_X +" Y= " +global_infoBulle_Mouse_Y+"</td></tr>"; //-- Rajout pour la démo
	Html += "<TR>";
	Html += "<TD id='tdInfoBulle' NOWRAP ALIGN='LEFT'>";
	Html += txt_;
	Html += "</TD>";
	Html += "</TR>";
	Html += "</TABLE>";
	Html += "</TD>";
	Html += "</TR>";
	Html += "</TABLE>";
  infoBulle_ObjWrite  ('Bulle', Html);
  infoBulle_ObjShowAll('Bulle', global_infoBulle_Mouse_X +global_infoBulle_Decal_X, global_infoBulle_Mouse_Y +global_infoBulle_Decal_Y, 1000);
  global_infoBulle_bBulle= true;
  return( true);
 }
 return(false);
}
//------------------
function infoBulle_BulleHide(){
  infoBulle_ObjWrite ('Bulle', "&nbsp;");
  infoBulle_ObjHide  ('Bulle');
  infoBulle_ObjMoveTo('Bulle', 0, 0);
  global_infoBulle_bBulle= false;
  return(true);
}

//------------------------------------
//  Mise à Jour  : 29.05.2006
//------------------------------------
function infoBulle_WhereMouse(e){
  var DocRef;

  if( global_infoBulle_NETSCAPE){
    global_infoBulle_Mouse_X = e.pageX;
    global_infoBulle_Mouse_Y = e.pageY;
  }
  else{
    if( document.documentElement && document.documentElement.clientWidth)
      DocRef = document.documentElement;
    else
      DocRef = document.body;

    global_infoBulle_Mouse_X = event.clientX +DocRef.scrollLeft;
    global_infoBulle_Mouse_Y = event.clientY +DocRef.scrollTop;
  }
  //-- La bulle est affichée on la MOVE
  if( global_infoBulle_bBulle)
    infoBulle_ObjShowAll('Bulle', global_infoBulle_Mouse_X +global_infoBulle_Decal_X, global_infoBulle_Mouse_Y +global_infoBulle_Decal_Y, 1000);
}
//== INITIALISATION ==================================
//-- Capture Souris events ---------------------------
if( global_infoBulle_NETSCAPE)
  window.captureEvents( Event.MOUSEMOVE);
document.onmousemove = infoBulle_WhereMouse;

//-- Création STYLE Bulle et DIV----------------------
// Nota : pour global_infoBulle_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( !global_infoBulle_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);
  }
//-- EOF ------------------------------------------------------
