


function IsNumeric(valor) 
{ 
var log=valor.length; var sw="S"; 
for (x=0; x<log; x++) 
{ v1=valor.substr(x,1); 
v2 = parseInt(v1); 
//Compruebo si es un valor numérico 
if (isNaN(v2)) { sw= "N";} 
} 
if (sw=="S") {return true;} else {return false; } 
} 

var primerslap=false; 
var segundoslap=false; 

function formateatxtFecNac(txtFecNac) 
{ 
var long = txtFecNac.length; 
var dia; 
var mes; 
var ano; 

if ((long>=2) && (primerslap==false)) { dia=txtFecNac.substr(0,2); 
if ((IsNumeric(dia)==true) && (dia<=31) && (dia!="00")) { txtFecNac=txtFecNac.substr(0,2)+"/"+txtFecNac.substr(3,7); primerslap=true; } 
else { txtFecNac=""; primerslap=false;} 
} 
else 
{ dia=txtFecNac.substr(0,1); 
if (IsNumeric(dia)==false) 
{txtFecNac="";} 
if ((long<=2) && (primerslap=true)) {txtFecNac=txtFecNac.substr(0,1); primerslap=false; } 
} 
if ((long>=5) && (segundoslap==false)) 
{ mes=txtFecNac.substr(3,2); 
if ((IsNumeric(mes)==true) &&(mes<=12) && (mes!="00")) { txtFecNac=txtFecNac.substr(0,5)+"/"+txtFecNac.substr(6,4); segundoslap=true; } 
else { txtFecNac=txtFecNac.substr(0,3);; segundoslap=false;} 
} 
else { if ((long<=5) && (segundoslap=true)) { txtFecNac=txtFecNac.substr(0,4); segundoslap=false; } } 
if (long>=7) 
{ ano=txtFecNac.substr(6,4); 
if (IsNumeric(ano)==false) { txtFecNac=txtFecNac.substr(0,6); } 
else { if (long==10){ if ((ano==0) || (ano<1940) || (ano>1992)) { txtFecNac=txtFecNac.substr(0,6); } } } 
} 

if (long>=10) 
{ 
txtFecNac=txtFecNac.substr(0,10); 
dia=txtFecNac.substr(0,2); 
mes=txtFecNac.substr(3,2); 
ano=txtFecNac.substr(6,4); 
// Año no viciesto y es febrero y el dia es mayor a 28 
if ( (ano%4 != 0) && (mes ==02) && (dia > 28) ) { txtFecNac=txtFecNac.substr(0,2)+"/"; } 
} 
return (txtFecNac); 
} 



//var nav4 = window.Event ? true : false;
//function acceptLetras(evt){ 
//var key = nav4 ? evt.which : evt.keyCode; 
//return (key <= 13 || (key >= 65 && key <= 256) );
//}

function acceptLetras(e) { 
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==32) return true; // barra espaciadora
	if (tecla==241) return true; // ñ
	if (tecla==209) return true; // Ñ
	if (tecla==45) return true; // -
	if (tecla==8) return true; //Tecla de retroceso (para poder borrar) 
    patron =/[A-Za-z]/; // Solo acepta letras 
    //patron = /\d/; Solo acepta números 
    //patron = /\w/; Acepta números y letras 
    //patron = /\D/; No acepta números 
    te = String.fromCharCode(tecla); 
    return patron.test(te);  
}  

function acceptNumero(e) { 
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==32) return true; // barra espaciadora
	if (tecla==8) return true; //Tecla de retroceso (para poder borrar) 
    //patron =/[A-Za-z]/; // Solo acepta letras 
    patron = /\d/; //Solo acepta números 
    //patron = /\w/; Acepta números y letras 
    //patron = /\D/; No acepta números 
    te = String.fromCharCode(tecla); 
    return patron.test(te);  
}  

function recorrerSexo(){
	for (i=0;i<document.frmRegistro.rdbgender.length;i++){ 
       if (document.frmRegistro.rdbgender[i].checked) 
		  return true;
    }
	return false;
}

function recorrerCole(){
	for (i=0;i<document.frmRegistro.rdbcole.length;i++){ 
       if (document.frmRegistro.rdbcole[i].checked) 
		  return true;
    }
	return false;
}

function checkMail(x){
	var filter  = /^(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x))
		return true;
	else
		return false;
}

//function checkMail(x){
//	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
//	if (filter.test(x))
//		return true;
//	else
//		return false;
//}

<!-- function recorrerEspecialidad(){
<!-- 	for (i=0;i<document.frmRegistro.txtfacultad.length;i++){ 
<!--        if (document.frmRegistro.txtfacultad[i].checked) 
<!-- 		  return true;
<!--     }
<!-- 	return false;
<!--   }  -->

function ConfirmaEnvio(xform){
	if(confirm('Esta seguro de Registrar estos Datos?'))
	{
		xform.hdnFlag.value = '2';
		xform.method='post';
		xform.action='registrase2.php';
		xform.submit();
	}
}

function Borrar(){
	document.frmRegistro.nombre.value = '';    
	document.frmRegistro.telefono.value = '';
	document.frmRegistro.direccion.value = '';
	document.frmRegistro.pais.value = '';

	document.frmRegistro.email.value = '';
	document.frmRegistro.obs.value = '';

}
function Envio(xform){
	//alert (document.frmRegistro.txtname.value.length);

	if (document.frmRegistro.nombre.value==''){
		alert('Ingrese su Nombre');
		document.frmRegistro.nombre.focus();
		document.frmRegistro.nombre.select();
		return false;
	}

		







	else if (document.frmRegistro.email.value==''){
		alert('Ingrese su comentario');
		document.frmRegistro.email.focus();
		document.frmRegistro.email.select();
		return false;
	}









	
	else{
		document.frmRegistro.hdnFlag.value = '1';
		return true;
	}
}


