$(document).ready(function() {
	$('a.external').click(function() {
    	window.open(this.href);
    	return false;
	 });
	$('h4.toggle').click(function() {
		$(this).toggleClass('h4on')
		$(this).next('div').slideToggle();
		return false;
	});
	$('h3.toggle').click(function() {
		$(this).toggleClass('h3on')
		$(this).next('div').slideToggle();
		return false;
	});
	$(function(){
		$('#nav li.on a')
			.css( {backgroundPosition: "0 -150px"} )
			.mouseover(function(){
				$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:500})
			})
			.mouseout(function(){
				$(this).stop().animate({backgroundPosition:"(0 -150px)"}, {duration:500})
			})
	});
	//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
	
	//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
		$(".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#login-panel').click(function() {
    	$('#uberpanel').slideToggle();
    	return false;
	 });
	$("ul.subnav li:last-child").addClass("nob"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
	$("ul.topnav li a").hover(function() { //When trigger is clicked...
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click
		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});
		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() { 
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
});

