function Add_Event( obj_, event_, func_, mode_){
  if( obj_.addEventListener)
    obj_.addEventListener( event_, func_, mode_? mode_:false);
  else
    obj_.attachEvent( 'on'+event_, func_);
}
//----------------------
function GetScrollPage(){
  var Left;
  var Top;
  var DocRef;

  if( window.innerWidth){
    with( window){
    	if(document.getElementById("DIV_MOVE") != null)
    	{
	     
	      Top    = pageYOffset -100;
    	}
    	else if(document.getElementById("DIV_MOVE2") != null)
        {    	  
    	  Top = pageYOffset-100;
    	 
        }
    }
  }
  else{ // Cas Explorer a part
    if( document.documentElement && document.documentElement.clientWidth)
      DocRef = document.documentElement;
    else
      DocRef = document.body;

	  var ms = navigator.appVersion.indexOf("MSIE")
	  ie6 = (ms>0) && (parseInt(navigator.appVersion.substring(ms+5, ms+6)) == 6)
		if(ie6)
		{
			 with( DocRef){
				 
				 if(document.getElementById("DIV_MOVE") != null)
			     {
					 	
					 	Top    = scrollTop- 100;
			     }
			     else if(document.getElementById("DIV_MOVE2") != null)
			     {
			    	     
			    	      Top    = scrollTop-30;
			      }
			      
        }
		}
		else
		{
			with( DocRef){
				if(document.getElementById("DIV_MOVE") != null)
		    	{
			     
			      Top    = scrollTop - 100;
		    	}
		    	else if(document.getElementById("DIV_MOVE2") != null)
		        {
		    	     
		    	      Top    = scrollTop-30;
		        }
		    }
		}
  }
  return({top:Top});
}
//---------------------------
function ObjGetPosition(obj_){
  var PosX = 0;
  var PosY = 0;
  //-- suivant type en parametre
  if( typeof(obj_)=='object')
    var Obj  = obj_;
  else
    var Obj  = document.getElementById( obj_);
  //-- Si l'objet existe
  if( Obj){
    //-- Recup. Position Objet
    PosY = Obj.offsetTop;
    //-- Si propriete existe
    if( Obj.offsetParent){
      //-- Tant qu'un parent existe
      while( Obj = Obj.offsetParent){
        if( Obj.offsetParent){ // on ne prend pas le BODY
          //-- Ajout position Parent
          PosY += Obj.offsetTop;
        }
      }
    }
  }
  //-- Retour des positions
  return({top:PosY});
}
//-------------------------------------
// MENU FLOTTANT //////////////////////
//-------------------------------------
var IdTimer_1;
var IdTimer_2;
var O_DivScroll;
var Rapport = 1.0/20.0;  // On divise par 20
var Mini = 2* Rapport;
//-----------------------
function DIV_Scroll( id_){
  var Obj = document.getElementById( id_);
  this.Obj = Obj;
  if( Obj){
    Obj.style.position = "absolute"; // IMPERATIF
    //-- Recup position de depart
    var Pos   = ObjGetPosition( id_);
    this.PosY = Pos.top;
    this.DebY = this.PosY;
    this.NewY = 0;
    this.Move = DIV_Deplace;
  }
}
//---------------------------
function DIV_Deplace( y_){
 
  if( arguments[0] != null){
    this.PosY = y_;
    if(document.getElementById("DIV_MOVE2") != null)
    	if( window.innerWidth){    		
    		var e =  parseInt(y_) - 1200;
    		if(e>400) e = 400;
    		this.Obj.style.top  = e+"px";
    	}
    	else
    	{
    		var e =  parseInt(y_) - 119;
    		if(e>450) e = 450;
    		this.Obj.style.top  = e +"px";
    	}
    else
    	this.Obj.style.top  = parseInt(y_) +"px";
  }
}
//---------------------------
function DIV_Replace( y_){
  //-- Calcul Delta deplacement
  var Delta_Y = (y_ -O_DivScroll.PosY) *Rapport;
  //-- Test si fin deplacement
  if((( Delta_Y < Mini)&&( Delta_Y > -Mini))){
    clearInterval( IdTimer_1);
    O_DivScroll.Move(  y_);
  }
  else{
    O_DivScroll.Move(  O_DivScroll.PosY +Delta_Y);
  }
}
//------------------------
function DIV_CheckScroll(){
  var Scroll  = GetScrollPage();
  //-- New position  du menu
  O_DivScroll.NewY = Scroll.top  +O_DivScroll.DebY;
  //-- Si pas la bonne Position
  if(( O_DivScroll.PosY != O_DivScroll.NewY)){
    //-- Clear l'encours
    clearInterval( IdTimer_1);
    IdTimer_1 = setInterval("DIV_Replace(" +O_DivScroll.NewY +")", 10);
  }
  return( true);
}
//-----------------------
function DIV_InitScroll(){
  //-- Recup position Objet
  if(document.getElementById("DIV_MOVE") != null)
	  O_DivScroll  = new DIV_Scroll('DIV_MOVE');
  else
	  O_DivScroll  = new DIV_Scroll('DIV_MOVE2');
  //-- Lance inspection si existe
  if( O_DivScroll.Obj)
    IdTimer_2 = setInterval('DIV_CheckScroll()',100);
}
//========================================
Add_Event( window, 'load', DIV_InitScroll);
//-- EOF --

