var Ajax = false;

//Função: Identificar o Componente
function AjaxRequest()
{
    Ajax = false;
    if(window.XMLHttpRequest) // mozilla
    {
        Ajax = new XMLHttpRequest();
    }
    else if(window.ActiveXObject) // ie
    {
        try
        {
            Ajax = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            try
            {
                Ajax = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e)
            {}
        }
    }
}

//Função: Requisição do Ajax
function ExeAjax(pagina,local)
{
	document.getElementById(local).innerHTML = '<img src=img/ajaxloader.gif border=0>';
    AjaxRequest();
    //Ajax.onreadystatechange = processaResposta;
	Ajax.onreadystatechange = function(){
		if(Ajax.readyState==4)
		{
			if(Ajax.status==200)
			{ 
				if(local == 'alerta-news'){
					LocalizaAlertaNews(local);
					AtualizaAlertaNews(local,Ajax.responseText);
				}
				else if(local == 'msgLogin'){
					AtualizaLogin(Ajax.responseText);
				}
				else if(local != ''){
					document.getElementById(local).innerHTML = Ajax.responseText;
				}
			}
		}
	};
    Ajax.open('GET', pagina, true);
	Ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
	Ajax.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	Ajax.setRequestHeader("Pragma", "no-cache");
    Ajax.send(null);
}

//Função: Retorno Ajax
/*function processaResposta()
{
    if(Ajax.readyState==4)
    {
        if(Ajax.status==200)
        { 
            document.getElementById('light').innerHTML = Ajax.responseText;
			Refresh();
        }
    }
}*/

//Função: Auto-Atualização
function Refresh(){
	setTimeout("ExeAjax()", 60000); //1000 = 1 segundo
}
function BuscarRk()
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var Rkano = document.formRanking.rkano.value  
var Rkm = document.formRanking.rkm.value  
var Rkcat = document.formRanking.rkcat.value

var url="ranking_tipo.asp";
url=url+"?rkano="+Rkano;
url=url+"&rkm="+Rkm;
url=url+"&rkcat="+Rkcat;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
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;
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4)
	{ 
	document.getElementById("lista-ranking").innerHTML=xmlHttp.responseText;
	}
}
