	$(document).ready(function()
	{	 
	    // Check for hash value in URL. If there is no hash then load the script for this page itself.
		var hash = window.location.hash.substr(1);
		
		if (hash.length > 0)
		{
			var href = $('#nav a').each(function()
			{
				var href = $(this).attr('href');
				
				if(hash==href.substr(0,href.length-4))
				{
					loadPage( hash );
				} 
			});
		}
		else
		{
			var sPath = window.location.pathname;
			var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
			
			$.getScript(sPage + '.js');
			
			activateLightbox();
		}
    
		$('#nav a').click(function()
		{					
			var pageName = $(this).attr('href').substr(0,$(this).attr('href').length-4);

			loadPage( pageName );
			
			return false;		
		});
	});
	
	function loadPage( pageName )
	{
		$('#contentHolder').load(pageName + '.php #content', '', function() 
		{
			var scriptFile = pageName + '.js';
			
			$.getScript(scriptFile);
			
			activateLightbox();
		});
								
		window.location.hash = pageName;
	}

	function activateLightbox()
	{
		// Activate any lightbox images
		$('a.lightbox').lightBox();
		$('area.lightbox').lightBox();
	}	