
	function lookup(inputString) {
	
		if(inputString.length == 0) {
		
			// Hide the suggestion box.
			$('#suggestions').hide();
		} else {
			$("#idHide").val("");				
			$.post("ajax.php", {queryString: ""+inputString+""}, function(data){				
				if(data.length >0) {
					$('#suggestions').show();
					$('#autoSuggestionsList').html(data);
				}
			});
		}
	} // lookup	
		
	
	function fill(thisValue,thisValueId) {
		$('#inputString').val(thisValue);
		$('#idHide').val(thisValueId);
		setTimeout("$('#suggestions').hide();", 200);
	}
	
	function ajax(url)
	{
		
		req = null;
		
		if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange;
		req.open("GET",url,true);
		req.send(null);
		
		} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {		
		req.onreadystatechange = processReqChange;
		req.open("GET",url,true);
		
		req.send();
		}
		}
	}
	
	function processReqChange()
	{
		if (req.readyState == 1) {
		document.getElementById('content').innerHTML = 	"Carregando, por favor aguarde...";
		}else if (req.readyState == 4) {	
			if (req.status ==200) {
			document.getElementById('content').innerHTML = req.responseText;
			} else {
			alert("Houve um problema ao obter os dados:n" + req.statusText);
			}
		}
	}
		
		
	function pesquisa(pag){
            url="ajax_resultado.php?_pagi_pg="+pag;
            ajax(url);
    }
		
	function exibirProdutosAjax(id,tipo){	
		$.post("produtos.php",{id: id, tipo: tipo},function(data){			
		// recebe a resposta da segunda página dentro da função (data)
		$("#content").html("");
		$("#content").html(data);
		});
	}
	
	$(function(){ 
						
		$("#buscar").click( function(){ // quando clicar no botao enviar id=enviar
		var id = $("#idHide").val(); // pego o valor do input id nome e coloco na variavel nome
		var tipo = $("#tipo").val(); // pego o valor do input id telefone e coloco na variavel
		
		if(id!=""){
		
			// passo por parametro as variaveis por post para a segunda pagina e retorno na
			//função (data)
			$.post("produtos.php",{id: id, tipo: tipo},function(data){
			
			// recebe a resposta da segunda página dentro da função (data)
			$("#content").html(data); 
			
			}); // fecho o $.post
		
		}else{
			return false;
		}

		}); 
	
		limpaValores = [];
		$(".limpa_valor").each(function(i){
		        limpaValores[i] = $(this).val();
		        $(this).focus(function(){
		            if ($(this).val() == limpaValores[i]) {
		                $(this).val("");
		            }
		        }).blur(function(){
		            if ($.trim($(this).val()) == "") {
		                $(this).val(limpaValores[i]);
		            }
		        });
		 });
		 
	});
