// JavaScript Document
function fregistrar()
{
	fmayus();
	nom=frmreg.txtnom.value;ape=frmreg.txtape.value;dir=frmreg.txtdir.value;
	
	tel=frmreg.txttel.value;cor=frmreg.txtcor.value;tip=frmreg.cbotipo.value;
	
	don=frmreg.txtdon.value;can=frmreg.txtcan.value;
	e=0;fno=0;fap=0;fdi=0;fte=0;fco=0;fti=0;fdo=0;fca=0;
	if(nom.length==0){alert("Falta Ingresar Nombres");fno=1;
	e++;frmreg.txtnom.style.backgroundColor='#FFFFCC';}
	else{frmreg.txtnom.style.backgroundColor='#FFFFFF';}
	if(ape.length==0){alert("Falta Ingresar Apellidos");fap=1;
	e++;frmreg.txtape.style.backgroundColor='#FFFFCC';}
	else{frmreg.txtape.style.backgroundColor='#FFFFFF';}
	if(dir.length==0){alert("Falta Ingresar Dirección");fdi=1;
	e++;frmreg.txtdir.style.backgroundColor='#FFFFCC';}
	else{frmreg.txtdir.style.backgroundColor='#FFFFFF';}
	if(tel.length==0){alert("Falta Ingresar Telefono");fte=1;
	e++;frmreg.txttel.style.backgroundColor='#FFFFCC';}
	else{frmreg.txttel.style.backgroundColor='#FFFFFF';}
	if(cor.length==0){alert("Falta Ingresar Correo");fco=1;
	e++;frmreg.txtcor.style.backgroundColor='#FFFFCC';}
	else{frmreg.txtcor.style.backgroundColor='#FFFFFF';}
	if(tip==0){alert("Falta Elegir El Tipo de Donación");fti=1;
	e++;frmreg.cbotipo.style.backgroundColor='#FFFFCC';}
	else{frmreg.cbotipo.style.backgroundColor='#FFFFFF';}
	if(don.length==0){alert("Falta Ingresar Especialidad");fdo=1;
	e++;frmreg.txtdon.style.backgroundColor='#FFFFCC';}
	else{frmreg.txtdon.style.backgroundColor='#FFFFFF';}
	if(can.length==0){alert("Falta Ingresar Cantidad");fca=1;
	e++;frmreg.txtcan.style.backgroundColor='#FFFFCC';}
	else if(can==0){alert("La Cantidad no puede ser CERO");fca=1;
	e++;frmreg.txtcan.style.backgroundColor='#FFFFCC';}
	else{frmreg.txtcan.style.backgroundColor='#FFFFFF';}
	if(e==0){ConfirmarEnvio(frmreg);}
	else
	{
		if(fca==1){frmreg.txtcan.focus();}
		if(fdo==1){frmreg.txtdon.focus();}
		if(fti==1){frmreg.cbotipo.focus();}
		if(fco==1){frmreg.txtcor.focus();}
		if(fte==1){frmreg.txttel.focus();}
		if(fdi==1){frmreg.txtdir.focus();}
		if(fap==1){frmreg.txtape.focus();}
		if(fno==1){frmreg.txtnom.focus();}
	}
}
function ffecha()
{
	f=new Date();
	d=f.getDate();
	m=f.getMonth()+1;
	a=f.getYear();
	if(d<10){d="0"+d;}
	if(m<10){m="0"+m;}
	frmreg.txtfecha.value=a+"-"+m+"-"+d;
}
function fcargar()
{
	frmreg.txtnom.focus();
	ffecha();
	frmreg.txtnom.style.backgroundColor='#FFFFFF';
	frmreg.txtape.style.backgroundColor='#FFFFFF';
	frmreg.txtdir.style.backgroundColor='#FFFFFF';
	frmreg.txttel.style.backgroundColor='#FFFFFF';
	frmreg.txtcor.style.backgroundColor='#FFFFFF';
	frmreg.cbotipo.style.backgroundColor='#FFFFFF';
	frmreg.txtdon.style.backgroundColor='#FFFFFF';
	frmreg.txtcan.style.backgroundColor='#FFFFFF';
}
function ConfirmarEnvio(form)
{
enviar = window.confirm('Se Guardaran los datos del formulario');
(enviar)?form.submit():'return false';
}
function validarletras(e) 
{ // 1
    tecla = (document.all) ? e.keyCode : e.which; // 2
    if (tecla==8) return true; // 3
    patron =/[A-Za-zñÑ\s]/; // No acepta números
    te = String.fromCharCode(tecla); // 5
    return patron.test(te); // 6
}
function validarnumeros(e) 
{ // 1
    tecla = (document.all) ? e.keyCode : e.which; // 2
    if (tecla==8) return true; // 3
    patron = /[.\d]/; // Solo acepta números
    te = String.fromCharCode(tecla); // 5
    return patron.test(te); // 6
}
function validartel(e) 
{ // 1
    tecla = (document.all) ? e.keyCode : e.which; // 2
    if (tecla==8) return true; // 3
    patron = /[-\d]/; // Solo acepta números
    te = String.fromCharCode(tecla); // 5
    return patron.test(te); // 6
}
function fmayus()
{
	frmreg.txtnom.value=frmreg.txtnom.value.toUpperCase();
	frmreg.txtape.value=frmreg.txtape.value.toUpperCase();
	frmreg.txtdir.value=frmreg.txtcor.value.toUpperCase();
	frmreg.txttel.value=frmreg.txttel.value.toUpperCase();
	frmreg.txtcor.value=frmreg.txtcor.value.toUpperCase();
	frmreg.txtdon.value=frmreg.txtdon.value.toUpperCase();
	frmreg.txtcan.value=frmreg.txtcan.value.toUpperCase();
}