/*
*
* scroller js for orrensjo.com by Ragnar Seton of dm9.se
*
*/
// globals
var sBox=new Object();
var SB_timer,SB_w,SB_h,SB_speed;
// flags
var SB_isRunning=false;

function startScroll(div,direction,speed)
{
	sBox=getElement(div);
	SB_speed=speed;
	if(ns4)
	{
		SB_w=(sBox.document.width) ? sBox.document.width : sBox.clip.width;
		SB_h=(sBox.document.height) ? sBox.document.Height : sBox.clip.Height;
	}
	else if(gebiSupport||ie4)
	{
		SB_w=(sBox.offsetWidth) ? parseInt(sBox.offsetWidth) :
			(ns6 && sBox.style.width) ? parseInt(sBox.style.width) : sBox.style.pixelWidth;
		SB_h=(sBox.offsetHeight) ? parseInt(sBox.offsetHeight) :
			(ns6 && sBox.style.Height) ? parseInt(sBox.style.Height) : sBox.style.pixelHeight;
	}
	switch(direction)
	{
		case 'left':
			SB_timer=setInterval("scrollLeft()",10);
		break;
		case 'right':
			SB_timer=setInterval("scrollRight()",10);
		break;
	}
	SB_isRunning=true;
}

function stopScroll()
{
	if(SB_isRunning)
	{
		clearInterval(SB_timer);
		SB_isRunning=false;
	}
}

function scrollLeft()
{
	if(ns4)
	{
		// rewrite
	}
	else if(gebiSupport||ie4)
	{
		/* 515 is the width of TNcontainer... it used to be a const. */
		if(parseInt(sBox.style.left)>(515-SB_w-7))
			sBox.style.left=Math.max(parseInt(sBox.style.left)-SB_speed,515-SB_w-7)+'px';
		else stopScroll();
	}
}

function scrollRight()
{
	if(ns4)
	{
		// rewrite
	}
	else if(gebiSupport||ie4)
	{
		if(parseInt(sBox.style.left)<20)
			sBox.style.left=Math.min(parseInt(sBox.style.left)+SB_speed,7)+'px';
		else stopScroll();
	}
}