// JavaScript Document
var startY = 120;
var sy;
var curY = startY;
var destY = curY;
var timerID, ton = 0;

function floatMenu()
{

  clearInterval(timerID);
  ton = 0;

  if(document.documentElement.scrollTop)
  {
    sy = document.documentElement.scrollTop;
  }
  else
  {
    sy = document.body.scrollTop;
  }

  destY = sy + startY;
  startFloat();
}


function startFloat()
{
  var elem = document.getElementById("menulayer");

  if(curY == destY)
  {
    clearInterval(timerID);
    ton = 0;
  }
  else if(curY < destY)
  {
    curY += 1;
    var newY = curY.toString() + "px";
    elem.style.top = newY;

    if(ton == 0)
    {
       timerID = setInterval("startFloat()", 10);
       ton = 1;
    }
  }
  else if(curY > destY)
  {
    curY -= 1;
    var newY = curY.toString() + "px";
    elem.style.top = newY;

    if(ton == 0)
    {
       timerID = setInterval("startFloat()", 10);
       ton = 1;
    }
  }
}

window.onscroll = floatMenu;
