// JavaScript Document
/*
Este Script Está hecho por Santi Rodriguez para www.climamania.com
La copia total o parcial sin autorización será castigada con penas incluso de cárcel, así que yo de tí no copiaria el codigo... ;)
CopyRight 2009
*/
function mas()
{
	var importe = document.getElementById('importe').value;
	var coef = document.getElementById('plazo').value;
	var imptram = parseInt(importe*0.02) + parseInt(importe);
	var total = coef*imptram
	var total2 = parseFloat(total); 
	var result=Math.round(total2*100)/100
	var mensaje = " incluido un 2% por costes de tramitación"
	if(coef == 0.046016)
	{
/* 25						window.alert('25')					*/
		var coef2 = 0.045216;
		var total = coef2*imptram;
		var total2 = parseFloat(total);
		var result=Math.round(total2*100)/100;
		document.getElementById('dato').innerHTML = result + mensaje;
		/*window.alert('25');*/
	}
		else
		{
/* 26						window.alert('26')					*/
			if(coef == 0.044477)
			{
				var coef2 = 0.043677
				var total = coef2*imptram
				var total2 = parseFloat(total); 
				var result=Math.round(total2*100)/100
				document.getElementById('dato').innerHTML = result + mensaje;
				/*window.alert('26');*/
			}
				else
				{
/* 27					window.alert('27')					*/
					if(coef == 0.043052)
					{
						var coef2 = 0.042252
						var total = coef2*imptram
						var total2 = parseFloat(total); 
						var result=Math.round(total2*100)/100
						document.getElementById('dato').innerHTML = result + mensaje;
						/*window.alert('27');*/
					}
						else
						{
/* 28					window.alert('28')					*/
							if(coef == 0.041729)
							{
								var coef2 = 0.040929
								var total = coef2*imptram
								var total2 = parseFloat(total); 
								var result=Math.round(total2*100)/100
								document.getElementById('dato').innerHTML = result + mensaje;
								/*window.alert('28');*/
							}
								else
								{
									/* 29					window.alert('29')					*/
									if(coef == 0.040497)
									{
										var coef2 = 0.039697
										var total = coef2*imptram
										var total2 = parseFloat(total); 
										var result=Math.round(total2*100)/100
										document.getElementById('dato').innerHTML = result + mensaje;
										/*window.alert('29');*/
									}
										else
										{
									/* 30					window.alert('30')					*/
											if(coef == 0.039348)
											{
												var coef2 = 0.038548
												var total = coef2*imptram
												var total2 = parseFloat(total); 
												var result=Math.round(total2*100)/100
												document.getElementById('dato').innerHTML = result + mensaje;
												/*window.alert('30');*/
											}
												else
												{
									/* 31					window.alert('31')					*/
													if(coef == 0.038274)
													{
														var coef2 = 0.037474
														var total = coef2*imptram
														var total2 = parseFloat(total); 
														var result=Math.round(total2*100)/100
														document.getElementById('dato').innerHTML = result + mensaje;
														/*window.alert('31');*/
													}
														else
														{
													/* 32				window.alert('32')					*/
															if(coef == 0.037266)
															{
																var coef2 = 0.036466
																var total = coef2*imptram
																var total2 = parseFloat(total); 
																var result=Math.round(total2*100)/100
																document.getElementById('dato').innerHTML = result + mensaje;
																/*window.alert('32');*/
															}
																else
																{
																/* 33				window.alert('33')					*/
																	if(coef == 0.036320)
																	{
																		var coef2 = 0.035520 
																		var total = coef2*imptram
																		var total2 = parseFloat(total); 
																		var result=Math.round(total2*100)/100
																		document.getElementById('dato').innerHTML = result + mensaje;
																		/*window.alert('33');*/
																	}
																		else
																		{
																	/* 34			window.alert('34')					*/
																			if(coef == 0.035431)
																			{
																				var coef2 = 0.034631
																				var total = coef2*imptram
																				var total2 = parseFloat(total); 
																				var result=Math.round(total2*100)/100
																				document.getElementById('dato').innerHTML = result + mensaje;
																				/*window.alert('34');*/
																			}
																				else
																				{
																		/* 35			window.alert('35')					*/
																					if(coef == 0.034592)
																					{
																						var coef2 = 0.033792
																						var total = coef2*imptram
																						var total2 = parseFloat(total); 
																						var result=Math.round(total2*100)/100
																						document.getElementById('dato').innerHTML = result + mensaje;
																						/*window.alert('35');*/
																					}
																						else
																						{
																				/* 36			window.alert('36')					*/
																							if(coef == 0.033800)
																							{
																								var coef2 = 0.033000
																								var total = coef2*imptram
																								var total2 = parseFloat(total); 
																								var result=Math.round(total2*100)/100
																								document.getElementById('dato').innerHTML = result + mensaje;
																								/*window.alert('36');*/
																							}
																								else
																								{
																					/* 37			window.alert('37')					*/
																									if(coef == 0.033051)
																									{
																										var coef2 = 0.032251
																										var total = coef2*imptram
																										var total2 = parseFloat(total); 
																										var result=Math.round(total2*100)/100
																										document.getElementById('dato').innerHTML = result + mensaje;
																										/*window.alert('37');*/
																									}
																										else
																										{
																						/* 38			window.alert('38')					*/
																											if(coef == 0.032342)
																											{
																												var coef2 = 0.031542
																												var total = coef2*imptram
																												var total2 = parseFloat(total); 
																												var result=Math.round(total2*100)/100
																												document.getElementById('dato').innerHTML = result + mensaje;
																												/*window.alert('38');*/
																											}
																												else
																												{
																								/* 39			window.alert('39')					*/
																													if(coef == 0.031669)
																													{
																														var coef2 = 0.030869
																														var total = coef2*imptram
																														var total2 = parseFloat(total); 
																														var result=Math.round(total2*100)/100
																														document.getElementById('dato').innerHTML = result + mensaje;
																														/*window.alert('39');*/
																													}
																														else
																														{
																										/* 40			window.alert('40')					*/
																															if(coef == 0.031030)
																															{
																																var coef2 = 0.030230 
																																var total = coef2*imptram
																																var total2 = parseFloat(total); 
																																var result=Math.round(total2*100)/100
																																document.getElementById('dato').innerHTML = result + mensaje;
																																/*window.alert('40');*/
																															}
																																else
																																{
																												/* 41			window.alert('41')					*/
																																	if(coef == 0.030423)
																																	{
																																		var coef2 = 0.029623
																																		var total = coef2*imptram
																																		var total2 = parseFloat(total); 
																																		var result=Math.round(total2*100)/100
																																		document.getElementById('dato').innerHTML = result + mensaje;
																																		/*window.alert('41');*/
																																	}
																																		else
																																		{
																																	/* 42			window.alert('42')					*/
																																			if(coef == 0.029845)
																																			{
																																				var coef2 = 0.029045
																																				var total = coef2*imptram
																																				var total2 = parseFloat(total); 
																																				var result=Math.round(total2*100)/100
																																				document.getElementById('dato').innerHTML = result + mensaje;
																																				/*window.alert('42');*/
																																			}
																																				else
																																				{
																																				/* 43			window.alert('43')					*/
																																					if(coef == 0.029293)
																																					{
																																						var coef2 = 0.028493
																																						var total = coef2*imptram
																																						var total2 = parseFloat(total); 
																																						var result=Math.round(total2*100)/100
																																						document.getElementById('dato').innerHTML = result + mensaje;
																																						/*window.alert('43');*/
																																					}
																																						else
																																						{																																							
																																						/* 44			window.alert('44')					*/
																																							if(coef == 0.028768)
																																							{
																																								var coef2 = 0.027968
																																								var total = coef2*imptram
																																								var total2 = parseFloat(total); 
																																								var result=Math.round(total2*100)/100
																																								document.getElementById('dato').innerHTML = result + mensaje;
																																								/*window.alert('44');*/
																																							}
																																								else
																																								{
																																									if(coef == 0.028265)
																																								/* 45			window.alert('45')					*/
																																									{
																																										var coef2 = 0.027465
																																										var total = coef2*imptram
																																										var total2 = parseFloat(total); 
																																										var result=Math.round(total2*100)/100
																																										document.getElementById('dato').innerHTML = result + mensaje;
																																										/*window.alert('45');*/
																																									}
																																										else
																																										{
																																									/* 46			window.alert('46')					*/
																																											if(coef == 0.027785)
																																											{
																																												var coef2 = 0.026985
																																												var total = coef2*imptram
																																												var total2 = parseFloat(total); 
																																												var result=Math.round(total2*100)/100
																																												document.getElementById('dato').innerHTML = result + mensaje;
																																												/*window.alert('46');*/
																																											}
																																												else
																																												{
																																												/* 47		window.alert('47')					*/
																																													if(coef == 0.027325)
																																													{
																																														var coef2 = 0.026525
																																														var total = coef2*imptram
																																														var total2 = parseFloat(total); 
																																														var result=Math.round(total2*100)/100
																																														document.getElementById('dato').innerHTML = result + mensaje;
																																														/*window.alert('47');*/
																																													}
																																														else
																																														{
																																														/* 48		window.alert('48')					*/
																																															if(coef == 0.026885)
																																															{
																																																var coef2 = 0.026085
																																																var total = coef2*imptram
																																																var total2 = parseFloat(total); 
																																																var result=Math.round(total2*100)/100
																																																document.getElementById('dato').innerHTML = result + mensaje;
																																																/*window.alert('48');*/
																																															}
																																																else
																																																{
																																																/* 49		window.alert('49')					*/
																																																	if(coef == 0.026463)
																																																	{
																																																		var coef2 = 0.025663
																																																		var total = coef2*imptram
																																																		var total2 = parseFloat(total); 
																																																		var result=Math.round(total2*100)/100
																																																		document.getElementById('dato').innerHTML = result + mensaje;
																																																		/*window.alert('49');*/
																																																	}
																																																		else
																																																		{
																																																		/* 50		window.alert('50')					*/
																																																			if(coef == 0.026058)
																																																			{
																																																				var coef2 = 0.025258
																																																				var total = coef2*imptram
																																																				var total2 = parseFloat(total); 
																																																				var result=Math.round(total2*100)/100
																																																				document.getElementById('dato').innerHTML = result + mensaje;
																																																				/*window.alert('50');*/
																																																			}			
																																																				else
																																																				{
																																																				/* 51		window.alert('51')					*/
																																																					if(coef == 0.025669)
																																																					{
																																																						var coef2 = 0.024869
																																																						var total = coef2*imptram
																																																						var total2 = parseFloat(total); 
																																																						var result=Math.round(total2*100)/100
																																																						document.getElementById('dato').innerHTML = result + mensaje;
																																																						/*window.alert('51');*/
																																																					}
																																																							else
																																																							{
																																																								/* 52		window.alert('52')					*/
																																																									if(coef == 0.025295)
																																																									{
																																																										var coef2 = 0.024495
																																																										var total = coef2*imptram
																																																										var total2 = parseFloat(total); 
																																																										var result=Math.round(total2*100)/100
																																																										document.getElementById('dato').innerHTML = result + mensaje;
																																																										/*window.alert('52');*/
																																																									}
																																																										else
																																																										{
																																																											/* 53		window.alert('53')					*/
																																																											if(coef == 0.024935)
																																																											{
																																																												var coef2 = 0.024135
																																																												var total = coef2*imptram
																																																												var total2 = parseFloat(total); 
																																																												var result=Math.round(total2*100)/100
																																																												document.getElementById('dato').innerHTML = result + mensaje;
																																																												/*window.alert('53');*/
																																																											}
																																																													else
																																																													{
																																																														/* 54		window.alert('54')					*/
																																																														if(coef == 0.024589)
																																																														{
																																																															var coef2 = 0.023789
																																																															var total = coef2*imptram
																																																															var total2 = parseFloat(total); 
																																																															var result=Math.round(total2*100)/100
																																																															document.getElementById('dato').innerHTML = result + mensaje;
																																																															/*window.alert('54');*/
																																																														}
																																																															else
																																																															{
																																																																/* 55		window.alert('55')					*/
																																																																if(coef == 0.024256)
																																																																{
																																																																	var coef2 = 0.023456
																																																																	var total = coef2*imptram
																																																																	var total2 = parseFloat(total); 
																																																																	var result=Math.round(total2*100)/100
																																																																	document.getElementById('dato').innerHTML = result + mensaje;
																																																																	/*window.alert('55');*/
																																																																}
																																																																	else
																																																																	{
																																																																		/* 56		window.alert('56')					*/
																																																																		if(coef == 0.023935)
																																																																		{
																																																																			var coef2 = 0.023135
																																																																			var total = coef2*imptram
																																																																			var total2 = parseFloat(total); 
																																																																			var result=Math.round(total2*100)/100
																																																																			document.getElementById('dato').innerHTML = result + mensaje;
																																																																			/*window.alert('56');*/
																																																																		}
																																																																			else
																																																																			{
																																																																				/* 57		window.alert('57')					*/
																																																																				if(coef == 0.023625)
																																																																				{
																																																																					var coef2 = 0.022825
																																																																					var total = coef2*imptram
																																																																					var total2 = parseFloat(total); 
																																																																					var result=Math.round(total2*100)/100
																																																																					document.getElementById('dato').innerHTML = result + mensaje;
																																																																					/*window.alert('57');*/
																																																																				}
																																																																					else
																																																																					{
																																																																						/* 58		window.alert('58')					*/
																																																																						if(coef == 0.023326)
																																																																						{
																																																																							var coef2 = 0.022526
																																																																							var total = coef2*imptram
																																																																							var total2 = parseFloat(total); 
																																																																							var result=Math.round(total2*100)/100
																																																																							document.getElementById('dato').innerHTML = result + mensaje;
																																																																							/*window.alert('58');*/
																																																																						}
																																																																							else
																																																																							{
																																																																								/*59            */
																																																																								if(coef == 0.023037)
																																																																								{
																																																																									var coef2 = 0.022237
																																																																									var total = coef2*imptram
																																																																									var total2 = parseFloat(total); 
																																																																									var result=Math.round(total2*100)/100
																																																																									document.getElementById('dato').innerHTML = result + mensaje;
																																																																									/*window.alert('59');*/
																																																																								}
																																																																									else
																																																																									{
																																																																										/*60            */
																																																																										if(coef == 0.022758)
																																																																										{
																																																																											var coef2 = 0.021958
																																																																											var total = coef2*imptram
																																																																											var total2 = parseFloat(total); 
																																																																											var result=Math.round(total2*100)/100
																																																																											document.getElementById('dato').innerHTML = result + mensaje;
																																																																											/*window.alert('60');*/
																																																																										}
																																																																											else
																																																																											{
																																																																												window.alert('Error en el cálculo, notífiquelo a santi@climamania.com')
																																																																											}
																																																																									}
																																																																							
																																																																							}
																																																																					}
																																																																			}
																																																																	}
																																																															}
																																																													}
																																																											}
																																																									}
																																																						}
																																																			}
																																																}
																																														}
																																												}
																																										}
																																								}
																																						}
																																				}
																																		}
																																}
																														}
																												}
																										}
																								}
																						}																				
																				}
																		}
																}
														}
												}
										}
								}
						}
				}
		}
	
}
function menos()
{
	var importe = document.getElementById('importe').value;
	var coef = document.getElementById('plazo').value;
	var imptram = parseInt(importe*0.02) + parseInt(importe);
	var total = coef*imptram
	var total2 = parseFloat(total); 
	var result=Math.round(total2*100)/100
	var mensaje = " incluido un 2% por costes de tramitación"
	document.getElementById('dato').innerHTML = result + mensaje;
}
function calcular()
{
	var importe = document.getElementById('importe').value;
	var coef = document.getElementById('plazo').value;
	var imptram = parseInt(importe*0.02) + parseInt(importe);
	var total = coef*imptram;
	document.getElementById('impt').style.color ='#000000';
	document.getElementById('plz').style.color ='#000000';
		if(importe > 3000)
		{
			if(coef < 0.047685)
			{
				mas();
			}
				else
				{
					menos();
				}
		}
			else
			{
				menos();
			}
	
	/*
	document.getElementById('dato').innerHTML = total + " incluido un 2% por costes de tramitación";
	*/
};
function validar()
{
	var importe = document.getElementById('importe').value;
	var coef = document.getElementById('plazo').value;
	var imptram = parseInt(importe*0.02) + parseInt(importe);
	var total = coef*imptram
	/*
	window.alert(imptram);
	window.alert(coef);
	window.alert(total);
	*/
	if(document.getElementById('importe').value == "")
	{
		document.getElementById('plz').style.color ='#000000';
		document.getElementById('impt').style.color ='#FF0000';
		window.alert('Falta el Importe Total');		
		
	}
		else 
		{
			if(document.getElementById('plazo').value == "NULL")
			{
				document.getElementById('impt').style.color ='#000000';
				document.getElementById('plz').style.color ='#FF0000'
				window.alert('Falta el Plazo');				
			}
				else
				{
					calcular()
				}
		}
	
};
