$(function() {

	var navWidth = ($("body").width() - 960) / 2;
	
	$("#navBgBar").width(navWidth);

	// navigation "on" animation
	var currentPage = "#" + $("body").attr("class");
	var delay;
	
	
	// set special sub-pages to render as parent page
	if($("body").attr("class") == 'news_detail') {
		currentPage = "#news";
	}
	
	if($("body").attr("class") == 'portfolio_contact') {
		currentPage = "#portfolio";
	}
	
	
	// delay animation of on class to match with nav bar swf
	switch(currentPage) {
		case '#services':
			delay = 400;
			break;
		case '#about':
			delay = 600;
			break;	
		case '#portfolio':
			delay = 700;
			break;
		case '#news':
			delay = 800;
			break;
		default:
			delay = 400;
	}
	
	$(currentPage).find("span").addClass("on").animate({opacity: 1.0}, delay).animate({marginTop:'0'}, 150);
	
	// navigation tab animation
	$("#main-nav li").hover(function(){
		$(this).find("span").animate({marginTop:'0'},{queue:false,duration:150});
	}, function(){
	
		if(!$(this).find("span").hasClass("on")) {
			$(this).find("span").animate({marginTop:'18px'},{queue:false,duration:150});
		}
	});

});