
var tabset = new Class( {	
	initialize: function(tabNavigation, tabGroup, selectedTab, tabClassSelector) {
		var htmlEleObj;
		this.tabNavigation = tabNavigation;
		this.tabGroup = tabGroup;
		this.selectedTab = selectedTab;
		this.tabContainers = $$(tabClassSelector);
		
		(this.tabContainers).each(function(el, i) {
			if(el != selectedTab) {
				el.setStyle("display", "none");
			}	
		});
		
		(this.tabNavigation).each(function(el, i) {
			if(el.hash == "#"+selectedTab.id) {
				el.addClass("on");
			}
			el.bindObj = this;
			el.onclick = this.selectTab;
		}, this);
	},
	selectTab: function () {
		
		htmlEleObj=this;
		this.bindObj.hideAllTabs();
		//var targetTabIDWithHash = $(this).getProperty("href");
		var targetTabIDWithHash = this.getAttribute("href",2);
		//alert("inside tab for "+targetTabIDWithHash);
		if(targetTabIDWithHash == "#tab2"){
		
			if(document.personal_info.CheckContent.value == ""){
				alert("please fill your personal details before you proceed");
				targetTabIDWithHash="#tab1";

				htmlEleObj=document.getElementById('tt1');
			}else{
			
				htmlEleObj=document.getElementById('tt2');
			}
		}

		if(targetTabIDWithHash == "#tab3"){
		
			if(document.Bank_details.CheckContent.value == ""){
				
				
				if(document.personal_info.CheckContent.value != ""){
					alert("please fill your contact details before you proceed");
					document.getElementById('tt1').removeClass("on");
					htmlEleObj=document.getElementById('tt2');		
					targetTabIDWithHash="#tab2";
				
				}else{
						alert("please fill your personal details before you proceed");
						htmlEleObj=document.getElementById('tt1');				
						targetTabIDWithHash="#tab1";
				}




			}
		}


		var targetTab = $E("div"+targetTabIDWithHash);
	//	alert("targetTabIDWithHash"+targetTabIDWithHash);
		$$(targetTabIDWithHash).setStyle("display", "block");
		
		//alert(document.getElementById('tt1'));
		htmlEleObj.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 myStoreDetailsTabs = new tabset($$("div#storeDetailsTabControl ul.tabNavigation li a"), "myStoreDetailsgroup", $("storedetailstab1"), $$("div#storeDetailsTabControl div.tab"));
});

