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
}
