var theHandle = []; var theRoot = []; var theThumb = []; var theScroll = []; var thumbTravel = []; var ratio = [];

var Scroller = {

	obj : null,

	init : function(count, id, left, top, width, height, speed)
	{
		if(document.getElementById) {
			theScroll[count] = new ypSimpleScroll(id, left, top, width, height, speed);
		}
	},

	initDrager : function(count, handler, root, thumb, minX, maxX, minY, maxY)
	{
		
		var buttons = '<div class="up" id="up'+count+'"><a href="#" onmousedown="theScroll['+count+'].scrollNorth(\''+count+'\')" onmousemove="return false;" onmouseout="theScroll['+count+'].endScroll()" onmouseup="theScroll['+count+'].endScroll()" onclick="return false;"></a></div><div class="dn" id="dn'+count+'""><a href="#" onmousedown="theScroll['+count+'].scrollSouth(\''+count+'\')" onmousemove="return false;" onmouseout="theScroll['+count+'].endScroll()" onmouseup="theScroll['+count+'].endScroll()" onclick="showup();return false;"></a></div><div class="thumb" id="'+thumb+'"></div>';

		document.getElementById(root).innerHTML = buttons + document.getElementById(root).innerHTML;

		theRoot[count]  = document.getElementById(root);
		theThumb[count]  = document.getElementById(thumb);
		
		var thisup = document.getElementById("up"+count);
		var thisdn = document.getElementById("dn"+count);
		
		theThumb[count].style.left = parseInt(minX+0) + "px";
		thisup.style.left = parseInt(minX-200) + "px";
		
		thisdn.style.left = parseInt(minX-200) + "px";
		theThumb[count].style.border =0;
		theThumb[count].style.top = parseInt(minY) + "px";
		thisup.style.top = 370 + "px";
		thisdn.style.top = parseInt(minY+maxY+5) + "px";
		
		//thisdn.style.width = theScroll[count].scrollW + "px";
		
		theRoot[count].style.height = parseInt(minY+maxY + 0) + "px";
		
		//thisdn.style.top = 0 + "px";
		//ukrycie buttona up
		
			thisup.style.visibility="hidden";	
		
		
		
		theScroll[count].load();

		Drag.init(theThumb[count], null, minX+0, maxX+0, minY, maxY);
		
		// the number of pixels the thumb can travel vertically (max - min)
		thumbTravel[count] = theThumb[count].maxY - theThumb[count].minY;

		// the ratio between scroller movement and thumbMovement
		ratio[count] = theScroll[count].scrollH / thumbTravel[count];

		theThumb[count].onDrag = function(x, y) {
			theScroll[count].jumpTo(null, Math.round((y - theThumb[count].minY) * ratio[count]));
		}
		
		
		
	}
}


function onLoad_addEvent(fn) {
	var _onLoad = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = fn;
	}
	else {
		window.onload = function() {
		_onLoad();
		fn();
	 }
}
}

onLoad_addEvent(function(){
	if(theScroll.length>0) {
		for(var i=0;i<theScroll.length;i++){
			Scroller.initDrager(i, "handle"+i, "scroll_"+i+"_Box", "thumb"+i, theScroll[i].clipW, theScroll[i].clipW, 20, theScroll[i].clipH-0);
		}
	}
}) 

function showup(object)
		{	
			var o = document.getElementById('up0');
			o.style.visibility="visible";
			
		}