// HISTORICO
	function pageload(hash) {		
		// hash doesn't contain the first # character.
		if(hash) {
			// restore ajax loaded state
			$("#conteudo").load(hash + ".php");
		} else {
			// start page
			$("#conteudo").load("principal.php");
		}
	}
	
	$(document).ready(function(){
	// Initialize history plugin.
	// The callback is called at once by present location.hash. 
	//Autocomplete
		function log(event, data, formatted) {
		$("<li>").html( !data ? "No match!" : "Selected: " + formatted).appendTo("#result");
	}
	
	function formatItem(row) {
		return row[0] + " (<strong>id: " + row[1] + "</strong>)";
	}
	function formatResult(row) {
		return row[0].replace(/(<.+?>)/gi, '');
	}
	
	$("#anunciante").autocomplete("search.php", {
		width: 260,
		selectFirst: false
	});
	$("#anunciante").result(function(event, data, formatted) {
		if (data)
			$(this).parent().next().find("input").val(data[1]);
	});
	//Final Autocomplete
	var options = {target: '#conteudo'}; 

    $('#pesquisa').submit(function() { 
        $(this).ajaxSubmit(options); 
        return false; 
    }); 
function showRequest(formData, jqForm, options) { 
    var queryString = $.param(formData); 
 
    return true; 
} 
function showResponse(responseText, statusText, xhr, $form)  { 
}

	$.historyInit(pageload);
	
	// set onlick event for buttons
	$("a[@rel='history']").livequery('click',function(){		
		var hash = this.href;
		hash = hash.replace(/^.*#/, '');
		// moves to a new page. 
		// pageload is called at once. 
		
		$("#conteudo").html('<table width="100%" height="600" bgcolor="#FFFFFF" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle"><img src="images/load.gif" /></td></tr></table>');
		$.historyLoad(hash);
		return false;
		
	});
	});
	//FIM DO HISTORICO


