var cs_T = 0;
var cs_DownId,cs_UpId,cs_Delta,cs_Interval,cs_Min,cs_Max,cs_Debug;
var cs_Down, cs_Up, cs_Cont;
function WireUpScroller(upId,downId,contId,min,max,delta,interval,scrollType,debug){
	cs_DownId	= downId;
	cs_UpId		= upId;
	cs_Cont		= contId;
	cs_Delta	= delta;
	cs_Interval = interval;
	cs_Min		= min;
	cs_Max		= max;
	cs_Debug	= (debug?true:false);

	cs_Down = document.getElementById(cs_DownId);
	cs_Up = document.getElementById(cs_UpId);
	
	cs_Down.style.cursor = 'pointer';
	cs_Up.style.cursor = 'pointer';
	
	cs_Cont = document.getElementById(contId);
	if(scrollType == 'press'){
		cs_Down.onmousedown	= cs_wireUpScrollDown;
		cs_Up.onmousedown	= cs_wireUpScrollUp;
		cs_Down.onmouseup	= cs_clearTimer;
		cs_Up.onmouseup		= cs_clearTimer;
		cs_Down.onmouseout	= cs_clearTimer;
		cs_Up.onmouseout	= cs_clearTimer;
	}else{
		cs_Down.onmouseover	= cs_wireUpScrollDown;
		cs_Up.onmouseover	= cs_wireUpScrollUp;
		cs_Down.onmouseout	= cs_clearTimer;
		cs_Up.onmouseout	= cs_clearTimer;
	}
}
function cs_clearTimer(){
	if(!isNaN(cs_T)){
		clearInterval(cs_T);
	}
}
function cs_wireUpScrollDown(){
	cs_clearTimer();
	cs_T = setInterval('cs_scrollDown();', cs_Interval);
}
function cs_wireUpScrollUp(){
	cs_clearTimer();
	cs_T = setInterval('cs_scrollUp();', cs_Interval);
}

function cs_scrollDown(){
	var x = parseInt(cs_Cont.style.marginTop);
	if(!x || isNaN(x)){
		x = 0;
	}
	if(x <= cs_Min){
		clearInterval(cs_T);
		return;
	}
	cs_Cont.style.marginTop = x - cs_Delta + 'px';
	if(cs_Debug){
		alert('New Min : ' + (x - cs_Delta));
	}
}
function cs_scrollUp(){
	var x = parseInt(cs_Cont.style.marginTop);
	if(!x || isNaN(x)){
		x = 0;
	}
	if(x >= cs_Max){
		clearInterval(cs_T);
		return;
	}
	cs_Cont.style.marginTop = x + cs_Delta + 'px';
	if(cs_Debug){
		alert('New Max : ' + (x + cs_Delta));
	}
}