$(document).ready(function() {

var hash = window.location.hash.substr(1);
	var href = $('#nav li a').each(function(){
		
		
		var href = $(this).attr('href');

		if(hash==href.substr(0,href.length-5)){
			var toLoad = hash+'.php#content';
			$('#panel').load(toLoad)
		}											
	
	
	});

	$('#nav li a').click(function(){
								  
		var toLoad = $(this).attr('href')+' #panel';
		$('#panel').hide('fast',loadContent);
		$('#load').remove();
		//$('#wrapper').append('<span id="load">Loading...</span>');
		$('#load').fadeIn('normal');
		function loadContent() {
			$('#panel').load(toLoad,'',showNewContent())
		}
		function showNewContent() {
			$('#panel').show('normal',hideLoader());
		}
		function hideLoader() {
			$('#load').fadeOut('normal');
		}
		return false;
		
	});

});


// Animated buttons

var currentItem = null;
var undoTimerHodler = false;
$(document).ready(
	function()
	{
		$('#nav a')
			.bind('mouseover', doItem);
		$('#nav a')
			.bind('mouseout', undoItem);
	}
);

function doItem()
{
	if(undoTimerHodler)
		window.clearTimeout(undoTimerHodler);
	if(currentItem) {
		$(currentItem).animate({height: 36}, 200);
	} else {
		$('#nav a').not(this).animate({height: 36}, 200);
	}
	currentItem = this;
	$(currentItem).animate({height: 42}, 200);
}


function undoItem()
{
	undoTimerHodler = window.setTimeout(undoTimer, 100);
}

function undoTimer()
{
	$('#nav a').animate({height: 36}, 200);
	currentItem = null;
}



	jQuery().ready(function(){
		$.localScroll();
	});





		