﻿$(document).ready(function(){

 checkURL();
	//References
	var sections = $("span a");
	var loading = $("#loading");
	var content = $("#loadjs"); 

       content.load('set.php')

	setInterval("checkURL()",250);
$("#loadingx").hide();

});
var lasturl="";	//here we store the current URL hash

function checkURL(hash)
{

	if(!hash) hash=window.location.hash;	//if no parameter is provided, use the hash value from the current address

	if(hash != lasturl)	// if the hash value has changed
	{
		lasturl=hash;	//update the current hash
		loadPage(hash);	// and load the new page
	}
}

function loadPage(url)	//the function that loads pages via AJAX
{
	url=url.replace('#','');	//strip the #page part of the hash and leave only the page number
$("#loadingx").show();
$("#section_recent").fadeOut("slow");
;
	$.ajax({	//create an ajax request to load_page.php
		type: "POST",
		url: "set.php",
		data: 'page='+url,	//with the page number as a parameter
		dataType: "html",	//expect html to be returned
		success: function(msg){
		$("#section_recent").fadeIn("slow")
$("#loadingx").hide();

			if(parseInt(msg)!=0)	//if no errors
			{
				$('#loadjs').html(msg);	//load the returned html into pageContet
			}
		}

	});

}

