///////////////////////////////////////fonction DROPDOWN
function changeLayer(idlayer,idBox){

	if(document.getElementById(idlayer).style.display=="none"){
	document.getElementById(idlayer).style.display = '';
	document.getElementById(idBox).className = 'dropDownArrow';
	}else{
	document.getElementById(idlayer).style.display = 'none';
	document.getElementById(idBox).className = 'dropUpArrow';
	}
	
}

///////////////////////////////////////fonction DROPDOWN ERROR
function changeLayerError(idlayer,idBox,idError){

	if(document.getElementById(idlayer).style.display=="none"){
	document.getElementById(idlayer).style.display = '';
	document.getElementById(idBox).className = 'dropDownArrowError';
	}else{
	document.getElementById(idlayer).style.display = 'none';
	document.getElementById(idBox).className = 'dropUpArrowError';
	}
	
}

///////////////////////////////////////fonctions INFOBULLES
//Compatibles IE, FF, Safari etc
//Prise en compte des champs SELECT et du scroll
var DOM = (document.getElementById ? true : false);
var IE  = (document.all && !DOM ? true : false);
var NS4 = (document.layers ? true : false);
var NAV_OK   = ( DOM || IE );
var NETSCAPE = ( navigator.appName == "Netscape");
var EXPLORER = ( navigator.appName =='Microsoft Internet Explorer');
var OPERA    = ( window.opera ? true : false);
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  = -10;   // Decalage X entre Pointeur Mouse et Bulle
var Decal_Y  = -10;   // Decalage Y entre Pointeur Mouse et Bulle
var bBulle= false;    // Flag Affichage de la Bulle

//-- Pour Test mode Cadre
var ZObjet = new RECT();   // Zone pour MouseMove
var ZBulle = new RECT();
var bCadre = false;        // Flag Affichage du Cadre
var bInit  = false;
var Fenetre = new RECT();
//=========================
// Definition pour le Cadre
//=========================
function RECT(){
  this.Left   =0;
  this.Top    =0;
  this.Right  =0;
  this.Bottom =0;
  this.InitRECT   =RECT_Set; 
  this.PtInRECT   =RECT_PtIn; 
}
//-------------------------------------------
function RECT_Set( left_, top_, larg_, haut_){
  with( this){
    Left   = ( left_ ? left_ : -1);
    Top    = ( top_  ? top_  : -1);
    Right  = Left + ( larg_ ? (larg_ -1): 0);
    Bottom = Top  + ( haut_ ? (haut_ -1): 0);
  }
}
//-------------------------
function RECT_PtIn( x_, y_){
  with( this){
    return(( x_ > Left) && ( x_ < Right) && ( y_ > Top ) && ( y_ < Bottom));
    if( x_ < Left || x_ > Right)  return( false);
    if( y_ < Top  || y_ > Bottom) return( false);
    return( true);
  }
}
//---------------------
function GetObjet(div_){
  if( DOM) return document.getElementById(div_);
  if( IE)  return document.all[div_];
  return( null);
}
//-----------------------------
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 Get_DimFenetre(){
  var L_Doc;
  var H_Doc;
  var DocRef;
  
  with( Fenetre){
    if( window.innerWidth){
      with( window){
        Left   = pageXOffset;
        Top    = pageYOffset;
        Right  = innerWidth;
        Bottom = innerHeight;

        if( NETSCAPE){
          L_Doc = document.body.offsetWidth;
          H_Doc = document.body.offsetHeight;
        }
        else{
          L_Doc = document.body.clientWidth;
          H_Doc = document.body.clientHeight;
        }
        if( Right  > L_Doc) Right  = L_Doc;
        if( Bottom > H_Doc) Bottom = H_Doc;
      }
    }
    else{ // Cas Explorer a part
      if( document.documentElement && document.documentElement.clientWidth)
        DocRef = document.documentElement;
      else
        DocRef = document.body;

      with( DocRef){
        Left   = scrollLeft;
        Top    = scrollTop;
        Right  = clientWidth;
        Bottom = clientHeight;
      }
    }
    //-- limite Maxi Fenetre Affichage
    Right  += Left;
    Bottom += Top;
  }
}
//------------------------------------
function ObjShowAll( div_, x_, y_, z_){
  var B_Obj = GetObjet( div_);
  var F_Obj = GetObjet( 'F' +div_);
  var MaxX, MaxY;
  var Haut, Larg;
  var SavY = y_;

  if( B_Obj){
    //-- Recup. dimension du DIV
    if( NETSCAPE){
      Larg = B_Obj.offsetWidth;
      Haut = B_Obj.offsetHeight;
    }
    else{
      Larg = B_Obj.scrollWidth;
      Haut = B_Obj.scrollHeight;
    }
    with( Fenetre){
      //-- Reajuste dimension fenetre
      MaxX = Right  - Larg;
      MaxY = Bottom - 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 reajuste
    //-- 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
    if( EXPLORER){ //-- Ajout pour SELECT sous IE
      with(F_Obj.style){
        left       = x_ +"px";
        top        = y_ +"px";
        zIndex     = z_-1;
        visibility = "visible";
      }
    }
    with(B_Obj.style){
      left       = x_ +"px";
      top        = y_ +"px";
      zIndex     = z_;
      visibility = "visible";
    }
    //-- Affectation Zone du Rectangle
    ZBulle.InitRECT( x_, y_, Larg, Haut);
  }
}
//---------------------
function Init_Bulle(){
  var Obj;
  var i, k;
  var bW3C = ( window.addEventListener ? true : false);

  //-- Pour les SELECT on supprime l'evenement herite
  Obj = document.getElementsByTagName('SELECT');
  for( i=0; i < Obj.length; i++){
    if( Obj[i].size == 1){
      for( k=0; k < Obj[i].options.length; k++){
        if( bW3C)
           Obj[i].options[k].addEventListener('mousemove', BulleHide, false);
        else
           Obj[i].options[k].attachEvent( 'onmousemove',    BulleHide);
      }
    }
    if( bW3C){
      Obj[i].addEventListener('scroll',    BulleHide, false);
      Obj[i].addEventListener('mousedown', BulleHide, false);
    }
    else{
      Obj[i].attachEvent( 'onscroll',    BulleHide);
      Obj[i].attachEvent( 'onmousedown', BulleHide);
    }
  }
  bInit=true;
}
//------------------------
// mode Cadre Independant
//------------------------
function CadreWrite( txt_){
  var Html;
  var B_Obj = GetObjet( 'Bulle');
  var F_Obj = GetObjet( 'FBulle');
  if( !bInit) Init_Bulle();
  if( B_Obj){
    //-- Recup dimension d'affichage
    Get_DimFenetre();
    Decal_X = -10;  // Decalage dans de la Bulle
    Decal_Y = -10;
    Html  = "<TABLE BORDER='1' BORDERCOLOR='#808080' CELLSPACING=0 CELLPADDING=2 BGCOLOR='#A0A0A0'>";
    Html += "<TR><TD class='Bulle' ALIGN='LEFT'>";
    Html += txt_;
    Html += "</TD></TR></TABLE>";
    B_Obj.innerHTML = Html;

    if( EXPLORER){ //-- Ajout pour SELECT sous IE
      with(F_Obj.style){
        height = B_Obj.offsetHeight;
        width  = B_Obj.offsetWidth;
        left   = B_Obj.offsetLeft;
        top    = B_Obj.offsetTop;
      }
    }
    //-- On affiche le resultat
    ObjShowAll('Bulle', Mouse_X +Decal_X, Mouse_Y +Decal_Y, 1000);
    bCadre= true;
    return( true);
  }
  return(false);
}
//------------------------
// mode Bulle Independant
//------------------------
function BulleWrite( txt_){
  var B_Obj = GetObjet( 'Bulle');
  var F_Obj = GetObjet( 'FBulle');
  var Html;
  if( !bInit) Init_Bulle();
  if( B_Obj){
    //-- Recup dimension d affichage
    Get_DimFenetre();
    Decal_X = 5;  // Decalage hors de la Bulle
    Decal_Y = 5;
    Html  = "<TABLE BORDER=0 CELLSPACING=0><TR><TD BGCOLOR='#0000c0'>";
    Html += "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=4 WIDTH='100%' BGCOLOR='#FFFFE8'>";
    Html += "<TR><TD class='Bulle' ALIGN='LEFT'>";
    Html += txt_;
    Html += "</TD></TR></TABLE></TD></TR></TABLE>";
    B_Obj.innerHTML = Html;

    if( EXPLORER){ //-- Ajout pour SELECT sous IE
      with(F_Obj.style){
        height = B_Obj.offsetHeight;
        width  = B_Obj.offsetWidth;
        left   = B_Obj.offsetLeft;
        top    = B_Obj.offsetTop;
      }
    }
    //-----------------------------------------//
    // IMPORTANT on n affiche pas la Bulle     //
    // l evenement MouseOver va avec MouseMove //
    //-----------------------------------------//
    // ObjShowAll(Bulle, Mouse_X +Decal_X, Mouse_Y +Decal_Y, 1000);
    bBulle= true;
    return( true);
  }
 return(false);
}
//------------------
function BulleHide(){
  var B_Obj = GetObjet( 'Bulle');
  var F_Obj = GetObjet( 'FBulle');

  if( EXPLORER){ //-- Ajout pour SELECT sous IE
    F_Obj.style.height = 0 +"px";
  }
  with(B_Obj){
    innerHTML        = "&nbsp;"
    style.left       = -1000+"px";
    style.top        = -1000 +"px";
    style.zIndex     = 0;
    style.visibility = "hidden";
  }
  //-- Pose les Flags
  bCadre = false;
  bBulle = false;
  return(true);
}
//------------------------------------
function WhereMouse(e){
  var DocRef;
  var Obj = null;
  var bRect= true;

  if( NETSCAPE){
    Mouse_X = e.pageX;
    Mouse_Y = e.pageY;
    Obj     = e.target;
    //-- Specifique FireFox
    if( Obj.boxObject){
      with( Obj){
        //-- La Zone de prise en compte
        ZObjet.InitRECT( boxObject.x, boxObject.y, boxObject.width, boxObject.height);
      }
      //-- Barre de defilement et autre sous FireFox
      Obj = e.originalTarget;
      if( Obj)
        if( Obj.prefix =="xul"){
          BulleHide();
          return( true);
        }
      //-- Test pour SELECT sous FireFox
      bRect = ZObjet.PtInRECT( Mouse_X, Mouse_Y);
    }
  }//-- Endif NETSCAPE
  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;
  }

  if( bBulle)
    if( bRect)
      ObjShowAll('Bulle', Mouse_X +Decal_X, Mouse_Y +Decal_Y, 1000);

  if( bCadre)// on ne move pas on test juste si dans Rect
    if( !ZBulle.PtInRECT( Mouse_X, Mouse_Y))
      BulleHide();

  return( true);
}
//== INITIALISATION ==================================
document.onmousemove = WhereMouse;

var Html;
  //-- Creation du DIV Bulle
  Html ='<div id="Bulle"></div>';
  if( EXPLORER) //-- Ajout pour SELECT sous IE
    Html +='<iframe id="FBulle" style="position:absolute;visibility:hidden;border:0px;" frameborder="0" scrolling="no">&nbsp;</iframe>';
  document.write( Html);
//-- EOF ------------------------------------------------------


///////////////////////////////////////fonctions VEUIILLEZ PATIENTER

function ShowHide(EltId,Action) {
            var elt = document.getElementById(EltId); if (!elt) return;
            Action = (typeof Action=="undefined" ) ? "" : Action.substring(0,1).toLowerCase();
            with(elt.style) {
                display = (Action=="" ) ? (display=="block" || display=="" ) ? "none" : "block" : (Action=="h" ) ? "none" : "block";
            }
   }
 
///////////////////////////////////////fonctions SPLASH
function splash(idsplash,splashformname){

 

            document.getElementById(idsplash).style.display = 'block';

            document.getElementById(idsplash).style.height = '100%';

            document.body.style.height = '2000px';

            document.body.style.overflow = 'hidden';

            selectObj = document.getElementsByTagName('select');

            

            for(var x=0; x < document.forms.length; x++)

            {

                        //alert('Formulaire n�'+ x +' : '+document.forms[x].name);

                        selectObj = document.forms[x].getElementsByTagName('select');

                        

                        if (document.forms[x].name != splashformname)

                        {

                                    for (var i = 0; i < selectObj.length; i++)

                                    {

                                                //alert(selectObj[i].name);           

                                                selectObj[i].style.display = 'none';

                                    }           

                        }

            }

}


function displaySplashBox(idsplashbox){	
	document.getElementById(idsplashbox).style.display = 'block';
}

function splashClose(idsplash){

            

            document.getElementById(idsplash).style.display = 'none';

            document.body.style.height = '';

            document.body.style.overflow = '';

            selectObjVoir = document.getElementsByTagName('select');

            for (var i = 0; i < selectObjVoir.length; i++)

            {

                        selectObjVoir[i].style.display = '';

            }                   
}

function splashCloseBox(idsplashbox){	
	document.getElementById(idsplashbox).style.display = 'none';
	   
}


///////////////////////////////////////fonctions switch couleur TR
function changeCouleur(ligne)
  {
  ligne.className = 'tableDisplayRankOv';
  }

function remetCouleur(ligne)
  {
  ligne.className = 'tableDisplayRank';
  }

function remetCouleurAlt(ligne)
  {
  ligne.className = 'tableDisplayRankAlt';
  }


function changeCouleurDetails(ligne)
  {
  ligne.className = 'tableDetailsOv ';
  }

function remetCouleurDetails(ligne)
  {
  ligne.className = 'tableDetailsIn';
  }

function remetCouleurAltDetails(ligne)
  {
  ligne.className = 'tableDetailsInAlt';
  }

///////////////////////////////////////fonction REVELE DETAILS
function reveleDetails(idlayer,idBox){

	if(document.getElementById(idlayer).style.display=="none"){
	document.getElementById(idlayer).style.display = '';
	document.getElementById(idBox).style.display = "none";
	}else{
	document.getElementById(idlayer).style.display = 'none';
	document.getElementById(idBox).style.display = '';
	}
	
}

///////////////////////////////////////fonction BUG IE CACHE COMBOBOX
function hideComboIE(){

}

function showComboIE(){

}

///////////////////////////////////////fonction utiles Javascript
function trim(myString)
{
	return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
}
