
function valida(f)
{

var encabezado='Han ocurrido los siguientes errores:\n\n';
var errores='';

for (i=0;i<f.elements.length;i++) 
{
      if((f.elements[i].type == "text")||(f.elements[i].type == "hidden")) 
         {
		
		 var campo=f.elements[i].name.split("_");
		 MM_validateForm(f.elements[i].id,8,campo[1]);

		 if (campo[1]=='R') var descripcion=' es Requerido'; 
		 if (campo[1]=='RisEmail') var descripcion=' Debe ser e-mail valido';
		 if (campo[1]=='RisNum') var descripcion=' Debe ser Numerico';
		 if (campo[1]=='Tam') var descripcion=' El tama� del campo debe ser mayor a 8 y menor a 15';
		 if (campo[1]=='NisNum') var descripcion=' Debe ser Numerico';
	     if (!document.MM_returnValue) errores=errores+f.elements[i].id+descripcion+"\n";
		 }
	 if(f.elements[i].type == "password") 
         {
		 var campo=f.elements[i].name.split("_");
		 MM_validateForm(f.elements[i].id,8,campo[1]);

		 if (campo[1]=='R') var descripcion=' es Requerido'; 
	     if (!document.MM_returnValue) errores=errores+f.elements[i].id+descripcion+"\n";
		 }
}
if (errores!='')
	{
	//Ext.MessageBox.alert('Errores',encabezado+errores);
	alert(encabezado+errores);
	}
else
	{
	f.submit();
	}
}	 

function clona()

	{

	var campo1=document.getElementById("Concesionario_Cedula");
	
	var campo11=document.getElementById("Concesionario Cedula");

	var campo2=document.getElementById("Concesionario_Pin");

	var campo22=document.getElementById("Concesionario Pin");

	var campo3=document.getElementById("Concesionario_Rif");

	var campo33=document.getElementById("Concesionario Rif");

	campo11.value=campo1.value;

	campo1.value="";

	campo22.value=campo2.value;

	campo2.value="";

	campo33.value=campo3.value;

	campo3.value="";

	}

function clona2()

	{
	
	var campo11=document.getElementById("E-Mail");
	var campo22=document.getElementById("Clave");
	var campo1=document.getElementById("E-Mail2");
	var campo2=document.getElementById("Clave2");


	campo11.value=campo1.value;
	campo1.value="";

	campo22.value=campo2.value;
	campo2.value="";

	}

function clona3()

	{

	var campo11=document.getElementById("Pin");
	var campo22=document.getElementById("Cedula");
	var campo1=document.getElementById("Pin2");
	var campo2=document.getElementById("Cedula2");
	


	campo11.value=campo1.value;
	campo1.value="";

	campo22.value=campo2.value;
	campo2.value="";
	}


function activaAlquiler(valor)
	{
	var d=document.getElementById("divAlquiler");
	if (valor!="P")
		{
		var campo1=document.getElementById("Couta/Alquiler Mensual");
		campo1.name="alquiler_R";
		d.style.visibility="visible";
		}
	else
		{
		var campo1=document.getElementById("Couta/Alquiler Mensual");
		campo1.name="alquiler_";
		var texto=document.getElementById("Couta/Alquiler Mensual");
		texto.value="";
		var texto=document.getElementById("Codigo Telefono Arrendador");
		texto.value="";
		var texto=document.getElementById("Telefono Arrendador");
		texto.value="";
		d.style.visibility="hidden";
		}
	}


function buscaErrorFormulario(valores)
	{
	var encabezado='Han ocurrido los siguientes errores:\n\n';
	var errores='';
	//alert(valores);
	cadena = valores.split(","); 
	//formulario de concesionario
	if (cadena[0]=="0")
		{
		var texto=document.getElementById(cadena[1]);
		var valor=texto.options[texto.selectedIndex].value;
		var textos=document.getElementById(cadena[2]);
		var valores=textos.options[textos.selectedIndex].value;
		if (valor=="-1")
			{
			errores=errores+"Debe Seleccionar un Concesioanrio\n";
			}
		if (valores=="-1")
			{
			errores=errores+"Debe Seleccionar un Vehiculo\n";
			}
		}
	//formulario datos personales
	if (cadena[0]=="1")
		{
		//alert(cadena[1]);
		//alert(cadena[2]);
		var texto=document.getElementById(cadena[1]);
		var valor=texto.options[texto.selectedIndex].text;
		var textos=document.getElementById(cadena[2]);
		var valores=textos.options[textos.selectedIndex].text;
		var codTlf=document.getElementById(cadena[3]);
		var Tlf=document.getElementById(cadena[4]);
		var codCel=document.getElementById(cadena[5]);
		var TlfCel=document.getElementById(cadena[6]);
		var codAlq=document.getElementById(cadena[7]);
		var TlfAlq=document.getElementById(cadena[8]);
		//alert(codTlf.value);
		//se revisa si el campo telefono de habitacion esta completo
		if ((codTlf.value!="")||(Tlf.value!=""))
			{
			if ((codTlf.value==""))
			errores=errores+"Telefono Habitacion esta incompleto falta Codigo de Area\n";
			if ((Tlf.value==""))
			errores=errores+"Telefono Habitacion esta incompleto falta numero de Telefono\n";
			}
		//se revisa que el campo celuylar este completo
		if ((codCel.value!="")||(TlfCel.value!=""))
			{
			if ((codCel.value==""))
			errores=errores+"Telefono Celular esta incompleto falta Codigo de Area\n";
			if ((TlfCel.value==""))
			errores=errores+"Telefono Celular esta incompleto falta numero de Telefono\n";
			}
		//se revisa que el campo telefono arrendador este completo
		if ((codAlq.value!="")||(TlfAlq.value!=""))
			{
			if ((codAlq.value==""))
			errores=errores+"Telefono Arrendador esta incompleto falta Codigo de Area\n";
			if ((TlfAlq.value==""))
			errores=errores+"Telefono Arrendador esta incompleto falta numero de Telefono\n";
			}
		//se revisa si el campo de antiguedad esta bien 
		if ((valor==0)&&(valores==0))
			{
			errores=errores+"Tiempo de Residencia no puede estar en cero ambos casos\n";
			
			}
		
		
		}
	//formulario datos laborales
	if (cadena[0]=="2")
		{
		var texto=document.getElementById(cadena[1]);
		var valor=texto.options[texto.selectedIndex].text;
		var textos=document.getElementById(cadena[2]);
		var valores=textos.options[textos.selectedIndex].text;
		var div=document.getElementById(cadena[3]);
		var texto1=document.getElementById(cadena[4]);
		var valor1=texto1.options[texto1.selectedIndex].text;
		var textos2=document.getElementById(cadena[5]);
		var valores2=textos2.options[textos2.selectedIndex].text;
		var codOfc=document.getElementById(cadena[6]);
		var TlfOfc=document.getElementById(cadena[7]);
		var codAnt=document.getElementById(cadena[8]);
		var TlfAnt=document.getElementById(cadena[9]);
		var otroIngreso=document.getElementById(cadena[10]);
		var fuenteIngreso=document.getElementById(cadena[11]);
		//se revisa si el campo de antiguedad esta bien 
		if ((valor==0)&&(valores==0))
			{
			errores=errores+"Actiguedad Actual no puede estar en cero ambos casos\n";
			
			}
		//se verifica si se coloco algun otro ingreso
		if ((otroIngreso.value>0)&&(fuenteIngreso.value==""))
			{
			errores=errores+"Debe Justificar sus Otros Ingresos\n";
			
			}
		//se revisa la antiguedad del trabajo anterior
		if (div.style.visibility=="visible")
			{
			if ((valor1==0)&&(valores2==0))
				{
				errores=errores+"Actiguedad Anterior no puede estar en cero ambos casos\n";	
				}
			//se revisa si el campo telefono de habitacion esta completo
			if ((codAnt.value!="")||(TlfAnt.value!=""))
				{
				if ((codAnt.value==""))
				errores=errores+"Telefono Oficina Anterior esta incompleto falta Codigo de Area\n";
				if ((TlfAnt.value==""))
				errores=errores+"Telefono Oficina Anterior esta incompleto falta numero de Telefono\n";
				}
			
			}
		//se revisa si el campo telefono de habitacion esta completo
		if ((codOfc.value!="")||(TlfOfc.value!=""))
			{
			if ((codOfc.value==""))
			errores=errores+"Telefono Oficina esta incompleto falta Codigo de Area\n";
			if ((TlfOfc.value==""))
			errores=errores+"Telefono Oficina esta incompleto falta numero de Telefono\n";
			}
		}
	//formulario de ingresos y gastos
	if (cadena[0]=="4")
		{
		var valor1=document.getElementById(cadena[1]);
		var valor2=document.getElementById(cadena[2]);
		if ((valor1.value>0)&&(valor2.value==""))
			{
			errores=errores+"Debe Justificar sus otros Ingresos\n";
			}
		}
	//formulario de prestamos de vehiculos
	if (cadena[0]=="5")
		{
		var ciclos=cadena[1];
		for(j=1;j<=ciclos;j++)
			{
			var valor1=document.getElementById(cadena[2]+" "+j);
			var valor2=document.getElementById(cadena[3]+" "+j);
			var valor3=document.getElementById(cadena[4]+" "+j);
			var valor4=document.getElementById(cadena[5]+" "+j);
			var valor5=document.getElementById(cadena[6]+" "+j);
			if ((valor1.value!="")||(valor2.value!="")||(valor3.value!="")||(valor4.value!=""))
				{
				if (valor1.value=="")
					{
					errores=errores+"Debe Expresar el Monto Financiado "+j+"\n";
					}
				if (valor2.value=="")
					{
					errores=errores+"Debe Expresar el Plazo "+j+"\n";
					}
				if (valor3.value=="")
					{
					errores=errores+"Debe Expresar Cuota Mensual Aproximada "+j+"\n";
					}
				if (valor4.value=="")
					{
					errores=errores+"Debe Expresar Saldo a la Fecha "+j+"\n";
					}
				if (valor5.value=="")
					{
					errores=errores+"Debe Expresar la Fecha de Cancelacion "+j+"\n";
					}
				}
			}
		}
	//formulario referencia bancaria
	if (cadena[0]=="6")
		{
		//alert("entrando");
		var ciclos=cadena[1];
		//alert(ciclos);
		for(j=1;j<=ciclos;j++)
			{
			var valor1=document.getElementById(cadena[2]+" "+j);
			var texto1=document.getElementById(cadena[3]+j);
			var valor2=texto1.options[texto1.selectedIndex].value;
			var texto1=document.getElementById(cadena[4]+j);
			var valor3=texto1.options[texto1.selectedIndex].value;
			var texto1=document.getElementById(cadena[5]+j);
			var valor4=texto1.options[texto1.selectedIndex].value;
			if ((valor1.value!="")&&(valor4==""))
				{
				errores=errores+"Debe Seleccionar un Banco "+j+"\n";
				}
			if ((valor1.value!="")&&(valor1.value.length!=20))
				{
				errores=errores+"Numero de Cuenta "+j+" NO es valido\n";
				}
			if ((valor1.value!="")&&(valor3=="0"))
				{
				errores=errores+"Debe Seleccionar el Tipo de Cuenta "+j+"\n";
				}
			if ((valor1.value!="")&&(valor2=="0"))
				{
				errores=errores+"Debe Seleccionar el Titular de la Cuenta "+j+"\n";
				}
			
			
			
			}
		}
	//formulario de tarjetas de credito
	if (cadena[0]=="7")
		{
		//alert("entrando");
		var ciclos=cadena[1];
		//alert(ciclos);
		for(j=1;j<=ciclos;j++)
			{
			var valor1=document.getElementById(cadena[2]+" "+j);
			var valor2=document.getElementById(cadena[3]+" "+j);
			var texto1=document.getElementById(cadena[4]+j);
			var valor3=texto1.options[texto1.selectedIndex].value;
			var texto1=document.getElementById(cadena[5]+j);
			var valor4=texto1.options[texto1.selectedIndex].value;
			var texto1=document.getElementById(cadena[6]+j);
			var valor5=texto1.options[texto1.selectedIndex].value;
			//alert(valor1.value);
			if ((valor1.value!="")||(valor2.value!=""))
				{
				if (valor4==0)
					{
					errores=errores+"Debe Seleccionar un Tipo de Tarjeta "+j+"\n";
					}
				if (valor5=="")
					{
					errores=errores+"Debe Seleccionar un Banco Emisor "+j+"\n";
					}
				if (valor1.value.length!=16)
					{
					errores=errores+"Numero de Tarjeta de Credito "+j+" NO Valido\n";
					}
				if (valor1.value=="")
					{
					errores=errores+"Debe Indicar el número de Tarjeta "+j+"\n";
					}
				if (valor2.value=="")
					{
					errores=errores+"Debe Indicar la linea de Credito "+j+"\n";
					}
				if (valor3==0)
					{
					errores=errores+"Debe Seleccionar un año de Emision "+j+"\n";
					}
				
				
				}
			}
		}
		if (cadena[0]=="8")
		{
		//alert("entrando");
		var ciclos=cadena[1];
		//alert(ciclos);
		for(j=1;j<=ciclos;j++)
			{
			var valor1=document.getElementById(cadena[2]+" "+j);
			var valor2=document.getElementById(cadena[3]+" "+j);
			var valor3=document.getElementById(cadena[4]+" "+j);
			var valor4=document.getElementById(cadena[5]+" "+j);
			var valor5=document.getElementById(cadena[6]+" "+j);
			var valor6=document.getElementById(cadena[7]+" "+j);
			
			if ((valor1.value!="")||(valor4.value!=""))
				{
				if ((valor1.value==""))
				errores=errores+"Telefono Habitacion "+j+" esta incompleto falta Codigo de Area\n";
				if ((valor4.value==""))
				errores=errores+"Telefono Habitacion "+j+" esta incompleto falta Número de Telefono\n";
				}
			if ((valor2.value!="")||(valor5.value!=""))
				{
				if ((valor2.value==""))
				errores=errores+"Telefono Oficina "+j+" esta incompleto falta Codigo de Area\n";
				if ((valor5.value==""))
				errores=errores+"Telefono Oficina "+j+" esta incompleto falta Número de Telefono\n";
				}
			if ((valor3.value!="")||(valor6.value!=""))
				{
				if ((valor3.value==""))
				errores=errores+"Telefono Celular "+j+" esta incompleto falta Codigo de Area\n";
				if ((valor6.value==""))
				errores=errores+"Telefono Celular "+j+" esta incompleto falta Número de Telefono\n";
				}
			if((valor1.value=="")&&(valor2.value=="")&&(valor3.value=="")&&(valor4.value=="")&&(valor5.value=="")&&(valor6.value==""))
				{
				errores=errores+"Debe indicar al menos un telefono para Referencia "+j+"\n";
				}
				
				
			}
		}
		//formulario de datos del conyuge
		if (cadena[0]=="9")
			{
			var texto=document.getElementById(cadena[1]);
			var valor=texto.options[texto.selectedIndex].text;
			var textos=document.getElementById(cadena[2]);
			var valores=textos.options[textos.selectedIndex].text;
			var valor1=document.getElementById(cadena[3]);
			var valor2=document.getElementById(cadena[4]);
			var textos=document.getElementById(cadena[5]);
			var valor3=textos.options[textos.selectedIndex].value;
			var valor4=document.getElementById(cadena[6]);
			var valor5=document.getElementById(cadena[7]);
			if ((valor==0)&&(valores==0)&&(valor3<=1))
				{
				errores=errores+"Tiempo de Antiguedad no puede estar en cero ambos casos\n";	
				}
			if ((valor1.value>0)&&(valor2.value==""))
				{
				errores=errores+"Debe Justificar los otros Ingresos\n";
				}
			if ((valor3==0)&&(valor4.value==""))
				{
				errores=errores+"Nombre de la Empresa es Requerido\n";
				}
			if ((valor3==0)&&(valor5.value==""))
				{
				errores=errores+"Cargo es Requerido\n";
				}
		
			}
	if(errores!="")
		{
		alert(encabezado+errores);
		exit(0);
		}

	}

function activaOtroTrabajo(year,mes)
	{
	var valor1=document.getElementById(year);
	var texto1=valor1.options[valor1.selectedIndex].text;
	var valor2=document.getElementById(mes);
	var texto2=valor2.options[valor2.selectedIndex].text;
	var div=document.getElementById("otroTrabajo");
	var campo1=document.getElementById("Empresa Anterior");
	var campo2=document.getElementById("Cargo Anterior");
	var campo3=document.getElementById("Sueldo Mensual Anterior");
	var campo4=document.getElementById("Codigo Telefono Anterior");
	var campo5=document.getElementById("Telefono Anterior");
	
	
	if (texto1>=2)
		{
		

		campo1.name="empresa2_";
		campo2.name="cargo2_";
		campo3.name="sueldo2_";
		

		div.style.visibility="hidden";
		}
	else 
		{
		if ((texto1==1)&&(texto2==12))
			{
			
			campo1.name="empresa2_";
			campo2.name="cargo2_";
			campo3.name="sueldo2_";
			div.style.visibility="hidden";
			}
		else
			{

			campo1.name="empresa2_R";
			campo2.name="cargo2_R";
			campo3.name="sueldo2_R";
			div.style.visibility="visible";
			}
		}

	}

function sumaActivos()
	{
	//alert("sumandoAvtivos");
	var valor1=document.getElementById("Total Ingresos");
	var sueldo=document.getElementById("Sueldo");
	var comision=document.getElementById("Comisiones");
	var ingresos=document.getElementById("Otros Ingresos");
	var conyuge=document.getElementById("Ingresos del Conyugue");
	if (sueldo.value=="") sueldo.value=0;
	else sueldo.value=parseFloat(sueldo.value);
	if (comision.value=="") comision.value=0;
	else comision.value=parseFloat(comision.value);
	if (ingresos.value=="") ingresos.value=0;
	else ingresos.value=parseFloat(ingresos.value);
	if (conyuge.value=="") conyuge.value=0;
	else conyuge.value=parseFloat(conyuge.value);
	var total=0;
	total=parseFloat(sueldo.value)+parseFloat(comision.value)+parseFloat(ingresos.value)+parseFloat(conyuge.value);
	var resultado= new oNumero(total);
	valor1.value=resultado.formato(2,true);
	}

function sumaPasivos()
	{
	//alert("sumandoAvtivos");
	var valor1=document.getElementById("Total Gastos");
	var sueldo=document.getElementById("Alquiler o Hipoteca");
	var comision=document.getElementById("Gastos Familiares");
	var ingresos=document.getElementById("Prestamos");
	var conyuge=document.getElementById("Tarjeta de Credito");
	if (sueldo.value=="") sueldo.value=0;
	else sueldo.value=parseFloat(sueldo.value);
	if (comision.value=="") comision.value=0;
	else 
		{
		var resultado2= new oNumero(comision.value);
		comision.value=resultado2.formato(2,true);
		}
	if (ingresos.value=="") ingresos.value=0;
	else ingresos.value=parseFloat(ingresos.value);
	if (conyuge.value=="") conyuge.value=0;
	else conyuge.value=parseFloat(conyuge.value);
	var total=0;
	total=parseFloat(sueldo.value)+parseFloat(comision.value)+parseFloat(ingresos.value)+parseFloat(conyuge.value);
	var resultado= new oNumero(total);
	valor1.value=resultado.formato(2,true);
	}


function IsNumber(e) {

tecla = (document.all) ? e.keyCode : e.which;

if (tecla==8) return true;

patron = /\d/; // Solo acepta nÃºmeros

te = String.fromCharCode(tecla);

return patron.test(te);

} 




function oNumero(numero)
{
//Propiedades
this.valor = numero || 0
this.dec = -1;
//Métodos
this.formato = numFormat;
this.ponValor = ponValor;
//Definición de los métodos
function ponValor(cad)
{
if (cad =='-' || cad=='+') return
if (cad.length ==0) return
if (cad.indexOf('.') >=0)
    this.valor = parseFloat(cad);
else
    this.valor = parseInt(cad);
}
function numFormat(dec, miles)
{
var num = this.valor, signo=3, expr;
var cad = ""+this.valor;
var ceros = "", pos, pdec, i;
for (i=0; i < dec; i++)
ceros += '0';
pos = cad.indexOf('.')
if (pos < 0)
    cad = cad+"."+ceros;
else
    {
    pdec = cad.length - pos -1;
    if (pdec <= dec)
        {
        for (i=0; i< (dec-pdec); i++)
            cad += '0';
        }
    else
        {
        num = num*Math.pow(10, dec);
        num = Math.round(num);
        num = num/Math.pow(10, dec);
        cad = new String(num);
        }
    }
pos = cad.indexOf('.')
if (pos < 0) pos = cad.lentgh
if (cad.substr(0,1)=='-' || cad.substr(0,1) == '+')
       signo = 4;
if (miles && pos > signo)
    do{
        expr = /([+-]?\d)(\d{3}[\.\,]\d*)/
        cad.match(expr)
        cad=cad.replace(expr, RegExp.$1+','+RegExp.$2)
        }
while (cad.indexOf(',') > signo)
    if (dec<0) cad = cad.replace(/\./,'')
        return cad;
}
}


function abrir_ventana2(name,ancho,alto){
	window.name="Tope";
	window.open(name, "ventana", "width="+ancho+",height="+alto+",dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=yes,resizable=no"); 
}


function cambiaColor(id,color)
	{
	
	var imput= document.getElementById(id);
	if (color==1)
	imput.className="combo2";
	else
	imput.className="combo";
	}

function mayuscula(id)
	{
	var imput= document.getElementById(id);
	imput.value=imput.value.toUpperCase();
	}

function minuscula(id)
	{
	var imput= document.getElementById(id);
	imput.value=imput.value.toLowerCase();
	}

function Patrimonio()
	{
	/////////////////ACTIVOS
	var valor1=document.getElementById("Patrimonio Activos Pasivos");
	var valor2=document.getElementById("Efectivo");
	var valor3=document.getElementById("Cuentas por Cobrar");
	var valor4=document.getElementById("Inmuebles");
	var valor5=document.getElementById("Otros Activos");
	var valor22=valor2.value.replace(/[.]/g,'');
	valor22=valor22.replace (",",".");
	var valor33=valor3.value.replace(/[.]/g,'');
	valor33=valor33.replace (",",".");
	var valor44=valor4.value.replace(/[.]/g,'');
	valor44=valor44.replace (",",".");
	var valor55=valor5.value.replace(/[.]/g,'');
	valor55=valor55.replace (",",".");
	
	//////////////////PASIVOS
	var valor6=document.getElementById("Prestamos");
	var valor7=document.getElementById("Cuentas por Pagar");
	var valor8=document.getElementById("Hipotecas por Pagar");
	var valor9=document.getElementById("Otros Pasivos");
	var valor66=valor6.value.replace(/[.]/g,'');
	valor66=valor66.replace (",",".");
	var valor77=valor7.value.replace(/[.]/g,'');
	valor77=valor77.replace (",",".");
	var valor88=valor8.value.replace(/[.]/g,'');
	valor88=valor88.replace (",",".");
	var valor99=valor9.value.replace(/[.]/g,'');
	valor99=valor99.replace (",",".");
	
	
	if ((valor2.value!="")&&(valor3.value!="")&&(valor4.value!="")&&(valor5.value!="")&&(valor6.value!="")&&(valor7.value!="")&&(valor8.value!="")&&(valor9.value!=""))
		{
		var activo=(parseFloat(valor22)) + (parseFloat(valor33)) + (parseFloat(valor44)) + (parseFloat(valor55)); //+(parseInt(valor3.value,10))+(parseInt(valor4.value,10))+(parseInt(valor5.value,10));
		var pasivo=(parseFloat(valor66)) + (parseFloat(valor77)) + (parseFloat(valor88)) + (parseFloat(valor99)); //parseInt(valor6.value,10)+parseInt(valor7.value,10)+parseInt(valor8.value,10)+parseInt(valor9.value,10);
		var total=0;
		if (activo>0)
			{	
			total=activo-pasivo;
			//alert(total);
			//var resultado= new oNumero(total);
			var num = new NumberFormat();
			num.setInputDecimal('.');
			num.setNumber(total); // obj.value is '1000.32'
			num.setPlaces('2', false);
			num.setCurrencyValue('$');
			num.setCurrency(false);
			num.setCurrencyPosition(num.LEFT_OUTSIDE);
			num.setNegativeFormat(num.LEFT_DASH);
			num.setNegativeRed(false);
			num.setSeparators(true, '.', ',');
			valor1.value=num.toFormatted();
			//valor1.value=tryNumber(total);//resultado.formato(0,true);
			}
		else
			{
			//alert("Los Activos no pueden dar cero")
			valor1.value="";
			}
		}
	else
		{
		valor1.value="";
		}
	
	}


function formatoNumerico(fld, milSep, decSep, e)
	{
	//alert("aqui");
	var sep = 0;
	var key = '';
	var i = j = 0;
	var len = len2 = 0;
	var strCheck = '0123456789';
	var aux = aux2 = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode == 13) return true; 
	key = String.fromCharCode(whichCode); // Get key value from key code
	if (strCheck.indexOf(key) == -1 && whichCode!=8) return false; // Not a valid key
	if (fld.value.length<14)
		len = fld.value.length;
	else
		len = 13;
	for(i = 0; i < len; i++)
		if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep))
		break;
	aux = '';
	for(; i < len; i++)
		if (strCheck.indexOf(fld.value.charAt(i))!=-1 && whichCode!=8)
			aux += fld.value.charAt(i);
	if (whichCode!=8)
		aux += key;
	len = aux.length;
	if (len == 0)
		fld.value = '';
	if (len == 1)
	fld.value = '0'+ decSep + '0' + aux;
	if (len == 2)
	fld.value = '0'+ decSep + aux;
	if (len > 2) 
		{
		aux2 = '';
		for (j = 0, i = len - 3; i >= 0; i--) 
			{
			if (j == 3) 
				{
				aux2 += milSep;
				j = 0;
				}
			aux2 += aux.charAt(i);
			j++;
			}
		fld.value = '';
		len2 = aux2.length;
		for (i = len2 - 1; i >= 0; i--)
			fld.value += aux2.charAt(i);
		fld.value += decSep + aux.substr(len - 2, len);     
		}
	
	return false; 
	} 


function teclapress(fld, e)
	{
	var whichCode = (window.Event) ? e.which : e.keyCode;
	if (whichCode==8)
		fld.value='';
	} 

function tryNumber(obj)
{
alert(obj);
var num = new NumberFormat();
num.setInputDecimal('.');
num.setNumber(obj); // obj.value is '1000.32'
num.setPlaces('2', false);
num.setCurrencyValue('$');
num.setCurrency(false);
num.setCurrencyPosition(num.LEFT_OUTSIDE);
num.setNegativeFormat(num.LEFT_DASH);
num.setNegativeRed(false);
num.setSeparators(true, '.', ',');
num.toFormatted();
alert(num);
return(num);
}

function block(capa)
	{
	soy = document.getElementById(capa);
	//alert(capa);
	soy.style.display = (soy.style.display == "block") ? "none" : "block";
      	}

function validaReg()
	{
	alert("aqui");
	var valor1=document.getElementById("mail");
	var valor2=document.getElementById("nacimeinto");
	alert(valor1.value);
	alert(valor2.value);	
	}
