var theHandle = []; var theRoot = []; var theThumb = []; var theScroll = []; var thumbTravel = []; var ratio = [];

function instantiateScroller(count, id, left, top, width, height, speed, posY){
	if(document.getElementById) {
		theScroll[count] = new ypSimpleScroll(id, left, top, width, height, speed, posY);
 	}
}

function createDragger(count, handler, root, thumb, minX, maxX, minY, maxY, posThumbY ){

		theScroll[count].load();
//		alert(theScroll[0].scrollH);
		if ( theScroll[count].id == "scroll0" && theScroll[count].scrollH > 0 ) {
			var buttons = '<div class="up" id="up'+count+'"><a href="#" onmouseover="theScroll['+count+'].scrollNorth(\''+count+'\')" onmouseout="theScroll['+count+'].endScroll()" onclick="return false;">&nbsp;</a></div><div class="dn"  id="dn'+count+'""><a href="#" onmouseover="theScroll['+count+'].scrollSouth(\''+count+'\')" onmouseout="theScroll['+count+'].endScroll()" onclick="return false;">&nbsp;</a></div><div class="thumb" id="'+thumb+'" style="left: 135px; top: 35px;">&nbsp;</div>';
		}
		else if ( theScroll[count].id == "scroll1" && theScroll[count].scrollH > 30 ) {
			var buttons = '<div class="up" id="up'+count+'"><a href="#" onmouseover="theScroll['+count+'].scrollNorth(\''+count+'\')" onmouseout="theScroll['+count+'].endScroll()" onclick="return false;">&nbsp;</a></div><div class="dn"  id="dn'+count+'""><a href="#" onmouseover="theScroll['+count+'].scrollSouth(\''+count+'\')" onmouseout="theScroll['+count+'].endScroll()" onclick="return false;">&nbsp;</a></div><div class="thumb" id="'+thumb+'" style="left: 135px; top: 35px;">&nbsp;</div>';
		}
		else {
			var buttons = '';
			return false;
		}

		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+15) + "px";
		thisup.style.left = parseInt(minX+15) + "px";
		thisdn.style.left = parseInt(minX+15) + "px";
		theThumb[count].style.border =0;
		//theThumb[count].style.top = parseInt(minY) + "px";
		theThumb[count].style.top = parseInt(posThumbY) + "px";
		thisup.style.top = 0 + "px";
		thisdn.style.top = parseInt(minY+maxY) + "px";
		//thisdn.style.top = 15 + "px";

		theScroll[count].load();

		//Drag.init(theHandle[count], theRoot[count]); //not draggable on screen
		Drag.init(theThumb[count], null, minX+15, maxX+15, minY, maxY-37);
		
		// 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];

//		alert(theScroll[count].scrollH);

		theThumb[count].onDrag = function(x, y) {
			theScroll[count].jumpTo(null, Math.round((y - theThumb[count].minY) * ratio[count]));
		}
//		theScroll[count].jumpTo(0, posY)
		
}	


// INITIALIZER:
// ==============================================================
// ala Simon Willison http://simon.incutio.com/archive/2004/05/26/addLoadEvent

/***************************************************/
/*******************  SAJÁT  ***********************/
/***************************************************/

addLoadEvent(function(){ 
	if(!document.body.currentStyle) return;
	var subs = document.getElementsByName('submenu');
	for(var i=0; i<subs.length; i++) {
		var li = subs[i].parentNode;
		if(li && li.lastChild.style) {
				li.onmouseover = function() {
					this.lastChild.style.visibility = 'visible';
				}
				li.onmouseout = function() {
					this.lastChild.style.visibility = 'hidden';
				}
		}
	}
}) 
