(function () {
	var carousel;
                
	YAHOO.util.Event.onDOMReady(function (ev) {
		var carousel = new YAHOO.widget.Carousel("vertrow", {
			isVertical: true,
			numVisible: 4,
			revealAmount: 25
		});
		
		carousel.render(); // get ready for rendering the widget
        carousel.show();   // display the widget
	});
})();

YAHOO.util.Event.onContentReady("nav", function () {
	var oMenuBar = new YAHOO.widget.MenuBar("nav", { 
	 autosubmenudisplay: true, 
	 hidedelay: 750, 
	 lazyload: false });

	var aSubmenuData = [
		{
	 		id: "welcome",
			itemdata: [
				{ text: "About TCAG", url: "about.html" },
			]
		},
		{
			id: "products",
			itemdata: [
				{ text: "Specify the Best", url: "specify-the-best.html" },
				{ text: "Engineering", url: "engineering.html" },
				{ text: "Potable Water Tanks", url: "potable-water.html" },
				{ text: "Wastewater Tanks", url: "wastewater.html" },
				{ text: "Elevated Water Tanks", url: "elevated-water-tanks.html" },
				{ text: "Fire Protection Tanks", url: "fire-protection.html" },
				{ text: "Industrial Liquids", url: "industrial-liquids.html" },
				{ text: "Petroleum", url: "petroleum.html" },
				{ text: "Field-Weld Tank Construction", url: "field-weld.html" },
				{ text: "Chemical Storage", url: "liquid-chemical-storage.html" },
				{ text: "Digesters", url: "liquid-digesters.html" },
				{ text: "Foundations", url: "foundations.html" }
			]
		},
		{
			id: "coatings",
			itemdata: [
				{ text: "Fusion Outperforms Glass", url: "http://www.tcaffiliates.com/common-docs/pdfs/fusion-vs-glass.pdf" },
				{ text: "Unmatched Coatings", url: "fusion.html" },
				{ text: "Life Cycle Cost Calculator - Fusion vs. Glass", url: "http://www.tcaffiliates.com/common-docs/pdfs/life-cycle-review.xlsx" },
				{ text: "Glass Life Cycle Cost Proven Invalid", url: "http://www.tcaffiliates.com/common-docs/pdfs/life-cycle-invalid.pdf" }
			]
		},
		{
			id: "gallery",
			itemdata: [
				{ text: "Pictorial Review", url: "gallery.php" },
				{ text: "Storage Systems", url: "liquid-storage-systems.php" }
			]
		},
		{
			id: "specs",
			itemdata: [
				{
					text: "Tank Specifications", url: "#",
					submenu: {
						id: "specssub",
						itemdata: [
							{ text: "Elevated Steel - Potable Water", url: "http://www.tcaffiliates.com/common-docs/specs/elevated.html" },
							{ text: "Diamond Elevated - Potable Water", url: "http://www.tcaffiliates.com/common-docs/specs/diamond.html" },
							{ text: "AWWA D103-97 - Potable Water &amp; Liquid Storage", url: "http://www.tcaffiliates.com/common-docs/specs/potable.html" },
							{ text: "AWWA D100 Tank Specification - Potable Water &amp; Liquid Storage", url: "http://www.tcaffiliates.com/common-docs/specs/awwa-d100-potable.pdf" },
							{ text: "Fire Protection - Water Storage", url: "http://www.tcaffiliates.com/common-docs/specs/fire-protection.html" }
						]
					}
				},
				{
					text: "Tank Calculators", url: "#",
					submenu: {
						id: "calculatorssub",
						itemdata: [
							{ text: "Horizontal", url: "horizontal-calculator.php" },
							{ text: "Liquid Dish Bottom", url: "liquid-dish-bottom-calculator.php" },
							{ text: "Liquid Flat Bottom", url: "liquid-flat-bottom-calculator.php" },
							{ text: "Liquid Hopper Bottom", url: "liquid-hopper-bottom-calculator.php" },
							{ text: "Liquid Slope Bottom", url: "liquid-slope-bottom-calculator.php" }
						]
					}
				}
			]
		},
		{
			id: "quote",
			itemdata: [
				{ text: "Bolted", url: "http://www.tankconnection.com/liqb.php" },
				{ text: "Welded", url: "http://www.tankconnection.com/liqw.php" }
			]
		},
		{
			id: "literature",
			itemdata: [
				{ text: "Fusion Outperforms Glass", url: "http://www.tcaffiliates.com/common-docs/pdfs/fusion-vs-glass.pdf" },
				{ text: "Liquid Coatings", url: "http://www.tcaffiliates.com/common-docs/pdfs/liquid-sales.pdf" },
				{ text: "Liquid Containment Solutions", url: "http://www.tcaffiliates.com/common-docs/pdfs/tc-liquid.pdf" },
				{ text: "Fire Protection", url: "http://www.tcaffiliates.com/common-docs/pdfs/fire-protection.pdf" },
				{ text: "RTP vs. API 12B", url: "http://www.tcaffiliates.com/common-docs/pdfs/rtp-vs-api12b.pdf" },
				{ text: "Aluminum Domes", url: "http://www.tcaffiliates.com/common-docs/pdfs/aluminum-domes.pdf" }
			]
		},
		{
			id: "contact",
			itemdata: [
				{ text: "Worldwide Rep Network", url: "http://www.tankconnection.com/contact.php" }
			]
		}
	];
	
	var ua = YAHOO.env.ua,
		oAnim;
 
	/* Push span elements in the nav down by 1px on Firefox 3.5 for Mac */
	if ((/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) && ((navigator.platform == "MacIntel") || (navigator.platform == "MacPPC")
		|| (navigator.platform == "Linux x86_64") || (navigator.platform == "Linux x86_32")
	)) {
		var ffv = new Number(RegExp.$1);
 
		if (ffv >= 3.0) {
			var tabs = YAHOO.util.Dom.getElementsByClassName("tab");
 
			for (var i = 0; i < tabs.length; i++) {
				tabs[i].style.top = "0.75em";
			}
		}
	}
 
	function onSubmenuBeforeShow(p_sType, p_sArgs) {
		var oBody,
			oElement,
			oShadow,
			oUL;
 
		if (this.parent) {
			oElement = this.element;
			oShadow = oElement.lastChild;
			oShadow.style.height = "0px";
 
			if (oAnim && oAnim.isAnimated()) {
				oAnim.stop();
				oAnim = null;
			}

			oBody = this.body;
 
			if (this.parent && 
			!(this.parent instanceof YAHOO.widget.MenuBarItem)) {
				if (ua.gecko || ua.opera) {
					oBody.style.width = oBody.clientWidth + "px";
				}
 
				if (ua.ie == 7) {
					oElement.style.width = oElement.clientWidth + "px";
				}
			}

			oBody.style.overflow = "hidden";
			oUL = oBody.getElementsByTagName("ul")[0];
			oUL.style.marginTop = ("-" + oUL.offsetHeight + "px");
		}
	}

	function onTween(p_sType, p_aArgs, p_oShadow) {
		if (this.cfg.getProperty("iframe")) {
			this.syncIframe();
		}

		if (p_oShadow) {
			p_oShadow.style.height = this.element.offsetHeight + "px";
		}
	}

	function onAnimationComplete(p_sType, p_aArgs, p_oShadow) {
		var oBody = this.body,
		oUL = oBody.getElementsByTagName("ul")[0];

		if (p_oShadow) {
			p_oShadow.style.height = this.element.offsetHeight + "px";
		}

		oUL.style.marginTop = "";
		oBody.style.overflow = "";

		if (this.parent && 
		!(this.parent instanceof YAHOO.widget.MenuBarItem)) {
			if (ua.gecko || ua.opera) {
				oBody.style.width = "";
			}

			if (ua.ie == 7) {
				this.element.style.width = "";
			}
		}            
	}

	function onSubmenuShow(p_sType, p_sArgs) {
		var oElement,
			oShadow,
			oUL;

		if (this.parent) {
			oElement = this.element;
			oShadow = oElement.lastChild;
			oUL = this.body.getElementsByTagName("ul")[0];
                    
			oAnim = new YAHOO.util.Anim(oUL, 
			{
				marginTop: { to: 0 }
			}, 0.25/* , YAHOO.util.Easing.easeIn */);

			oAnim.onStart.subscribe(function () {
				oShadow.style.height = "100%";
			});
 
			oAnim.animate();

			if (YAHOO.env.ua.ie) {
				oShadow.style.height = oElement.offsetHeight + "px";
				oAnim.onTween.subscribe(onTween, oShadow, this);
			}

			oAnim.onComplete.subscribe(onAnimationComplete, oShadow, this);
		}
	}

	oMenuBar.subscribe("beforeRender", function () {
		if (this.getRoot() == this) {
			this.getItem(0).cfg.setProperty("submenu", aSubmenuData[0]);
			this.getItem(1).cfg.setProperty("submenu", aSubmenuData[1]);
			this.getItem(2).cfg.setProperty("submenu", aSubmenuData[2]);
			this.getItem(3).cfg.setProperty("submenu", aSubmenuData[3]);
			this.getItem(4).cfg.setProperty("submenu", aSubmenuData[4]);
			this.getItem(5).cfg.setProperty("submenu", aSubmenuData[5]);
			this.getItem(6).cfg.setProperty("submenu", aSubmenuData[6]);
			this.getItem(7).cfg.setProperty("submenu", aSubmenuData[7]);
			this.getItem(8).cfg.setProperty("submenu", aSubmenuData[8]);
		}
	});

/*
	oMenuBar.subscribe("beforeShow", onSubmenuBeforeShow);
	oMenuBar.subscribe("show", onSubmenuShow);
*/
	oMenuBar.render();
});