//On load page, init the timer which check if the there are anchor changes each 300 ms  
$().ready(function(){
	setInterval("checkAnchor()", 300);
});
var currentAnchor = null;
//Function which check if there are anchor changes, if there are, sends the ajax petition
function checkAnchor(){
	//Check if it has changes
	if(currentAnchor != document.location.hash){
		// Show we're doing something
		$("#loading").show();
		currentAnchor = document.location.hash;
		//if there is not anchor, the loads the default section
		var qstring;
		if(!currentAnchor)
			query = "section=home";
		else
		{
			//Creates the  string callback. This converts the url URL/#main&id=2 in URL/?section=main&id=2
			var splits = currentAnchor.substring(1).split('&');
			//Get the section
			var section = splits[0];
			delete splits[0];
			//Create the params string
			var params  = splits.join('&');
			qstring = "section=" + section + params;
		}
		// I don't make a call if there's no data.
		// JQuery doesn't like it otherwise
		// For now I return success. Later I might not
		if(! qstring){
			$("#loading").hide();
			return true;
		}
		// Send the request

// Here's the difference from the original, which 
// used a 'get', and the ajax call I'm using.
//		$.get("callbacks.php",query, function(data){
//			$("#content").html(data);

		$.ajax({
			type: "POST",
			url: "mfds.cgi",
			cache: false,
			data: qstring,
			success: function(msg){
				$("#content").html(msg);
				$("#loading").hide();
			}
		});
	}  
}  
  