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

	YAHOO.util.Event.onContentReady("mainmenu", 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("mainmenu", { autosubmenudisplay: true, hidedelay: 750, showdelay: 0, lazyload: true });

/*
			Define an array of object literals, each containing 
			the data necessary to create a submenu.
*/

		var aSubmenuData = [
		
			{
				id: "mnuAccueil"
			},

			{
				id: "mnuVente", 
				itemdata: [
					{ text: "Liste de prix...", url: "javascript:ListePrix()" },
					{ text: "Conditions de vente", url: "/index.php?section=conditions_vente" }
				]		
			},

			{
				id: "mnuNewsletter",
				itemdata: [
					{ text: "Lire les newsletter", url: "/index.php?section=newsletter&style=default" },
					{ text: "S'abonner", url: "/index.php?section=newsletter_manage&action=subscribe&style=default" },
					{ text: "Se d&eacute;sabonner", url: "/index.php?section=newsletter_manage&action=unsubscribe&style=default" }
				]
			},

			{
				id: "mnuContacts",
				itemdata: [
					{ text : "Contacts", url: "/index.php?section=contacts" },
					{ text : "Situation", url: "/index.php?section=situation" }
				]
			},

			{
				id: "mnuDistributeurs"
			},

			{
				id: "mnuPartenaires"
			},

			{
				id: "mnuCabinet"
			}
		];


/*
		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++) {
					if (aSubmenuData[i].itemdata != null) {
						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();				 

	});

