jQuery(document).ready(function() 
{
	initClassNames();
	setNav(); //nav.js
	if( isHome() )
	{
		setNewsArrows(); //set in animate.js
		setNewsBaseBtns();
	}
	
	if( isDiary() )
	{
		setDiaries(); //set in animate.js
		setDiaryH1Btns(); //set in nav.js
	}
		
	if( getNavName() == '/projects' )
	{
		if( isProjectList() ) //if showing projects in a list
		{
			setProjectAssetThumbs();//set in nav.js
			setProjectImageArrows(); //set in animate.js
		}
		else //if showing individual project page
		{
			setProjectAssetArrows(); //set in animate.js
			fixVerticalText(); //set in hacks.js
		}
	}
	
});


//--- utils --//

function isHome()
{
	if( getNavName() == '/'   ||   getNavName() == '/index'   ||   getNavName() == '/hugh-broughton/' )	return true;
	else																							return false;
}


function isDiary()
{
	if( getNavName().indexOf('/antarctic-diaries') != -1 )	return true;
	else													return false;
}


function getWindowHeight()
{
	var winH;
	
	if (navigator.appName.indexOf("Microsoft")!=-1) 
	{
		winH = document.documentElement.clientHeight;
	}
	else
	{
		winH = window.innerHeight - 2;
	}
	
	return winH;
}


//function getPageName()
//{
//	var sPath = window.location.pathname;
//	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1).split(".html").join("").split(".php").join("");
//	
//	return sPage;
//}


function getNavName()
{
	return window.location.pathname.toString().split('.html').join('').split('.php').join('');
}


function isProjectList()
{
	if( window.location.toString().indexOf( '&id=' ) == -1   &&   window.location.toString().indexOf( '?project-list=' ) != -1   ||  
		window.location.toString().indexOf( '&id=' ) == -1   &&   getNavName() == '/projects' )		return true;
	else																							return false;
}

//
//function isProjectPage()
//{
//	if( window.location.toString().indexOf( '&id=' ) != -1)	return true;
//	else													return false;
//}


function initClassNames()
{
	if (document.getElementsByClassName == undefined) {
		document.getElementsByClassName = function(className)
		{
			var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)");
			var allElements = document.getElementsByTagName("*");
			var results = [];

			var element;
			for (var i = 0; (element = allElements[i]) != null; i++) {
				var elementClass = element.className;
				if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass))
					results.push(element);
			}

			return results;
		}
	}
}


/*function isFF( belowVersion )
{
	var version = parseFloat( jQuery.browser.version.slice(0,3) );
	
	alert( 'FF version: ' + version );
	
	if( jQuery.browser.mozilla   &&   version < belowVersion )
	{
		return true;
	}
	else
	{
		return false;
	}
}*/


function isIE()
{
	if( jQuery.browser.msie )
	{
		return true;
	}
	else
	{
		return false;
	}
}


function isIE6()
{
	if( jQuery.browser.msie   &&   jQuery.browser.version == "6.0" )
	{
		return true;
	}
	else
	{
		return false;
	}
}


function isIE7()
{
	if( jQuery.browser.msie   &&   jQuery.browser.version == "7.0" )
	{
		return true;
	}
	else
	{
		return false;
	}
}

