//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 chek if there are anchor changes, if there are, sends the ajax petition
function checkAnchor(){
	//Check if it has changes
	if(currentAnchor != document.location.hash){
		currentAnchor = document.location.hash;
		//if there is not anchor, the loads the default show
		if(!currentAnchor)
			query = "show=empty";
		else
		{
			//Creates the  string callback. This converts the url URL/#main&id=2 in URL/?show=main&id=2
			var splits = currentAnchor.substring(1).split('&');
			//Get the show
			var show = splits[0];
			delete splits[0];
			
			// faw - get the id split
			var eventid = splits[1];
			var eventsplits = eventid.split('=');
			var eventid = eventsplits[1];
			
			//document.write (eventid);
			
			//Create the params string
			var params = splits.join('&');
			var query = "show=" + show + params;
		}
		//Send the petition
		// fawtodo
		$.get("http://www.rfll.ch/wp-content/plugins/refill-events/callbacks.php",query, function(data){ 
			$(".loaded" + eventid).html(data); 
		});
	}
}

