/*
 * Hook called on load
 */
function apostropheReady() {
	spaceTabs();
	aBackgroundSize();	
	wordmarkHover();
}

function wordmarkHover() {
	$(".a-header h1").hover(function() {
		$("h1 > a[id='duke']").addClass("duke-over").removeClass("duke-out");
		$("h1 > a[id='department']").addClass("department-over").removeClass("department-out");
	},
	function() {
		$("h1 > a[id='duke']").addClass("duke-out").removeClass("duke-over");
		$("h1 > a[id='department']").addClass("department-out").removeClass("department-over");
	});
}

function spaceTabs ()
{
	var navMain = $('.a-nav-main')
	var navItems = navMain.children('li');
	var navItemCount = navMain.children().length;

	if ( navItemCount > 1)
		{
			//var totalwidth = 0;
			var totalwidth = 960 - (navItemCount + 1);

			//$(navItems).each(function() {
			//	totalwidth += $(this).outerWidth();
			//});
//alert (navItemCount);
//alert (totalwidth);
			//var whiteSpace = 960 - totalwidth;
			
			//var itemmargin = (whiteSpace / (navItemCount));
			var itemwidth = (totalwidth / (navItemCount))
			//navItems.children('a').css('paddingLeft', Math.floor(itemmargin / 2));
			//navItems.children('a').css('paddingRight', Math.floor(itemmargin / 2));
			navItems.children('a').css('width',(itemwidth))
			navMain.css('visibility','visible');
		}
}

function aBackgroundSize()
{
	if (!Modernizr.backgroundsize)
	{
		// For Browsers that do not suport background-size
		apostrophe.log('aBackgroundSize');
		var w = $(window);

		if (!$.browser.msie)
		{
			w.resize(function(){
				aBackgroundSize();
			});			
		}
		
		// Checking window size against image aspect ratio.
		if ((w.width()/w.height()) < (4/3)) 
		{			
			$('body').addClass('tall');
			apostrophe.log('tall');			
		}
		if ((w.width()/w.height()) > (4/3))
		{
			$('body').removeClass('tall');
			apostrophe.log('wide');
		}
	}
}

