function c_1()
{
	document.getElementById('banner').innerHTML = '<a href="http://www.web1.com"><img alt="prestamos - hipotecas" title="prestamos - hipotecas" src="img/banner_01.gif"/></a>';setTimeout('c_2()',5000);}function c_2(){	document.getElementById('banner').innerHTML = '<a href="http://www.gabinetlaboral.com"><img alt="prestamos - hipotecas" title="prestamos - hipotecas" src="img/banner_02.gif"/></a>';setTimeout('c_1()',5000);}function c_3(){	document.getElementById('banner').innerHTML = '<a href="http://www.web3.com"><img alt="prestamos - hipotecas" title="prestamos - hipotecas" src="img/banner_03.gif"/></a>';
	setTimeout('c_1()',5000);
}
function nomesnumeros(e) // Amb aquesta funció el que feim es que nomes es puguin introduir numeros
{
	var tecla;
	tecla = (document.all) ? e.keyCode : e.which; 
	if (tecla== 8 || tecla == 0 || tecla == 9 || tecla == 11) return true; 
	admeses =/[0-9]/; 
	teclacorrecta = String.fromCharCode(tecla); 
	return admeses.test(teclacorrecta); 
}
function nomeslletres(e) // Amb aquesta funció el que feim es que nomes es puguin introduir lletres
{
   var tecla;
   tecla = (document.all) ? e.keyCode : e.which; 
   if (tecla ==8 || tecla == 0 || tecla == 9 || tecla == 11 || tecla == 32) return true; 
   admeses =/[A-Za-zñÑ]/; 
   teclacorrecta = String.fromCharCode(tecla); 
   return admeses.test(teclacorrecta); 
}
function numerosicomes(e) // Amb aquesta funció el que feim es que nomes es puguin introduir numeros, comes i punts
{
	var tecla;
	tecla = (document.all) ? e.keyCode : e.which; 
	if (tecla == 8 || tecla == 0 || tecla == 9 || tecla == 11) return true; 
	admeses =/[0-9\,\.]/; 
	teclacorrecta = String.fromCharCode(tecla); 
	return admeses.test(teclacorrecta); 
}
function formatear_numero(numero)
{
	var auxNumero='';
	var strNumero= numero + '';
	for (var i = 0; i < strNumero.length; i++)        
	{ 
		var ch = strNumero.substring(i, i + 1)
		if (ch == '.') 
		{  
			auxNumero = auxNumero + ',';
		} 
		else 
		{
			auxNumero = auxNumero + ch;           
		}             
	}  
	return auxNumero; 
}
function desformatear_numero(numero)
{
	var auxNumero='';
	var strNumero= numero + '';
	for (var i = 0; i < strNumero.length; i++)        
	{	 
		var ch = strNumero.substring(i, i + 1)
		if (ch == ',') 
		{  
			auxNumero = auxNumero + '.';
		} 
		else 
		{
			auxNumero = auxNumero + ch;           
		}             
	}  
	return auxNumero; 
}
function calcul() // Calcula l'import a pagar 
{
	var moneda;
	moneda = "-€";
	
	imp = parseInt(desformatear_numero(document.forms[1].importe.value))
	plazo_meses = parseInt(desformatear_numero(document.forms[1].plazo.value))
	tipo_mensual = parseFloat(desformatear_numero(document.forms[1].tipo.value))
	
	medida = 12.0
	
	var frecuencia;
	frecuencia = 12;
	var pcarencia;
	var interes;
	var intereses;
	var pagomes;
	var plazosin;
	importe = document.forms[1].importe.value*1;
	plazo = document.forms[1].plazo.value*1;
	pcarencia = document.forms[1].plazo.value*1*frecuencia;
	interes = document.forms[1].tipo.value/(100*frecuencia);
	intereses = importe*interes;
	intereses = Math.round(intereses);
	
	document.forms[1].carencia.value = (intereses + moneda);
	
	
	if ( isNaN(imp) || imp == 0 )
	{ 
		alert("Debe rellenar 'Importe'")
		return; 
	}
	if ( isNaN(plazo_meses) || plazo_meses == 0 )
	{ 
		alert("Debe rellenar 'Años'")
		return; 
	}
	if ( tipo_mensual > 20.0 ) 
	{ 
		alert("El Tipo de interés es superior al 20% y no es aceptable para un préstamo hipotecario.")
		return; 
	}
	plazo_meses = plazo_meses * medida
	// EL TIPO DE INTERES VIENE EN ANIOS Y LOS PASAMOS A TIPO INTERES MENSUAL
	tipo_mensual = tipo_mensual / 1200.0
	y  = 1.0 + tipo_mensual
	cuota = imp * tipo_mensual * Math.pow(y,plazo_meses) / ( Math.pow(y,plazo_meses) - 1.0 )
	document.forms[1].cuota.value = formatear_numero(Math.round(cuota *100.00) / 100.00) + moneda;
	tipo_mensual_max = 4.00 / 1200.0;
}
function check()
{
	if(document.getElementById('Motivo').value == "")				
	{					
		alert('Elija un motivo de envío');					
		return false;				
	}
	var mailito = document.frmFormMail.mail.value;
	var cadena = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	if (cadena.test(mailito)) 
	{
		document.frmFormMail.submit();
	} 
	else 
	{
		alert('Introduzca una dirección de e-mail válida');
	}
}