// Init

 window.onload = function() {
	 var isScrolledByMuis = 0;
	var maxBeneden = $('scrollContent').offsetHeight - 460;
	if (parseFloat(maxBeneden) < 0) {

			maxBeneden = 0;
			scrollControl.setValue(0);
		}
    scrollControl = new Control.Slider('handlerScroll',
                       'containerScroll',                                  
                       {axis:'vertical',
                    	   range:$R(0, maxBeneden, false)

                       });	
   
    scrollControl.options.onChange = function(value) {
    	  // ...
    	$('scrollContent').style.top = '-' + value + 'px';

    	};
    	
	scrollControl.options.onSlide = function(value) {
		  // ...
		
		$('scrollContent').style.top = '-' + value + 'px';
	
	};

 }
 
 
 
 /***********************************************
  * 
  * SCROLL MOUSE WHEEL SCRIPT
  * 
  * 
  */
 
 /** This is high-level function.
  * It must react to delta being more/less than zero.
  */

 function handler(delta) {
	 	
	 isScrolledByMuis = 1;
	 
	 	var maxBeneden = $('scrollContent').offsetHeight - 460;
		
		if (parseFloat(maxBeneden) < 0) {

			maxBeneden = 0;
			scrollControl.setValue(0);
		}
		
         if (delta < 0) {
        	 
        	 topValue = parseFloat(document.getElementById('scrollContent').style.top);
        	 
        	 maxBeneden = maxBeneden - maxBeneden - maxBeneden;
        	 
        	 if (topValue > maxBeneden) {
        		 
        		 if (topValue < 0) {
        			 
        			 scrollControlReken = topValue - topValue - topValue;
        			 
        		 } else {
        			 
        			 scrollControlReken = topValue;
        			 
        		 }
        		 scrollControl.setValue(scrollControlReken);
        		 topValue = topValue + (delta * 20);
        		 $('scrollContent').style.top = topValue + "px"; 
        		 
        	 }
        	 
        	
        	 
         }
 		 else
 		 {
 			topValue = parseFloat(document.getElementById('scrollContent').style.top);
 			
 			if (topValue <= 0) {
 				if (topValue < 0) {
       			 
       			 scrollControlReken = topValue - topValue - topValue;
       			 
	       		 } else {
	       			 
	       			 scrollControlReken = topValue;
	       			 
	       		 }
 				 scrollControl.setValue(scrollControlReken);
 				topValue = topValue + (delta * 20);
 				$('scrollContent').style.top = topValue + "px"; 
 				
 			} else {
 				scrollControl.setValue(1);
 				$('scrollContent').style.top = "1px"; 
 				 
 				
 			}
 		 }
         
         isScrolledByMuis = 0;
         
 }

 /** Event handler for mouse wheel event.
  */
 function wheeleh(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)
                 handler(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', wheeleh, false);
 /** IE/Opera. */
 window.onmousewheel = document.onmousewheel = wheeleh;



