var ajax = null
if (window.XMLHttpRequest) {
	ajax = new XMLHttpRequest();
}else if (window.ActiveXObject){
	ajax = new ActiveXObject("Microsoft.XMLHTTP");
}
var url =location.href
var cookies = {
	date: new Date(),
	criar: function(strName, strValue, intDays) {
		if ( intDays ) {
			this.date.setTime(this.date.getTime()+(intDays*24*60*60*1000));
			var expires = "; expires=" + this.date.toGMTString();
		} else {
			var expires = "";
		}
		document.cookie = strName + "=" + strValue + expires + "; path=/";
	},
	ler: function(strName) {
		var strNameIgual = strName + "=";
		var arrCookies = document.cookie.split(";");
		for ( var i = 0, strCookie; strCookie = arrCookies[i]; i++ ) {
			while ( strCookie.charAt(0) == " ") {
				strCookie = strCookie.substring(1,strCookie.length);
			}
			if ( strCookie.indexOf(strNameIgual) == 0 ) {
				return strCookie.substring(strNameIgual.length,strCookie.length);
			}
		}
		return null;
	},
	apagar: function(strName) {
		var $cookie_data = new Date ( );
 		$cookie_data.setTime ( $cookie_data.getTime() - 1 );
	  	document.cookie = strName += "= ; expires=" + $cookie_data.toGMTString()+ ";" + ";";
	},
	busca:function ( cookie_name ){
		var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );
		if ( results ){
			return ( unescape ( results[1] ) );
		}else{
			return null;
		}
	}
}
var pagina = "normal.shtml";
String.prototype.trim = function(){
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
function elemento(e){
	return document.getElementById(e)	
}
function carrega(url,e){
	ajax.open("GET",url,true);
	ajax.setRequestHeader("Content-Type", "content=text/html; charset=iso-8859-1");
	ajax.onreadystatechange = function(){
		if (ajax.readyState == 4 ) {
			if(ajax.responseText.trim()=="retorno=erro"){
				cookies.criar('acessoOraculo',"false",0);
				redirecionar()
			}else{
				cookies.criar('acessoOraculo',"true",0);
				redirecionar()
			}
			delete ajax;
		}else if(ajax.readyState == 1 ){
			 e.innerHTML = "<b>enviando...</b>"
		}
	}
	ajax.send(null);
}
function redirecionar(){
	if(!cookies.busca('acessoOraculo') == false){
		if (cookies.ler('acessoOraculo') == "false"){
			if (url.indexOf("index") !=-1){
				elemento("resposta").innerHTML = "<b>Senha inválida!</b>";
			}
			location.href="index.shtml";	
		}else{
			if (url.indexOf("index") !=-1){
				location.href=pagina;
			}
		}
	}else{
		location.href="index.shtml";
	}
}
function enviaSenha(f){
	//e = f.senha.value.toUpperCase();
	//f.senha.disabled = "disabled";
	e = "";
	for (i=0; i<f.resp.length; i++) {
		if (f.resp[i].checked) {
			pagina = f.resp[i].value
		}
	}
	//carrega("validar.shtml?senha="+e, elemento("resposta"));
	location.href = pagina;
	return false;
}
function flash(swf,w,h){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+w+'" height="'+h+'" id="CodeFlash" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="movie" value="'+swf+'" /><param name="quality" value="hight" /><param name="bgcolor" value="#ffffff" /><embed src="'+swf+'" wmode="transparent" quality="high" bgcolor="#ffffff" width="'+w+'" height="'+h+'" id="CodeFlash1" name="CodeFlash" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}
/*
if (url.indexOf("index") ==-1){
	redirecionar()		
}*/