$(document).ready(function () {
	  $.history.init(pageload);	   
		$('a[href=' + document.location.hash + ']').addClass('selected');
		$('a[rel=ajax]').click(function () {
		
			var hash = this.href;
			hash = hash.replace(/^.*#/, '');
	 		$.history.load(hash);	
	 		$('a[rel=ajax]').removeClass('selected');
	 		$('a[href=' + window.location.hash + ']').addClass('selected');
	 	
	 		$('#content').hide();
	 		$('#loading').show();
	 		
			getPage();
	
			return false;
		});	
	});
	
	function pageload(hash) {
	 getPage();    
	}
		
	function getPage() {
		var data = 'page=' + encodeURIComponent(window.location.hash);
		$.ajax({
			url: "ajax_loader.php",	
			type: "GET",		
			data: data,		
			cache: false,
			success: function (html) {	
				$('#loading').hide();				
				$('#content').html(html);
				$('#content').fadeIn('slow');		
        	
			}		
		});
	}
