var HScrolling = 0;
var HScrollSpeed = 10;
var HSAmount = 0;
var HSMin = 0;
var HSTime;


function startHScroll(dir){
	HScrolling = dir;
	doHScroll();
}

function stopHScroll(){
	HScrolling = 0;
	clearTimeout(HSTime);
}

function doHScroll(){
	if(HScrolling == 0) {
		return;
	}
	HSAmount += HScrollSpeed * HScrolling;
	
	if ( HSAmount < HSMin) {
		HSAmount = HSMin;
	}
	if ( HSAmount > document.getElementById('background').scrollWidth -  document.getElementById('background').offsetWidth) {
		HSAmount = document.getElementById('background').scrollWidth - document.getElementById('background').offsetWidth;
	}
	document.getElementById('background').scrollLeft = HSAmount;
	HSTime = setTimeout('doHScroll()', 20);
}

