

var mainContent = ""; 
var scrollPos = 0; 
var scrollingOn = 1; 

var scrollingDown = 0;
var scrollingUp = 0;
var scrollSpeed = 50; 

function incrementalScroll(amt) {
    document.getElementById("content").scrollTop += amt; 
}

function scroller() {
    if (!scrollingOn) {
	return false; 
    }

    if (scrollingDown) {
	incrementalScroll(scrollSpeed); 
    } else if (scrollingUp) {
	incrementalScroll(-scrollSpeed); 
    }
}

setInterval("scroller();", 50); 

function disableScrolling() {
    scrollingOn = 0; 
}

function _setPos(pos) {
    document.getElementById("content").scrollTop = pos;     
}




function processKeyDown(event) {
    var key = 0;
    
    if (window.event) {
	key = window.event.keyCode;
    } else {
	key = event.which;
    }

    var handled = false;  

    // PageUp 
    if (key == 33) {
        incrementalScroll( -50 ); 
	handled = true; 
	// PageDown
    } else if (key == 34) {
        incrementalScroll( 50 ); 
	handled = true; 

	// Up key 
    } else if (key == 38) {
        incrementalScroll( -25 ); 
	handled = true; 
	// Down key
    } else if (key == 40) {
        incrementalScroll( 25 ); 
	handled = true; 
    }
  
    if (handled) {
	if (event) {
	    event.cancelBubble = true;
	    if (event.stopPropagation) event.stopPropagation ();  
	}  
	return false;
    }
    return true; 

} 	

function processMouseWheel(event) {

    if (window.event != null &&
	window.event.type == "mousewheel") {

	if (window.event.wheelDelta > 0) {
	    incrementalScroll( -50 ); 
	} else {
	    incrementalScroll( 50 ); 
	}
    } else {	
	if (event.detail > 0) {
	    incrementalScroll( 50 ); 
	} else {
	    incrementalScroll( -50 ); 
	}
    }	
}



function startScrollingForward( amt ) {
    scrollingDown = 1;  
    scrollingUp = 0; 
    scrollSpeed = amt; 

}

function startScrollingBackward( amt ) {
    scrollingUp = 1; 
    scrollingDown = 0; 
    scrollSpeed = amt; 
}

function resetScrolling() {
    scrollingUp = 0; 
    scrollingDown = 0; 
    scrollSpeed = 0; 
} 

function onLoad() {
    //	document.getElementById("content").innerHTML = mainContent; 
    resetScrolling(); 
    if (window.addEventListener) 
	window.addEventListener('DOMMouseScroll', processMouseWheel, false);

}




/* The following are the default functions for each of the buttons in the scroller-div. 
   To actually add functionality for a given page, redefine the function on that page, 
   somewhere after the <script src='scroll.js'> line; for instance: 

   <script language='Javascript' src='scroll.js'></script>
   <script>
   function downArrow_over() { alert('Moused over the down arrow'); }

   </script>

*/

function downArrow_down() {}
function downArrow_click() {}
function downArrow_up() {}
function downArrow_over() {
    flip('image2', 'image2on'); 
    flip('image13', 'image13on'); 
    window.status='Scroll // DOWN'; 
    return true;
}
function downArrow_out() {
    resetScrolling(); 
    flip('image2','image2off'); 
    flip('image13','image13off'); 
    window.status=''; return true; 
}

function upArrow_down() {}
function upArrow_click() {}
function upArrow_up() {}
function upArrow_over() {
    flip('image2', 'image2on'); 
    flip('image12', 'image12on'); 
    window.status='Scroll // UP'; 
    return true;
}
function upArrow_out() {
    resetScrolling(); 
    flip('image2','image2off'); 
    flip('image12','image12off'); 
    window.status=''; 
    return true; 
}


function leftArrow_down() {}
function leftArrow_click() {}
function leftArrow_up() {}
function leftArrow_over() {
    flip('image2', 'image2on'); 
    flip('image14', 'image14on'); 
    window.status='History // BACK'; 
    return true;
}
function leftArrow_out() {
    flip('image2','image2off'); 
    flip('image14','image14off'); 
    window.status=''; 
    return true; 
}


function rightArrow_down() {}
function rightArrow_click() {}
function rightArrow_up() {}
function rightArrow_over() {
    flip('image2', 'image2on'); 
    flip('image15', 'image15on'); 
    window.status='History // FORWARD'; 
    return true;
}
function rightArrow_out() {
    flip('image2','image2off'); 
    flip('image15','image15off'); 
    window.status=''; 
    return true;
}


function center_down() {}; 
function center_up() {}; 
function center_click() {};
function center_over() {
	flip('image2', 'image2on'); 
	flip('image19', 'image19on'); 

}; 
function center_out() {
	flip('image2', 'image2off'); 
	flip('image19', 'image19off'); 
}; 

