var speedR = 4;
var speedL = -4;
var accelerationR = 0;
var accelerationL = -0;
var refreshRate = 10; //miliseconds
var menu_width;
var left = 0;
var total = 0;
var direction;
var acceleration;
var stopped = true;

var menuCategoryId;

function InitScrollMenu(menuCategoryClientId)
{
   menuCategoryId = menuCategoryClientId;
   setDivText();
}

function setDivText()
{
   var div = document.getElementById(menuCategoryId);
   div.style.left = left + "px";                           
}



function initmove()
{   
   if (!stopped) 
   {
    var objScroll = document.getElementById(menuCategoryId);      
    width = parseInt(objScroll.style.width);   
    if (!((direction>0)&&(parseInt(objScroll.style.left)>=0)))//for left
                  if (!((direction<0)&&((536-width)>(parseInt(objScroll.style.left))))) //for right
                      {
                           objScroll.style.left = parseInt(objScroll.style.left)+direction+"px";
                           left = parseInt(objScroll.style.left);                           
                           direction = direction + acceleration;   
                           setTimeout("initmove()", refreshRate);
                      }
   }
}     
function moveLeft()
{
   if (stopped)
   {
      direction = speedL;
      acceleration = accelerationL;
      stopped = false;
      initmove();
   }
}

function moveRight()
{
   if (stopped)
   {
      direction = speedR;
      acceleration = accelerationR;
      stopped = false;
      initmove();
   }
}

function stop()
{
   stopped = true;
}
