var j = jQuery.noConflict();


var default_content="";
jQuery(document).ready(function(){



	checkURL();
	jQuery('.navigation li a').click(function (e){
			checkURL(this.hash);
			jQuery('title').html(jQuery(this).attr('title'));//change title
			//jQuery('#pageContent').hide();//hide content ;
			jQuery(this).addClass('selected')
			
	});



	//filling in the default content
	default_content = jQuery('#pageContent').html();
	setInterval("checkURL()",250);
	
});




var lasturl="";
function checkURL(hash)
{
	if(!hash) hash=window.location.hash;
	if(hash != lasturl)
	 
	{
		lasturl=hash;
		// FIX - if we've used the history buttons to return to the homepage,
		// fill the pageContent with the default_content
		if(hash=="")
		jQuery('#pageContent').html(default_content);
		else
		loadPage(hash);
		jQuery('#pageContent').hide();//hide content ;
		jQuery('a[rel=ajax]').removeClass('selected');
	}
}


function loadPage(url)
{
	url=url.replace('#','');
	
	jQuery('#loading').css('visibility','visible');
	
	jQuery.ajax({
		type: "POST",
		url: "load_page.php",
		data: 'page='+url,
		dataType: "php",
		success: function(msg){
			
			if(parseInt(msg)!=0)
			{
				jQuery('#loading').css('visibility','hidden');
				jQuery('#pageContent').html(msg);
				jQuery('#pageContent').fadeIn('slow');
			}
		}
		
	});

}
