
function movemenu(offset)
{
  var menu = document.getElementById("qmpanel");
  var l = parseInt(menu.style.left);
  if (!l) l = 0;
  l += offset;

  size = qmSize;
  w = qmImageSize * qmLength;

  if (w + l < size) l = size - w;
  if (l > 0) l = 0;

  menu.style.left = l + "px";

//  alert(menu.style.left);
}

function animateMove(length, steps, interval) { 
  var menu = document.getElementById("qpanel");
  if (menu.moving) 
    window.clearInterval(menu.moving);

  var step = 0;
  menu.moving = window.setInterval(
    function() { 
      movemenu(length);
      step++;
      if (step > steps)
        window.clearInterval(menu.moving);
    }, 
    interval);
}


function quickmenuRoll(dir)
{
  animateMove(8*dir, 10, 20);
}

function startMove(dir) 
{
  var menu = document.getElementById("qmpanel");
  if (menu.moving) 
    window.clearInterval(menu.moving);
  
  menu.moving = window.setInterval(
    function() { 
      movemenu(qmStep*dir);
    }, 
    qmInterval);
}

function stopMove() 
{
  var menu = document.getElementById("qmpanel");
  if (menu.moving) 
    window.clearInterval(menu.moving);
  saveOffset();
}

function resetmenu()
{
  var menu = document.getElementById("qmpanel");
  menu.style.left = "0px";
}

function saveOffset()
{
  var menu = document.getElementById("qmpanel");
  var offset = menu.style.left;

  setcookie("quickmenuoffset", String(offset));
}

function loadOffset()
{
  var menu = document.getElementById("qmpanel");
  var offset;

  offset = getcookie("quickmenuoffset");
  menu.style.left = offset;
}
