var nblst=0  //nbre de listes
var coef= new Array()
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;
}

function Show(){
	document.write ('<table class=norm border=0 cellpadding=0 cellspacing=2>');
	document.write ('	<tr height=10><td rowspan=3 width=100><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;width='+this.width+'px;">'+this.content+'</div></td>');
	document.write ('								<td id=tdup'+this.id+' 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;" 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;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+' 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++){
 		coef[i]=Math.ceil((eval('scroller'+i+'.scrollHeight')-eval('scroller'+i+'.clientHeight'))/parseInt(eval('tdscroll'+i+'.style.height')));
		if (coef[i]!=0){
			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';
		}
		else{
			eval('tdscroll'+i+'.style').display='none';
			eval('tdup'+i+'.style').display='none';
			eval('tddown'+i+'.style').display='none';
		}
		
 }

}