/*
 Repositioning of div sections relative to the current scroll window
*/


// PARAMETRAGE DU SCRIPT
var tjs_delai=1000;
var tjs_max=800;
var i=10;
var originalpos;

function StartReposition(layername)
{
// Last parameter of the function
	i++;
	window.status= i;
	MoveLayer(layername,GetTop(layername,"1",false)); // Same remark as above

}

// Second parameter of MoveLayer() is the height of the layer
function MoveLayer(nom,tp)
{
	if (document.getElementById)
	{ //IE5 et NS6
	  document.getElementById(nom).style.top=tp;
	}

	if ((document.all)&&(!document.getElementById))
	{ //IE4 seul
	  document.all[nom].style.top=tp;
	}

	if (document.layers)
	{ //NS4.X seul
	  document.layers[nom].top=tp;
	}
}

function GetTop(nom, hauteur, Initialize)
{
	// Partie 1 : Récupération de la position du calque et de la page
	if (document.getElementById) { //IE5
		var pos=parseInt(document.getElementById(nom).style.top);
		var wintop=parseInt(document.body.scrollTop);
		var avail=document.body.clientHeight;
	}
	if ((document.getElementById)&&(!document.all)) { //NS6
		var pos=parseInt(document.getElementById(nom).style.top);
		var wintop=parseInt(window.pageYOffset);
		var avail=document.body.clientHeight;
	}
	if ((document.all)&&(!document.getElementById)) { //IE4 seul
		var pos=parseInt(document.all[nom].style.top);
		var wintop=parseInt(document.body.scrollTop);
		var avail=document.body.clientHeight;
	}
	if (document.layers) { //NS4.X seul
		var pos=parseInt(document.layers[nom].top);
		var wintop=parseInt(window.pageYOffset);
		var avail=window.innerHeight;
	}

	var top;

	if (Initialize)
		top = pos;
	else
		top = wintop + originalpos;


	return top;
}

function InitializeReposition(layername, IntervalTime)
{
	originalpos = GetTop(layername, "1", true);
	setInterval("StartReposition('" + layername + "')",IntervalTime);

}
