$(document).ready(function(){
	
	function initializeTabFromURL() {
		if (self.location.hash == '#news') {
			$("a#tab_1").trigger('click');	
		} else if (self.location.hash == '#tours') {
			$("a#tab_2").trigger('click');	
		} else if (self.location.hash == '#programs') {
			$("a#tab_3").trigger('click');
		}
	}
	
	$("#tab_navigation").show();
	
	initializeTabFromURL();
	
	// This is so the back button will switch tabs
    setInterval(initializeTabFromURL, 300);
	
	$("a")
	   .filter("#tab_1")
		 .click(function(){
		   $("#news_content").show();
		   $("#tours_content, #programs_content").hide(); 
		   $(".news_tab").attr("class","news_tab");
		   $(".tours_tab").attr("class","tours_tab alt_primary");
		   $(".programs_tab").attr("class","programs_tab alt_secondary");
		 })
	   .end()
	   .filter("#tab_2")
		 .click(function(){
		   $("#tours_content").show();
		   $("#news_content, #programs_content").hide();
		   $(".news_tab").attr("class","news_tab alt_primary");
		   $(".tours_tab").attr("class","tours_tab");
		   $(".programs_tab").attr("class","programs_tab alt_secondary"); 
		 })
	   .end()
	   .filter("#tab_3")
		 .click(function(){
		   $("#programs_content").show();
		   $("#tours_content, #news_content").hide();
		   $(".news_tab").attr("class","news_tab alt_primary");
		   $(".tours_tab").attr("class","tours_tab alt_secondary");
		   $(".programs_tab").attr("class","programs_tab");
		 })
	   .end()
	
});	