/*ACEITAR SOMENTE NUMEROS NO CAMPO*/
function somente_numeros(){
	var tecla = event.keyCode;
	if (tecla > 47 && tecla < 58 || tecla == 44){ 
		return true;
	}else{
		if (tecla != 8){
			event.keyCode = 0;
		}else{
			return true;
		}
	}
}

/*FORMATAR DATA*/
function formatarData(src,mask) {
	var i		= src.value.length;
	if (i == 10 && window.event.keyCode != 9){
		src.value	= src.value;
	} else	{
		var saida	= mask.substring(0,1);
		var texto	= mask.substring(i);
		if (texto.substring(0,1) != saida) {
			src.value += texto.substring(0,1);
		}
	}
}

/*MASCARAR TELEFONE*/
function mascarar(src,msk) {
	var i		= src.value.length;
	var x		= msk.substring(0,1);
	var y		= msk.substring(i);
	
	if (y.substring(0,1) != x) {
		src.value += y.substring(0,1);
	}
}

/*# MOEDA #*/
function moeda(valor,cx)	{
	if (valor)	{
		var doc = eval('document.all.'+cx);
		if (window.event.keyCode == 190 || window.event.keyCode == 194 || window.event.keyCode == 110 || window.event.keyCode == 188)	{
			doc.value = valor.substr(0, (valor.length-1));
		}	else	{
			valor = mascaraCentavosLimpar(valor);
			if (mascaraCentavosLimpar(valor).length > 1)	{
				str = valor.replace(".", "");
				doc.value = str.substr(0, (str.length-1))+"."+str.substr((str.length-1), str.length);
			}	else	{
				valor = mascaraCentavosLimpar(valor);
				if (valor.length == 0)	{
					doc.value = "0.0"+valor;
				}	else	{
					doc.value = "0."+valor;
				}
			}
		}
	}
}

/* LIMPA OS CENTAVOS */
function mascaraCentavosLimpar(valor)	{
	if (valor.indexOf("0")  == 0)	{
		valor = valor.replace("0.", "");
		valor = valor.replace("0.0", "");
	}
	valor = valor.replace(".", "");
	return valor;
}


/* FUNÇÃO QUE VALIDA O FORMULÁRIO DE ATUALIZAÇÃO DE PASSAGEIROS*/
function vldCadastroPax()
{
	var f = document.frm;
	var vc_msg = '';	
	
		if(f.nomeVC.value == ''){vc_msg += 'Nome\n';}
		if(f.sobrenomeVC.value == ''){vc_msg += 'Último Nome\n';}
		if(f.nomecompletoVC.value == ''){vc_msg += 'Nome Completo\n';}
		if(f.apelidoVC.value == ''){vc_msg += 'Como prefere ser chamado\n';}
		if(f.nascimentoDT.value == ''){vc_msg += 'Data de Nascimento\n';}
		if(f.rgVC.value == ''){vc_msg += 'RG\n';}
		if(f.emailVC.value == ''){vc_msg += 'E-mail\n';}
		if(f.foneVC.value == ''){vc_msg += 'Telefone\n';}
		if(vc_msg != ''){alert('Os seguintes campos devem ser preenchidos\n\n' + vc_msg);}
		else{
			f.submit();
		}
}

/* PERMITE APENAS NÚMEROS */
function Numeros(){
	var tecla = event.keyCode;
	if (tecla > 47 && tecla < 58){ 
		return true;
	}else{
		if (tecla != 8){
			event.keyCode = 0;
		}else{
			return true;
		}
	}
}

