/* Popup 2.0 --------------------/
x: Nome da página
n: Alias da página (background)
w: Tamanho horizontal
h: Tamanho vertical
s: Scrollbar
Script que chama popup: javascript:pop('nomedapagina.htm','alias_de_background',480,345,'yes');
--------------------------------*/

function pop(x,n,w,h,s) {
	var l = ( (window.screen.width  - w) / 2 );
	var t = ( (window.screen.height - h) / 2 );
    janelinha = window.open(x,n,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+s+',resizable=no,top='+t+',left='+l+',screenX='+l+',screenY='+t+',copyhistory=no,height='+h+',width='+w+'');
	janelinha.focus();
}

/*Função para mostrar ou ocultar uma layer*/
function showP(num){
	atual = num;
	ativa(num);
	checaAvancarVoltar();
	var i = 1;
	for (i=0;i<10;i++){
		if (document.getElementById('p' + i)){
			eval("document.getElementById('p" + i +"').style.display = 'none'");
			if (i == num) {
				eval("document.getElementById('p" + num +"').style.display = 'block'");
			}
		}
	}
}

/*Funções para a paginação das fotos da página Idéias*/
function hideAll() {
	document.getElementById('p1').style.display = 'none';
	document.getElementById('p2').style.display = 'none';
	document.getElementById('p3').style.display = 'none';
	document.getElementById('p4').style.display = 'none';
}

function ativa(num) {
	eval("document.getElementById('bt" + num +"').src= 'img/bt"+ num +"-on.gif'");
}

function desativaAll() {
	document.getElementById('bt1').src = 'img/bt1-off.gif';
	document.getElementById('bt2').src = 'img/bt2-off.gif';
	document.getElementById('bt3').src = 'img/bt3-off.gif';
	document.getElementById('bt4').src = 'img/bt4-off.gif';
}

function checaAvancarVoltar() {
	if (atual>1) {
		document.getElementById('voltar').style.display = 'block';
	}
	else {
		document.getElementById('voltar').style.display = 'none';
	}
	if (atual<4) {
		document.getElementById('avancar').style.display = 'block';
	}
	else {
		document.getElementById('avancar').style.display = 'none';
	}
}

function avancar(){
	hideAll();
	desativaAll();
	showP(atual+1);
}

function voltar(){
	hideAll();
	desativaAll();
	showP(atual-1);
}

/*Funções para mostrar ou ocultar os layers de cadastro*/
function mostraCadastrado() {
	document.getElementById('txtJaCadastrado').style.display = 'block';
	document.getElementById('formJaCadastrado').style.display = 'block';
	document.getElementById('txtNaoCadastrado').style.display = 'none';
	document.getElementById('formNaoCadastrado').style.display = 'none';
}

function mostraNaoCadastrado() {
	document.getElementById('txtJaCadastrado').style.display = 'none';
	document.getElementById('formJaCadastrado').style.display = 'none';
	document.getElementById('txtNaoCadastrado').style.display = 'block';
	document.getElementById('formNaoCadastrado').style.display = 'block';
}

/* Função para mudar automaticamente de form */
function autotab(atual,destino){
	if (atual.getAttribute&&atual.value.length==atual.getAttribute("maxlength"))
	destino.focus()
}
