/*	Scrolling DIV Code 
		All except MM_findObj and browser ID (c)2004-2006 Lee Collier
		Unauthorised copying prohibited.
		www.lpcollier.net
*/


/* browser identification */

NS4 = (document.layers);
NS6 =  ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 5));
IE4 = (document.all);
MAC45 = (navigator.appVersion.indexOf("MSIE 4.5") != -1);
ver4 = (NS4 || IE4);   
isMac = (navigator.appVersion.indexOf("Mac") != -1);

function showLayer(divname,refimage,xoffset,yoffset)
{
	
	div=MM_findObj(divname);

	if (NS4)
	{
		div.top = findloc(refimage)[1]+yoffset;
		div.left = findloc(refimage)[0]+xoffset;
	}
	else if (NS6)
	{
  	   	div.style.top = findloc(refimage)[1]+yoffset;
		div.style.left = findloc(refimage)[0]+xoffset;
	}
	else
	{
		div.style.pixelTop = findloc(refimage)[1]+yoffset;
		div.style.pixelLeft = findloc(refimage)[0]+xoffset;
	}
	
	if (NS4) div.visibility = "show"
		else div.style.visibility = "visible";
}

function MM_findObj(n, d)
{
	var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}	

function goUp()
{
	document.mytext.scrollTop=document.mytext.scrollTop-24;
}

function goDown()
{
	document.mytext.scrollTop=document.mytext.scrollTop+24;
}

function scrollDown()
{

	if(document.mytext.scrollTop<document.maxScroll)
	{
		document.inScroll=true;
		if(document.scrollFlag==true)
		{
			document.mytext.scrollTop=document.mytext.scrollTop+16;
			if (document.mytext.scrollTop<document.maxScroll)
				document.scrollTimer=window.setTimeout('scrollDown()',16);
		}
		document.inScroll=false;
	}
}

function scrollUp()
{
	if(document.mytext.scrollTop>0)
	{
		document.inScroll=true;
		if(document.scrollFlag==true)
		{
			document.mytext.scrollTop=document.mytext.scrollTop-16;
			if (document.mytext.scrollTop>0)
				document.scrollTimer=window.setTimeout('scrollUp()',16);
		}
		document.inScroll=false;
	}
}

function startScrollUp()
{
	document.scrollFlag=false;
	while (document.inScroll==true);
	window.clearTimeout(document.slideTimer);
	document.scrollFlag=true;
	document.scrollTimer=window.setTimeout('scrollUp()',500);
}

function startScrollDown()
{
	document.scrollFlag=false;
	while (document.inScroll==true);
	window.clearTimeout(document.slideTimer);
	document.scrollFlag=true;
	document.scrollTimer=window.setTimeout('scrollDown()',500);
}

function stopScroll()
{
	if(document.scrollFlag)
	{
		document.scrollFlag=false;
		window.clearTimeout(document.scrollTimer);
	}
}
function handle(delta) {
	if (delta < 0)
		goDown();
	else
		goUp();
}

function wheel(event){
	var delta = 0;
	if (!event) event = window.event;
	if (event.wheelDelta) {
		delta = event.wheelDelta/120; 
		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;
}

function initScroll()
{	
	document.scrollTimer = new Object;
	document.inScroll = new Object;
	document.scrollFlag = new Boolean(false);
	document.mytext = MM_findObj("textdiv");
	document.mytext.scrollTop=1;
	document.maxScroll = new Object;
	if(document.mytext.scrollTop!=1)
	{
		// workaround Opera scroll bug
		document.mytext.style="overflow:auto; width:150;";
	}
	document.mytext.scrollTop=0;
	document.maxScroll=document.mytext.scrollHeight-218;  //255 is height of the text div - must be correct!!

	/* Wheel initialization code. */
	if (window.addEventListener)
		window.addEventListener('DOMMouseScroll', wheel, false);
	window.onmousewheel = document.onmousewheel = wheel;
}


