// Counter
var nTop = 0;

// Start and Stop
var timer;
var stepwidth=3;
var stepwidthmouse=40;

var timeout=10;

if (window.addEventListener) window.addEventListener('DOMMouseScroll', wheel, false);
window.onmousewheel = document.onmousewheel = wheel;


// Scroll up
function goUp()
{
  
  try {
     document.body.style.cursor='pointer';
  } catch (e){
     document.body.style.cursor='hand';
  }
  
  var objDiv =document.getElementById("rightinfocontentscroll"); 
  
  // If nTop < 0 scroll
  if(nTop < 0)
   {
    
    nTop=nTop+stepwidth;
    objDiv.style.top=nTop+'px';
		
		// Dont stop scrolling, if the mouse is over the scrollbutton
    
	timer=setTimeout("goUp();", timeout);
   } else {
   		stopScroll();
   }
}

// Scroll down
function goDown()
{

  var objDiv =document.getElementById("rightinfocontentscroll"); 
  
  // Height of div
  var nHeight = '-'+objDiv.clientHeight;
  
  try {
     document.body.style.cursor='pointer';
  } catch  (e) {
     document.body.style.cursor='hand';
  }
  
	// If nTop >= height scroll
  if(nTop >= parseInt(nHeight)+500)
  {
    nTop=nTop-stepwidth;
    objDiv.style.top=nTop+'px';
  		// Dont stop scrolling, if the mouse is over the scrollbutton
	timer=setTimeout("goDown();", timeout);
  }  else {
   		stopScroll();
   }
}

function stopScroll() {
	document.body.style.cursor='default';  
	clearTimeout(timer);
}




/** Event handler for mouse wheel event.
 */
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;
}



function handle(delta) {
        var objDiv =document.getElementById("rightinfocontentscroll"); 

        var nHeight = '-'+objDiv.clientHeight;        
		
        if (delta < 0) {
			if(nTop >= parseInt(nHeight)+500)
  			{
   				nTop=nTop-stepwidthmouse;
   				objDiv.style.top=nTop+'px';
			} 
        } else {
       		if(nTop < 0)
 			{
    			nTop=nTop+stepwidthmouse;
   				objDiv.style.top=nTop+'px';
			}	
	
        }
		
}

function anchorClick(positionoffset) {
	  var objDiv =document.getElementById("rightinfocontentscroll");
	  objDiv.style.top=-positionoffset+'px';
	  nTop=-positionoffset;	 		 
	  return false;
}
