/**************************************************************************\
  * Phenix Agenda                                                            *
  * http://phenix.gapi.fr                                                    *
  * Written by Stephane TEIL <phenix-agenda@laposte.net>                     *
  * --------------------------------------------                             *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
\**************************************************************************/

var backcolor="#000000"; // couleur du fond du titre
var width=422; // largeur de la bulle
var border="0"; // taille de la bordure
ns4 = (document.layers) ? true : false;
ope = (document.getElementById) ? true : false;
ie4 = (document.all) ? true : false;
if (ie4) {
  ie5 = (navigator.userAgent.indexOf('MSIE 5')>0 || navigator.userAgent.indexOf('MSIE 6')>0) ? true : false;
} else {
  ie5 = false;
}

var x=0;
var y=0;
var xGauche;

var snow=0;
var sw=0;
var cnt=0;

if ( (ns4) || (ie4) || (ope) ) {
  if (ie4)
    over = document.all["infoBulle"].style;
  else if (ope)
    over = document.getElementById("infoBulle").style;
  else if (ns4)
    over = document.infoBulle;
  document.onmousemove = mouseMove;
  if (ns4)
    document.captureEvents(Event.MOUSEMOVE);
}

function nd() {
  if ( cnt >= 1 ) {
    sw = 0;
  }
  if ( (ns4) || (ie4) || (ope) ) {
    if ( sw == 0 ) {
      snow=0;
      hideObject(over);
    } else {
      cnt++;
    }
  }
}

function atc(texte) {
  sw=0;
  width = 100;
  layerWrite("<TABLE width="+width+" border=0 cellpadding="+border+" cellspacing=0 bgcolor=\""+backcolor+"\"><TR><TD><TABLE width=\"100%\" border=0 cellpadding=2 cellspacing=0><TR><TD class=\"ibTexte\" nowrap>"+texte+"</TD></TR></TABLE></TD></TR></TABLE>");
  disp();
}
function dtc(heure, titre, texte) {
  sw=0;
  width = 390;
  layerWrite("<TABLE width="+width+" border=0 cellpadding="+border+" cellspacing=0 bgcolor=\""+backcolor+"\"><TR><TD><TABLE width=\"100%\" border=0 cellpadding=0 cellspacing=0><TR valign=\"top\"><TD class=\"ibHeure\" nowrap>"+heure+"&nbsp;</TD><TD class=\"ibTitre\" width=\"100%\">"+titre+"</TD></TR></TABLE><TABLE width=\"100%\" border=0 cellpadding=2 cellspacing=0><TR><TD class=\"ibTexte\">"+texte+"</TD></TR></TABLE></TD></TR></TABLE>");
  disp();
}
function mtc(titre, texte) {
  sw=0;
  width = 330;
  layerWrite("<TABLE width="+width+" border=0 cellpadding="+border+" cellspacing=0 bgcolor=\""+backcolor+"\"><TR><TD><TABLE width=\"100%\" border=0 cellpadding=0 cellspacing=0><TR><TD class=\"ibHeure\">"+titre+"</TD></TR></TABLE><TABLE width=\"100%\" border=0 cellpadding=2 cellspacing=0><TR><TD class=\"ibTexte\">"+texte+"</TD></TR></TABLE></TD></TR></TABLE>");
  disp();
}
function stc(heure, titre, texte) {
  sw=1;
  cnt=0;
  width = 422;
  layerWrite("<TABLE width="+width+" border=0 cellpadding="+border+" cellspacing=0 bgcolor=\""+backcolor+"\"><TR><TD><TABLE width=\"100%\" border=0 cellpadding=0 cellspacing=0><TR valign=\"top\"><TD class=\"ibHeure\" nowrap>"+heure+"&nbsp;</TD><TD class=\"ibTitre\" width=\"100%\">"+titre+"</TD><TD align=\"right\" class=\"ibTitre\"><A href=\"/\" onClick=\"cClick(); return false;\"><IMG src=\"image/popup_close.gif\" width=\"13\" height=\"13\" alt=\"Fermer\" border=\"0\"></A></TD></TR></TABLE><TABLE width=\"100%\" border=0 cellpadding=2 cellspacing=0><TR><TD class=\"ibTexte\">"+texte+"</TD></TR></TABLE></TD></TR></TABLE>");
  disp();
  snow=0;
}

function infoagenda(Section,Debut,Fin,BusCnn,BusExtra,RemorqueCnn,RemorqueExtra,Nbre,Chauffeur,Destination, Cree){
  sw=0;
  width = 270;
  layerWrite("<table class=\"ibtable\" width="+width+" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\""+backcolor+"\"><tr><td><table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr valign=\"top\"><td class=\"ibHeure\" nowrap>"+Debut+"</td><td class=\"ibHeure\" nowrap>-</td><td class=\"ibHeure\" nowrap>"+Fin+"</td><td class=\"ibTitre\" width=\"100%\">"+Section+"</td></tr></table><table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td class=\"ibTexte\">Bus CNN :</td><td class=\"ibTexte1\">"+BusCnn+"</td></tr><tr class=\"ibRow\"><td class=\"ibTexte\">Remorque CNN :</td><td class=\"ibTexte1\">"+RemorqueCnn+"</td></tr><tr><td class=\"ibTexte\">Bus supplémentaire :</td><td class=\"ibTexte1\">"+BusExtra+"</td></tr><tr class=\"ibRow\"><td class=\"ibTexte\">Remorque supplémentaire :</td><td class=\"ibTexte1\">"+RemorqueExtra+"</td></tr><tr><td class=\"ibTexte\">Nombre de personnes :</td><td class=\"ibTexte1\">"+Nbre+"</td></tr><tr class=\"ibRow\"><td class=\"ibTexte\">Chauffeur :</td><td class=\"ibTexte1\">"+Chauffeur+"</td></tr><tr><td class=\"ibTexte\">Destination :</td><td class=\"ibTexte1\">"+Destination+"</td></tr></table><table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr valign=\"top\"><td class=\"ibCree\" nowrap>Créé le "+Cree+"</td></tr></table></td></tr></table>");
  disp();
}


function disp() {
  if ( (ns4) || (ie4) || (ope) ) {
    if (snow == 0) 	{
      if (sw == 0) {
        if (x-(width/2)<8)
          xG = 8;
        else if (x+(width/2)>screen.width-23)
          xG = screen.width-width-23;
        else
          xG = x-(width/2);
        moveTo(over,xG,y+20)
      }
      else {
        xGauche = Math.max(146,x-width+5);
        moveTo(over,xGauche,y+10);
      }
      showObject(over);
      snow=1;
    }
  }
}

function mouseMove(e) {
  if (ie5) {
    x=event.x+document.body.scrollLeft;
    y=event.y+document.body.scrollTop;
  }
  else if (ie4) {
    x=event.x;
    y=event.y;
  }
  else if (ope) {
    x=e.pageX;
    y=e.pageY;
  }
  else if (ns4) {
    x=e.pageX;
    y=e.pageY;
  }
  if (snow) {
    if (x-(width/2)<8)
      xG = 8;
    else if (x+(width/2)>screen.width-23)
      xG = screen.width-width-23;
    else
      xG = x-(width/2);
    moveTo(over,xG,y+20);
  }
}

function cClick() {
  hideObject(over);
  sw=0;
}

function layerWrite(txt) {
  if (ie4)
    document.all["infoBulle"].innerHTML = txt;
  else if (ope)
    document.getElementById("infoBulle").innerHTML = txt;
  else if (ns4) {
    var lyr = document.infoBulle.document;
    lyr.write(txt);
    lyr.close();
  }
}

function showObject(obj) {
  if (ie4 || ope)
    obj.visibility = "visible";
  else if (ns4)
    obj.visibility = "show";
}

function hideObject(obj) {
  if (ie4 || ope)
    obj.visibility = "hidden";
  else if (ns4)
    obj.visibility = "hide";
}

function moveTo(obj,xL,yL) {
  obj.left = xL;
  obj.top = yL;
}
