$(document).ready(function() {
	/////////////////////////
	// Nav Btn Spacing
	////////////////////////
	
	var theNav = $('.navigation ul.mainMenu');
 	var btnCount = theNav.children().length;
	var totalWidth = 0;
	var navWidth = 960;
	/////////
 function formatNav() {
	 clearInterval(spcInt);
		$('li.top').each(function() {
        totalWidth += $(this).width();
		});
    var theDiff = Math.round((navWidth - totalWidth) / (btnCount-1));
	$('li.top').css('margin-right', (theDiff+'px'));
	$('li.top.last').css('margin-right','0');
	//$('#nav-cont').css({'margin-top' : '0', 'display' :'none'});
	$('li.top').fadeIn(2000);
	//alert(theDiff+'px' +'  '+ navWidth+'  '+totalWidth+'  '+btnCount);
};

var spcInt = setInterval(formatNav, 500);


	/////////////////////////
	// Page Fade Transitions
	////////////////////////

	$('#bodyContent').css('display', 'none');
	$('#bodyContent').fadeIn(2000);
	
	/////
	$('a.transition').click(function(event) {
		event.preventDefault();
		linkLocation = this.href;
		$('#bodyContent').fadeOut(500, redirectPage);
		$('li.top').fadeOut(500);
	});
	////
	function redirectPage() {
		window.location = linkLocation;
	};

	////////////////////////
	// Menu Fade Transitions
	////////////////////////

	$('li.top').hover(function() {
		$(this).addClass('hover');
		$('.subMenu', this).css('display', 'none');
		$('.subMenu', this).fadeIn(500);

	}, function() {
		$(this).removeClass('hover');
		$('.subMenu', this).css('display', 'none');
	});

	$('li.top').click(function() {
		$(this).removeClass('hover');
		//$('ul:first', 'ul.dropdown li').css('display', 'none');
	});
	
});

