// MENU FLOTTANT

var IdTimer_1;
var Rapport = 1.0/5.0; // On divise par 20
var Mini = 2* Rapport;

//-------------------
function getTop(Object){
    if (Object.offsetParent)
        return (Object.offsetTop + getTop(Object.offsetParent));
    else
        return (Object.offsetTop);
}
//-------------------
function GetTopPage(){
	var Top;
	var DocRef;
	if(window.innerWidth){
		with( window){
		Top = pageYOffset;
		}
	}
	else{ 
		// Cas Explorer a part
		if( document.documentElement && document.documentElement.clientWidth)
			DocRef = document.documentElement;
		else
			DocRef = document.body;
		with( DocRef){
			Top = scrollTop;
		}
	}
	return(Top); 
}
//-----------------------
function DIV_Scroll( id_){
	var Obj = document.getElementById( id_);
	this.Obj = Obj;
	if( Obj){
		//-- Recup position de depart
		this.PosY = 0;
		this.DebY = this.PosY;
		this.NewY = 0;
		this.Move = DIV_Deplace;
	}
}
//---------------------------
function DIV_Deplace( y_ ){
	this.PosY = y_;
	this.Obj.style.top = parseInt(y_) +"px";
} 
//---------------------------
function DIV_Replace( y_ ){
	//-- Calcul Delta deplacement
	var Delta_Y = (y_ - DivScroll.PosY) *Rapport;
	//-- Test si fin deplacement
	if((( Delta_Y < Mini)&&( Delta_Y > -Mini))){
		clearInterval( IdTimer_1);
		DivScroll.Move( y_ );
	}
	else{
		DivScroll.Move( DivScroll.PosY + Delta_Y );
	}
}

//------------------------
function Menu_Scroll(){
	//-- New position du menu              // haut   
	DivScroll.NewY = (Math.max(0,GetTopPage()-(95 + Math.max(0, (1120 - screen.height))))) + DivScroll.DebY;
	//-- Si pas la bonne Position
	if(( DivScroll.PosY != DivScroll.NewY )){
		//-- Clear l'encours
		clearInterval( IdTimer_1);
		IdTimer_1 = setInterval("DIV_Replace("+ DivScroll.NewY +")", 30);
	}
	return( true);
} 

var DivScroll = new DIV_Scroll('divMenu');
var menu_bottom = getTop(document.getElementById("divMenuBottom"));
onscroll = Menu_Scroll;
