if (!/localhost|file\:/.test(location.href)) 
	document.domain = 'terra.com.br';

function abre(pagina,janela,w,h,scrolling) {
	window.open(pagina,janela,'width='+w+',height='+h+',scrollbars='+scrolling+',toolbar=no,location=no,status=no,menubar=no,resizable=no,left=0,top=5');
}

function showLevel(show){
	var help = document.getElementById(show);
	if ( help.style.display == "none" || !help.style.display) {
		document.getElementById('info').style.display = "none";
		document.getElementById('config').style.display = "none";
		document.getElementById('tecn').style.display = "none";
		help.style.display = "block";
	}else {
		help.style.display = "none";
	}
}

function displayinfo(pagina,janela,w,h,withcookie) {
 var show
 show = 1
 if (withcookie) {
 show = !GetCookie(withcookie)
 document.cookie = withcookie+"=1;path=/;domain=.terra.com.br"
  }
 if (show) { 
  resultado = window.open(pagina,janela,'width='+w+',height='+h+',scrollbars=no,toolbar=no,location=no,status=no,menubar=no,resizable=no,left=0,top=0')
  if ((navigator.appName != "Microsoft Internet Explorer") && (navigator.appVersion.substring(0,1) >= "3")) resultado.focus();
}
}

//registra a hora e data no formulário de denúncia
function infoData(){
	
	//registra hora e data do acesso à página
	var hoje = new Date();
	var diaDoMes = hoje.getDate();
	diaDoMes=(String(diaDoMes).length<2)? "0"+String(diaDoMes) : diaDoMes;
	var mes = hoje.getMonth() + 1;
	mes = (String(mes).length<2)? "0"+String(mes) : mes;
	var ano = hoje.getFullYear();
	var hora = hoje.getHours();
	var minuto = hoje.getMinutes();
	
	diaDenuncia = diaDoMes + "." + mes + "." + ano;
	horaDenuncia = hora + ":" + minuto;
	document.formulario.Dia.value = diaDenuncia
	document.formulario.Hora.value = horaDenuncia
};

/* DICAS ALEATÓRIAS */
function carregarDicas(){
	var urldicas;
	//ajustar path
	(/\/novidades\/|\/ajuda\/|\/assine\/|\/jogar\//.test(location.pathname))
		? urldicas = '../js/dicas.txt'
		: urldicas = 'js/dicas.txt';
	//salvar o conteudo do arquivo na propriedade .dicas, passando a função pra quando estiver carregado
	if (typeof carregarDicas.dicas == "undefined") {
		var dicas = $.get(urldicas, function(data){setDicas(data)});
	} else {
		mostraDicas();
	};
	function setDicas(texto){
		//remover espaços etc
		var dicas = texto.replace("\r", "").replace(/\n+/g, "\n").replace(/^\s*/, "").replace(/\s*$/, "");
		//separar por linhas, em Array
		dicas = dicas.split("\n");
		carregarDicas.dicas = dicas;
		mostraDicas();
	};
	function mostraDicas(){
		//numero aleatorio (max = nº de linhas do arquivo)
		var aleatoria = Math.floor(Math.random()*(carregarDicas.dicas.length-1));
		//insere o texto no DIV
		$('#exibicaoDicas').fadeOut('slow',function(){
			$('#exibicaoDicas').text(carregarDicas.dicas[aleatoria]).fadeIn('slow');
		});
	}
	
}

// cancela a ação dos cliques em links (pra substituir com JS)
function cancelclick(e) {
		(e && e.preventDefault)
			? e.preventDefault() // FF
			: e.returnValue = false; //IE7
		return false; // IE, outros
}

// COMPORTAMENTOS JS

// topo.htm
$(function(){ //on document ready		

	$('#m_bem_vindo a').click(function(e){
		cancelclick(e);
		$('#box_login_container').fadeIn();
	});

	$('#box_login_fechar').click(function(event){
		cancelclick(event);
		$('#box_login_container').fadeOut();
	});
});

//-->