function showCalcularHipoteca(elem) {
  var value = this.innerHTML.replace(/[^0-9]/g, "");
  $('cantidad').value = value
  $('plazo').value = 30;
  $('interes').value = 4.5;
  calcularHipoteca(value, 30, 4.5);
  Modalbox.show( $('hipotecabox'), {title: "Calcular hipoteca", width: 600}); return false;
}

function calcularHipoteca(cantidad_str, plazo, interes) {
  cantidad=cantidad_str.replace(/[^0-9]/g, "");
  meses=plazo*12;
  interes_mensual = interes.toString().replace(/,/,'.')/12;
  $('mes').innerHTML = Math.floor( (interes_mensual * cantidad) / (100 * (1.0 - Math.pow(1.0+interes_mensual/100.0, 0-meses ) ) ) );
}

window.onload = function() {  
  var elements = $A(document.getElementsByClassName("mortage-price"));  
  elements.each(  
    function(e) {  
      Event.observe(e, "click", showCalcularHipoteca);  
    }  
  );  
}  
