/*------------------------------------------------------------------------
# G3 Site - Version 1.0
# ------------------------------------------------------------------------
# Copyright (C) 2007-2010 G3 Brasil Comunicação e Marketing Ltda, All Rights Reserved.
# Author: G3 - z4n6uz
# Websites:  http://www.agenciag3brasil.com.br
-------------------------------------------------------------------------*/




try
{
	xmlhttp = new XMLHttpRequest();
}
catch(ee)
{
	try
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(E)
		{
			xmlhttp = false;
		}
	}
}

fila=[];
ifila=0;



function ajaxLoad(url, destino)
{


	if(destino!=Object)
		destino = document.getElementById(destino);
		
		destino.innerHTML="<center class='fs6'><img src='img/carregando.gif' width='100' height='78' /></center>";

	fila[fila.length]=[url,destino];
	
	if((ifila+1)==fila.length)
		ajaxRun();
}

function ajaxShow(valor,destino)
{
	switch(valor)
	{
		case "ok":
			ajaxLoad('src/admin.php','cont-right');
		break;
		
		case "no":
			ajaxLoad('adm/index.php?msgNo=usuário ou senha inválidos','cont-right');
		break;
		
		case "sair":
			
		break;
		
		default:
			destino.innerHTML = unescape(valor.replace(/\+/g," "));
		break;
	}
}

function ajaxRun()
{
	url = fila[ifila][0];
	destino = fila[ifila][1];
	
	xmlhttp.open("POST", url, true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
	xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	xmlhttp.setRequestHeader("Pragma", "no-cache");
	
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4)
		{
			switch(xmlhttp.status)
			{
				case 200: { ajaxShow(xmlhttp.responseText,destino); break }
				case 204: { ajaxShow("O servidor n&atilde;o respondeu ao chamado",destino); break }
				case 400: { ajaxShow("Endere&ccedil;o inv&aacute;lido",destino); break }
				case 403: { ajaxShow("Voc&ecirc; n&atilde;o possui permiss&atilde;o para acessar esse arquivo",destino); break }
				case 404: { ajaxShow("Arquivo n&atilde;o encontrado",destino); break }
				case 500: { ajaxShow("Erro interno do servidor...",destino); break }
				case 502: { ajaxShow("Servidor ocupado.",destino); break }
				case 503: { ajaxShow("O servidor n&atilde;o respondeu no tempo limite",destino); break }
				 default: { ajaxShow("Algum erro ocorreu ao carregar este conte&uacute;do...",destino); break }
			}
			
			ifila++;
			
			if(ifila<fila.length)
				setTimeout("ajaxRun()",20);
		}
	}
	xmlhttp.send(url);
}

