/* If you make changes to this file you MUST update the query string version 
*  in footer3.dat, footer_wide.dat and /assets/scripts/investors.js
*  example: src="/assets/scripts/header.js?v=2008-02-18"
*  so that the new version is fetched, and not retrieved from cached */

/* make sure p1 namespace is created */
if (!p1) { var p1 = {}; }

/* set up textbox hint overlays */
p1.OverLabel = function(el, posLeft, posTop) {
	/* show/hide textbox hint overlays */
	function hideLabel (field, hide) {
		YAHOO.util.Dom.getElementsByClassName( 'overlabel' , 'label', '', 
			function() {
				var id = this.htmlFor || this.getAttribute('for');
				if (id && id == field.id) { this.style.visibility = (hide) ? 'hidden' : 'visible'; }
			}
		);
	}

	var yui_util = YAHOO.util;
	var yui_Event = yui_util.Event;
	var yui_Dom = yui_util.Dom;	
	
	if (!document.getElementById) return;      
	
	this.input = document.getElementById(el);
	if (!this.input) { return; }
	if (!this.input.title) { return; }
	
	// create the label
	this.label = document.createElement('label');
	this.label.setAttribute('for', el);
	this.label.htmlFor = el;
	this.label.innerHTML = this.input.title;
	yui_Dom.addClass(this.label, 'overlabel');
	
	// position & add the label
	yui_Dom.setStyle(this.label, 'visibility', 'hidden');
	yui_Dom.setStyle(this.label, 'position', 'absolute');
	this.label = this.input.parentNode.insertBefore(this.label, this.input);
	var regInput = yui_Dom.getRegion(this.input);
	var regLabel = yui_Dom.getRegion(this.label);
	switch (posLeft) {
		case 'left':
			posLeft = regInput.left;
			break;
		case 'center':
			var wInput = (regInput.right - regInput.left);
			var wLabel = (regLabel.right - regLabel.left);
			posLeft = regInput.left + Math.ceil((wInput - wLabel) / 2 - 0.5);
			break;
		case 'right':
			var wLabel = (regLabel.right - regLabel.left);
			posLeft = regInput.right - wLabel;
			break;
		default:
			if (YAHOO.lang.isNumber(posLeft)) { posLeft = regInput.left + posLeft; }
	}
	switch (posTop) {
		case 'top':
			posTop = regInput.top;
			break;
		case 'middle':
			var hInput = (regInput.bottom - regInput.top);
			var hLabel = (regLabel.bottom - regLabel.top);
			posTop = regInput.top + Math.ceil((hInput - hLabel) / 2 - 0.5);
			break;
		case 'bottom':
			var hLabel = (regLabel.bottom - regLabel.top);
			posTop = regInput.bottom - hLabel;
			break;
		default:
			if (YAHOO.lang.isNumber(posTop)) { posTop = regInput.top + posTop; }
	}
	yui_Dom.setXY(this.label, [posLeft, posTop]);
	yui_Dom.setStyle(this.label, 'visibility', 'visible');

	// Hide any fields having an initial value.
	if (this.input.value.replace(/^\s+|\s+/g,"") !== '') {
		hideLabel(this.input, true);
	} else {
		hideLabel(this.input, false);
	}
			
	// Set handlers to show and hide labels.
	yui_Event.addListener(this.input, 'focus', 
		function () {
			hideLabel(this, true);
		}
	);
	yui_Event.addListener(this.input, 'blur',
		function () {
			if (this.value.replace(/^\s+|\s+/g,"") === '') { hideLabel(this, false); }
		}
	);
	// Handle clicks to label elements (for Safari).
	yui_Event.addListener(this.input, 'click',
		function () {
			var id, input;
			id = this.getAttribute('for');
			if (id && (input = document.getElementById(id))) {
				input.focus();
			}
		}
	);
	
	return this;
};


/* initialize textbox hint overlays */
YAHOO.util.Event.onContentReady( 'ss_query', function() { var ol_ss_query = p1.OverLabel('ss_query', 'center', 'middle'); } );













// Initialize and render the menu bar when it is available in the DOM
YAHOO.util.Event.onContentReady("menubar-About", function () {

	// "beforerender" event handler for the menu bar
	function onMenuBarBeforeRender(p_sType, p_sArgs) {

		var oSubmenuData = {
			"about": [
				{ text: "About Main Page", url: "http://www.power-one.com/about/" },
				{ text: "Careers", url: "http://www.power-one.com/careers/" }, 
				{ text: "Corporate News", url: "http://investor.power-one.com/releases.cfm" },
				{ text: "Download Catalogs", url: "http://www.power-one.com/cgi-bin/start.cgi/dynamic/selector/catalog_download.html" },
				{ text: "Environmental Policy", url: "http://www.power-one.com/about/environmental_policy.html" },
				{ text: "Graphics Library", url: "http://www.power-one.com/cgi-bin/start.cgi/dynamic/graphic_upload/show_items.html" },
				{ text: "ISO Certifications", url: "http://www.power-one.com/about/environmental_policy.html" },
				{ text: "Power-One Logos", url: "http://www.power-one.com/about/logos/index.html" },
				{ text: "RoHS Compliance", url: "http://www.power-one.com/about/rohs.html" },
				{ text: "Subscribe to RSS News", url: "http://www.power-one.com/feeds/" },
				{ text: "Trade Shows/Conferences", url: "http://www.power-one.com/tradeshow.html" }
			],

			"contacts": [
				{ text: "Contacts Main Page", url: "http://www.power-one.com/contact/" },
				{ text: "Addresses &amp; Maps", url: "http://www.power-one.com/contact/" }, 
				{ text: "Careers", url: "http://www.power-one.com/careers/" },
				{ text: "Investor Contacts", url: "http://investor.power-one.com/contactus.cfm" },
				{ text: "Distributor Locations", url: "http://www.power-one.com/cgi-bin/rep_form.cgi?page_from=distrib" },
				{ text: "Download Catalogs", url: "http://www.power-one.com/cgi-bin/start.cgi/dynamic/selector/catalog_download.html" },
				/* { text: "Order Catalogs", url: "http://www.power-one.com/cgi-bin/start.cgi/dynamic/selector/catalog_form.html" }, */
				{ text: "Price &amp; Delivery", url: "http://www.power-one.com/cgi-bin/start.cgi/dynamic/selector/dcpricendel.html?interest=" },
				{ text: "Product Returns", url: "http://www.power-one.com/cgi-bin/start.cgi/dynamic/selector/rma/rma_start.html" },
				{ text: "Sales Offices", url: "http://www.power-one.com/cgi-bin/rep_form.cgi?page_from=sales" },
				{ text: "Technical Support", url: "http://www.power-one.com/cgi-bin/start.cgi/dynamic/selector/emailtech.html" },
				{ text: "Webmaster", url: "http://www.power-one.com/cgi-bin/start.cgi/dynamic/forms/webmaster.html" }
			],

			"investors": [
				/*
				{ text: "Investors Main Page", url: "http://investor.power-one.com/index.cfm" },
				{ text: "Corporate Governance", url: "http://investor.power-one.com/governance.cfm" },
				{ text: "SEC Filings", url: "http://investor.power-one.com/sec.cfm" },
				{ text: "Stock Quote", url: "http://investor.power-one.com/stockquote.cfm" }
				
				{ text: "Analyst Coverage", url: "http://phx.corporate-ir.net/phoenix.zhtml?c=73416&p=irol-analysts" },
				{ text: "Corporate News", url: "http://phx.corporate-ir.net/phoenix.zhtml?c=73416&p=irol-news&nyo=0" },
				{ text: "General Information", submenu: { id: "general-information", itemdata: [        
						{ text: "Audio Archives", url: "http://phx.corporate-ir.net/phoenix.zhtml?c=73416&p=irol-audioArchives" },
						{ text: "Info Request", url: "http://phx.corporate-ir.net/phoenix.zhtml?c=73416&p=irol-infoReq" },
						{ text: "Investor Events", url: "http://phx.corporate-ir.net/phoenix.zhtml?c=73416&p=irol-Calendar" },
						{ text: "Investor FAQ", url: "http://phx.corporate-ir.net/phoenix.zhtml?c=73416&p=irol-faq" },
						{ text: "Presentations", url: "http://phx.corporate-ir.net/phoenix.zhtml?c=73416&p=irol-presentations" }
					] }
				}, 
				{ text: "Governance", submenu: { id: "governance", itemdata: [        
						{ text: "Introduction", url: "http://phx.corporate-ir.net/phoenix.zhtml?c=73416&p=irol-govhighlights" },
						{ text: "Code of Conduct", url: "http://phx.corporate-ir.net/phoenix.zhtml?c=73416&p=irol-govConduct" },
						{ text: "Committee Composition", url: "http://phx.corporate-ir.net/phoenix.zhtml?c=73416&p=irol-govCommComp" },
						{ text: "Governance Guidelines", url: "http://phx.corporate-ir.net/phoenix.zhtml?c=73416&p=irol-govGuidelines" },
						{ text: "Management & Directors", url: "http://phx.corporate-ir.net/phoenix.zhtml?c=73416&p=irol-govboard" },
						{ text: "Senior Office Code of Ethics", url: "http://media.corporate-ir.net/media_files/irol/73/73416/corpgov/CodeofEthics92404.pdf" }
					] }
				}, 
				{ text: "PWER Performance", submenu: { id: "pwer-performance", itemdata: [        
						{ text: "Current Price", url: "http://phx.corporate-ir.net/phoenix.zhtml?c=73416&p=irol-stockQuote" },
						{ text: "Charting Tools", url: "http://phx.corporate-ir.net/phoenix.zhtml?c=73416&p=irol-stockchart" },
						{ text: "Fundamentals", url: "http://phx.corporate-ir.net/phoenix.zhtml?c=73416&p=irol-fundhighlightsa" }
					] }
				},*/ 
				/*{ text: "SEC Filings", url: "http://phx.corporate-ir.net/phoenix.zhtml?c=73416&p=irol-sec" } /*,
				/*{ text: "Investor Profile PDF", url: "http://www.power-one.com/investor/investor_profile.pdf" } */
				
			],

			"newsroom": [
				{ text: "Corporate News", url: "http://investor.power-one.com/releases.cfm" },
				{ text: "Product News", url: "http://www.power-one.com/investor/press.html" },
				{ text: "Trade Shows/Conferences", url: "http://www.power-one.com/tradeshow.html" },
				{ text: "Subscribe to RSS News", url: "http://www.power-one.com/feeds/" }
			],

			"tech-reference": [
				{ text: "Tech Reference Main Page", url: "http://www.power-one.com/technical/" },
				{ text: "Graphics Library", url: "http://www.power-one.com/cgi-bin/start.cgi/dynamic/graphic_upload/show_items.html" }, 
				{ text: "Industry Links", url: "http://www.power-one.com/technical/x_links.html" },
				{ text: "Power-One Logos", url: "http://www.power-one.com/about/logos/index.html" },
				{ text: "Regulatory Agencies", url: "http://www.power-one.com/technical/x_regulate.html" },
				{ text: "Technical Articles", url: "http://www.power-one.com/technical/x_tech-articles.html" }
			]
		};

		// Add a submenu to each of the menu items in the menu bar
		this.getItem(0).cfg.setProperty("submenu", { id: "menu-About", zindex: 10, itemdata: oSubmenuData["about"] });
		this.getItem(1).cfg.setProperty("submenu", { id: "menu-Contacts", zindex: 10, itemdata: oSubmenuData["contacts"] });
		// this.getItem(2).cfg.setProperty("submenu", { id: "menu-Investors", zindex: 10, itemdata: oSubmenuData["investors"] });
		this.getItem(3).cfg.setProperty("submenu", { id: "menu-Newsroom", zindex: 10, itemdata: oSubmenuData["newsroom"] });
		this.getItem(4).cfg.setProperty("submenu", { id: "menu-Tech-Reference", zindex: 10, itemdata: oSubmenuData["tech-reference"] });
	}

	/*
		 Instantiate the menubar.  The first argument passed to the 
		 constructor is the id of the element in the DOM that 
		 represents the menubar; the second is an object literal 
		 representing a set of configuration properties for 
		 the menubar.
	*/
	var oMenuBar = new YAHOO.widget.MenuBar("menubar-About", { autosubmenudisplay: true, showdelay: 250, hidedelay: 750, lazyLoad: true });

	// Subscribe to the "beforerender" event
	oMenuBar.beforeRenderEvent.subscribe(onMenuBarBeforeRender);

	/*
		 Call the "render" method with no arguments since the markup for 
		 this menu already exists in the DOM.
	*/
	oMenuBar.render();          
});




