function abre_janela(mypage, myname, w, h,scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+15+',left='+15+',scrollbars='+scroll+',resizable,statusbar=no'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

////////////////////////////

function nomebacia(nomebacia){
    switch(nomebacia){
    	case 'am' : nome='Bacia Amazônica'; cima='110px'; esq='80px'; bg='red'; ftcor='white'; break;

    	case 'at' : nome='Bacia Araguaia-Tocantins'; cima='120px'; esq='200px'; bg='yellow'; ftcor='blue'; break;

        case 'pt' : nome='Bacia do Prata'; cima='270px'; esq='185px'; bg='#FF00FF'; ftcor='white'; break;

        case 'sf' : nome='Bacia do São Francisco'; cima='200px'; esq='250px'; bg='#00A651'; ftcor='white'; break;

        case 'ass' : nome='Bacias do Atlântico Sul'; cima='250px'; esq='270px'; bg='#F7A81E'; ftcor='white'; break;

        case 'asno' : nome='Bacias do Atlântico Sul'; cima='50px'; esq='200px'; bg='#F7A81E'; ftcor='white'; break;

        case 'asne' : nome='Bacias do Atlântico Sul'; cima='100px'; esq='270px'; bg='#F7A81E'; ftcor='white'; break;
    }

 document.getElementById('nomebaciahidro').style.display='block';
 document.getElementById('nomebaciahidro').innerHTML=nome;
 document.getElementById('nomebaciahidro').style.top=cima;
 document.getElementById('nomebaciahidro').style.left=esq;
 document.getElementById('nomebaciahidro').style.background=bg;
 document.getElementById('nomebaciahidro').style.color=ftcor;
}

/////////////////////////
function novaPagina(id){
	var novaPagina = document.getElementById("novaPagina");
	if(novaPagina){
		novaPagina.parentNode.removeChild(novaPagina);
	} else {	
		var inserirPagina = document.getElementById("inserirPagina");
		var novaPagina = document.createElement("div");
		novaPagina.setAttribute("id","novaPagina");
		novaPagina.className = "divForm";
		var info = '<form id="formNovaPagina" action="celulas.php" method="POST">';
    	info += '<input type="hidden" name="acao" value="inserirPagina">';
    	info += '<input type="hidden" name="id" value="'+id+'">';
    	info += '<b>Titulo</b><br/><input type="text" name="titulo" value="" size="50"/><br>';
		info += '<b>Descrição</b><br/><textarea name="descpagina" rows="10" cols="40"></textarea><br>';
		info += '<input type="button" value="cancelar" onclick="novaPagina(\''+id+'\')"> ';
		info += '<input type="submit" value="enviar">';
		info += '</form>';
		novaPagina.innerHTML = info;
		inserirPagina.appendChild(novaPagina);
	}

}
/////////////////////////

function novaCelula(idcelula){
	var novaCelula = document.getElementById("novaCelula");
	if(novaCelula){
		novaCelula.parentNode.removeChild(novaCelula);
	} else {
		var inserirNovaCelula = document.getElementById("inserirNovaCelula");
		var novaCelula = document.createElement("div");
		novaCelula.setAttribute("id","novaCelula");
		novaCelula.className = "divForm";
		var info = '<form id="formNovaCelula" action="celulas.php" method="POST" enctype="multipart/form-data">';
    	info += '<input type="hidden" name="acao" value="inserirCelula"/>';
    	info += '<input type="hidden" name="idcelula" value="'+idcelula+'"/>';
    	info += '<b>Titulo</b><br/><input type="text" name="titulocel" value="" size="50"/><br/>';
		info += '<b>Texto</b><br/><textarea name="conteudocel" rows="10" cols="40"></textarea><br/>';
		info += '<b>Imagem</b><br/><input type="file" name="imagenscel"/><br/>';
		info += '<input type="button" value="cancelar" onclick="novaCelula(\''+idcelula+'\')"/> ';
		info += '<input type="submit" value="enviar"/>';
		info += '</form>';
		novaCelula.innerHTML = info;
		inserirNovaCelula.appendChild(novaCelula);
	}
	//var novaCel = document.getElementById('novaCelula');
	//var novaCelStyle = novaCel.style;
		//novaCelStyle.display = 'block';
	/*if(novaCelStyle.display == 'none'){
		alert("block");
		//novaCelStyle.display = 'block';
	} else if(novaCelStyle.display == 'block'){
		alert("none");
		//novaCelStyle.display = 'none';
	}*/
	
}

///////////////////////////

function editarCelula(keyid){
	var div = document.getElementById("formEditarCelula");
	if(div){
		div.parentNode.removeChild(div);
	} else {
		var div = document.createElement("div");
		div.setAttribute("id","formEditarCelula");
		div.className = "divForm";
		div.innerHTML = "Carregando formulário. Aguarde! . . .";
		var celula = document.getElementById('keyid'+keyid);
		celula.appendChild(div);
		var url = 'celulas.php?acao=editarcelula&keyid='+keyid;
		requestHTTP("GET",url,true);
	}
	
}

//////////////////////////

function excluirCelula(keyid){
	if(confirm("Tem certeza que deseja excluir esta célula?")==true){
		var url = "celulas.php?acao=excluirCelula&keyid="+keyid;
		requestHTTP("GET",url,true);
		var idkeyid = document.getElementById('keyid'+keyid);
		idkeyid.parentNode.removeChild(idkeyid);
	} else {
		return false;
	}
	
}
///////////////////////////
function trataDados(){	
	var meuXML = ajax.responseXML;
	if(meuXML){
		var raiz = meuXML.documentElement;
		var nodos;
		if(raiz.hasChildNodes()){ 
			nodos = raiz.childNodes;
		}
		//editarCelula
		if(raiz.getAttribute('title')=="editarCelula"){
			var keyid = nodos[0].firstChild.nodeValue;
			var info = '<form name="formEditarCelula" action="celulas.php" method="post" enctype="multipart/form-data">';
			info += '<input name="acao" type="hidden" value="editacelula"/>';
			info += '<input name="keyid" type="hidden" value="'+keyid+'"/>';
			info += '<input name="idcelula" type="hidden" value="'+nodos[1].firstChild.nodeValue+'"/>';
			info += '<b>Titulo</b><br/>';
			info += '<input name="titulocel" type="text" value="'+nodos[2].firstChild.nodeValue+'" size="60"/><br/>';
			info += '<b>Conteúdo</b><br/>';
			info += '<textarea cols="47" rows="10" name="conteudocel">'+nodos[3].firstChild.nodeValue+'</textarea><br/>';
			info += '<b>Imagem</b><br/>';
			var imagenscel = nodos[4];
			if(imagenscel.ChildNodes){
				alert("foi");
				var imagem = imagenscel.childNodes;
				for(var i=0; i<imagem.length; i++){
					info += '<div style="border: 1px #33ccff solid; margin-bottom: 3px;">';
					info += '<img style="padding: 3px;" src="'+imagem[i].firstChild.nodeValue+'" alt=""/>';
					info += '<br/><input type="radio" name="excluirImg" value="'+i+'"/>Excluir ou Substituir por: <input type="file" name="imagem['+i+']"/>';
					info += '</div>';
				}
			}
			info += '<b>Inserir nova imagem</b>: <input type="file" name="novaImagem"/><br/>';
			info += '<div style="margin: 10px; text-align: left;">';
			info += '<input name="buttom" type="submit" value="Cancelar" onclick="editarCelula(\''+keyid+'\')"/>'
			info += '&nbsp;<input name="submit" type="submit" value="Enviar"/>'
			info += '</div>';
			info += '</form>';
			var div = document.getElementById("formEditarCelula");
			var celula = document.getElementById('keyid'+keyid);
			div.innerHTML = info;
			
		}
	}
}
/*/////////////////////////

var x,y
var step=60
var flag=0


var message="0000"
message=message.split("")

var xpos=new Array()
for (i=0;i<=message.length-1;i++) {
xpos[i]=-50
}

var ypos=new Array()
for (i=0;i<=message.length-1;i++) {
ypos[i]=-50
}

function handlerMM(e){
x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX
y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY
flag=1
}

function makesnake() {

for (i=message.length-1; i>=1; i--) {
xpos[i]=xpos[i-1]+step
ypos[i]=ypos[i-1]
}
xpos[0]=x+15
ypos[0]=y

for (i=0; i<message.length-1; i++) {
var thisspan = eval("span"+(i)+".style")
thisspan.posLeft=xpos[i]
thisspan.posTop=ypos[i]
}

var timer=setTimeout("makesnake()",60)
}


for (i=0;i<=message.length-1;i++) {
document.write("<div id='span"+i+"' class='peixes'><img src=\"imagens/peixemouse.gif\" width=\"50\" alt=\"\"/>")
//document.write(message[i])
document.write("</div>")
}

document.onmousemove = handlerMM;     */


