function calcularHipoteca(){
	var importe      = document.getElementById("precio");
	var duracion     = document.getElementById("plazo");
	var tipo_interes = document.getElementById("interes");
	var cuota        = document.getElementById("cuota");
	var error        = false;
	var msg          = "<dt>Error en los siguientes campos:<\/dt>";
	var temp;
	var resultado;

	tipo_interes.value = tipo_interes.value.replace(",", ".");	// quitamos posibles comas y las cambiamos por ceros decimales

	if( isNaN(importe.value) || importe.value <= 0 ){
    	importe.value = "";importe.focus();
    	msg = msg+"<dd><strong>precio de la vivienda<\/strong> El valor no es válido.<\/dd>";
    	error = true;
	}
	if( isNaN(duracion.value) || duracion.value == 0 ){
    	msg = msg+"<dd><strong>plazo de la hipoteca<\/strong> El valor no es válido.<\/dd>";error = true;
	}
	if( isNaN(tipo_interes.value) || tipo_interes.value == 0.0 || tipo_interes.value <= 0 ){
    	tipo_interes.value = "";tipo_interes.focus();
   	 	msg = msg+"<dd><strong>tipo de interés<\/strong> El valor no es válido.<\/dd>";
    	error = true;
	}

	importe      = parseInt(importe.value);
	duracion     = parseInt(duracion.value);
	tipo_interes = parseFloat(tipo_interes.value);
	duracion     = duracion * 12; //pasamos la duracion en tiempo a meses
	tipo_interes = tipo_interes / 1200.0; //el interes debe ser mensual
	temp         = 1.0 + tipo_interes;
	resultado    = importe * tipo_interes * Math.pow(temp,duracion) / ( Math.pow(temp,duracion) - 1.0 );
	cuota.value= Math.round(resultado*100)/100;
}

