/*************************************************************************
  This code is from Dynamic Web Coding at www.dyn-web.com
  Copyright 2001-4 by Sharon Paine 
  See Terms of Use at www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

function initScrollLayers() {
  // arguments: id of layer containing scrolling layers (clipped layer), id of layer to scroll, 
  // if horizontal scrolling, id of element containing scrolling content (table?)
  var wndo1 = new dw_scrollObj('wn', 'lyr', null);

  // arguments: dragBar id, track id, axis ("v" or "h"), x offset, y offset
  // (x/y offsets of dragBar in track)
  wndo1.setUpScrollbar("dragBar", "track", "v", 1, 1);
  

  
  // Read instructions if your scrolling layers are inside tables 
  
  // Scrollbars initially hidden in this example 
  dw_showLayers("scrollbar");
}

function dw_showLayers() {
  if ( document.getElementById ) {
    var lyr, i;
    for (i=0; arguments[i]; i++) {
      lyr = document.getElementById( arguments[i] );
      lyr.style.visibility = "visible";
    }
  }
}

  // SCROLLING BY MOUSEWHEEL HANDLER - delete if you want to restore normal mousewheeling
  // This is high-level function.
  // It must react to delta being more/less than zero.
 
function handle(delta) {
        if (delta < 0){
			dw_scrollObj.scrollBy('wn',0,(-30));
        }else{
			dw_scrollObj.scrollBy('wn',0,(30));
		}
}

  // 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;
}

  // SCROLLING BY MOUSEWHEEL LISTENER
if (window.addEventListener)
         // DOMMouseScroll is for mozilla.
        window.addEventListener('DOMMouseScroll', wheel, false);
  // IE/Opera.
window.onmousewheel = document.onmousewheel = wheel;

	// *** SCROLLING BY KEYPRESS HANDLER - delete this too if you want ***

	// This will capture keypresses and scroll up/down depending on the key code.
	// You must manually specify a scroller name here ('content'), as only one can respond to keys.
function scrKeyDown(evt){
	 var evt = evt?evt:window.event;
	 var key = evt.keyCode?evt.keyCode:(evt.charCode?evt.charCode:evt.which);
	 if (key==38) dw_scrollObj.scrollBy('wn',0,(30));       // 'A', 'a' or 'Up'
	 if (key==40) dw_scrollObj.scrollBy('wn',0,(-30));       // 'Z', 'z' or 'Down'

}

  // SCROLLING BY KEYPRESS LISTENER
if (window.addEventListener)
         // DOMMouseScroll is for mozilla.
        window.addEventListener('KEYPRESS', scrKeyDown, false);
  // IE/Opera.
window.onkeypress = document.onkeypress = scrKeyDown;
window.onkeydown = document.onkeydown = scrKeyDown;
