 //On load page, init the timer which check if the there are anchor changes each 300 ms  
$(document).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(){  
			$().ajaxStart(function() { $('#load').show(); });
			$().ajaxStop(function() { $('#load').hide();  });											   
		
    //Check if it has changes  
     if(currentAnchor != document.location.hash){  
         currentAnchor = document.location.hash;  
         //if there is not anchor, the loads the default section  
         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('&');  
             var query = "section=" + section + params;  
         }  
         //Send the petition  
		 
		  if (!section) { section = 'home';  }
		 //$('body').css('background-image', "url(images/"+section+".jpg)"); 

         $.get("callbacks.php",query, function(data){  	
					 //alert(data);
        	$("#conteudo").html(data);
			/*$("#menu ul li ul li").each(function(index){
				var dado = $(this).html().split('href="#');
 				var dado2 =  dado[1].split('">');
				
				var nome = dado2[1].split('</');
				//alert(section+" "+dado2[0]);
				if (section == dado2[0]) { 
					$("#menu ul li ul li a").addClass('ativo');	
				}	else {
					$("#menu ul li ul li a").removeClass('ativo');	
				}
			});*/
	
		});  
		 
}  
 }  
