var xmlHttp

function showBuscaAjax(str,str_pagina)
{
	if (document.getElementById("str_ajax_retorno_carregado"+str).value == "1")
	{
		document.getElementById("str_ajax_retorno_carregado"+str).value = "0";
		document.getElementById("str_ajax_retorno"+str).innerHTML="";
	}
	else
	{
		document.getElementById("str_ajax_retorno_carregado"+str).value = "1";
		document.getElementById("str_qual_id").value = str;
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		}        
	
		var url=str_pagina;
		url=url+"?str_valores_pesq="+str;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("str_ajax_retorno"+document.getElementById("str_qual_id").value).innerHTML=xmlHttp.responseText;
	}
	else if (xmlHttp.readyState==1)
	{
		document.getElementById("str_ajax_retorno"+document.getElementById("str_qual_id").value).innerHTML="Carregando...<br/><span style='color:#FF0000;'>Atenção: caso a página não carreque, clique no link novamente.</span>";
	}
}


function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}