var WTabs = {};
WTabs.tabsCon = "#tabArea";
WTabs.pickTab= "0";
WTabs.Load= 1;
WTabs.index = 0;
WTabs.Max = 9;

WTabs.setupTabs = function(){
	$("#whereTabs").css({"display":"block"});
	$("#contentRef").css({"display":"none"});
	$(WTabs.tabsCon).addClass("jsStyle");
	//1) determine active tab, set as active
	if(window.location.hash.length>0){
		if(window.location.hash.split("#")[1].match("pnl")){
			WTabs.pickTab="#"+window.location.hash.split("#")[1];
			WTabs.chooseTab("tab-all");
		}else{
			WTabs.chooseTab("tab-"+window.location.hash.split("#")[1]);
		}
	}else{
		WTabs.chooseTab("tab-all");
	}
	$("#whereTabs li a").click(function(){ 
		WTabs.chooseTab("tab-"+this.href.split("#")[1]);
		return false;
	});
	$(WTabs.tabsCon+" #productList li a").bind("mouseenter",function(){
		if(!this.className.match("active")){
			$(this).children("span").css({"opacity":"0"});//,"height":"0px"
			$(this).children("span").animate({"opacity":"1"},300);	//,"height":"100%"
		}
	});
	$(WTabs.tabsCon+" #productList li a").bind("mouseleave",function(){
		if(!this.className.match("active")){
			$(this).children("span").animate({"opacity":"0"},300);	//,"height":"0px"
		}
	});
	$(WTabs.tabsCon+" #productList li a").click(function(){
		WTabs.switchPanel( "#"+this.href.split("#")[1], this );
		return false;
	});
	//5) setUp slider
	//longSlider();
	
};

WTabs.chooseTab = function(cN){
	$("#tabArea .previous, #tabArea .next, #tabArea .ends").remove();
	$(".slider").css({"left":"0px"});
	$("#whereTabs li a").removeClass("active");
	$("#whereTabs li a."+cN).addClass("active");
	switch(cN){
		case "tab-rx":
			$(WTabs.tabsCon+" #productList li").addClass("hide").removeClass("activeOption");
			$(WTabs.tabsCon+" #productList li.tabrx").removeClass("hide").addClass("activeOption");
			break;
		case "tab-non-rx":
			$(WTabs.tabsCon+" #productList li").removeClass("hide").addClass("activeOption")
			$(WTabs.tabsCon+" #productList li.tabrx").addClass("hide").removeClass("activeOption");
			$(WTabs.tabsCon+" #productList li.tabNorx").removeClass("hide").addClass("activeOption");
			break;
		default:
			$(WTabs.tabsCon+" #productList li").removeClass("hide").addClass("activeOption");
			break;
	}
	if(WTabs.Load == 1){
		if(WTabs.pickTab!="0"){
			var a = $(WTabs.tabsCon+" #productList .activeOption a")[0];
			for(var i=0;i<$(WTabs.tabsCon+" #productList .activeOption a").length;i++){
				if($(WTabs.tabsCon+" #productList .activeOption a")[i].href.match(WTabs.pickTab)){
					a = $(WTabs.tabsCon+" #productList .activeOption a")[i];	
				}
			}
			WTabs.switchPanel( "#"+a.href.split("#")[1], a );	
		}else{
			WTabs.switchPanel( "#"+$(WTabs.tabsCon+" #productList .activeOption a")[0].href.split("#")[1], $(WTabs.tabsCon+" #productList .activeOption a")[0] );
		}
		WTabs.Load = 0;
	}else{
		WTabs.switchPanel( "#"+$(WTabs.tabsCon+" #productList .activeOption a")[0].href.split("#")[1], $(WTabs.tabsCon+" #productList .activeOption a")[0] );
	}
	WTabs.setupSlide();
};

WTabs.switchPanel = function(val,t){
	$(".contentPanel").animate({"opacity":"0"},300,function(){
		$(".contentPanel *").remove();
		WTabs.openPanel(val);
	});
	$(WTabs.tabsCon+" #productList li a.active span").animate({"opacity":"0"},200);	
	$(WTabs.tabsCon+" #productList li a").removeClass("active");
	$(t).addClass("active");
	$(t).children("span").animate({"opacity":"1"},200);	
};

WTabs.openPanel = function(val){
	$(".contentPanel")[0].innerHTML += $(val)[0].innerHTML;
	$(".contentPanel").animate({"opacity":"1"},300,function(){});
	$('.contentPanel img').ifixpng();
};

WTabs.setupSlide = function(){
	var lsConfig = {};
	lsConfig.SliderItems = "li.activeOption a";
	lsConfig.Slider = "#productList ul";
	lsConfig.SliderWrap = "#tabArea";
	lsConfig.accelertation = .5;
	lsConfig.slideAmount = 63;
	lsConfig.numtoShow = 9;
	lsConfig.moveSpeed = 25;
	
	longSlider(lsConfig);
}
/*WTabs.Slide = function(nI){
	
}*/
