/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
	Códigos ASCII:
	8 = BackSpace;	9 = Tab;	46 = Delete;
	37 = Seta para esquerda;	38 = Seta para cima; 
	39 = Seta para direita;		40 = Seta para baixo;
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
function isTeclaValida(tecla){
	if(tecla > 47 && tecla < 58
		|| tecla == 8 
		|| tecla == 9
		|| tecla == 37
		|| tecla == 38
		|| tecla == 46){
		return true;
	}
	return false;
}

function numero(e){
	var tecla = (window.event) ? event.keyCode : e.which;
    return isTeclaValida(tecla);
}

function mascaraData(objeto, e) {
	var tecla = (window.event) ? event.keyCode : e.which;
	if(tecla != 8){
		if(objeto.value.length == 2){ 
			objeto.value = objeto.value + '/';
		}
		if(objeto.value.length == 5) {
			objeto.value = objeto.value + '/';
		}
	}
}

function validaData(objeto) {
	var date=objeto.value;
	var ardt=new Array;
	var ExpReg=new RegExp("(0[1-9]|1[012])/(0[1-9]|[12][0-9]|3[01])/[12][0-9]{3}");
	ardt=date.split("/");
	erro=false;
	if ( date.search(ExpReg)==-1){
		erro = true;
		}
	else if (((ardt[0]==4)||(ardt[0]==6)||(ardt[0]==9)||(ardt[0]==11))&&(ardt[1]>30))
		erro = true;
	else if ( ardt[0]==2) {
		if ((ardt[1]>28)&&((ardt[2]%4)!=0))
			erro = true;
		if ((ardt[1]>29)&&((ardt[2]%4)==0))
			erro = true;
	}
	if (erro) {
		objeto.focus();
		return false;
	}
	return true;
}

function validaForm(form){
	
	if(!validaData(form.ano)){
		alert("Ingrese la fecha de su nacimiento\nEJ: 12/23/1960");
		return false;
	}
	if(form.pais.value == ''){
		alert('Selecciona tu país');
		return false;
	}
	
	return true;
}