J=jQuery.noConflict();


J(document).ready(function(){
	var w=0;
	var i=0;
	var max = 230;
	var tabPositions=new Array();
	var current=0;
	J("#tabs li").each(function(){
		tabPositions[i]=w;
		w+=J(this).width();
		w+=parseInt(J(this).css("padding-left"));
		
		i++;
	});
	
	//alert(tabPositions.length);
	
	if(w>max){
		J("#tabs").width(w+max);
		J("#scroll_left").show();
		J("#scroll_left").click(function(e){
			if(current<=tabPositions.length-1){
				if(current<tabPositions.length-1){
					current++;
				}
				J("#tabs").animate({"left":29-tabPositions[current]+"px"},"slow");
				J("#scroll_right").show("slow");
				if(w-tabPositions[current]<=max){
					J(this).hide("slow");
				}
			}
		});
		
		J("#scroll_right").click(function(e){
			if(current>0){
				current--;
				var diff=29;
				if(current==0){
					diff=0;
					J(this).hide("slow");
				}
				J("#tabs").animate({"left":diff-tabPositions[current]+"px"},"slow");
				J("#scroll_left").show("slow");
			}
		});
	}
	
	
	var firstTab=J("#tabs li:first a");
	var tabID=firstTab.attr("rel");
	
	firstTab.parent().addClass("active");
	J("#"+firstTab.attr("rel")).removeClass("hidden");

	J("#tabs li a").each(
		function(){
			J(this).click(function(){
				var tab=J(this);
				J("#tabs li").each(
				function(){
					J(this).removeClass("active");
				});
				
				tab.parent().addClass("active");
				tabID=tab.attr("rel");
				
				J("#tab_content div").addClass("hidden");
				J("#tab_content div.column").removeClass("hidden");
				
				J("#"+tabID).removeClass("hidden");
				
				return false;
			});
			
		}
	);
	
	// J("#tab_content table tr").each(
	// 	function(row){
	// 		J(this).mouseover(function(){
	// 			//J(this.firstChild).hide();
	// 			var cityLink=J(this).find("a");
	// 			var imageURL=J(cityLink[0]).attr("rel");
	// 			J("#"+tabID+" .chart_image").attr("src",imageURL);
	// 
	// 			J(this).addClass("rollover");
	// 
	// 		});
	// 
	// 		J(this).mouseout(function(){
	// 			J(this).removeClass("rollover");
	// 		});
	// 	});
});




/*
J=jQuery.noConflict();

J(document).ready(function(){
	var w=0;
	J("#tabs li").each(function(){
		w+=J(this).width();
		w+=parseInt(J(this).css("padding-left"));
	});

	if(w>300){
		J("#tabs").width(w);
		J("#scroll_left").show();
		J("#scroll_left").click(function(e){
			J("#tabs").animate({"left":(300-w)+"px"},"slow");
			J(this).hide("slow");
			J("#scroll_right").show("slow");
		});
		
		J("#scroll_right").click(function(e){
			J("#tabs").animate({"left":"0"},"slow");
			J(this).hide("slow");
			J("#scroll_left").show("slow");
		});
		
	}
	
	
	var firstTab=J("#tabs li:first a");
	var tabID=firstTab.attr("rel");
	
	firstTab.parent().addClass("active");
	J("#"+firstTab.attr("rel")).removeClass("hidden");

	J("#tabs li a").each(
		function(){
			J(this).click(function(){
				var tab=J(this);
				J("#tabs li").each(
				function(){
					J(this).removeClass("active");
				});
				
				tab.parent().addClass("active");
				tabID=tab.attr("rel");
				
				J("#tab_content div").addClass("hidden");
				
				J("#"+tabID).removeClass("hidden");
				
				return false;
			});
			
		}
	);
	
	J("#tab_content table tr").each(
				function(row){
					J(this).mouseover(function(){
						//J(this.firstChild).hide();
						var cityLink=J(this).find("a");
						var imageURL=J(cityLink[0]).attr("rel");
						J("#"+tabID+" .chart_image").attr("src",imageURL);
						
						J(this).addClass("rollover");
					
					});
					
					J(this).mouseout(function(){
						J(this).removeClass("rollover");
					});
					
	
	
				});
	
	
});


*/