function calcular_cuota(){
	h=document.fr_calc.hip.value;
	h=h.replace(/,/,".");
	m=document.fr_calc.mes.value;
	i=document.fr_calc.int.value;
	i=i.replace(/,/,".");
	if(h!="" && m!="" && i != ""){
		c=cuota(i,m,h);	
		if(c != 0){
			document.fr_calc.cuota.value=c;
		}
	}
}
function cuota(int,mes,hip){	
	i=int;
	m=mes;
	h=hip;
	f =1-(Math.pow((1+i/1200),-m*12));		
	c = h * (i/1200)/f;	
	return dec(c);
}
function dec(valor){
	v=valor;
	if ((v==0)||isNaN(v))
	{
	b=0;
	}
	else
	{
	a=parseInt((v+.005)*100);
	b=(a/100);
	}
	return(b);
}

function validar_int(e) 
{
	tecla = (document.all) ? e.keyCode : e.which;
	
	//alert(tecla);
	//Tecla de retroceso para borrar, siempre la permite
	if (tecla==8) return true;
	//,
	if (tecla==44) return true; 
	//.
	if (tecla==46) return true;
	//TAB
	if (tecla==0) return true;
	//ENTER
	if (tecla==13) {
		doSubmit();
		return false;
	}
	
	// Patron de entrada, en este caso solo acepta letras
	patron = /\d/;
	
	tecla_final = String.fromCharCode(tecla);
	return patron.test(tecla_final); 
} 

function validar_num(e) 
{
	tecla = (document.all) ? e.keyCode : e.which;
	
	//alert(tecla);
	//Tecla de retroceso para borrar, siempre la permite
	if (tecla==8) return true;
	//TAB
	if (tecla==0) return true;
	//ENTER	
	if (tecla==13) {
		doSubmit();
		return false;
	}
	
	// Patron de entrada, en este caso solo acepta letras
	patron = /\d/;
	
	tecla_final = String.fromCharCode(tecla);
	return patron.test(tecla_final); 
} 

function doSubmit() {
  // omitted logic that sets the action on the form based on the selected option
  //document.frmSearch.submit();
  calcular_cuota()
  document.fr_calc.Calcular.focus();
}
