function validar(f) {
	if(f.ti_total.value=='') {
		alert("You must fill the 'Interest' field");
		return false;
	}
	if(f.ti_total.value==0) {
		alert("The 'Interest' field must be greater than 0");
		return false;
	}		
	if(f.ahorros.value=='') {
		alert("You must fill the 'Initial Savings' field");		
		return false;
	}
	if(f.calculo[0].checked) {
		if(f.precio.value=='' || f.precio.value==0) {
			alert("You must fill the 'Principal' field");		
			return false;
		}
	}
	if(f.calculo[1].checked) {
		if(f.cuota.value=='' || f.cuota.value==0) {
			alert("You must fill the 'Monthly payment' field");		
			return false;
		}
	}
	return true;
}
function mostrarPrecio() {
	id_cuota_label = document.getElementById('cuota_mensual_label');
	id_cuota_input = document.getElementById('cuota_mensual_input');
	id_precio_label = document.getElementById('precio_inmueble_label');
	id_precio_input = document.getElementById('precio_inmueble_input');		
	id_boton = document.getElementById('boton');		
	id_precio_label.style.display = 'none';
	id_precio_input.style.display = 'none';
	id_cuota_label.style.display = 'inline';
	id_cuota_input.style.display = 'inline';
	id_boton.value='Compute monthly payment';
}
function mostrarCuota() {
	id_cuota_label = document.getElementById('cuota_mensual_label');
	id_cuota_input = document.getElementById('cuota_mensual_input');
	id_precio_label = document.getElementById('precio_inmueble_label');
	id_precio_input = document.getElementById('precio_inmueble_input');		
	id_boton = document.getElementById('boton');		
	id_precio_label.style.display = 'inline';
	id_precio_input.style.display = 'inline';
	id_cuota_label.style.display = 'none';
	id_cuota_input.style.display = 'none';
	id_boton.value='Compute principal';
}
function comprobarGastosEuros() {
	id_euros = document.getElementById('gastos_compra');
	id_porciento = document.getElementById('gastos_porciento');
	if(id_euros.value!='') {
		if(id_porciento.selectedIndex!=0) {
			id_porciento.selectedIndex = 0;
		}
	}
}
function comprobarGastosPorciento() {
	id_euros = document.getElementById('gastos_compra');
	id_porciento = document.getElementById('gastos_porciento');
	if(id_porciento.selectedIndex!=0) {
		id_euros.value = '';
	}
}
