// JavaScript Document

function initScrollLayer() {
  // 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 wndo = new dw_scrollObj('wn', 'lyr1');
  
  // bSizeDragBar set true by default (explained at www.dyn-web.com/dhtml/scroll/ )
  // wndo.bSizeDragBar = false;
  
  // arguments: dragBar id, track id, axis ("v" or "h"), x offset, y offset
  // (x/y offsets of dragBar in track)
  wndo.setUpScrollbar("dragBar", "track", "v", 1, 1);
  
  // pass id('s) of scroll area(s) if inside table(s)
  // i.e., if you have 3 (with id's wn1, wn2, wn3): dw_scrollObj.GeckoTableBugFix('wn1', 'wn2', 'wn3');
  dw_scrollObj.GeckoTableBugFix('wn'); 
  //console.log("scoll initiated");
  fixfix();
  
  document.getElementById('firstLink').focus();
//  alert(document.getElementById('firstLink').innerHTML);
}
function fixfix()
{
	m=document.getElementById("lyr1").offsetHeight;
	if( m<255)
	{
		e=document.getElementById("scrollLinks");
		e.style.width=0;
		//e.style.visibility='hidden';
		e.style.display="none";
		//document.getElementById("hold").style.width=parseInt(document.getElementById("hold").style.width)+12+"px";
	}
	//console.log("inside fixfix");
//document.getElementById("t1").innerHTML+=m.offsetHeight+","+m.style.offsetHeight;//+","+m1.offsetHeight+","+m2.offsetHeight;
}
function handle(delta) 
{
        if (delta < 0)
		dw_scrollObj.initScroll('wn','down',700);
        else
		dw_scrollObj.initScroll('wn','up',700);
		dw_scrollObj.doubleSpeed('wn');
 
		window.setTimeout("stopwheel()",100);
}
function stopwheel() 
{
		if(dw_scrollObj != null)
		dw_scrollObj.stopScroll('wn');
}
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;
}
/** Initialization code. 
 * If you use your own event management code, change it as required.
 */

function setMouseWheel()
{
if (window.addEventListener)
        /** DOMMouseScroll is for mozilla. */
window.addEventListener('DOMMouseScroll', wheel, false);
/** IE/Opera. */
window.onmousewheel = document.onmousewheel = wheel;
}

function removeMouseWheel()
{
if (window.removeEventListener)
        /** DOMMouseScroll is for mozilla. */
window.removeEventListener('DOMMouseScroll', wheel, false);
/** IE/Opera. */
window.onmousewheel = document.onmousewheel = function(){};
}
