// the number you pass to initLeft doesn't matter since it will get
// changed onactivate
//ypSlideOutMenu(id, direction, left, top, width, height)
//top = 31+154=185+15
var MenuLeft = 0;
var MenuTop = getMenuTop();
var MenuWidth = 181;
var MenuHeight = 150;

var Menu1 = new ypSlideOutMenu("Menu1", "down", MenuLeft, MenuTop, MenuWidth, MenuHeight);
var Menu2 = new ypSlideOutMenu("Menu2", "down", MenuLeft, MenuTop, MenuWidth, MenuHeight);
var Menu3 = new ypSlideOutMenu("Menu3", "down", MenuLeft, MenuTop, MenuWidth, MenuHeight);
var Menu4 = new ypSlideOutMenu("Menu4", "down", MenuLeft, MenuTop, MenuWidth, MenuHeight);
var Menu5 = new ypSlideOutMenu("Menu5", "down", MenuLeft, MenuTop, MenuWidth, MenuHeight);


// for each menu, we set up hte onactivate event to call repositionMenu with the amount offset from center, in pixels
Menu1.onactivate = function() { repositionMenu(Menu1, 0); }
Menu2.onactivate = function() { repositionMenu(Menu2, 149); }
Menu3.onactivate = function() { repositionMenu(Menu3, 223); }
Menu4.onactivate = function() { repositionMenu(Menu4, 297); }
Menu5.onactivate = function() { repositionMenu(Menu4, 942); }

// this function repositions a menu to the speicified offset from center
function repositionMenu(menu, offset)
{
  var intWindowWidth;
  var newLeft = 0;
  var calculateOffset = 0;

  newLeft = offset;

  intWindowWidth = getWindowWidth();
  //alert(intWindowWidth);

  // the new left position should be the center of the window + the offset
  if (intWindowWidth > 728)
  {
    if (navigator.appName.indexOf('Microsoft') != -1)
    {
      //calculateOffset = (intWindowWidth / 2) - 370;
      calculateOffset = (intWindowWidth / 2) - 371;
    }
    else
    {
      //calculateOffset = (intWindowWidth / 2) - 368;
      calculateOffset = (intWindowWidth / 2) - 405;
    }
  }

  newLeft = newLeft + calculateOffset;

  //var newLeft = getWindowWidth() / 2 + offset;
  //var newLeft = offset+100;
  //var newLeft = offset+51;
  //var newLeft = offset;
  //var newLeft = offset+142;

  // setting the left position in netscape is a little different than IE
  menu.container.style ? menu.container.style.left = newLeft + "px" : menu.container.left = newLeft;
}

function getMenuTop()
{
  var intTop;

  if (navigator.appName.indexOf('Microsoft') != -1)
  {
    intTop = 355;
  }
  else
  {
    intTop = 355;
  }
  return intTop;
}

// this function calculates the window's width - different for IE and netscape
function getWindowWidth()
{
  return window.innerWidth ? window.innerWidth : document.body.offsetWidth;
}

ypSlideOutMenu.writeCSS();
