function pageload(hash) {

	var caminho=hash.split("/");

	$("#content").html("");
	$("#content").hide();
	$("#portfolio").html("");
	$("#portfolio").hide();
	window.scrollTo(0, 0);

	if(caminho[0]=="portfolio" || caminho[0]=="portfolio_item"){
			
			$("#menu").animate({'left':'830'},600, function(){
				pageload_ajax(hash);
			});
	}else{
		$("#accordion_menu").css('visibility','hidden');
		$("#menu").animate({'left':'0'},600, function(){
			pageload_ajax(hash);
		});
	}
}

function pageload_ajax(hash) {

	var caminho=hash.split("/");
	if(hash) pagina=caminho[0]; else pagina="inicio";
		
	$.ajax({
			type: "GET", 
			url: pagina+".php", 
			beforeSend: function(){
				$("#load").html("<b>Carregando...</b>");
			},
			data: caminho[1]+"="+caminho[2]+"&indice="+caminho[3], 
			success: function(resp){ 
					
				if(caminho[0]=="portfolio" || caminho[0]=="portfolio_item"){
					$("#accordion_menu").css('visibility','visible');
					$("#portfolio").html(resp);
					$("#portfolio").fadeIn('slow');
				}else{
					$("#content").html(resp);
					$("#content").fadeIn('slow');
				}

				$("#load").html("");
				
			}, 
			error: function(e){ 
				alert('Error: ' + e);
			} 
	});
}


$(document).ready(function(){

$.historyInit(pageload);

$("a").live("click",function(){
	if ($(this).hasClass('navAjax')){
		var hash = this.href;
		hash = hash.replace(/^.*#/, '');
		$.historyLoad(hash);
		return false;
	}
});



// this initialises the demo scrollpanes on the page.
	$('#tipo_projeto').jScrollPane({'dragMinHeight':20,'dragMaxHeight':20});
	
// this initialises the demo scrollpanes on the page.
	$('#cliente').jScrollPane({'dragMinHeight':20,'dragMaxHeight':20});
	
// this initialises the demo scrollpanes on the page.
	$('#data').jScrollPane({'dragMinHeight':20,'dragMaxHeight':20});

$(".accordion_header_data").click( function () {
	$("#submenu_data").hide;
	$("#submenu_data").show;	
	return false;
  }); 

	$("#submenu_cliente").hide();
	$("#submenu_tipo_projeto").hide();
	$("#submenu_data").hide();

$(".accordion_header_data").toggle(function() {
	$("#submenu_data").show('slow');
	}, function() {
	$("#submenu_data").hide('slow');
});

$(".accordion_header_tipo_projeto").toggle(function() {
	$("#submenu_tipo_projeto").show('slow');
	}, function() {
	$("#submenu_tipo_projeto").hide('slow');
});

$(".accordion_header_cliente").toggle(function() {
	$("#submenu_cliente").show('slow');
	}, function() {
	$("#submenu_cliente").hide('slow');
});

$('body').mousemove(function(event) {
   $('#load').css({
	 top: (event.pageY + 10) + 'px',
	 left: (event.pageX + 10) + 'px'
   });
}); 			


});
		

