/* Copyright 2008 Paul Bennett - http://paulicio.us
 * Scroller.js
 * Captures mouse wheel events and runs the ScrollSmoothly
 * function based on their output.
 * Aims to aid usability by allowing the user to scroll the 
 * page horizontally smoothly using only their mousewheel.
 * Mousewheel event capture by Adomas Paltanavičius at http://adomas.org/
 */



function handle(delta) {     
var n_speed = 2;
var n_intSpeed = 5;
var n_intRepeat = 30;


if (n_speed == 1) {
	n_intSpeed = 5;
	n_intRepeat = 30;
} else if (n_speed == 2) {
	n_intSpeed = 30;
	n_intRepeat = 20;
} else if (n_speed == 3) {
	n_intSpeed = 50;
	n_intRepeat = 30;
}



	
        if (delta <0)
                ScrollSmoothly(n_intSpeed,n_intRepeat,'right');
        else if (delta >0)
                ScrollSmoothly(n_intSpeed,n_intRepeat,'left');
}
 
function wheel(event){
        var delta = 0;
        if (!event) 
                event = window.event;
        if (event.wheelDelta) {
                delta = event.wheelDelta/12;
                if (window.opera)
                        delta = -delta;
        } else if (event.detail) {
                delta = -event.detail/3;
        }
        if (delta)
                handle(delta);
        if (event.preventDefault)
                event.preventDefault();
	event.returnValue = false;
}

var repeatCount = 0;

function ScrollSmoothly(scrollPos,repeatTimes, direction) {

  
	if(repeatCount < repeatTimes)
		if(direction == 'right')
			window.scrollBy(scrollPos,0);
		else
			window.scrollBy(-scrollPos,0);
	else
	{
		repeatCount = 0;
		clearTimeout(cTimeout);
		return;
	}
	repeatCount++;
	cTimeout = setTimeout("ScrollSmoothly('" + scrollPos + "','"+ repeatTimes +"','"+ direction +"')",10);
}


 
/* Initialization code. */
if (window.addEventListener)
        window.addEventListener('DOMMouseScroll', wheel, false);
window.onmousewheel = document.onmousewheel = wheel;

