var scrolling = 0;	// Controls whether the layer is scrolling or not
var yT = 0;	// Pixel position the top of the scrolling layer should be set to
var lT = 0;	// Initial position for the top of the layer
var yI = 15;	// Increment that the scrolling layer should move at
var yH = 0;	// Hight of scrollling layer
var object = null;	// Stores the generic DOM for the scrolling layer to access style properties


function startScroll(objectID,direction) {
	
	if(document.getElementById(objectID))
	{
		object = document.getElementById(objectID);
		scrolling = 1;
		scroll(direction); 
	}
}

function scroll(direction) {
	if (scrolling == 1) {
		
		//this is used to scroll down
		if(direction == 0)
		{		
			yT -= yI;
			object.scrollTop = yT;
			if(object.scrollTop > yT)
			{
			  yT = object.scrollTop;
			  scolling = 0;
			}
		}		
		//this is used to scroll up
		else if(direction == 1)
		{	
			yT = yT + yI;
			object.scrollTop = yT;
			if(object.scrollTop < yT)
			{
			  yT = object.scrollTop;
			  scolling = 0;
			}
	  	}	  	
		//this is used to scroll left
	  	else if(direction == 2)
		{		
			yT -= yI;
			object.scrollLeft = yT;
			if(object.scrollLeft > yT)
			{
			  yT = object.scrollLeft;
			  scolling = 0;
			}			
	  	}
	  	//this is used to scroll right
	  	else if(direction == 3)
		{		
			yT = yT + yI;
			object.scrollLeft = yT;
			if(object.scrollLeft < yT)
			{
			  yT = object.scrollLeft;
			  scolling = 0;
			}			
	  	}

		code2run = 'scroll('+ direction + ')';
		setTimeout(code2run,0);
	}
	return false;
}

function stopScroll() {
	scrolling = 0;
	return false;
}