// specify the width of a "page" of scrollable items
scrollJump=523

scrollStep=2
timerLeft=""
timerRight=""


function toLeft(id){
  document.getElementById(id).scrollLeft-=scrollJump
//  document.getElementById(id).scrollLeft=0
}

function scrollDivLeft(id,thewidth){
  clearTimeout(timerRight) 
  document.getElementById(id).scrollLeft+=scrollStep
  timerRight=setTimeout("scrollDivLeft('"+id+"',"+thewidth+")",10)

	//alert (width);

	var jump = thewidth - 643;

	if(document.getElementById(id).scrollLeft == jump){
		//alert("left: "+document.getElementById(id).scrollLeft+"  and width is: "+(thewidth));
		document.getElementById(id).scrollLeft-=thewidth;
		document.getElementById(id).scrollLeft = 0;
		timerRight=setTimeout("scrollDivLeft('"+id+"',"+thewidth+")",10)
	}
		
}//

function scrollDivRight(id,thewidth){
  clearTimeout(timerLeft)
  document.getElementById(id).scrollLeft-=scrollStep
  timerLeft=setTimeout("scrollDivRight('"+id+"',"+thewidth+")",10)

	var jump = 0;
	var jumpto = thewidth - 643;

	if(document.getElementById(id).scrollLeft == jump){
		//alert("left: "+document.getElementById(id).scrollLeft+"  and width is: "+(thewidth));
		document.getElementById(id).scrollLeft+=jumpto;
		//document.getElementById(id).scrollLeft = 0;
		timerRight=setTimeout("scrollDivRight('"+id+"',"+thewidth+")",10)
	}


}

function toRight(id){
  document.getElementById(id).scrollLeft+=scrollJump
//  document.getElementById(id).scrollLeft=document.getElementById(id).scrollWidth
}

function stopMe(){
  clearTimeout(timerRight) 
  clearTimeout(timerLeft)


function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;

	alert("left: "+curleft);
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

}
