// JavaScript Document
function _validaFormulario(frm){
		var campos = new Array();
		var mensagem = new Array();
		var temp1 = frm.campos_obrigatorios.value;
		var temp2 = frm.mensagem_preenchidos.value;
		campos = temp1.split(",");
		mensagem = temp2.split(",");
		for(i = 0; i < campos.length; i++){		
			if(campo = document.getElementById(campos[i])){
				if(campo.type == "text" || campo.type == "password"){
					if(campo.value == ""){
						alert(mensagem[i]);
						campo.focus();
						return false;
					}
				} else if(campo.type == "select-one"){
					if(campo.value == "0"){
						alert(mensagem[i]);
						campo.focus();
						return false;
					}
				}
				if(campos[i] == "email" || campos[i] == "email_cadastro"){
					  var txt = campo.value;
					  if ((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 7))){
						alert('E-mail incorreto');
						campo.focus();
						return false;
					  }
				}
			}
			
		}
	}
	
function formatar(mascara, documento){
  var i = documento.value.length;
  var saida = "#";
  var texto = mascara.substring(i);
  if (SomenteNumeros(documento)){
	  if (texto.substring(0,1) != saida){
		documento.value += texto.substring(0,1);
	  }
  }
  
}
function SomenteNumeros()
{
	if(event.keyCode < 48 || event.keyCode > 57)
	{
		event.keyCode = 0;
			return false;
	}
	else
	{
		return true;
	}
}
