/*<![CDATA[*/

  function init ()
   {
    this.node = document.getElementById(this.id);
    if(this.node)
     {
      this.node.style.display = "block";
      this.node.style.visibility = "visible";
      if (navigator.appName.indexOf("Microsoft")!=-1)
       var availWidth = (document.body.offsetWidth + 20);
      else
       var availWidth = window.innerWidth;
      //alert(availWidth+" - ("+this.node.offsetLeft+" + "+this.node.offsetWidth+")");
      this.evalPosition = availWidth - (this.node.offsetLeft + this.node.offsetWidth);
      //alert(this.evalPosition);
      this.evalWidth = this.node.offsetWidth + this.evalPosition;
     }
   }

  function moveInterval ()
   {
    if(this.node)
     {
      var newPosition;
      change = Math.round(this.max * (this.evalX * this.evalX * this.evalX * this.evalX));
      if(this.direction == "right")
        newPosition = this.evalPosition - change;
      else if(this.direction == "left")
        newPosition = this.evalPosition + change;
      if(change <= this.max)
        this.node.style.right = newPosition+"px";
      else
       {
        this.active = false;
        window.clearInterval(this.interval);
       }
      this.evalX += 0.04;
     }
   }

  function start ()
   {
    this.active = true;
    var t = this;
    this.interval = window.setInterval(function() { t.moveInterval(); }, 25);
   }

function move(id, direction, max)
 {
  this.evalPosition;
  this.evalWidth;
  this.evalX = 0;
  this.interval;
  this.node;
  this.id = id;
  this.direction = direction;
  this.max = max;
  this.init = init;
  this.start = start;
  this.active = false;
  this.moveInterval = moveInterval;
 }

var position = true;
var moveObject1 = false;
var moveObject2 = false;

function menu()
 {
  if((moveObject1 == false || moveObject1.active == false) && (moveObject2 == false || moveObject2.active == false))
   {
    var direction;
    var max;
    var id;

    if(document.getElementById("menu3"))
     {
      if(position == true)  direction = "right";
      else  direction = "left";
     }
    else
     {
      direction = "";
     }
    moveObject1 = new move("menu2", direction, 300);
    moveObject1.init();
    moveObject1.start();

    if(document.getElementById("menu3"))
     {
      id = "menu3";
      if(position == true)  direction = "left";
      else  direction = "right";
     }
    else
     {
      id = "menu4";
      if(position == false)  direction = "left";
      else  direction = "right";
     }
    moveObject2 = new move(id, direction, 300);
    moveObject2.init();
    moveObject2.start();

    if(position == true)
      position = false;
    else
      position = true;
   }
 }

/*]]>*/
