var default_content="";

$(document).ready(function(){
	checkURL();
	$('ul li a').click(function (e){

			checkURL(this.hash);

	});
	
	default_content = $('#corpo_buscar').html();
	
	setInterval("checkURL()",250);
	
});

var lasturl="";

function checkURL(hash)
{
	if(!hash) hash=window.location.hash;
	
	if(hash != lasturl)
	{
		lasturl=hash;
		
	
		if(hash=="")
		$('#conteudo').html(default_content);
		
		else
		loadPage(hash);
	}
}


function loadPage(url)
{

	url=url.replace('#','');
	url=url.replace('/','&');
	url=url.replace('/','=');
	
	$('#carregando').css('visibility','visible');
	$("#conteudo").fadeIn("normal");
	
	$.ajax({
		type: "POST",
		url: "load_page.php",
		data: 'incdir='+url,
		dataType: "php",
		success: function(msg){
			
			if(parseInt(msg)!=0)
			{	
				$('#conteudo').fadeIn("normal");	
				$('#conteudo').html(msg);
				$('#carregando').css('visibility','hidden');
				
				
			}
		}
		
	});

}

function atualizar()
{
   if(navigator.userAgent.indexOf("MSIE") != -1){
   	history.go(0);
   }else{
   	window.location.reload();
   }
}

function rolagem(){
	$('html,body').animate({scrollTop: $('#conteudo').offset().top}, 500);
}

function rolagemTopo(){
	$('html,body').animate({scrollTop: $('#inutil').offset().top}, 500);
}

function abrirPortfolio(){
	document.forms["formPortfolio"].submit();
}

function exePlayer(midia,titulo){
	 $('html,body').animate({scrollTop: $('#box').offset().top}, 1000);
	document.getElementById("box_conteudo_titulo2").innerHTML = titulo;
	ajax('#play/midia/'+midia,'playerindex');
}

function exePlayer2(midia,id){
	 ajax('#play/midia/none','playerindex');
	 document.getElementById("box_conteudo_titulo2").innerHTML = '';
	 ajax('#play_modal/midia/'+midia,id);
}


