$(document).ready(function() {
	//animate the logo & banner
	$('#logo').animate({ marginLeft: "-85px" }, 1000);
	$('#banner img').fadeIn(1000);
	
	//animate the nav
	var links = $('.main_nav > li > a');
	links.each(function(index, elm) {
		$(elm).mouseover(function() {
			$(this).animate({ paddingBottom: "+=5px", marginTop: "-=5px" }, 'fast');				  
		});
		$(elm).mouseout(function() {
			$(this).animate({ paddingBottom: "-=5px", marginTop: "+=5px" }, 'fast');
		});
	});
	
	//grab tabs, tab contents, and hide them
	var tabs = $('.tabs > li > a');
	var contents = $('.tab_content');
	contents.hide();
	
	//store animation state
	var animating = false;
	
	//add mouse events
	tabs.each(function(index, tab) {
		$(tab).click(function() {
			if($(tab).hasClass('active')) {
				//tab already active, do nothing
			} else if (animating == true) {
				//animations not finished, do nothing
			} else {
				//hide all content, then show target content
				contents.hide();
				animating = true;
				$(contents[index]).slideDown(1000, function() { animating = false; });
				//change active tab style
				tabs.removeClass('active');
				$(this).addClass('active');
			}
		});
		//animate the tabs
		$(tab).mouseover(function() {
			$(this).animate({ paddingBottom: "+=10px", marginTop: "-=10px" }, 'fast');				  
		});
		$(tab).mouseout(function() {
			$(this).animate({ paddingBottom: "-=10px", marginTop: "+=10px" }, 'fast');
		});
	});
	
	//see if a tab was included in the url
	var page_hash = self.document.location.hash.substring(1);
	var start_tab = tabs.filter(function(index) {
		if(page_hash) {
			return $(this).attr("href") == "#" + page_hash;
		} else {
			return index == 0;
		}
	}).click();
});

