function vldForm(frm)
{
	var form	= eval('document.'+ frm);
	var qtdCampos	= form.length;
	var x;
	
	for(x=0;x<=qtdCampos-1;x++)
	{
		if(form.elements[x].valid != null)
		{
			if(form.elements[x].valid == 'n' || form.elements[x].valid == 'N')
			{
				if(isNaN(form.elements[x].value))
				{
					alert('Por favor preencha os campos corretamente *');
					form.elements[x].focus();
					return(false);
				}
			}
			else
			{
				if(form.elements[x].name.indexOf("email") != -1)
				{
					if(
						form.elements[x].value.indexOf("@") <= 0  ||
						form.elements[x].value.indexOf(".") == -1 ||
						form.elements[x].value.length <= 5
					)
					{
						alert('E-mail Inválido *');
						form.elements[x].focus();
						return(false)
					}
				}
				else if(form.elements[x].value == '' || form.elements[x].value == ' ')
				{
					alert('Por favor preencha os campos obrigatórios *');
					form.elements[x].focus();
					return(false);
				}
			}
		}
	}
	
	return(true);
}

function montaCombo(inicio,fim,incremento,nome,complemento,mostra)
{
	var x, ret;
	inicio	= parseInt(inicio);
	fim		= parseInt(fim);

	ret	= "<select name='"+ nome +"' id='"+ nome +"' "+ complemento +">";
	ret += "<option value=''></option>";
		if(fim >= inicio){
			for(x=inicio;x<=fim;x += incremento){
				if(mostra == x){
					ret += "<option value='"+ x +"' selected>"+ x +"</option>";
				}
				else{
					ret += "<option value='"+ x +"'>"+ x +"</option>";
				}
			}
		}
		else{
			for(x=inicio;x<=fim;x -= incremento){
				if(mostra == x){
					ret += "<option value='"+ x +"' selected>"+ x +"</option>";
				}
				else{
					ret += "<option value='"+ x +"'>"+ x +"</option>";
				}
			}
		}
	ret += "</select>";
	
	return(ret);
}


//FUNÇÃO QUE APENAS DEIXA DIGITAR NÚMEROS PONTOS E VÍRGULAS
function somenteNumeros() // PARA EVENTO OnKeyDown
{
	var Tecla = window.event.keyCode;
if (!(	(Tecla > 95 && Tecla < 106) || 
	(Tecla > 44 && Tecla < 58) 		|| 
		(Tecla > 32 && Tecla < 41)  ||
			(
			Tecla == 17  ||
			Tecla == 16  ||
			Tecla == 8   || 
			Tecla == 9   || 
			Tecla == 13  ||
			Tecla == 144 ||
			Tecla == 188 ||
			Tecla == 190 ||
			Tecla == 110 ||
			Tecla == 194 
			)
		)
	)
{window.event.returnValue = false;}
}


function MascaraCPF(Obj,Opcao)
{var KeyCod = window.event.keyCode;
 //PARA EVENTO ONBLUR / ONKEYUP
 if(Opcao == 0 && ((!(KeyCod == 16 || KeyCod == 8 || (KeyCod > 34 && KeyCod < 41)) && ((KeyCod > 47 && KeyCod < 58) || (KeyCod > 95 && KeyCod < 106))) || (KeyCod == 0)) || (RetornaNumeros(Obj.value).length == 11 && (!(KeyCod == 16 || KeyCod == 8 || (KeyCod > 34 && KeyCod < 41)))))
	{
	var NovoTexto = '';
	 var TextoAntigo = RetornaNumeros(Obj.value)
	 if(TextoAntigo.length > 11)
		{TextoAntigo = TextoAntigo.substr(0,11)}
	 for(Pos=0; Pos<TextoAntigo.length; Pos++)
		{NovoTexto+= TextoAntigo.substr(Pos,1)
		 if(NovoTexto.length == 3 || NovoTexto.length == 7)
			{NovoTexto+= '.'}
		 if(NovoTexto.length == 11) 
			{NovoTexto+= '-'}
		}
	 Obj.value = NovoTexto
	}
}

function MascaraCEP(Obj,Opcao)
{var KeyCod = window.event.keyCode;
 //PARA EVENTO ONBLUR / ONKEYUP	
 if(Opcao == 0 && ((!(KeyCod == 16 || KeyCod == 8 || (KeyCod > 34 && KeyCod < 41)) && ((KeyCod > 47 && KeyCod < 58) || (KeyCod > 95 && KeyCod < 106))) || (KeyCod == 0)) || (RetornaNumeros(Obj.value).length == 8 && (!(KeyCod == 16 || KeyCod == 8 || (KeyCod > 34 && KeyCod < 41)))))
	{var NovoTexto = '';
	 var TextoAntigo = RetornaNumeros(Obj.value)
	 if(TextoAntigo.length > 8)
		{TextoAntigo = TextoAntigo.substr(0,8)}
	 for(Pos=0; Pos<TextoAntigo.length; Pos++)
		{NovoTexto+= TextoAntigo.substr(Pos,1)
		 if(NovoTexto.length == 5)
			{NovoTexto+= '-'}
		}
	 Obj.value = NovoTexto
	}
}

function RetornaNumeros(Texto){
var CharPego = new RegExp("[^0-9]","gi")
var NovoTexto= Texto.replace(CharPego,'')
	return NovoTexto
}
function comboData(nomeCampo,complemento,sDia,sMes,sAno){
	
	var anoInicial, anoAtual, data, dataAtual, anosMais, marcar, x, y, nomeCampo, Sdia, Smes, Sano, edicao, retorno;

			data = new Date();
			anoInicial = 1910;
			dataAtual = data.getDate() +'/'+ data.getMonth() +'/'+ data.getFullYear();
			anoAtual = data.getFullYear();
			anosMais = parseInt(anoAtual)+3;
			edicao = false;
			retorno	= "";

				if(sDia == undefined && sMes == undefined && sAno == undefined)
				{
					sDia	= data.getDate();
					sMes	= (data.getMonth())+1;
					sAno	= data.getFullYear();
				}
			//==================== DIA ====================>
			for(x=1;x<=31;x++){// Escrevendo o Combo com os Dias
				if(x == 1){
					retorno += "<select id='"+ nomeCampo +"cbDia' onChange=\"document.getElementById('"+ nomeCampo +"').value = document.getElementById('"+ nomeCampo +"cbDia').value +'/'+ document.getElementById('"+ nomeCampo +"cbMes').value +'/'+ document.getElementById('"+ nomeCampo +"cbAno').value;\" style='width:40px' "+ complemento +">";
				}
				if(x <= 9){
					y = "0"+ x;
				}
				else{
					y = x;
				}
					if(sDia == y){
						marcar = " selected";
					}
					else{
						marcar = "";
					}
				retorno += "<option value='"+ y +"'"+ marcar +">"+ y +"</option>";
				if(x == 31){
					retorno += "</select> / ";
				}
			}
			//==================== MES ====================>
				for(x=1;x<=12;x++){//Escrevendo o Combo com os Meses;
					if(x == 1){
						retorno += "<select id='"+ nomeCampo +"cbMes' onChange=\"document.getElementById('"+ nomeCampo +"').value = document.getElementById('"+ nomeCampo +"cbDia').value +'/'+ document.getElementById('"+ nomeCampo +"cbMes').value +'/'+ document.getElementById('"+ nomeCampo +"cbAno').value;\" style='width:40px' "+ complemento +">";
					}
					if(x <= 9){
						y = "0"+ x;
					}
					else{
						y = x;
					}
					
						if(sMes == y){
							marcar = " selected";
						}
						else{
							marcar = "";
						}
					retorno += "<option value='"+ y +"'"+ marcar +">"+ y +"</option>";
					if(x == 12){
						retorno += "</select> / ";
					}				
				}
			//==================== ANO ====================>
			for(x=anoInicial;x<=anosMais;x++){
				if(x == anoInicial){
					retorno += "<select id='"+ nomeCampo +"cbAno' onChange=\"document.getElementById('"+ nomeCampo +"').value = document.getElementById('"+ nomeCampo +"cbDia').value +'/'+ document.getElementById('"+ nomeCampo +"cbMes').value +'/'+ document.getElementById('"+ nomeCampo +"cbAno').value;\" style='width:60px' "+ complemento +">";
				}

					if(sAno == x){
						marcar = " selected";
						edicao = true;
					}
					else{
						if(x == anoAtual && edicao == false){
							marcar = " selected";
						}
						else{
							marcar = "";
						}
					}

				retorno += "<option value='"+ x +"'"+ marcar +">"+ x +"</option>";
				if(x == anosMais){
					retorno += "</select>";
				}				
			}
		//================== HIDDEN COM  O VALOR DA DATA ======================>
		retorno += " <input type='hidden' name='"+ nomeCampo +"' id='"+ nomeCampo +"' value='"+ sDia +"/"+ sMes +"/"+ sAno +"'>";
		
		return(retorno);
}