var winH,winW = 0;
var divFin;

function init_scroll(){
	divFin = document.getElementById('divFin');
	getWindowSize();
	setInterval("scrollPage()",10);
}
  
function getWindowSize(){
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
		winW = window.innerWidth;
		winH = window.innerHeight;
  } else if (document.all){
	//Must be called after body tag has been parsed
		winW = document.body.clientWidth;
		winH = document.body.clientHeight;
	}
	$("scroll_window").style.width = winW + "px";
}

window.onresize = getWindowSize;

var currentPosY = 0;
var newPosY = 0;
var playVideo = false;

function movePageTo(y) {
	newPosY = y;
	if(y==0) playVideo = true;
	if(!isNaN(winW) && winW>0){
		newPosY = Math.ceil(newPosY); // + largeur de bloc /2 - largeur de fenetre/2
	}
}
function scrollPage(){
	if(newPosY<0) {
		newPosY = 0;
	}
	if(isNaN(newPosY)) {
		newPosY = 0;
	}
	while(newPosY!=currentPosY){
		// deplacement a effectuer : newPosY - currentPosY
		sensDefil = ((newPosY - currentPosY)>0)?1:-1;
		shift = Math.ceil(Math.abs(newPosY - currentPosY)/10) * sensDefil;
		//alert(shift + " / " + newPosY + " / " + currentPosY);
		currentPosY = currentPosY + shift;
//		window.scrollTo(currentPosY,0);
		$('full_content').style.left = -1 * currentPosY + "px";
		return false;
	}
	if(newPosY==0 && playVideo) {
		play();
		playVideo=false;
	}
}

function moveToAncre(){
	// utilise en consultation
	getWindowSize();
	// utilise dans l'admin
//	window.scrollTo(window.location.hash.substring(3),0);
	$('full_content').style.left = -1 * window.location.hash.substring(3) + "px";
}

