var _showScrollButtons = false; //flag to show the left and right scroll buttons
var _scrollLoc = 0;
var _scrollInt = false;
document.onmouseup = function() { if(_scrollInt){window.clearInterval(_scrollInt);} } // stops the scrolling.
document.onmouseout = function() { if(_scrollInt){window.clearInterval(_scrollInt);} } // stops the scrolling.

function _scrollLeft(){	// set up to scroll left;
	window.clearInterval(_scrollInt); //clears intervals to make sure stuv doesn't break more stuff.
	_scrollInt = window.setInterval("_scroll(20);", 10);
}

function _scrollRight(){ // same, but right;
	window.clearInterval(_scrollInt);
	_scrollInt = window.setInterval("_scroll(-20);", 10);
}

function _scroll(dir){	// scroll the contents;
	sc=document.getElementById('_scroller');
	_scrollLoc = _scrollLoc + dir;
	_scrollLoc = _checkScrollLoc();
	sc.style.marginLeft =_scrollLoc;
}

function _checkScrollLoc(){ // check to see if the contents are being over-scrolled.
	inn=document.getElementById('_inner');
	view=document.getElementById('_container');
	dir = (-1*(inn.clientWidth))+view.clientWidth; //max scroll = the negative width of the contents + the width of the view.
	if (_scrollLoc < dir)	
		_scrollLoc = dir;
	if (_scrollLoc > 0)
		_scrollLoc = 0;
	return _scrollLoc;
}

function _scrollPane(x,y,content,extra){
	output = "<table cellpadding=0 cellspacing=0 border=0><tr valign=middle>";
	if (_showScrollButtons) {
		output += "<td>";
		output +=_leftButton();
		output +="</td>";
	}
	output += "<td><div id='_container' style='overflow: hidden; width: "+x+"; height: "+y+"; "+extra+"'><div id='_scroller'>";
	output +="<table id='_inner' cellpadding=0 cellspacing=0><tr valign=top><td>";
	output +=content;
	output +="</td></tr></table>";
	output +="</div></div></td>";
	if (_showScrollButtons) {
		output += "<td>";
		output +=_rightButton();
		output += "</td>";
	}
	output += "</tr></table>";
	document.write(output);	
}


function _leftButton(){
	return "<a onmousedown='_scrollLeft();'><div id=_leftArrow style='cursor:pointer;background-image:url(images/arrow_left.gif) center center no-repeat;width:20px;height:20px;'></div></a>"; //left button;
}
function _rightButton(){
	return "<a onmousedown='_scrollRight();'><div id=_rightArrow style='cursor:pointer;background-image:url(images/arrow_right.gif) center center no-repeat;width:20px;height:20px;'></div></a>";
}