$(document).ready(function() {

	//Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	$("#pageBanner").addClass($("ul.tabs li.active a").attr("class")); // show the default active banner
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		
		$("#pageBanner").removeClass(); //Remove any active banner
		$("#pageBanner").addClass($("ul.tabs li.active a").attr("class")); // Show the active tab banner
		
		if($("ul.tabs li:last").hasClass("active")){
			$("ul.tabs li:last").removeClass("lastlist"); 
		}else{
			$("ul.tabs li:last").addClass("lastlist");	
		}
		

		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content

		return false;
	});
	
	$("a.mainlevel").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		//$(this).addClass("active"); //Add "active" class to selected tab
		var activeTabHead = $(this).attr("rel"); //Find the rel attribute value to identify the active tab
		$(activeTabHead).addClass("active");
		
		$("#pageBanner").removeClass(); //Remove any active banner
		$("#pageBanner").addClass($("ul.tabs li.active a").attr("class")); // Show the active tab banner
		
		if($("ul.tabs li:last").hasClass("active")){
			$("ul.tabs li:last").removeClass("lastlist");
		}else{
			$("ul.tabs li:last").addClass("lastlist");	
		}
		

		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).attr("href"); //Find the href attribute value to identify the active tab content
		$(activeTab).fadeIn(); //Fade in the active content

		return false;
	});
	
	if(document.location.hash !=''){
		hashtag = document.location.hash;
		jQuery('ul.tabs li a[href*='+hashtag+']').trigger('click');
		$.scrollTo('ul.tabs', 800);
	}

});
