
	var slider;

	function handle(delta) {
        if (delta < 0)
		slider.setValue( slider.getYValue() + 40 );
        else
		slider.setValue( slider.getYValue() - 40 );
      }
      	
	function init () {
		
		if ( ! YAHOO.util.Dom.get('scrollbar') ) return;
		
		var content = YAHOO.util.Dom.get('content');
		
		var timer;
		
		if ( content.scrollHeight > content.offsetHeight ) {
			YAHOO.util.Dom.get('scrollbar').style.visibility = 'visible';
		} else {
			return;
		}
	
		slider = YAHOO.widget.Slider.getVertSlider("scrolltrack", "scrollbutton", 0, 385-32 );
		slider.onChange = update;
		
		YAHOO.util.Dom.get('scrollup').onmousedown = function () {
			clearInterval ( timer );
			timer = setInterval ( "slider.setValue( slider.getYValue() - 10 )" , 10 );
			//slider.setValue( slider.getYValue() - 50 );
		}
		
		YAHOO.util.Dom.get('scrollup').onmouseup = function () {
			clearInterval ( timer );
		}
		
		YAHOO.util.Dom.get('scrollup').onmouseout = function () {
			clearInterval ( timer );
		}
		
		YAHOO.util.Dom.get('scrolldown').onmousedown = function () {
			clearInterval ( timer );
			timer = setInterval ( "slider.setValue( slider.getYValue() + 10 )" , 10 );
			//slider.setValue( slider.getYValue() + 50 );
		}
		
		YAHOO.util.Dom.get('scrolldown').onmouseup = function () {
			clearInterval ( timer );
		}
		
		YAHOO.util.Dom.get('scrolldown').onmouseout = function () {
			clearInterval ( timer );
		}
		
	}
	
	function update () {
		var sliderY = slider.getYValue();
		var content = YAHOO.util.Dom.get('content');
		content.scrollTop = sliderY * (content.scrollHeight-content.offsetHeight) / (385-32);
	}

	function wheel(event){
        var delta = 0;
        if (!event) /* For IE. */
                event = window.event;
        if (event.wheelDelta) { /* IE/Opera. */
                delta = event.wheelDelta/120;
                /** In Opera 9, delta differs in sign as compared to IE.
                 */
                if (window.opera)
                        delta = -delta;
        } else if (event.detail) { /** Mozilla case. */
                /** In Mozilla, sign of delta is different than in IE.
                 * Also, delta is multiple of 3.
                 */
                delta = -event.detail/3;
        }
        /** If delta is nonzero, handle it.
         * Basically, delta is now positive if wheel was scrolled up,
         * and negative, if wheel was scrolled down.
         */
        if (delta)
                handle(delta);
        /** Prevent default actions caused by mouse wheel.
         * That might be ugly, but we handle scrolls somehow
         * anyway, so don't bother here..
         */
        if (event.preventDefault)
                event.preventDefault();
	event.returnValue = false;
}

/** Initialization code. 
 * If you use your own event management code, change it as required.
 */
if (window.addEventListener)
        /** DOMMouseScroll is for mozilla. */
        window.addEventListener('DOMMouseScroll', wheel, false);
/** IE/Opera. */
window.onmousewheel = document.onmousewheel = wheel;
	    
	YAHOO.util.Event.addListener(window, "load", init);
