// JavaScript Document

/*	YUI Left Nav
------------------------------------*/
/*
	 Initialize and render the Menu when its elements are ready 
	 to be scripted.
*/
YAHOO.util.Event.onContentReady("leftNavServices", function () {
	var oMenu = new YAHOO.widget.Menu(
						"leftNavServices", 
						{
							position: "static", 
							hidedelay: 200, 
							lazyload: true, 
							effect: { 
								effect: YAHOO.widget.ContainerEffect.FADE,
								duration: 0.2
							} 
						}
				);
	
	var aSubmenuData = [
		{
			id: "buy", 
			itemdata: [ 
				{ text: "Link 1", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 2", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 3", url: "#" }
			]
		},

		{
			id: "deliver", 
			itemdata: [
				{ text: "Link 1", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 2", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 3", url: "#" }                
			]    
		},
		
		{
			id: "move", 
			itemdata: [
				{ text: "Receiving and Moving", url: "#", classname: "yuimenuitem_border" },
				{ text: "Delivery and Installations", url: "#", classname: "yuimenuitem_border" },
				{ text: "Reconfigurations", url: "#", classname: "yuimenuitem_border" },
				{ text: "Ergonomics", url: "#", classname: "yuimenuitem_border" },
				{ text: "Seismic Bracing", url: "#" }
			] 
		},
		
		{
			id: "recycle",
			itemdata: [
				{ text: "Link 1", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 2", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 3", url: "#" }
			]
		},
		
		{
			id: "storage",
			itemdata: [
				{ text: "Link 1", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 2", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 3", url: "#" }
			]
		},
		
		{
			id: "surplus",
			itemdata: [
				{ text: "Link 1", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 2", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 3", url: "#" }
			]
		}
	];
	
	// Subscribe to the Menu instance's "beforeRender" event
	oMenu.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]);
			}
		}
	});
	oMenu.render();
});


/*	MORE INFO
----------------------------------------*/
YAHOO.util.Event.onContentReady("leftNavMoreInfo", function () {
	var oMenu2 = new YAHOO.widget.Menu(
						"leftNavMoreInfo", 
						{
							position: "static", 
							hidedelay: 200, 
							lazyload: true, 
							effect: { 
								effect: YAHOO.widget.ContainerEffect.FADE,
								duration: 0.2
							} 
						}
				);
	
	var aSubmenuData2 = [
		{
			id: "locations", 
			itemdata: [ 
				{ text: "Link 1", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 2", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 3", url: "#" }
			]
		},

		{
			id: "contact", 
			itemdata: [
				{ text: "Link 1", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 2", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 3", url: "#" }                
			]    
		},
		
		{
			id: "feedback",
			itemdata: [
				{ text: "Link 1", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 2", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 3", url: "#" }
			]
		},
		
		{
			id: "faqs",
			itemdata: [
				{ text: "Link 1", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 2", url: "#", classname: "yuimenuitem_border" },
				{ text: "Link 3", url: "#" }
			]
		}
	];
	
	// Subscribe to the Menu instance's "beforeRender" event
	oMenu2.subscribe("beforeRender", function () {
		var nSubmenus2 = aSubmenuData2.length, i;
		if (this.getRoot() == this) {
			for (i = 0; i < nSubmenus2; i++) {
				this.getItem(i).cfg.setProperty("submenu", aSubmenuData2[i]);
			}
		}
	});
	oMenu2.render();
});



/*	YUI Center Sliding Contents
------------------------------------*/
function YUI_DivSlide(elementID, elementToggle, maxHeight) {
	var element = document.getElementById(elementID);
	if(element.offsetHeight > 30) {
		var attributes = {
			height: { to: 30 }
		};
		var anim = new YAHOO.util.Anim(element, attributes, 0.5, YAHOO.util.Easing.backIn);
		elementToggle.innerHTML = "+";
	} else {
		var attributes = {
			height: { to: maxHeight }
		};
		var anim = new YAHOO.util.Anim(element, attributes, 0.5, YAHOO.util.Easing.backOut);
		elementToggle.innerHTML = "-";
	}
	anim.animate();
}