dojo.require("dojo.io.*");
dojo.hostenv.writeIncludes(); 

djConfig.bindEncoding = "ISO-8859-1";
var djConfig = { isDebug: true, debugContainerId : "statusContainer" }; 
var url = document.URL
var server =  url.split("/")[0] + "/" + url.split("/")[1] + "/" + url.split("/")[2] 

function ajax_request(caminho,arquivo,id) {

path = server + "/" + caminho + arquivo;
//alert(path)
dojo.io.bind({
    url: path ,
    load: function(type, data, evt){
          document.getElementById(id).innerHTML = data
          },
    error: function(type, error){
           alert(type + " " + error)
           },
    mimetype: "text/html",
	encoding: "ISO-8859-1"
});

}

function ajax_request_retorna(caminho,arquivo) {

path = server + "/" + caminho + arquivo;

dojo.io.bind({
    url: path ,
    load: function(type, data, evt){			
          return data
          },
    error: function(type, error){
           alert(type + " " + error)
           },
    mimetype: "text/html",
	encoding: "ISO-8859-1"
});

}


function vai_para_url(selecao)
{
	var sel = selecao.selectedIndex;
	var link_sel;
	var verifica_link_externo = /^http/;
	if (sel > 0)
	{
		link_sel = selecao.options[sel].value;
		if (verifica_link_externo.test(link_sel))
		{
			window.open(link_sel,"blank");
		}
		else
		{
			parent.location = link_sel;
		}
	}
}

function exibe_aviso_email() {
	
	var ck = dojo.io.cookie;
	var controlaCookie = false
	avisar = true;

	if (controlaCookie) {
		if (ck.isSupported()){		
			avisar = false;
			if (ck.getCookie("aviso_email") != "0") {		
				ck.set("aviso_email", "0", 1);
				avisar = true;
			}
		}
	}
	
	if (avisar) { 
		$("div_overlay").style.display = "block";
		$("div_alerta").style.display = "block";
		$("div_flash").style.display = "";	
	}
	else {
		$("div_flash").style.display = "block";		
	}
}

function exibe_flash(id) {
	var ck = dojo.io.cookie;
	exibir = true;
	if (ck.isSupported()) exibir = (ck.getCookie("aviso_email") == "0"? true : false)
	if (exibir) $(id).style.display = "block";		
}	

function fechar_alerta() {
	$('div_alerta').style.display = "none";
	$('div_overlay').style.display = "none";	
	$('div_flash').style.display = "block";
}


function verificaBusca(){
if ($('query').value == "") {
	alert("Digite algo para iniciar a pesquisa.")
	return false;
} else {
	return true;	
}
}