var h, hideIt;
function show(n) {
  for (var m = 0; m < menus; m ++) {
    hide(m);
  };

  document.getElementById(n + "overlay").style.visibility = "";
  for (var i = 0; i < items[n]; i ++) {
    document.getElementById(n + "contents" + i).style.visibility = "";
  };
};

function hide(n) {
  if (hideIt == false) {
    hideIt == true;
    return;
  };

  if (document.getElementById(n + "overlay").style.visibility = "") return;

  for (var i = 0; i < items[n]; i ++) {
    document.getElementById(n + "contents" + i).style.visibility = "hidden";
  };
  document.getElementById(n + "overlay").style.visibility = "hidden";
};

function sethide(n) {
  hideIt = true;
  h = setTimeout("hide(" + n + ");", 50);
};

function highlight(n, i) {
  hideIt = false;
  i.style.background = "#0000FF";
  i.style.filter = "alpha(style=4,opacity=100)";
  i.style.color = "#ffffff";
};

function dehighlight(n, i) {
  i.style.background = "#0080ff";
  i.style.filter = "alpha(style=4,opacity=100)";
  i.style.color = "#ffffff";
  sethide(n);
};

var menus = 0, items = new Array();
function makeMenu(title, x, y, w) {
  var n = menus;

  var numItems = (arguments.length - 4) / 2;
  items[n] = numItems;

 document.write("<div id='" + n + "overlay' style='visibility:hidden; border:1px solid #0000ff; background:#0080ff; filter:alpha(style=4,opacity=100); position:absolute; height:" + (numItems * 25 +2) + "px; width:" + (w + 2) + "px;left:" + x + "px; top:" + (y + 18) + "px' onmouseover='hideIt = false;' onmouseout='sethide(" + n + ");'></div>");

  for (var i = 0; i < numItems; i ++) {
    document.write("<div id='" + n + "contents" + i + "' style='padding:2px; cursor:hand; position:absolute; visibility:hidden; height:18px; width:" + w + "px; left:" + (x + 1) + "px; top:" + (y +22 + i*25) + "px' onmouseover='highlight(" + n + ", this);' onmouseout='dehighlight(" + n + ", this);' onclick='location = \"" + arguments[5 + i*2] + "\";'>&nbsp;" + arguments[4 + i*2] + "</div>");
  };

  document.write("<div id='" + n + "title' style='background:#0080ff; cursor:hand; border:1px solid #8C5FA0;  filter:alpha(style=4,opacity=90); padding:1px; position:absolute; height:18px; left:" + x + "px; top:" + y + "px' onmouseover='show(" + n + "); hideIt = false;' onmouseout='sethide(" + n + ");'>&nbsp;" + title + "&nbsp;</div>");


  menus ++;
};

makeMenu("Futons",30,130, 130,
"Futon Mattresses", "http://www.thefutonstore.net/futons_toronto/futon.htm",
"Product Descriptions", "http://www.thefutonstore.net/futons_toronto/futon-feat.htm");

makeMenu("Bed Frames", 80,130, 96,
"All Beds", "http://www.thefutonstore.net/futons_toronto/all-beds.htm",
"Hardwood Beds", "http://www.thefutonstore.net/futons_toronto/hardwoodbeds.htm",
"Pine Beds", "http://www.thefutonstore.net/futons_toronto/pine-beds.htm",
"The Tara", "http://www.thefutonstore.net/futons_toronto/tara.htm",
"The Mission", "http://www.thefutonstore.net/futons_toronto/mission.htm",
"The Condo", "http://www.thefutonstore.net/futons_toronto/condo.htm");

makeMenu("Pine Sofa Beds", 160, 130, 96,
"Pine Sofa Beds", "http://www.thefutonstore.net/futons_toronto/pine.htm",
"A Frames", "http://www.thefutonstore.net/futons_toronto/basic-aframe.htm",
"L Frames", "http://www.thefutonstore.net/futons_toronto/basic.htm",
"The Sierra", "http://www.thefutonstore.net/futons_toronto/sierra.htm",
"The Proto", "http://www.thefutonstore.net/futons_toronto/proto.htm",
"The Tahoe", "http://www.thefutonstore.net/futons_toronto/tahoe.htm");

makeMenu("Hardwood  Sofa Beds", 257, 130, 140,
"All Ash Frames", "http://www.thefutonstore.net/futons_toronto/ash.htm",
"The Vista Sofa Bed", "http://www.thefutonstore.net/futons_toronto/vista.htm",
"The Elton Sofa Bed", "http://www.thefutonstore.net/futons_toronto/elton.htm",
"The Titan Sofa Bed", "http://www.thefutonstore.net/futons_toronto/titan.htm",
"The Kingston Sofa Bed", "http://www.thefutonstore.net/futons_toronto/kingston.htm",
"The Cardinal Sofa Bed", "http://www.thefutonstore.net/futons_toronto/cardinal.htm",
"New Yorker Sofa Bed", "http://www.thefutonstore.net/futons_toronto/newyorker.htm",
"The Fuji Sofa Bed", "http://www.thefutonstore.net/futons_toronto/fuji.htm",
"The Glasgow Sofa Bed", "http://www.thefutonstore.net/futons_toronto/glasgo.htm");

makeMenu("Upholstered Sofas", 386, 130, 120,
"Upholstered Sofas", "http://www.thefutonstore.net/futons_toronto/upholstered.htm");

makeMenu("Metal Sofa Beds",501,130,100,
"Metal Sofa Bed", "http://www.thefutonstore.net/futons_toronto/metal.htm");

makeMenu("Accessories",602,130,100,
"Accessories", "http://www.thefutonstore.net/buyonline/index.php?cPath=63_31",
"Pet Beds", "http://www.thefutonstore.net/buyonline/product_info.php?cPath=63_31&products_id=142",
"Pine Crates", "http://www.thefutonstore.net/buyonline/product_info.php?cPath=63_31&products_id=64",
"Travel Mats", "http://www.thefutonstore.net/buyonline/product_info.php?cPath=63_31&products_id=131");

makeMenu("Online Store",682,130,100,
"Online Store", "http://www.thefutonstore.net/buyonline/");


