 /*
      Initialize and render the MenuBar when its elements are ready 
      to be scripted.
 */

YAHOO.util.Event.onContentReady("navigation", function () {

/*
  Instantiate a MenuBar:  The first argument passed to the constructor
  is the id for the Menu element to be created, the second is an 
  object literal of configuration properties.
*/
var oMenuBar = new YAHOO.widget.MenuBar("navigation", { 
					autosubmenudisplay: true, 
					hidedelay: 750, 
					lazyload: true });

/*
  Define an array of object literals, each containing 
  the data necessary to create a submenu.
*/
var aSubmenuData = [
  {
    id: "home"
  },
  {
      id: "products", 
      itemdata: [
	{ text: "Extreme Burn", url: "quick-trim-extreme-burn-patented-8-hour-weight-loss-formula.html" },
	{ text: "Celluslim", url: "quick-trim-celluslim-body-sculpting-gel.html" },
	{ text: "Fast Cleanse!", url: "quick-trim-fast-cleanse-48-hour-super-diet-detox.html" },
	{ text: "Burn &amp; Cleanse", url: "quick-trim-burn-and-cleanse-14-day-diet-system.html" }
      ]
  },
  {
    id: "blog"
  }
];
/*
Subscribe to the "beforerender" event, adding a submenu 
to each of the items in the MenuBar instance.
*/
oMenuBar.subscribe("beforeRender", function () {
  var nSubmenus = aSubmenuData.length,
  i;
  if (this.getRoot() == this) {
    for (i = 0; i < nSubmenus; i++) {
	this.getItem(i).cfg.setProperty("submenu", aSubmenuData[i]);
    }
}
});
/*
Call the "render" method with no arguments since the 
markup for this MenuBar instance is already exists in 
the page.
*/
oMenuBar.render();
});
