var nblst=0  //nbre de listes
var coef= new Array()
var scrollInitiate=false; //indique si la/les listes sont initialisées
var scrltimeout=new Array();

function scrollIt(id){
if(window.event.button==1){
	eval('scrollbar'+id+'.style').top = window.event.y-parseInt(eval('scrollbar'+id+'.style.height'))/2;
	if (parseInt(eval('scrollbar'+id+'.style.top'))<=0) eval('scrollbar'+id+'.style').top =0;
	if (parseInt(eval('scrollbar'+id+'.style.top'))>parseInt(eval('tdscroll'+id+'.style.height'))-parseInt(eval('scrollbar'+id+'.style.height')) ) eval('scrollbar'+id+'.style').top=parseInt(eval('tdscroll'+id+'.style.height'))-parseInt(eval('scrollbar'+id+'.style.height'));
	eval('scroller'+id).scrollTop =parseInt(eval('scrollbar'+id+'.style.top'))*coef[id];
}
}
function scrollUpDown(id,direction){
	if (direction<0)
		eval('scrollbar'+id+'.style').top = (parseInt(eval('scrollbar'+id+'.style').top)+1)+'px';
	else
		if (direction>0) eval('scrollbar'+id+'.style').top = (parseInt(eval('scrollbar'+id+'.style').top)-1)+'px';
	if (parseInt(eval('scrollbar'+id+'.style.top'))<=0) eval('scrollbar'+id+'.style').top =0;
	if (parseInt(eval('scrollbar'+id+'.style.top'))>parseInt(eval('tdscroll'+id+'.style.height'))-parseInt(eval('scrollbar'+id+'.style.height')) ) eval('scrollbar'+id+'.style').top=parseInt(eval('tdscroll'+id+'.style.height'))-parseInt(eval('scrollbar'+id+'.style.height'));
	eval('scroller'+id).scrollTop =parseInt(eval('scrollbar'+id+'.style.top'))*coef[id];
	scrltimeout[id]=setTimeout('scrollUpDown('+id+','+direction+')',10);
}
function scrollWheel(id,direction){
	if (direction<0)
		eval('scrollbar'+id+'.style').top = (parseInt(eval('scrollbar'+id+'.style').top)+10)+'px';
	else
		if (direction>0) eval('scrollbar'+id+'.style').top = (parseInt(eval('scrollbar'+id+'.style').top)-10)+'px';
	if (parseInt(eval('scrollbar'+id+'.style.top'))<=0) eval('scrollbar'+id+'.style').top =0;
	if (parseInt(eval('scrollbar'+id+'.style.top'))>parseInt(eval('tdscroll'+id+'.style.height'))-parseInt(eval('scrollbar'+id+'.style.height')) ) eval('scrollbar'+id+'.style').top=parseInt(eval('tdscroll'+id+'.style.height'))-parseInt(eval('scrollbar'+id+'.style.height'));
	eval('scroller'+id).scrollTop =parseInt(eval('scrollbar'+id+'.style.top'))*coef[id];
}
function stopScroll(id){
	clearTimeout(scrltimeout[id]);
}
function Scrollist(height,width,color){
	this.id						= nblst;
	nblst++;
	this.content			= '';
	this.height				= height;
	this.width				=	width;
	this.color				= color;
	this.Show					= Show;
	this.update	=updateScroll;
}
function updateScroll(){eval('scroller'+this.id).innerHTML=this.content;Init();}
function Show(){
	document.write ('<table class=norm border=0  width='+(this.width+15)+'  cellpadding=0 cellspacing=0>');
	document.write ('	<tr height=10><td rowspan=3 width='+(this.width)+'><div id=scroller'+this.id+' onmousewheel="scrollWheel('+this.id+',event.wheelDelta);"  style="border:\'1px solid '+this.color+'\';position:relative;height='+this.height+'px;overflow:hidden;">'+this.content+'</div></td>');
	document.write ('								<td id=tdup'+this.id+' style="display:none;" bgcolor='+this.color+' valign=top height=1%><img border=0 style="cursor:hand;" vspace=0 src="'+imgUp+'" onmouseout=\'stopScroll('+this.id+');\' onmouseup=\'stopScroll('+this.id+');\' onmousedown=\'scrollUpDown('+this.id+',1);\'></td>');
	document.write ('	</tr>');
	document.write ('	<tr><td id=tdscroll'+this.id+' style="position:relative;display:none" style="height='+parseInt(this.height-20)+';" onmousemove="scrollIt('+this.id+');" onmousedown="scrollIt('+this.id+');"><div id=scrollbar'+this.id+' onmousemove="scrollIt('+this.id+');"  style="position:absolute;display:block;overflow:hidden;cursor:hand;background-color='+this.color+';width=11px;height=1px;top=0;"></div></td></tr>');
	document.write ('	<tr height=10><td id=tddown'+this.id+' style="display:none;" bgcolor='+this.color+' height=1% valign=bottom width=1><img style="cursor:hand;" onmouseout=\'stopScroll('+this.id+');\' onmouseup=\'stopScroll('+this.id+');\' onmousedown=\'scrollUpDown('+this.id+',-1);\' src="'+imgDown+'"></td></tr>');
	document.write ('</table>');

}
function Init(){
 var i=0;
 for (i=0;i<nblst;i++){
	if (eval('scroller'+i+'.scrollHeight')>eval('scroller'+i+'.clientHeight')){
		coef[i]=Math.ceil((eval('scroller'+i+'.scrollHeight')-eval('scroller'+i+'.clientHeight'))/parseInt(eval('tdscroll'+i+'.style.height')));
		eval('scrollbar'+i+'.style').height=Math.floor (((parseInt(eval('tdscroll'+i+'.style.height'))*coef[i])-(eval('scroller'+i+'.scrollHeight')-eval('scroller'+i+'.clientHeight')))/coef[i])+'px';
		eval('tdscroll'+i+'.style').display='';
		eval('tdup'+i+'.style').display='';
		eval('tddown'+i+'.style').display='';
	}
	else{
		eval('tdscroll'+i+'.style').display='none';
		eval('tdup'+i+'.style').display='none';
		eval('tddown'+i+'.style').display='none';

	}
 }
 scrollInitiate=true;
}


