$(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-4)){
			var toLoad = hash+'.php #content';
			$('#content').load(toLoad)											
		}
		});

	$('#navigation li a').click(function(){	  
		var toLoad = $(this).attr('href')+' #content';
		$('#content').hide('fast',loadContent);
		$('#load').remove();
		$('#wrapper').append('<span id="load">LOADING...</span>');
		$('#load').fadeIn('normal');
		window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-4);
		deleteAllMenuStyle('#navigation');
		deleteQuickLinkStyle('#quicklinks');
		$(this).addClass("yuimenubaritemlabel active");
		
		function deleteAllMenuStyle(a){
		$(a).find("li a").each(function(){								 
		$(this).attr('class', 'yuimenubaritemlabel');	
			});
		}
		
		function deleteQuickLinkStyle(a){
		$(a).find("li a").each(function(){								 
		$(this).removeClass('active noClass');	
			});
		}
		
		function loadContent() {
			$('#content').load(toLoad,'',showNewContent())
		}
		function showNewContent() {
		$('#content').show('normal',hideLoader());
		}
		function hideLoader() {
			$('#load').fadeOut('normal');
		}
		return false;
		
	});
	
	$('#quicklinks li a').click(function(){	  
		var toLoad = $(this).attr('href')+' #content';
		$('#content').hide('fast',loadContent);
		$('#load').remove();
		$('#wrapper').append('<span id="load">LOADING...</span>');
		$('#load').fadeIn('normal');
		window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-4);
		deleteAllMenuStyle('#quicklinks');
		deleteAllMenuStyle('#navigation');
		$(this).addClass("active");
		
		function deleteAllMenuStyle(a){
		$(a).find("li a").each(function(){								 
		$(this).removeClass('active noClass');	
			});
		}
		
		function loadContent() {
			$('#content').load(toLoad,'',showNewContent())
		}
		function showNewContent() {
		$('#content').show('normal',hideLoader());
		}
		function hideLoader() {
			$('#load').fadeOut('normal');
		}
		return false;
		
	});
});
