$(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+'.html #content';
			$('#content').load(toLoad)
		}											
	});
	

	$('#nav li a').click(function(){
								  
		clearClicked();
		
		if( $(this).attr('href') == "tab1.php")
			$('#bot2').attr('src', 'img/tab_1-2.png');
		else if( $(this).attr('href') == "tab2.php" )
			$('#bot3').attr('src', 'img/tab_2-2.png');
		else if( $(this).attr('href') == "tab3.php" )
			$('#bot4').attr('src', 'img/tab_3-2.png');
		else if( $(this).attr('href') == "tab4.php" )
			$('#bot5').attr('src', 'img/tab_4-2.png');
								  
		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-5);
		
		function loadContent() {
			$('#content').load(toLoad,'',showNewContent())
		}
		function showNewContent() {
			$('#content').show('normal',hideLoader());
		}
		function hideLoader() {
			$('#load').fadeOut('normal');
		}
		
		function clearClicked()
		{
			$('#bot2').attr('src', 'img/tab_1-1.png');
			$('#bot3').attr('src', 'img/tab_2-1.png');
			$('#bot4').attr('src', 'img/tab_3-1.png');
			$('#bot5').attr('src', 'img/tab_4-1.png');
		}
		
		return false;
		
	});

});
