function redimen() {

	var ifram = document.getElementById('meio');

	var altura = ifram.contentWindow.document.body.scrollHeight;

	if(altura > 10)	ifram.style.height = altura+'px';

	else ifram.style.height = 100;

}


function formataData(campo) {

	if(campo.value.length==2) campo.value=campo.value+"/";	

	if(campo.value.length==5) campo.value=campo.value+"/";	

}

function formataCEP(campo) {

	if(campo.value.length==5) campo.value=campo.value+"-";

}

function soNum(evento) {

	var navegador = navigator.appName.toLowerCase();

	var mozilla = navegador.indexOf("netscape")+1;

	tecla = mozilla ? evento.which : evento.keyCode;
	if ( !(tecla >= 48 && tecla <= 57) && (tecla!=8) && (tecla!=11) && (tecla!=0)) {

		return false;

	}

}
function validaTrocaSenha(formu) { 

	var campo=new Array(formu.asenha,formu.nsenha,formu.ncsenha);
	var msgs=new Array('"SENHA ANTIGA"','"NOVA SENHA"','"REPITA NOVA SENHA"');
	for(x=0;x<=(campo.length-1);x++) {
		if(campo[x].value.length==0) {
			alert('Complete o campo '+msgs[x]+'...');
			return false;
		}
	}
	
	if(document.getElementById('nsenha').value!=document.getElementById('ncsenha').value) {
		alert('As NOVAS SENHAS nao se conferem!');
		return false;
	}
}

function validaPerdiSenha(formu) { 

	var campo=new Array(formu.email);
	var msgs=new Array('"E-MAIL"');
	for(x=0;x<=(campo.length-1);x++) {
		if(campo[x].value.length==0) {
			alert('Complete o campo '+msgs[x]+'...');
			return false;
		}
	}
}

function validaCadastro(formu) { 

	var campo=new Array(formu.loja_n,formu.membro_n,formu.nome_obreiro,formu.dn_obreiro,formu.endereco,formu.end_bairro,formu.cidade,formu.uf,formu.cep,formu.telefones,formu.email,formu.senha,formu.nivel);

	var msgs=new Array('"NUMERO DA LOJA"','"NUMERO DO MEMBRO"','"NOME DO OBREIRO"','"DATA DE NASCIMENTO DO OBREIRO"','"ENDERECO"','"BAIRRO"','"CIDADE"','"UF"','"CEP"','"TELEFONES"','"E-MAIL"','"SENHA"');
	for(x=0;x<=(campo.length-1);x++) {
		if(campo[x].value.length==0) {

			alert('Complete o campo '+msgs[x]+'...');

			return false;

		}
	}

	var testa=new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);

 	if(!(testa.test(formu.email.value))) {

		alert('Seu e-mail está incorreto!');

		return false;

	}
	
	if(document.getElementById('nivel').value=='nivel0') {
		alert('Complete o campo NIVEL...');
		return false;
	} else {
		
		if(document.getElementById('nivel').value=='nivel1') {
			if(document.getElementById('resposta1nivel1').value.length==0 || document.getElementById('resposta2nivel1').value.length==0 || document.getElementById('resposta3nivel1').value.length==0) {
				alert('Por favor responda as perguntas referentes ao NIVEL 1');
				return false;
			}
		} else if(document.getElementById('nivel').value=='nivel2') {
			if(document.getElementById('resposta1nivel2').value.length==0 || document.getElementById('resposta2nivel2').value.length==0 || document.getElementById('resposta3nivel2').value.length==0) {
				alert('Por favor responda as perguntas referentes ao NIVEL 2');
				return false;
			}
		} else if(document.getElementById('nivel').value=='nivel3') {
			if(document.getElementById('resposta1nivel3').value.length==0 || document.getElementById('resposta2nivel3').value.length==0 || document.getElementById('resposta3nivel3').value.length==0) {
				alert('Por favor responda as perguntas referentes ao NIVEL 3');
				return false;
			}
		} else {
			alert('Complete o campo NIVEL...');
			return false;
		}
	
	}

}



function validaDados(formu) { 

	var campo=new Array(formu.loja_n,formu.membro_n,formu.obreiro_nome,formu.obreiro_dn,formu.endereco,formu.end_bairro,formu.cidade,formu.uf,formu.cep,formu.telefones,formu.email,formu.nivel);

	var msgs=new Array('"NUMERO DA LOJA"','"NUMERO DO MEMBRO"','"NOME DO OBREIRO"','"DATA DE NASCIMENTO DO OBREIRO"','"ENDERECO"','"BAIRRO"','"CIDADE"','"UF"','"CEP"','"TELEFONES"','"E-MAIL"','"SENHA"');
	for(x=0;x<=(campo.length-1);x++) {
		if(campo[x].value.length==0) {

			alert('Complete o campo '+msgs[x]+'...');

			return false;

		}
	}

	var testa=new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);

 	if(!(testa.test(formu.email.value))) {

		alert('Seu e-mail está incorreto!');

		return false;

	}
	
	if(document.getElementById('nivel').value=='nivel0') {
		alert('Complete o campo NIVEL...');
		return false;
	} else {
		if(document.getElementById('nivela').value==1) var nivela='nivel1';
		else if(document.getElementById('nivela').value==2) var nivela='nivel2';
		else var nivela='nivel3';
		if(document.getElementById('nivel').value=='nivel1' && nivela!=document.getElementById('nivel').value) {
			if(document.getElementById('resposta1nivel1').value.length==0 || document.getElementById('resposta2nivel1').value.length==0 || document.getElementById('resposta3nivel1').value.length==0) {
				alert('Por favor responda as perguntas referentes ao NIVEL 1');
				return false;
			}
		} else if(document.getElementById('nivel').value=='nivel2' && nivela!=document.getElementById('nivel').value) {
			if(document.getElementById('resposta1nivel2').value.length==0 || document.getElementById('resposta2nivel2').value.length==0 || document.getElementById('resposta3nivel2').value.length==0) {
				alert('Por favor responda as perguntas referentes ao NIVEL 2');
				return false;
			}
		} else if(document.getElementById('nivel').value=='nivel3' && nivela!=document.getElementById('nivel').value) {
			if(document.getElementById('resposta1nivel3').value.length==0 || document.getElementById('resposta2nivel3').value.length==0 || document.getElementById('resposta3nivel3').value.length==0) {
				alert('Por favor responda as perguntas referentes ao NIVEL 3');
				return false;
			}
		} 
	
	}

}


function pop(pagina,nome,larg,altu,scrollbar) {

  PosIniX=((screen.availWidth/2)-(larg/2));

  PosIniY=((screen.availHeight/2)-(altu/2));

  window.open(pagina,nome,'toolbar=no,location=no,directories=no,menubar=no,scrollbars='+scrollbar+',resizable=no,top='+PosIniY+',left='+PosIniX+',width='+larg+',height='+altu+'');

  window.refresh;

}

function nav() {

	nav=navigator.appName.toLowerCase();

	moz=nav.indexOf('netscape')+1;

	if(moz) return 'moz';

	else return 'ie';

}

