
var tabset = new Class( {
	initialize: function(tabNavigation, tabGroup, selectedTab, tabClassSelector) {
		this.tabNavigation = tabNavigation;
		this.tabGroup = tabGroup;
		this.selectedTab = selectedTab;
		this.tabContainers = $$(tabClassSelector);
		this.location = window.location.hash;
		
		if($E(this.location)&& this.location !="" && this.location !=null) {
			this.selectedTab = $E(this.location);
		}
						
		(this.tabContainers).each(function(el, i) {
			if(el != this.selectedTab) {
				el.setStyle("display", "none");
			}	
		}, this);
		
		(this.tabNavigation).each(function(el, i) {
			if(el.hash == "#"+this.selectedTab.id) {
				el.addClass("on");
			}
			el.bindObj = this;
			el.onclick = this.selectTab;
			
			//el.onmouseover = this.changeRolloverState;
			
		}, this);
	},
	changeRolloverState: function() {
		var anchor = this;
		if (anchor.hasClass("on")) return;
	},
	selectTab: function () {
		this.bindObj.hideAllTabs();
		//var targetTabIDWithHash = $(this).getProperty("href");
		var targetTabIDWithHash = this.getAttribute("href",2);
		//targetTabIDWithHash  = this.hash.slice(1);
		
		targetTabIDWithHash = targetTabIDWithHash.substring(targetTabIDWithHash.indexOf("#"))
		
		
		var targetTab = $E("div"+targetTabIDWithHash);
		
		$$(targetTabIDWithHash).setStyle("display", "block");
		this.addClass("on");
		
		return false;
	},
	hideAllTabs: function() {
		(this.tabContainers).each(function(el, i) {
			el.setStyle("display", "none");	
		});
		
		(this.tabNavigation).each(function(el, i) {
			el.removeClass("on");
		});
	}
});
	
window.addEvent('domready', function(){
	var myTabs = new tabset($$("div#crossSell ul.tabNavigation li a"), "mygroup", $("tab1"), $$("div#crossSell div.tab"));
	var myPsiTabs = new tabset($$("div#productSupportInfo ul.tabNavigation li a"), "myPsigroup", $("psiTab1"), $$("div#productSupportInfo div.tab"));
	var ffProductDetails = new tabset($$("div#productInformation ul.tabNavigation li a"), "productInformation", $("productInformation01"), $$("div#productInformation div.tab"));
	var myStoreDetailsTabs = new tabset($$("div#storeDetailsTabControl ul.tabNavigation li a"), "myStoreDetailsgroup", $("storedetailstab1"), $$("div#storeDetailsTabControl div.tab"));
	var genericTabs = new tabset($$("div#genericTabbed ul.tabNavigation li a"), "genericTabbedGroup", $("generictab1"), $$("div#genericTabbed div.tab"));
});