/*
Scrollable division by Fredrik Klarqvist
Date of creation: 2001-08-01

Usage:
1. Create your division, with the desired height/width/clipproperties

<div id="dropDownContent" style="position:absolute; left:0px; top:0px; width:120px; visibility: visible; z-index:1; clip:rect(0,120,194,0)"> 
</div>

2. Create your scrollarrows/symbols and apply the scrollUp/scrollDown method to the desired event

<a href="#" onMouseOver="scrollUp('dropDownContent');" onMouseOut="stopScrollUp();">ScrollUp</a>
<a href="#" onMouseOver="scrollDown('dropDownContent');" onMouseOut="stopScrollDown();">ScrollDown</a>
*/


var timerIDDown = 0;
var timerIDUp = 0;

function getDivStyleObj(divName)
{
if (document.layers)
	{return document.layers[divName];}
else if (document.getElementById)
	{return document.getElementById(divName).style;}
else
	{return document.all(divName).style;}
}

function scrollDown(divName)
{ 
divStyleObj = getDivStyleObj(divName);
intTop = parseInt(divStyleObj.top);
intNewTop = parseInt(intTop - 2);

if (document.getElementById || document.all)
	{
	divHeight = document.getElementById(divName).offsetHeight;
	strClip = divStyleObj.clip;
	strClip = strClip.substring(strClip.indexOf('(')+1,strClip.indexOf(')'));
	
	//NS uses pt for some clip-properties
	if (strClip.indexOf('pt')>0)
		{		
		strClip = strClip.replace('pt','px')	
		}
	arrClip = strClip.split('px');
	
	intTopClip = parseInt(arrClip[0]);
	intRightClip = parseInt(arrClip[1]);
	intDownClip = parseInt(arrClip[2]);
	intLeftClip = parseInt(arrClip[3]);
	
	intNewTopClip = intTopClip + 2;
	intNewDownClip = intDownClip + 2;
	
	if (intNewDownClip<divHeight)
		{	
		divStyleObj.clip = 'rect(' +intNewTopClip +',' +intRightClip +',' +intNewDownClip +',' +intLeftClip +')';
		divStyleObj.top=intNewTop;
		}
	else
		{stopScrollDown();}
	}
else 
{
divHeight = divStyleObj.document.height;
intTopClip = parseInt(divStyleObj.clip.top);
intNewTopClip = intTopClip + 2;
intDownClip = parseInt(divStyleObj.clip.height);
intNewDownClip = intDownClip + 2;
if (intNewDownClip+intNewTopClip<divHeight)
	{
	divStyleObj.clip.height = intNewDownClip;
	divStyleObj.clip.top = intNewTopClip;
	divStyleObj.top=intNewTop;
	}
else
	{stopScrollDown();}
}	
timerIDDown = setTimeout("scrollDown('" +divName +"')",10);
}

function scrollUp(divName)
{ 
//get the right obj for each browser version
divStyleObj = getDivStyleObj(divName);

//get the top-position of the division
intTop = parseInt(divStyleObj.top);

//add 1 px to create new top-position
intNewTop = parseInt(intTop + 2);

//IE4+, NS6
if (document.getElementById || document.all)
	{
	//get the height of the division
	divHeight = document.getElementById(divName).offsetHeight;
	
	//get clip-properties of the division
	strClip = divStyleObj.clip;
	
	//parse the actual clip-properties
	strClip = strClip.substring(strClip.indexOf('(')+1,strClip.indexOf(')'));
	
	//create an array with all clip-values
	arrClip = strClip.split('px');
	
	//get the specified clip-values
	intTopClip = parseInt(arrClip[0]);
	intRightClip = parseInt(arrClip[1]);
	intDownClip = parseInt(arrClip[2]);
	intLeftClip = parseInt(arrClip[3]);
	
	//change the top/down clip-values
	intNewTopClip = intTopClip - 2;
	intNewDownClip = intDownClip - 2;	

	//check that the divisions clip-position is higher than 0, this means that the div is in the start-position
	if (intNewTopClip>0)
		{	
		//apply new clip-properties
		divStyleObj.clip = 'rect(' +intNewTopClip +',' +intRightClip +',' +intNewDownClip +',' +intLeftClip +')';
		
		//apply the new top-position
		divStyleObj.top=intNewTop;
		}
	else
		{stopScrollUp();}
	}
//NS4	
else 
{
//get the height of the division
divHeight = divStyleObj.document.height;

//get the topclip-value
intTopClip = parseInt(divStyleObj.clip.top);

//change the topclip-value
intNewTopClip = intTopClip - 2;

//get the downclip-value
intDownClip = parseInt(divStyleObj.clip.height);

//change the downclip-value
intNewDownClip = intDownClip - 2;

//check that the topclip-value is higher than 0, this means that the div is in the start-position
if (intNewTopClip>0)
	{
	//apply the new clip-values and the new top-position
	divStyleObj.clip.height = intNewDownClip;
	divStyleObj.clip.top = intNewTopClip;
	divStyleObj.top=intNewTop;
	}
else
	{stopScrollUp();}
}	
timerIDUp = setTimeout("scrollUp('" +divName +"')",10);
}


function stopScrollUp()
{
clearTimeout(timerIDUp)
}

function stopScrollDown()
{
clearTimeout(timerIDDown)
}