var scrollStep=2;		// Scrolling Steps

// this variable value will be set from the page
var effectiveScrolling=0;   // difference between Total Scroll Length minus Open area
///------------------------------------------------------------------
var timerLeft="";		/// it will store timer pointer for Scroll Left
var timerRight=""; 		/// it will store timer pointer for Scroll Right
var autoscroll="";		/// it will store timer pointer for Auto Scroll
var autoscrollDirection="";   /// it will store scrolling direction

function toLeft(id){
  document.getElementById(id).scrollLeft=0;
}

function scrollDivLeft(id){
  clearTimeout(autoscroll);  /// Stop Auto Scroll
  clearTimeout(timerRight);
  document.getElementById(id).scrollLeft+=scrollStep;
  timerRight=setTimeout("scrollDivLeft('"+id+"')",20);
}

function scrollDivRight(id){
  clearTimeout(autoscroll);  /// Stop Auto Scroll
  clearTimeout(timerLeft);
  document.getElementById(id).scrollLeft-=scrollStep;
  timerLeft=setTimeout("scrollDivRight('"+id+"')",20);
}

function toRight(id){
  document.getElementById(id).scrollLeft=document.getElementById(id).scrollWidth;
}

function stopMe(){
  clearTimeout(autoscroll);  /// Stop Auto Scroll	
  clearTimeout(timerRight);
  clearTimeout(timerLeft);
}


function AutoScrollToLeft(id){
  clearTimeout(autoscroll);    
  if(document.getElementById(id).scrollLeft < effectiveScrolling )
  {  	
	autoscrollDirection="LEFT";
	document.getElementById(id).scrollLeft+=scrollStep;
	autoscroll=setTimeout("AutoScrollToLeft('"+id+"')",30);
  }else
  {
  	autoscrollDirection="RIGHT";
	document.getElementById(id).scrollLeft-=scrollStep;
	autoscroll=setTimeout("AutoScrollToRight('"+id+"')",30);
  }
  
}

function AutoScrollToRight(id){
  clearTimeout(autoscroll);    
  if(document.getElementById(id).scrollLeft > 0 )
  {  	
	autoscrollDirection="RIGHT";
	document.getElementById(id).scrollLeft-=scrollStep;
	autoscroll=setTimeout("AutoScrollToRight('"+id+"')",30);
  }else
  {
  	autoscrollDirection="LEFT";
	document.getElementById(id).scrollLeft+=scrollStep;
	autoscroll=setTimeout("AutoScrollToLeft('"+id+"')",30);
  }
  
}

function RestartAutoScroll(id)
{ 
	if(autoscrollDirection=="LEFT")
	{
		autoscroll=setTimeout("AutoScrollToLeft('"+id+"')",1000);  // wait for 1 seconds and restart autoscrolll
	}else
	{
		autoscroll=setTimeout("AutoScrollToRight('"+id+"')",1000); // wait for 1 seconds and restart autoscrolll
	}	
	// Note: (1000 miliseconds = 1 second) 	
}

