/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Mr J | http://www.huntingground.net/
http://javascript.internet.com/miscellaneous/scroll-div-horizontal.html
 */
 
var scrollStep=1;
var direction="left";

var timerLeft="";
var timerRight="";

var limit = 900;

function toLeft(id){
  document.getElementById(id).scrollLeft=0
}

function scrollDivLeft(id){
  clearTimeout(timerRight) 
  document.getElementById(id).scrollLeft+=scrollStep
  if(document.getElementById(id).scrollLeft > limit) {
	stopMe()
	direction = "right"
	scrollDivRight(id)
	return
  }
  timerRight=setTimeout("scrollDivLeft('"+id+"')",50)
}

function scrollDivRight(id){
  clearTimeout(timerLeft)
  document.getElementById(id).scrollLeft-=scrollStep
   if(document.getElementById(id).scrollLeft < 2) {
	stopMe()
	direction = "left"
	scrollDivLeft(id)
	return
  }
  timerLeft=setTimeout("scrollDivRight('"+id+"')",50)
}

function toRight(id){
  document.getElementById(id).scrollLeft=document.getElementById(id).scrollWidth
}

function stopMe(){
  clearTimeout(timerRight) 
  clearTimeout(timerLeft)
}

function scrollDiv(id) {
	limit = ((document.getElementById('scroller').offsetWidth) - (document.getElementById(id).offsetWidth)) - 5
	if(direction == "left") {
		scrollDivLeft(id)
	}
	if(direction == "right") {
		scrollDivRight(id)
	}

}

function Highlight(variable,color){
 variable.style.backgroundColor = color; 
}
function HighlightI(variable,image){
 variable.style.backgroundImage = image; 
}
