window.addEvent('domready', function(){

	//JavaScript Weiche
	$('scrollme').style.overflow = 'hidden';
	$('scrollbar').style.display = 'block';
	
	//Variablen setzen
	var el = $('scroller'), scrolldiv = $('scrollme');
	var contentdiv = $('scrollme');
	
	//Scrollweite des DIVS
	var divrange = (contentdiv.offsetHeight + 50) - parseInt($('rightcolum').offsetHeight);

	//Scrollbalkenhöhe setzten				
	var sliderheight = $('rightcolum').offsetHeight / (contentdiv.offsetHeight + 50) * $('rightcolum').offsetHeight;

	$('knob').style.height = sliderheight + 'px';
	
	// Create the new slider instance
	if(sliderheight < contentdiv.offsetHeight){
		var sliderpos = 0;
		var pfeiltimer = 0;
	
		knobslider = new Slider(el, el.getElement('.knob'), {
			steps: 100,	// There are 35 steps
			wheel: true, // Using the mousewheel is possible too
			mode: 'vertical',
			onChange: function(value){
				scrolldiv.setStyle('top', '-'+divrange*value/100);
				sliderpos = value;
			}
		}).set(scrolldiv.getStyle('top').toInt());
		
		//SCROLLUP
		var scrollup = function(){
			if(pfeiltimer) {
				window.clearTimeout(pfeiltimer);
				pfeiltimer = 0;
			}
			knobslider.set(sliderpos-2);
			pfeiltimer = window.setTimeout(scrollup, 50);
		};
		
		$('pup').onmousedown = function() {
			pfeiltimer = window.setTimeout(scrollup, 50);
		}
		
		$('pup').onmouseup = function() {
			if(pfeiltimer) {
				window.clearTimeout(pfeiltimer);
				pfeiltimer = 0;
			}
		}
		
		$('pup').onmouseout = $('pup').onmouseup;
		
		//SCROLLDOWN
		var scrolldown = function(){
			if(pfeiltimer) {
				window.clearTimeout(pfeiltimer);
				pfeiltimer = 0;
			}
			knobslider.set(sliderpos+2);
			pfeiltimer = window.setTimeout(scrolldown, 50);
		};
		
		$('pdown').onmousedown = function() {
			pfeiltimer = window.setTimeout(scrolldown, 50);
		}
		
		$('pdown').onmouseup =  $('pup').onmouseup;
		
		$('pdown').onmouseout = $('pdown').onmouseup;
		
		
	}else{
		//Kurze Seite = Keine Scroller
		$('scrollbar').style.display = 'none';
	}
});