function limpaCache(url)
{
   if (url.indexOf("?") >=0 ) return url + "&rand=" + encodeURI(Math.random());
   		else return url + "?randon=" + encodeURI(Math.random());
}

function novaUrl()
{
  d = document.url;
  if (d.u.value == '') return false;
  
  pagina = limpaCache( "insereurl.php?url="+d.u.value);
  http.open("GET", pagina, true);
  //mostra_div("espera2");
  http.onreadystatechange = resposta_novaUrl;
  http.send(null);
}


function resposta_novaUrl()
{
  if (http.readyState == 4) {
	
	  if (http.status == 200) {
			var Retorno = http.responseText.split("|");
			var div = document.getElementById("retorno");
				div.innerHTML = Retorno[0];
				//esconde_div("aguardelogin");
	  }
	  else	
	  {
		var div = document.getElementById("retorno");
			div.innerHTML = "Servidor temporariamente indisponivel. Tente novamente mais tarde.";
			//esconde_div("aguardelogin");
	  }
  }
}


function getHTTPObject() {
var req;

try {
 if (window.XMLHttpRequest) {
  req = new XMLHttpRequest();

  if (req.readyState == null) {
   req.readyState = 1;
   req.addEventListener("load", function () {
   req.readyState = 4;

   if (typeof req.onReadyStateChange == "function")
    req.onReadyStateChange();
   }, false);
  }

  return req;
 }

 if (window.ActiveXObject) {
  var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];

  for (var i = 0; i < prefixes.length; i++) {
   try {
    req = new ActiveXObject(prefixes[i] + ".XmlHttp");
    return req;
   } catch (ex) {};
  }
 }
} catch (ex) {}

alert("XmlHttp Objects not supported by client browser");
}
var http = getHTTPObject();





function mostra_div(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';  
		}  
		else {    
			if (document.layers) { // Netscape 4      
			document.id.display = 'block';
			}    
			else { // IE 4      
				 document.all.id.style.display = 'block';    
				 }  
		}
	}
	
function esconde_div(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
		}
		else {
			if (document.layers) { // Netscape 4
			document.id.display = 'none';    
			}    
			else { // IE 4      
			document.all.id.style.display = 'none';    
			}  
		}
	}
