<!--
function chkForm() {
	var e = "";
  	var c = document.getElementById("cad");
	
	// public area
	
		// contato
	if(c.who.value == "cot") {
  		e += (c.nome.value == "") ? "O campo NOME é obrigatório!\r\n" : "";
  		e += (c.email.value == "") ? "O campo EMAIL é obrigatório!\r\n" : "";
  			if((c.email.value != "") && (!isEmailValido(c.email.value))){
  				e += "Formato inválido no e-mail, altere por favor !\r\n";
  			}
  		e += (c.telddd.value == "") ? "O campo DDD é obrigatório!\r\n" : "";
		e += (c.tel.value == "") ? "O campo TELEFONE é obrigatório!\r\n" : "";
		e += (c.mens.value == "") ? "O campo MENSAGEM é obrigatório!\r\n" : "";
	}
	
		// processo de selecao
	if(c.who.value == "pro_for") {
  		e += (c.nome.value == "") ? "O campo NOME é obrigatório!\r\n" : "";
  		e += (c.email.value == "") ? "O campo EMAIL é obrigatório!\r\n" : "";
  			if((c.email.value != "") && (!isEmailValido(c.email.value))){
  				e += "Formato inválido no e-mail, altere por favor !\r\n";
  			}
		e += (c.end.value == "") ? "O campo ENDERECO é obrigatório!\r\n" : "";
		e += (c.num.value == "") ? "O campo NÚMERO é obrigatório!\r\n" : "";
		e += (c.bai.value == "") ? "O campo BAIRRO é obrigatório!\r\n" : "";
		if((c.cep1.value == "") && (c.cep2.value == "")){
			e += "O campo CEP é obrigatório!\r\n";
		} else {
			var cep = c.cep1.value+"-"+c.cep2.value;
			var field_cep = document.createElement('input');
			field_cep.setAttribute('type', 'hidden');
			field_cep.setAttribute('name', 'cep');
			field_cep.setAttribute('value', cep);
			c.appendChild(field_cep);
		}
		e += (c.cid.value == "") ? "O campo CIDADE é obrigatório!\r\n" : "";
		e += (c.est.value == "") ? "O campo ESTADO é obrigatório!\r\n" : "";
		e += (c.prof.value == "") ? "O campo PROFISSÃO é obrigatório!\r\n" : "";
  		e += (c.telddd1.value == "") ? "O campo DDD 1 é obrigatório!\r\n" : "";
		e += (c.tel1.value == "") ? "O campo TELEFONE 1 é obrigatório!\r\n" : "";
	}
	
		// colabora 1
	if(c.who.value == "com_ado") {
  		e += (c.nome.value == "") ? "O campo NOME é obrigatório!\r\n" : "";
  		e += (c.email.value == "") ? "O campo EMAIL é obrigatório!\r\n" : "";
		  	if((c.email.value != "") && (!isEmailValido(c.email.value))){
  				e += "Formato inválido no e-mail, altere por favor !\r\n";
  			}
		e += (c.nome_org.value == "") ? "O campo ORGANIZAÇÃO é obrigatório!\r\n" : "";
		e += (c.cpf.value == "") ? "O campo CPF é obrigatório!\r\n" : "";
		e += (c.end.value == "") ? "O campo ENDERECO é obrigatório!\r\n" : "";
		e += (c.num.value == "") ? "O campo NUMERO é obrigatório!\r\n" : "";
		e += (c.bai.value == "") ? "O campo BAIRRO é obrigatório!\r\n" : "";
		if((c.cep1.value == "") && (c.cep2.value == "")){
			e += "O campo CEP é obrigatório!\r\n";
		} else {
			var cep = c.cep1.value+"-"+c.cep2.value;
			var field_cep = document.createElement('input');
			field_cep.setAttribute('type', 'hidden');
			field_cep.setAttribute('name', 'cep');
			field_cep.setAttribute('value', cep);
			c.appendChild(field_cep);
		}
		e += (c.cid.value == "") ? "O campo CIDADE é obrigatório!\r\n" : "";
		e += (c.est.value == "") ? "O campo ESTADO é obrigatório!\r\n" : "";
  		e += (c.telddd1.value == "") ? "O campo DDD 1 é obrigatório!\r\n" : "";
		e += (c.tel1.value == "") ? "O campo TELEFONE 1 é obrigatório!\r\n" : "";

	    var hz = false;
		var ind = 0;
		for (h = 0; h < c.contribui_x.length; h++) {
			if(c.contribui_x[h].checked){
				hz = true;
				ind = h;
			}
		}
		if(!hz && c.contribui_vt.value == ""){
			e += "O campo VALOR é obrigatório!\r\n";
		}
		if(hz && c.contribui_vt.value == "" && !c.contribui_x[3].checked){
			if(!c.contribui_valor){
				var field_z = document.createElement('input');
				field_z.setAttribute('type', 'hidden');
				field_z.setAttribute('name', 'contribui_valor');
				field_z.setAttribute('value', c.contribui_x[ind].value);
				c.appendChild(field_z);
			} else {
				c.contribui_valor.setAttribute('value', c.contribui_x[ind].value);
			}
		}
		if(hz && !c.contribui_x[3].checked && c.contribui_vt.value != "" || !hz && c.contribui_vt.value != ""){
			e += "Selecione um Valor!\r\n";
		}
		if(c.contribui_x[3].checked && c.contribui_vt.value == ""){
			e += "Digite um Valor!\r\n";
		}
		if(c.contribui_x[3].checked && c.contribui_vt.value != ""){
			if(!c.contribui_valor){
				var field_z = document.createElement('input');
				field_z.setAttribute('type', 'hidden');
				field_z.setAttribute('name', 'contribui_valor');
				field_z.setAttribute('value', removeNonNumbers(c.contribui_vt.value));
				c.appendChild(field_z);
			} else {
				c.contribui_valor.setAttribute('value', removeNonNumbers(c.contribui_vt.value));
			}
		}
	}
	
		// colabora 2
	if(c.who.value == "com_par") {
  		e += (c.nome.value == "") ? "O campo NOME é obrigatório!\r\n" : "";
  		e += (c.email.value == "") ? "O campo EMAIL é obrigatório!\r\n" : "";
		  	if((c.email.value != "") && (!isEmailValido(c.email.value))){
  				e += "Formato inválido no e-mail, altere por favor !\r\n";
  			}
		e += (c.nome_org.value == "") ? "O campo ORGANIZAÇÃO é obrigatório!\r\n" : "";
		e += (c.cpf.value == "") ? "O campo CPF é obrigatório!\r\n" : "";
		e += (c.end.value == "") ? "O campo ENDERECO é obrigatório!\r\n" : "";
		e += (c.num.value == "") ? "O campo NUMERO é obrigatório!\r\n" : "";
		e += (c.bai.value == "") ? "O campo BAIRRO é obrigatório!\r\n" : "";
		if((c.cep1.value == "") && (c.cep2.value == "")){
			e += "O campo CEP é obrigatório!\r\n";
		} else {
			var cep = c.cep1.value+"-"+c.cep2.value;
			var field_cep = document.createElement('input');
			field_cep.setAttribute('type', 'hidden');
			field_cep.setAttribute('name', 'cep');
			field_cep.setAttribute('value', cep);
			c.appendChild(field_cep);
		}
		e += (c.cid.value == "") ? "O campo CIDADE é obrigatório!\r\n" : "";
		e += (c.est.value == "") ? "O campo ESTADO é obrigatório!\r\n" : "";
  		e += (c.telddd1.value == "") ? "O campo DDD 1 é obrigatório!\r\n" : "";
		e += (c.tel1.value == "") ? "O campo TELEFONE 1 é obrigatório!\r\n" : "";
		
		var ind = "";
		if(c.contribui_f1.checked){
			ind += c.contribui_f1.value+";";
		}
		if(c.contribui_f2.checked){
			ind += c.contribui_f2.value+";";
		}
		if(c.contribui_f3.checked){
			ind += c.contribui_f3.value+";";
		}
		if(c.contribui_f4.checked){
			ind += c.contribui_f4.value+";";
		}
		if(c.contribui_f5.checked){
			ind += c.contribui_f5.value+";";
		}
		if(c.contribui_f6.checked){
			ind += c.contribui_f6.value;
		}

		if(ind == ""){
			e += "O campo LINHA TEMÁTICA é obrigatório!\r\n";
		} else {
			if(!c.contribui_forma){
			  var field_z = document.createElement('input');
			  field_z.setAttribute('type', 'hidden');
			  field_z.setAttribute('name', 'contribui_forma');
			  field_z.setAttribute('value', ind);
			  c.appendChild(field_z);
			} else {
			  c.contribui_forma.setAttribute('value', ind);
			}
		}
		
		if(c.contribui_vta.value == ""){
			e += "O campo VALOR DA DOAÇÃO é obrigatório!\r\n";
		} else {
			if(!c.contribui_valor){
			  var field_z = document.createElement('input');
			  field_z.setAttribute('type', 'hidden');
			  field_z.setAttribute('name', 'contribui_valor');
			  field_z.setAttribute('value', removeNonNumbers(c.contribui_vta.value));
			  c.appendChild(field_z);
			} else {
			  c.contribui_valor.setAttribute('value', removeNonNumbers(c.contribui_vta.value));
			}
		}
		
		e += (c.contribui_data.value == "") ? "O campo PERIODICIDADE é obrigatório!\r\n" : "";
		
	}
	
		// colabora 3
	if(c.who.value == "com_ami") {
  		e += (c.nome.value == "") ? "O campo NOME é obrigatório!\r\n" : "";
  		e += (c.email.value == "") ? "O campo EMAIL é obrigatório!\r\n" : "";
		  	if((c.email.value != "") && (!isEmailValido(c.email.value))){
  				e += "Formato inválido no e-mail, altere por favor !\r\n";
  			}
		e += (c.nome_org.value == "") ? "O campo ORGANIZAÇÃO é obrigatório!\r\n" : "";
		e += (c.cpf.value == "") ? "O campo CPF é obrigatório!\r\n" : "";
		e += (c.end.value == "") ? "O campo ENDERECO é obrigatório!\r\n" : "";
		e += (c.num.value == "") ? "O campo NUMERO é obrigatório!\r\n" : "";
		e += (c.bai.value == "") ? "O campo BAIRRO é obrigatório!\r\n" : "";
		if((c.cep1.value == "") && (c.cep2.value == "")){
			e += "O campo CEP é obrigatório!\r\n";
		} else {
			var cep = c.cep1.value+"-"+c.cep2.value;
			var field_cep = document.createElement('input');
			field_cep.setAttribute('type', 'hidden');
			field_cep.setAttribute('name', 'cep');
			field_cep.setAttribute('value', cep);
			c.appendChild(field_cep);
		}
		e += (c.cid.value == "") ? "O campo CIDADE é obrigatório!\r\n" : "";
		e += (c.est.value == "") ? "O campo ESTADO é obrigatório!\r\n" : "";
  		e += (c.telddd1.value == "") ? "O campo DDD 1 é obrigatório!\r\n" : "";
		e += (c.tel1.value == "") ? "O campo TELEFONE 1 é obrigatório!\r\n" : "";
	
	    var hz = false;
		var ind = 0;
		for (h = 0; h < c.contribui_x.length; h++) {
			if(c.contribui_x[h].checked){
				hz = true;
				ind = h;
			}
		}
		if(!hz && c.contribui_vta.value == "" | c.contribui_vtb.value == "" | c.contribui_vtc.value == ""){
			e += "O campo VALOR é obrigatório!\r\n";
		}
		if(hz & c.contribui_vta.value == "" & c.contribui_vtb.value == "" & c.contribui_vtc.value == "" & !c.contribui_x[6].checked & !c.contribui_x[7].checked & !c.contribui_x[8].checked){
			if(!c.contribui_valor){
				var field_z = document.createElement('input');
				field_z.setAttribute('type', 'hidden');
				field_z.setAttribute('name', 'contribui_valor');
				field_z.setAttribute('value', c.contribui_x[ind].value);
				c.appendChild(field_z);
			} else {
				c.contribui_valor.setAttribute('value', c.contribui_x[ind].value);
			}
		}
		if(!c.contribui_x[6].checked & c.contribui_vta.value != "" || c.contribui_x[6].checked & c.contribui_vta.value == ""){
			e += "Selecione a opção e informe o valor acima do mínimo estabelecido!\r\n";
		}
		if(!c.contribui_x[7].checked & c.contribui_vtb.value != "" || c.contribui_x[7].checked & c.contribui_vtb.value == ""){
			e += "Selecione a opção e informe o valor da doação única!\r\n";
		}
		if(!c.contribui_x[8].checked & c.contribui_vtc.value != "" || c.contribui_x[8].checked & c.contribui_vtc.value == ""){
			e += "Selecione a opção e informe o trabalho voluntário!\r\n";
		}
		if(c.contribui_x[6].checked & c.contribui_vta.value != ""){
			if(!c.contribui_valor){
				var field_z = document.createElement('input');
				field_z.setAttribute('type', 'hidden');
				field_z.setAttribute('name', 'contribui_valor');
				field_z.setAttribute('value', removeNonNumbers(c.contribui_vta.value));
				c.appendChild(field_z);
			} else {
				c.contribui_valor.setAttribute('value', removeNonNumbers(c.contribui_vta.value));
			}
		}
		if(c.contribui_x[7].checked & c.contribui_vtb.value != ""){
			c.contribui_data.setAttribute('value', ''); ;
			if(!c.contribui_valor){
				var field_z = document.createElement('input');
				field_z.setAttribute('type', 'hidden');
				field_z.setAttribute('name', 'contribui_valor');
				field_z.setAttribute('value', removeNonNumbers(c.contribui_vtb.value));
				c.appendChild(field_z);
			} else {
				c.contribui_valor.setAttribute('value', removeNonNumbers(c.contribui_vtb.value));
			}
		}
		if(c.contribui_x[8].checked & c.contribui_vtc.value != ""){
			c.contribui_data.setAttribute('value', 'Trabalho'); ;
			if(!c.contribui_forma){
				var field_z = document.createElement('input');
				field_z.setAttribute('type', 'hidden');
				field_z.setAttribute('name', 'contribui_forma');
				field_z.setAttribute('value', c.contribui_vtc.value);
				c.appendChild(field_z);
			} else {
				c.contribui_forma.setAttribute('value', c.contribui_vtc.value);
			}
		}
	}
	
		// colabora 4
	if(c.who.value == "com_est") {
  		e += (c.nome.value == "") ? "O campo NOME é obrigatório!\r\n" : "";
  		e += (c.email.value == "") ? "O campo EMAIL é obrigatório!\r\n" : "";
		  	if((c.email.value != "") && (!isEmailValido(c.email.value))){
  				e += "Formato inválido no e-mail, altere por favor !\r\n";
  			}
		e += (c.nome_org.value == "") ? "O campo ORGANIZAÇÃO é obrigatório!\r\n" : "";
		e += (c.cpf.value == "") ? "O campo CPF é obrigatório!\r\n" : "";
		e += (c.end.value == "") ? "O campo ENDERECO é obrigatório!\r\n" : "";
		e += (c.num.value == "") ? "O campo NUMERO é obrigatório!\r\n" : "";
		e += (c.bai.value == "") ? "O campo BAIRRO é obrigatório!\r\n" : "";
		if((c.cep1.value == "") && (c.cep2.value == "")){
			e += "O campo CEP é obrigatório!\r\n";
		} else {
			var cep = c.cep1.value+"-"+c.cep2.value;
			var field_cep = document.createElement('input');
			field_cep.setAttribute('type', 'hidden');
			field_cep.setAttribute('name', 'cep');
			field_cep.setAttribute('value', cep);
			c.appendChild(field_cep);
		}
		e += (c.cid.value == "") ? "O campo CIDADE é obrigatório!\r\n" : "";
		e += (c.est.value == "") ? "O campo ESTADO é obrigatório!\r\n" : "";
  		e += (c.telddd1.value == "") ? "O campo DDD 1 é obrigatório!\r\n" : "";
		e += (c.tel1.value == "") ? "O campo TELEFONE 1 é obrigatório!\r\n" : "";
	
	    var hz = false;
		var ind = 0;
		for (h = 0; h < c.contribui_x.length; h++) {
			if(c.contribui_x[h].checked){
				hz = true;
				ind = h;
			}
		}
		if(!hz && c.contribui_vta.value == "" | c.contribui_vtb.value == ""){
			e += "O campo VALOR é obrigatório!\r\n";
		}
		if(hz & c.contribui_vta.value == "" & c.contribui_vtb.value == "" & !c.contribui_x[2].checked & !c.contribui_x[3].checked){
			if(!c.contribui_valor){
				var field_z = document.createElement('input');
				field_z.setAttribute('type', 'hidden');
				field_z.setAttribute('name', 'contribui_valor');
				field_z.setAttribute('value', c.contribui_x[ind].value);
				c.appendChild(field_z);
			} else {
				c.contribui_valor.setAttribute('value', c.contribui_x[ind].value);
			}
		}
		if(!c.contribui_x[2].checked & c.contribui_vta.value != "" || c.contribui_x[2].checked & c.contribui_vta.value == ""){
			e += "Selecione a opção e informe um outro valor!\r\n";
		}
		if(!c.contribui_x[3].checked & c.contribui_vtb.value != "" || c.contribui_x[3].checked & c.contribui_vtb.value == ""){
			e += "Selecione a opção e informe o trabalho voluntário!\r\n";
		}
		if(c.contribui_x[2].checked & c.contribui_vta.value != ""){
			if(!c.contribui_valor){
				var field_z = document.createElement('input');
				field_z.setAttribute('type', 'hidden');
				field_z.setAttribute('name', 'contribui_valor');
				field_z.setAttribute('value', removeNonNumbers(c.contribui_vta.value));
				c.appendChild(field_z);
			} else {
				c.contribui_valor.setAttribute('value', removeNonNumbers(c.contribui_vta.value));
			}
		}
		if(c.contribui_x[3].checked & c.contribui_vtb.value != ""){
			if(!c.contribui_forma_valor){
				var field_z = document.createElement('input');
				field_z.setAttribute('type', 'hidden');
				field_z.setAttribute('name', 'contribui_forma');
				field_z.setAttribute('value', removeNonNumbers(c.contribui_vtb.value));
				c.appendChild(field_z);
			} else {
				c.contribui_forma.setAttribute('value', removeNonNumbers(c.contribui_vtb.value));
			}
		}
		e += (c.contribui_data.value == "") ? "O campo SELECIONE é obrigatório!\r\n" : "";

	}
	
	// admin area
	
		// login
	if(c.who.value == "log") {
  		e += (c.login.value == "") ? "O campo USUARIO é obrigatório!\r\n" : "";
  		e += (c.passwd.value == "") ? "O campo SENHA é obrigatório!\r\n" : "";
	}
		// conteudo
	if(c.who.value == "not") {
  		e += (c.titulo.value == "") ? "O campo TITULO é obrigatório!\r\n" : "";
		e += (c.texto.value == "") ? "O campo TEXTO é obrigatório!\r\n" : "";
		if(c.data.value != ""){
			var data_sql = c.data.value.substring(6) + "-" + c.data.value.substring(3, 5) + "-" + c.data.value.substring(0, 2);
			var field_cdat = document.createElement('input');
			field_cdat.setAttribute('type', 'hidden');
			field_cdat.setAttribute('name', 'cdata');
			field_cdat.setAttribute('value', data_sql);
			c.appendChild(field_cdat);
		} else {
			e += "O campo DATA é obrigatório!\r\n";
		}
		if(c.isFot){
			if(c.isFot.checked){
				isFO(c.isFot,c.isFot.value);
			}
		}
		if(c.isArq){
			if(c.isArq.checked){
				isAR(c.isArq,c.isArq.value);
			}
		}
	}
	if(c.who.value == "pro") {
  		e += (c.titulo.value == "") ? "O campo ORGANIZAÇÃO é obrigatório!\r\n" : "";
		e += (c.subtitulo.value == "") ? "O campo TÍTULO é obrigatório!\r\n" : "";
		// e += (c.texto.value == "") ? "O campo TEXTO é obrigatório!\r\n" : "";
		if(c.data.value != ""){
			var data_sql = c.data.value.substring(6) + "-" + c.data.value.substring(3, 5) + "-" + c.data.value.substring(0, 2);
			var field_cdat = document.createElement('input');
			field_cdat.setAttribute('type', 'hidden');
			field_cdat.setAttribute('name', 'cdata');
			field_cdat.setAttribute('value', data_sql);
			c.appendChild(field_cdat);
		} else {
			e += "O campo DATA é obrigatório!\r\n";
		}
		if(c.isFot){
			if(c.isFot.checked){
				isFO(c.isFot,c.isFot.value);
			}
		}
		if(c.isArq){
			if(c.isArq.checked){
				isAR(c.isArq,c.isArq.value);
			}
		}
	}
	if(c.who.value == "pen") {
  		e += (c.titulo.value == "") ? "O campo ORGANIZAÇÃO é obrigatório!\r\n" : "";
		e += (c.subtitulo.value == "") ? "O campo TÍTULO é obrigatório!\r\n" : "";
		// e += (c.texto.value == "") ? "O campo TEXTO é obrigatório!\r\n" : "";
		if(c.data.value != ""){
			var data_sql = c.data.value.substring(6) + "-" + c.data.value.substring(3, 5) + "-" + c.data.value.substring(0, 2);
			var field_cdat = document.createElement('input');
			field_cdat.setAttribute('type', 'hidden');
			field_cdat.setAttribute('name', 'cdata');
			field_cdat.setAttribute('value', data_sql);
			c.appendChild(field_cdat);
		} else {
			e += "O campo DATA é obrigatório!\r\n";
		}
		if(c.isFot){
			if(c.isFot.checked){
				isFO(c.isFot,c.isFot.value);
			}
		}
		if(c.isArq){
			if(c.isArq.checked){
				isAR(c.isArq,c.isArq.value);
			}
		}
	}
	
		// quemapoia
	if(c.who.value == "qu2") {
  		e += (c.catTipo.value == "") ? "O campo CLASSIFICAÇÃO é obrigatório!\r\n" : "";
		if(c.isFot){
			if (!c.isFot.checked) {
				e += (c.foto.value == "") ? "O campo LOGOTIPO é obrigatório!\r\n" : "";
			}
		} else {
			e += (c.foto.value == "") ? "O campo LOGOTIPO é obrigatório!\r\n" : "";
		}
	}
	
		// galeria
	if(c.who.value == "gal") {
  		e += (c.tema.value == "") ? "O campo TEMA é obrigatório!\r\n" : "";
	}
	
		// protema
	if(c.who.value == "pte") {
  		e += (c.tema.value == "") ? "O campo TEMA é obrigatório!\r\n" : "";
	}
	
		// album
	if(c.who.value == "alb") {
		e += (c.galID.value == "") ? "O campo GALERIA é obrigatório!\r\n" : "";
		e += (c.foto.value == "") ? "O campo FOTO é obrigatório!\r\n" : "";
  		e += (c.titulo.value == "") ? "O campo TITULO é obrigatório!\r\n" : "";
	}
	
		// audiocast
	if(c.who.value == "mid") {
  		e += (c.tema.value == "") ? "O campo TEMA é obrigatório!\r\n" : "";
  		if(c.data.value != ""){
			var data_sql = c.data.value.substring(6) + "-" + c.data.value.substring(3, 5) + "-" + c.data.value.substring(0, 2);
			var field_cdat = document.createElement('input');
			field_cdat.setAttribute('type', 'hidden');
			field_cdat.setAttribute('name', 'cdata');
			field_cdat.setAttribute('value', data_sql);
			c.appendChild(field_cdat);
		} else {
			var data_sql = "";
			var field_cdat = document.createElement('input');
			field_cdat.setAttribute('type', 'hidden');
			field_cdat.setAttribute('name', 'cdata');
			field_cdat.setAttribute('value', data_sql);
			c.appendChild(field_cdat);
		}
	}
	
	if (e == "") {
		// c.submit();
		return true;
	} else {
		window.alert(e);
		return false;
	}
}

function isFO(element,datafot) {
	var c = document.getElementById("cad");
	if(c.foto){
		if (element.checked) {
			c.foto.setAttribute('type', 'hidden');
			c.foto.setAttribute('value', datafot);
		} else {
			c.foto.setAttribute('type', 'file');
			c.foto.setAttribute('value', "");
		}
	}
}

function isAR(element,datafot) {
	var c = document.getElementById("cad");
	if(c.arqv){
		if(element.checked){	
			c.arqv.setAttribute('type', 'hidden');
			c.arqv.setAttribute('value', datafot);
		} else {
			c.arqv.setAttribute('type', 'file');
			c.arqv.setAttribute('value', "");
		}
	}
}

function chkNum(oe) {
	if(oe.keyCode>=48&&oe.keyCode<=57||oe.which>=48&&oe.which<=57) { 
		return true; 
	} else if (oe.keyCode==8||oe.keyCode==9||oe.which==8||oe.which==9) {
    	return true; 
  	} else {
    	return false;
  	}
}

function formataDados(evento,mascara){
    var caracteres = "0123456789";
    
    var dat = document.getElementById("data");
    
    if(dat.value.length == mascara.length) {
		return false;
    }
    	pos = dat.value.length; 
		if (mascara.charAt(pos) != '0'){ 
		    dat.value = dat.value + mascara.charAt(pos);
		    pos++;
		}
    if(mascara.charAt(dat.value.length) == '0') {
	    if(caracteres.indexOf(String.fromCharCode(evento.keyCode)) >= 0) {
			return true;
		}
	}
	return false;
}

function desformataDados(obj){
    if ((obj.value == "") || (obj.value == null)){
        return "";
    }
    resposta = "";
    for (i = 0; i < obj.value.length; i++) {
        if ((obj.value.charAt(i) != ".") && (obj.value.charAt(i) != ",")
                && (obj.value.charAt(i) != "-") && (obj.value.charAt(i) != "/") 
                && (obj.value.charAt(i) != ":") 
                && (obj.value.charAt(i) != "(") && (obj.value.charAt(i) != ")")) 
        {

            resposta = resposta + obj.value.charAt(i);
        }
    }
    return resposta;
}

function removeNonNumbers(str)
{
  var s = new String(str);
  sr = s.replace(/\D*/g,"");
  return sr;
}

function formataData(campo,teclapres) // uso: <input onkeyup="formataData(this,event);">
{
  var tecla = teclapres.keyCode;
  var vr = removeNonNumbers(campo.value);
  tam = vr.length;
  if (tecla != 9 && tecla != 8)
  {
    if (tam >= 2 && tam < 4)
    {
      campo.value = vr.substr(0,2) + '/' + vr.substr(2,tam);
    }
    else if (tam >= 4)
    {
      campo.value = vr.substr(0,2) + '/' + vr.substr(2,2) + '/' + vr.substr(4,4);
    }
		
  }
}

function formataMoeda(campo,len) // uso: <input onkeyup="formataMoeda(this,16);">
{
  n = '__0123456789';
  d = campo.value;
  l = d.length;
  r = '';
  if (l > 0)
  {
    z = d.substr(0,l-1);
    s = '';
    a = 2;
    for (i=0; i < l; i++)
    {
      c = d.charAt(i);
      if (n.indexOf(c) > a)
      {
        a = 1;
        s+= c;
      }
    }
    l = s.length;
    t = len-1;
    if (l > t)
    {
      l = t;
      s = s.substr(0,t);
    }
    if (l > 2)
    {
      r = s.substr(0,l-2)+','+s.substr(l-2,2);
    }
    else if (l == 2)
    {
      //r='0,'+s;
      r = s;
    }
    else if (l == 1)
    {
      //r='0,0'+s;
      r = s;
    }

    if (r == '')
    {
      r = '0,00';
    }
    else
    {
      l = r.length;
      if (l > 6)
      {
        j = l % 3;
        w = r.substr(0,j);
        wa = r.substr(j,l-j-6);
        wb = r.substr(l-6,6);
        if (j > 0)
        {
          w+= '.';
        }
        k = (l-j)/3-2;
        for (i=0; i < k; i++)
        {
          w+= wa.substr(i*3,3)+'.';
        }
        r = w + wb;
      }
    }
  }
  campo.value = (r.length <= len) ? r: z;
}

function isEmailValido(email)
{
  var reg1 = new RegExp(/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/);
  var reg2 = new
RegExp(/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,6}|[0-9]{1,3})(\]?)$/);
  return (!reg1.test(email) && reg2.test(email)) ? true: false;
}
//-->