var Tabs = {

	header : null,

	init : function() {
		
		if (!$$(".tabs .header")) { return; }
		
		Tabs.header = $$(".tabs .header")[0];
	
		ImagePreloader.load([
			"/pitney/images/W-Pitney_ReadingPage-news-state1.jpg",
			"/pitney/images/W-Pitney_ReadingPage-news-state2.jpg"
		]);

		var join_us_tab = new Element("a", {"class" : "join_us_tab", "href" : "#"});
		join_us_tab.observe("click", function(e) { Tabs.select("join_us_tab"); e.stop(); });

		var news_tab = new Element("a", {"class" : "news_tab", "href" : "#"});
		news_tab.observe("click", function(e) { Tabs.select("news_tab"); e.stop(); });
	
		Tabs.header.appendChild(join_us_tab);
		Tabs.header.appendChild(news_tab);
	},
	
	select : function(which_tab) {
		var newClass = "header header_" + which_tab;
		
		Tabs.header.writeAttribute("class", newClass);
		
		var tabs = $$(".tabs .content");
		tabs.each(function(n) {
			if (n.hasClassName(which_tab)) {
				n.removeClassName("hide");	
			} else {
				n.addClassName("hide");
			}
		});
	}

}

document.observe("dom:loaded", Tabs.init);