var tabManager = function(){
	this.switchTab = function(tabsection,tabid){
		tabtoactivate = $(tabid);
		
		//activate this item
		$$('[rel="' + tabsection + '"]').each(function(skipelement,ele){
			
			ele = ele.down();
			
			console.log("checking element " + ele.id);
			
			if (ele.id != skipelement.id){
				//deactivate
				ele.removeClassName('activeTab');
				SPNC.moveImageIndex(ele,0);
				
				//hide any content
				$('content_' + ele.id).hide();
			}
		
		}.bind(this,tabtoactivate));
		
		//switch
		tabtoactivate.addClassName('activeTab');
		SPNC.moveImageIndex(tabtoactivate,2);		
		//show any content
		$('content_' + tabtoactivate.id).show();
	};
	
	this.init = function(){
		//initialize the various tab sections
		$$('a[class~="defaultTab"]').each(function(ele){
			this.switchTab(ele.rel,ele.down().id);
		});
	};
	
	return this;
}();

//request startup
Event.observe(document,'hoverize:upgradecomplete',tabManager.init);