/*'CONSTANTE' DE POSITION RETOUR HAUT PAGE ========================================
   0 : gauche
   1 : milieu
   2 : droite
*/
var POS_HT_PAGE = 1;

/*	===============================================================
	POSITION RETOUR HAUT DE PAGE
	===============================================================
DIV a inserer dans les pages :
------------------------------------------------------------
<div id="retour" style="position:absolute;">
<a href="#hautpage">Retour Haut de Page</a>
</div>
------------------------------------------------------------
*/
/*===============================
	Gestion du DIV 'retour haut de page' sous forme d'objet
	Appel dans onload_script.js
*/

function getObj(name){
//Mozilla && IE5+
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
		this.decal = 0;
}
/*===============================
la fonction est appellee a interval regulier depuis onload_script.js
*/
function positionit(){
	var scroll_g=document.all? document.body.scrollLeft : pageXOffset;
	var scroll_h=document.all? document.body.scrollTop : pageYOffset;
	var win_width=document.all? document.body.clientWidth : window.innerWidth;
	var win_height=document.all? document.body.clientHeight : window.innerHeight;
	var visible = "block" ;
	var invisible = "none" ;
	switch(POS_HT_PAGE){
	case 0 : // gauche
		var x_pos = parseInt(scroll_g) + "px";
		break;
	case 1 : // milieu
		var x_pos = parseInt(scroll_g) + ((parseInt(win_width)-50+retour.decal)/2) + "px";
		break;
	case 2 : // droite
		var x_pos = parseInt(scroll_g) + (parseInt(win_width)-50+retour.decal) + "px";
		break;
	}
	x_pos = document.layers? parseFloat(x_pos) : x_pos;
	var y_pos = parseInt(win_height) + parseInt(scroll_h) -30 + "px";
	y_pos = document.layers? parseFloat(y_pos) : y_pos;
	if (scroll_h > 10){
		retour.style.left= x_pos;
		retour.style.top= y_pos;
	retour.style.display = visible;
	}else{
	retour.style.display = invisible;
	}
}

// test d'existence du layer 'retour'
var test_layer = document.getElementById("retour");
if (test_layer){
	//d("Layer present")
    var retour = new getObj('retour'); // gestion du layer retour haut sous forme d'objet
    setInterval("positionit()",200);// lancement tous les 200 milliemes de seconde
}
