// companyContactUs.js, used in both the company's contact us and press site's contact us pages.
// Requires the Protoype JavaScript Library

var CompanyTabs = new function() {
	this.allTabIds = ["tab_consumer", "tab_alx", "tab_corporate"];
	this.allTabContentsIds = ["consumer_contacts", "alx_contacts", "corporate_contacts"];

	this.hideTabContents = function() {
		for (var i=0; i < CompanyTabs.allTabIds.length; i++) {
			$(CompanyTabs.allTabContentsIds[i]).hide();
		}
	};

	this.init = function() {
		for (var i=0; i < CompanyTabs.allTabIds.length; i++) {
			// Setup onclick behavior
			$(CompanyTabs.allTabIds[i]).onclick = function(e) {
				// hides all tab contents
				CompanyTabs.hideTabContents(); 

				if (e == "undefined" || e == null) {
					e = window.event;	
				}

				// Show tab contents that was clicked on.
				if (e.target) {
					$( e.target.rel ).show();
				} else if (e.srcElement) {
					$( e.srcElement.rel ).show();
				}

				// Fixes the side gradient and height of containing div.
				sidebar.adjust_height( ); 
				
				// prevent propagation and use of href.
				return false;
			};
		}
	};
};

if (window.addEventListener) {  // DOM compliant
	window.addEventListener("load", CompanyTabs.init, false);
} else { // Assumes window.attachEvent (IE method)
	window.attachEvent("onload", CompanyTabs.init);
}
