//--------------------------------------------------
// scrool_area.js
// Utile pour le diaporama des videos
// ( Rub51 et ses articles )
//--------------------------------------------------



//--------------------------------------------------
// infos_dev()
//--------------------------------------------------
// affichage de certaines donnees pour le dev.
//--------------------------------------------------
d = false; // pour n'afficher qu'une fois la fenetre d'infos.
function infos_dev(prm) {

	str=prm+'\n\n';
	str+='max_droite='+max_droite+'\n';
	str+='objScroller1.x='+objScroller1.x+'\n';
	alert(str);
/*if (d==false) {
	str=prm+'\n';
	str+='max_droite='+max_droite+'\n';
	str+='objScroller1.x='+objScroller1.x+'\n';
	d=true;
	alert(str);
}*/
}

function verifyCompatibleBrowser1(){ 
	this.ver=navigator.appVersion; 
	this.dom=document.getElementById?1:0; 
	this.ie5=(this.ver.indexOf('MSIE 5')>-1 && this.dom)?1:0; 
	this.ie4=(document.all && !this.dom)?1:0; 
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0; 
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5); 
	return this; 
} 
bw=new verifyCompatibleBrowser1(); 
var speed=180;
var loop, timer;
function ConstructObject1(obj,nest){ 
	//alert(bw.ns4)
	nest=(!nest) ? '':'document.'+nest+'.'; 
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight; 
	this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight; 
	this.scrollWidth=bw.ns4?this.css.document.width:this.el.offsetWidth; 
	this.clipWidth=bw.ns4?this.css.clip.width:this.el.offsetWidth;
	this.up=MoveAreaUp1;
	this.down=MoveAreaDown1; 
	this.left=MoveAreaLeft1;
	this.right=MoveAreaRight1; 
	this.MoveArea1=MoveArea1; 
	//this.x=0; 
	// this.y=0; 
	this.obj = obj + 'Object'; 
	eval(this.obj + '=this'); 
	return this; 
}
function MoveArea1(x,y){ 
	//alert(this.obj);
	this.x=x;
	this.y=y;
	this.css.left=x;
	this.css.top=y;
	document.getElementById("divContentListe1").style.left=x+'px';
	/*document.getElementById("divContentListe1").style.top=y+'px';*/
	//document.formuposlayer.poslayer.value=this.y;
}
function MoveAreaDown1(move){ 
		if(this.y>-this.scrollHeight+objContainer1.clipHeight){ 
			this.MoveArea1(0,this.y-move);
			if(loop){ setTimeout(this.obj+'.down('+move+')',speed)}
		}
}
function MoveAreaUp1(move){ 
		if(this.y<0){
			this.MoveArea1(0,this.y-move); 
			if(loop){ setTimeout(this.obj+'.up('+move+')',speed)}
		}
}
function MoveAreaLeft1(move){
		if(this.x<0){ 
			this.MoveArea1(this.x-move,0);
			//alert(this.x-move);
			if(loop){ setTimeout(this.obj+'.left('+move+')',speed)}
		}
}


function MoveAreaRight1(move){ 
	//alert(this.scrollWidth+objContainer1.clipWidth + ' ' + this.x + ' ' + max_droite);
	
	/*if((this.scrollWidth+objContainer1.clipWidth+this.x)>max_droite){*/
	if ((max_droite+this.x) > 396 ) {
		this.MoveArea1(this.x-move,0); 
		//alert(this.x-move);
		if(loop){ setTimeout(this.obj+'.right('+move+')',speed)}
	}
	else {
		pp = 'this.scrollWidth='+this.scrollWidth+'\n';
		pp+= 'objContainer1.clipWidth='+objContainer1.clipWidth+'\n';
		pp+= 'this.x='+this.x+'\n';
		/*alert(pp);*/
	}
}



function PerformScroll1(speed){ 
		/*alert('PerformScroll1(speed)');
		alert('initialised='+initialised);
		alert('speed='+speed);*/
		if(initialised){
			loop=true;
			if(speed<0) {
				objScroller1.left(speed)
				}
			else {
				objScroller1.right(speed)
				}
		}
}

function CeaseScroll1(){ 
	loop=false;
	if(timer) clearTimeout(timer); 
}

var initialised; 
function InitialiseScrollableArea1(){ 
	objContainer1=new ConstructObject1('divContainerListe1'); 
	objScroller1=new ConstructObject1('divContentListe1','divContainerListe1');
	objScroller1.MoveArea1(0,0);
	objContainer1.css.visibility='visible';
	initialised=true;
}