/************************************************
* Dynamic Calculator generation - JEB 03-26-2008*
************************************************/

function getcalc(name, containerid)
{
	if (name == "mensuales")
	{
		var CP = formatCurrency("125000");
		var TI = addPct("7.5");
		var CA = "30";

		var search = location.search;
		search = search.replace(/\?/,'');
		var searchAttributes = search.split('&');
		for(var no=0;no<searchAttributes.length;no++)
		{
			var items = searchAttributes[no].split('=');

			if (items[0] == "CP")
			{
				CP = (items[1]!="0")?formatCurrency(floor(items[1])):"";
			}
			if (items[0] == "TI")
			{
				TI = addPct(items[1]);	
			}
			if (items[0] == "CA")
			{
				CA = items[1];	
			}
		}
		
		document.getElementById(containerid).innerHTML = "<form name=\"hipomens\" method=\"post\" action=\"default.html\" ><div style=\"float:left; width:295px; height:25px;\">	<img src=\"App_Images/calculadora/calc-header.gif\" alt=\"Calculadora\" height=\"25px\" width=\"175px\"/><img src=\"App_Images/calculadora/calc-bienes-raices.gif\" alt=\"Calculadora\" height=\"25px\" width=\"120\"/></div><div class=\"calctitle\">	PAGOS MENSUALES HIPOTECA <img src=\"App_Images/calculadora/orangearrow.gif\" height=\"9px\" width=\"6px\"/></div><div align=\"right\" style=\"float:left; width:291px; border-top:solid 2px #839DB8; background-color:#D5DBE7; padding:2px;\">	<table>	<tr>		<td style=\"font-size:9px; text-align:right\">Cantidad del pr&eacute;stamo  :			</td>		<td style=\"font-size:9px;\">			<input name=LA size=14 value=\"" + CP + "\" onFocus=\"setdefault(document.hipomens);document.hipomens.LA.select();document.hipomens.LA.focus();\" onChange=\"basicedit(document.hipomens);this.value=formatCurrency(this.value);\">		</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">			Tasa de inter&eacute;s anual:					</td>		<td style=\"font-size:9px;\">			<input name=IR size=14 value=\"" + TI + "\"  onFocus=\"document.hipomens.IR.select();document.hipomens.IR.focus();\" onChange=\"basicedit(document.hipomens);this.value=addPct(this.value);\">		</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Cantidad de a&ntilde;os:	</td>		<td>			<input name=YR size=14 value=\"" + CA + "\" onChange=\"basicedit(document.hipomens);\" onFocus=\"document.hipomens.YR.select();document.hipomens.YR.focus();\">		</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td colspan=\"2\" style=\"font-size:9px; text-align:right\">			<a href=\"javascript:computehipomens(document.hipomens);\">				<img style=\"border:none;\" src=\"App_Images/calculadora/calcbutton.gif\" alt=\"Calcular\" width=\"110\" height=\"19\"/>			</a>		</td>	  </tr>	</table></div><div  align=\"right\" style=\"float:left; width:291px; border-top:solid 2px #FFFFFF; background-color:#D5DBE7; padding:2px;\">	<table>		<tr>			<td style=\"font-size:9px; text-align:right\">				Pago mensual (principal e inter&eacute;s)					</td>			<td style=\"font-size:9px;\">				<input name=PI size=14>			</td>		</tr>	</table></div></form>"
		

        var firefox = navigator.userAgent.indexOf("Firefox");
       
        if (firefox > -1 || window.opera)
        {
            parent.document.getElementById('frmCalc').style.height= 230 + 'px';
        }
	}
	
	if (name == "vehiculos")
	{
		var CP = formatCurrency("25000");
		var TI = addPct("8.95");
		var CA = "6";

		var search = location.search;
		search = search.replace(/\?/,'');
		var searchAttributes = search.split('&');
		for(var no=0;no<searchAttributes.length;no++)
		{
			var items = searchAttributes[no].split('=');

			if (items[0] == "CP")
			{
				CP = (items[1]!="0")?formatCurrency(floor(items[1])):"";
			}
			if (items[0] == "TI")
			{
				TI = addPct(items[1]);	
			}
			if (items[0] == "CA")
			{
				CA = items[1];	
			}
		}
		
		document.getElementById(containerid).innerHTML = "<form name=\"vehimens\" method=\"post\" action=\"default.html\" ><div style=\"float:left; width:295px; height:25px;\">	<img src=\"App_Images/calculadora/calc-header.gif\" alt=\"Calculadora\" height=\"25px\" width=\"175px\"/><img src=\"App_Images/calculadora/calc-vehiculos.gif\" alt=\"Calculadora\" height=\"25px\" width=\"120\"/></div><div class=\"calctitle\">	PAGOS MENSUALES VEHICULO <img src=\"App_Images/calculadora/orangearrow.gif\" height=\"9px\" width=\"6px\"/></div><div align=\"right\" style=\"float:left; width:291px; border-top:solid 2px #839DB8; background-color:#D5DBE7; padding:2px;\">	<table>	<tr>		<td style=\"font-size:9px; text-align:right\">Cantidad del pr&eacute;stamo  :			</td>		<td style=\"font-size:9px;\">			<input name=LA size=14 value=\"" + CP + "\" onFocus=\"setdefault(document.vehimens);document.vehimens.LA.select();document.vehimens.LA.focus();\" onChange=\"basicedit(document.vehimens);this.value=formatCurrency(this.value);\">		</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">			Tasa de inter&eacute;s anual:					</td>		<td style=\"font-size:9px;\">			<input name=IR size=14 value=\"" + TI + "\"  onFocus=\"document.vehimens.IR.select();document.vehimens.IR.focus();\" onChange=\"basicedit(document.vehimens);this.value=addPct(this.value);\">		</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Cantidad de a&ntilde;os:	</td>		<td>			<input name=YR size=14 value=\"" + CA + "\" onChange=\"basicedit(document.vehimens);\" onFocus=\"document.vehimens.YR.select();document.vehimens.YR.focus();\">		</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td colspan=\"2\" style=\"font-size:9px; text-align:right\">			<a href=\"javascript:computehipomens(document.vehimens);\">				<img style=\"border:none;\" src=\"App_Images/calculadora/calcbutton.gif\" alt=\"Calcular\" width=\"110\" height=\"19\"/>			</a>		</td>	  </tr>	</table></div><div  align=\"right\" style=\"float:left; width:291px; border-top:solid 2px #FFFFFF; background-color:#D5DBE7; padding:2px;\">	<table>		<tr>			<td style=\"font-size:9px; text-align:right\">				Pago mensual (principal e inter&eacute;s)					</td>			<td style=\"font-size:9px;\">				<input name=PI size=14>			</td>		</tr>	</table></div></form>"
		
		
        var firefox = navigator.userAgent.indexOf("Firefox");
       
        if (firefox > -1 || window.opera)
        {
            parent.document.getElementById('frmCalc').style.height= 230 + 'px';
        }
	}
	
	if (name == "mensmax")
	{
		var SB = formatCurrency("3500");
		var PM = formatCurrency("400");
		var TI = addPct("7.5");

		var search = location.search;
		search = search.replace(/\?/,'');
		var searchAttributes = search.split('&');
		for(var no=0;no<searchAttributes.length;no++)
		{
			var items = searchAttributes[no].split('=');

			if (items[0] == "SB")
			{
				SB = (items[1]!="0")?formatCurrency(floor(items[1])):"";
			}
			if (items[0] == "PM")
			{
				PM =  formatCurrency(floor(items[1]));	
			}
			if (items[0] == "TI")
			{
				TI = addPct(items[1]);	
			}

		}
		
		document.getElementById(containerid).innerHTML = "<form name=\"mensmax\" method=\"post\" action=\"default.html\"><div style=\"float:left; width:295px; height:25px;\">	<img src=\"App_Images/calculadora/calc-header.gif\" alt=\"Calculadora\" height=\"25px\" width=\"175px\"/><img src=\"App_Images/calculadora/calc-bienes-raices.gif\" alt=\"Calculadora\" height=\"25px\" width=\"120\"/></div><div class=\"calctitle\">	MENSUALIDAD M&Aacute;XIMA <img src=\"App_Images/calculadora/orangearrow.gif\" height=\"9px\" width=\"6px\"/></div><div align=\"right\" style=\"float:left; width:291px; border-top:solid 2px #839DB8; background-color:#D5DBE7; padding:2px;\">	<table>	<tr>		<td style=\"font-size:9px; text-align:right\">Sueldo Bruto Mensual:			</td>		<td style=\"font-size:9px;\">			<input name=income size=14 value=\"" + SB + "\" onFocus=\"document.mensmax.income.select();document.mensmax.income.focus();\" onChange=\"cppbasicedit(document.mensmax);this.value=formatCurrency(this.value);\" maxlength=\"9\"> 		</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">			Pagos mensuales de la deuda:<br>(Incluye las tarjetas de cr&eacute;dito)					</td>		<td style=\"font-size:9px;\">			<input name=auto size=14 value=\"" + PM + "\" onFocus=\"document.mensmax.auto.select();document.mensmax.auto.focus();\" onChange=\"cppbasicedit(mensmax);this.value=formatCurrency(this.value);\" maxlength=\"9\">					</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Tasa de Inter&eacute;s:	</td>		<td>			<input name=rate size=14 value=\"" + TI + "\" onFocus=\"document.mensmax.rate.select();document.mensmax.rate.focus();\" onChange=\"cppbasicedit(mensmax);this.value=addPct(this.value);\" maxlength=\"5\">		</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td colspan=\"2\" style=\"font-size:9px; text-align:right\">			<a href=\"javascript:computecpp(document.mensmax);\">				<img style=\"border:none;\" src=\"App_Images/calculadora/calcbutton.gif\" alt=\"Calcular\" width=\"110\" height=\"19\" />			</a>		</td>	  </tr>	</table></div><div  align=\"right\" style=\"float:left; width:291px; border-top:solid 2px #FFFFFF; background-color:#D5DBE7; padding:2px;\">	<table>		<tr>			<td style=\"font-size:9px; text-align:right\">				Pago mensual (principal e inter&eacute;s)					</td>			<td style=\"font-size:9px;\">				<input type=\"text\" name=payment size=\"14\" >			</td>		</tr>	</table></div></form>"
		
		 var firefox = navigator.userAgent.indexOf("Firefox");
       
        if (firefox > -1 || window.opera)
        {
            parent.document.getElementById('frmCalc').style.height= 240 + 'px';
        }
	}
	
	if (name == "refnow")
	{
		var HA = formatCurrency("125000");
		var PH = formatCurrency("960");
		var TI = addPct("7.5");
		var AP = "30";
		var search = location.search;
		search = search.replace(/\?/,'');
		var searchAttributes = search.split('&');
		for(var no=0;no<searchAttributes.length;no++)
		{
			var items = searchAttributes[no].split('=');

			if (items[0] == "HA")
			{
				HA = (items[1]!="0")?formatCurrency(floor(items[1])):"";
			}
			if (items[0] == "PH")
			{
				PH = formatCurrency(floor(items[1]));	
			}
			if (items[0] == "TI")
			{
				TI = addPct(items[1]);	
			}
			if (items[0] == "AP")
			{
				AP = items[1];	
			}
		}
		
		document.getElementById(containerid).innerHTML = "<form name=\"refnow\" method=\"post\" action=\"default.html\"><div style=\"float:left; width:295px; height:25px;\">	<img src=\"App_Images/calculadora/calc-header.gif\" alt=\"Calculadora\" height=\"25px\" width=\"175px\"/><img src=\"App_Images/calculadora/calc-bienes-raices.gif\" alt=\"Calculadora\" height=\"25px\" width=\"120\"/></div><div class=\"calctitle\">	REFINANCIAR AHORA <img src=\"App_Images/calculadora/orangearrow.gif\" height=\"9px\" width=\"6px\"/></div><div align=\"right\" style=\"float:left; width:291px; border-top:solid 2px #839DB8; background-color:#D5DBE7; padding:2px;\">	<table>	<tr>		<td style=\"font-size:9px; text-align:right\">Hipoteca actual:			</td>		<td style=\"font-size:9px;\">			<input name=principal size=14 value=\"" + HA + "\" 			onFocus=\"document.refnow.principal.select();			document.refnow.principal.focus();\" onChange=\"rnbasicedit(document.refnow);this.value=formatCurrency(this.value);\" maxlength=\"9\"> 		</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Pago de hipoteca actual:</td>		<td style=\"font-size:9px;\">			<input name=payment size=14 value=\"" + PH + "\"			onFocus=\"document.refnow.payment.select();			document.refnow.payment.focus();\" onChange=	\"rnbasicedit(document.refnow);this.value=formatCurrency(this.value);\" maxlength=\"9\">				</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Tasa de Inter&eacute;s para financiar:	</td>		<td>			<input name=intRate2 size=14 value=\"" + TI + "\" 			onFocus=\"document.refnow.intRate2.select();			document.refnow.intRate2.focus();\" onChange=\"rnbasicedit(document.refnow);this.value=addPct(this.value);\" maxlength=\"5\" >		</td>	</tr>		<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">A&ntilde;os en el nuevo pr&eacute;stamo:	</td>		<td>			<input name=nper2 size=14 value=\"" + AP + "\" 		onFocus=\"document.refnow.nper2.select();		document.refnow.nper2.focus();\" onChange=\"rnbasicedit(document.refnow);\" maxlength=\"3\">		</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td colspan=\"2\" style=\"font-size:9px; text-align:right\">			<a href=\"javascript:computerefnow(document.refnow);\">				<img style=\"border:none;\" src=\"App_Images/calculadora/calcbutton.gif\" alt=\"Calcular\" width=\"110\" height=\"19\" />			</a>		</td>	  </tr>	</table></div><div  align=\"right\" style=\"float:left; width:291px; border-top:solid 2px #FFFFFF; background-color:#D5DBE7; padding:2px;\">	<table>		<tr>			<td style=\"font-size:9px; text-align:right\">Nuevo pago de hipoteca:					</td>			<td style=\"font-size:9px;\">				<input name=payment2 size=\"14\">			</td>		</tr>								<tr>			<td colspan=\"2\" style=\"height:5px;\"></td>		</tr>		<tr>			<td style=\"font-size:9px; text-align:right\">Ahorros Mensuales:					</td>			<td style=\"font-size:9px;\">				<input name=moSave size=\"14\">			</td>		</tr>							</table></div></form>" 
		
		var firefox = navigator.userAgent.indexOf("Firefox");
        
        if (firefox > -1 || window.opera)
        {
            parent.document.getElementById('frmCalc').style.height= 290 + 'px';
        
        }
	}
	
	if (name == "amort")
	{
		var CP = formatCurrency("125000");
		var NP = "360";
		var TI = addPct("7.5");
		
		var search = location.search;
		search = search.replace(/\?/,'');
		var searchAttributes = search.split('&');
		for(var no=0;no<searchAttributes.length;no++)
		{
			var items = searchAttributes[no].split('=');

			if (items[0] == "CP")
			{
				CP = (items[1]!="0")?formatCurrency(floor(items[1])):"";
			}
			if (items[0] == "NP")
			{
				NP = items[1];	
			}
			if (items[0] == "TI")
			{
				TI = addPct(items[1]);	
			}
		}
		
		document.getElementById(containerid).innerHTML = "<form name=\"amort\" method=\"post\" action=\"default.html\"><div style=\"float:left; width:295px; height:25px;\">	<img src=\"App_Images/calculadora/calc-header.gif\" alt=\"Calculadora\" height=\"25px\" width=\"175px\"/><img src=\"App_Images/calculadora/calc-bienes-raices.gif\" alt=\"Calculadora\" height=\"25px\" width=\"120\"/></div><div class=\"calctitle\">	AMORTIZACI&Oacute;N DE HIPOTECA <img src=\"App_Images/calculadora/orangearrow.gif\" height=\"9px\" width=\"6px\"/>		</div><div align=\"right\" style=\"float:left; width:291px; border-top:solid 2px #839DB8; background-color:#D5DBE7; padding:2px;\"><table><tr>	<td style=\"font-size:9px; text-align:right\">Cantidad del pr&eacute;stamo  :			</td>	<td style=\"font-size:9px;\">		<input name=\"p\" size=14 onFocus=\"document.amort.p.select();		document.amort.p.focus();\" value=\"" + CP + "\" onChange=\"ambasicedit(document.amort);this.value=formatCurrency(this.value);\" maxlength=\"9\"> 	</td></tr><tr>	<td colspan=\"2\" style=\"height:5px;\"></td></tr><tr>	<td style=\"font-size:9px; text-align:right\">		N&uacute;mero de pagos:				</td>	<td style=\"font-size:9px;\">		<input name=\"y\" size=14 onFocus=\"document.amort.y.select();		document.amort.y.focus();\" value=\"" + NP + "\" onChange=\"ambasicedit(document.amort);\" maxlength=\"5\">			</td></tr><tr>	<td colspan=\"2\" style=\"height:5px;\"></td></tr><tr>	<td style=\"font-size:9px; text-align:right\">Tasa de Inter&eacute;s :	</td>	<td>		<input name=\"ir\" size=14 onFocus=\"document.amort.ir.select();		document.amort.ir.focus();\" value=\"" + TI + "\" onChange=\"ambasicedit(document.amort);this.value=addPct(this.value);\" maxlength=\"6\">	</td></tr><tr>	<td colspan=\"2\" style=\"height:5px;\"></td></tr><tr>	<td colspan=\"2\" style=\"font-size:9px; text-align:right\">		<a href=\"javascript:PrintAmort(document.amort);\">			<img style=\"border:none;\" src=\"App_Images/calculadora/calcbutton.gif\" alt=\"Calcular\" width=\"110\" height=\"19\" />		</a>	</td>  </tr></table></div></form>" 
		
		  var firefox = navigator.userAgent.indexOf("Firefox");
        
        if (firefox > -1 || window.opera)
        {
            parent.document.getElementById('frmCalc').style.height= 200 + 'px';
        }
        
	}

	if (name == "ahorros")
	{
		var QA = formatCurrency("10000");
		var AA = formatCurrency("2500");
		var AM = formatCurrency("100");
		var MA = "12";
		var search = location.search;
		search = search.replace(/\?/,'');
		var searchAttributes = search.split('&');
		for(var no=0;no<searchAttributes.length;no++)
		{
			var items = searchAttributes[no].split('=');

			if (items[0] == "QA")
			{
				QA = (items[1]!="0")?formatCurrency(floor(items[1])):"";
			}
			if (items[0] == "AA")
			{
				AA = formatCurrency(floor(items[1]));	
			}
			if (items[0] == "AM")
			{
				AM = formatCurrency(floor(items[1]));	
			}
			if (items[0] == "MA")
			{
				MA = items[1];	
			}
		}
				
		document.getElementById(containerid).innerHTML = "<form name=\"ahorro\" method=\"post\" action=\"default.html\"><div style=\"float:left; width:295px; height:25px;\"><img src=\"App_Images/calculadora/calc-header.gif\" alt=\"Calculadora\" height=\"25px\" width=\"175px\"/><img src=\"App_Images/calculadora/calc-bienes-raices.gif\" alt=\"Calculadora\" height=\"25px\" width=\"120\"/></div><div class=\"calctitle\">	AHORROS <img src=\"App_Images/calculadora/orangearrow.gif\" height=\"9px\" width=\"6px\"/></div><div align=\"right\" style=\"float:left; width:291px; border-top:solid 2px #839DB8; background-color:#D5DBE7; padding:2px;\">	<table>	<tr>		<td style=\"font-size:9px; text-align:right\">			&iquest;Cu&aacute;nto quieres ahorrar?:		</td>		<td style=\"font-size:9px;\">			<input type=\"hidden\" name=IR value=\"0\">			<input name=\"SG\" value=\"" + QA+ "\" onFocus=\"document.ahorro.SG.select(); document.ahorro.SG.focus();\" onChange=\"ahbasicedit(document.ahorro);this.value=formatCurrency(this.value);\" maxlength=\"9\" size=\"14\"> 		</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Cantidad ahorrada actualmente:</td>		<td style=\"font-size:9px;\">			<input name=BB value=\"" + AA + "\" onFocus=\"document.ahorro.BB.select();document.ahorro.BB.focus();\" onChange=\"ahbasicedit(document.ahorro);this.value=formatCurrency(this.value);\" maxlength=\"9\" size=\"14\">											</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Ahorros mensuales actuales:	</td>		<td>			<input name=MS value=\"" + AM + "\" onFocus=\"document.ahorro.MS.select();document.ahorro.MS.focus();\" onChange=\"ahbasicedit(document.ahorro);this.value=formatCurrency(this.value);\" maxlength=\"9\" size=\"14\">		</td>	</tr>		<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Meses a ahorrar:	</td>		<td>			<input name=\"YS\" value=\"" + MA + "\" onFocus=\"document.ahorro.YS.select();document.ahorro.YS.focus();\" maxlength=\"3\" size=\"14\">		</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td colspan=\"2\" style=\"font-size:9px; text-align:right\">			<a href=\"javascript:calcAhorro(document.ahorro);\">				<img style=\"border:none;\" src=\"App_Images/calculadora/calcbutton.gif\" alt=\"Calcular\" width=\"110\" height=\"19\" />			</a>		</td>	  </tr>	</table></div><div  align=\"right\" style=\"float:left; width:291px; border-top:solid 2px #FFFFFF; background-color:#D5DBE7; padding:2px;\">	<table>		<tr>			<td style=\"font-size:9px; text-align:right\">Meses para alcanzar meta de ahorros (con   ahorros actuales):</td>			<td style=\"font-size:9px;\">				<input type=\"text\" name=\"MA\" size=\"14\">			</td>		</tr>		<tr>			<td colspan=\"2\" style=\"height:5px;\"></td>		</tr>		<tr>			<td style=\"font-size:9px; text-align:right\">Ahorro mensual para alcanzar meta (bajo el per&iacute;odo de   tiempo que deseas):	</td>			<td>				<input type=\"text\" name=\"MI\" size=\"14\">			</td>		</tr>					</table></div></form>"
		
		  var firefox = navigator.userAgent.indexOf("Firefox");
        
        if (firefox > -1 || window.opera)
        {
            parent.document.getElementById('frmCalc').style.height= 300 + 'px';
        }
        
	}

	if (name == "alquilar")
	{
		var AA = formatCurrency("975");
		var CP = formatCurrency("175000");
		var PP = addPct("10");
		var TI = addPct("7.5");		
		var AP = "30";
		var AV = "7";
		var CT = addPct("1");
		var AC = addPct("2");
		var search = location.search;
		search = search.replace(/\?/,'');
		var searchAttributes = search.split('&');
		for(var no=0;no<searchAttributes.length;no++)
		{
			var items = searchAttributes[no].split('=');

			if (items[0] == "AA")
			{
				AA = (items[1]!="0")?formatCurrency(floor(items[1])):"";
			}
			if (items[0] == "CP")
			{
				CP = formatCurrency(floor(items[1]));	
			}
			if (items[0] == "PP")
			{
				PP = addPct(items[1]);	
			}
			if (items[0] == "TI")
			{
				TI = addPct(items[1]);	
			}
			if (items[0] == "AP")
			{
				AP = items[1];	
			}
			if (items[0] == "AV")
			{
				AV = items[1];	
			}
			if (items[0] == "CT")
			{
				CT = addPct(items[1]);	
			}
			if (items[0] == "AC")
			{
				AC = addPct(items[1]);	
			}
		}
		
		document.getElementById(containerid).innerHTML = "<form name=\"rentbuy\" method=\"post\" action=\"default.html\"><div style=\"float:left; width:295px; height:25px;\">	<img src=\"App_Images/calculadora/calc-header.gif\" alt=\"Calculadora\" height=\"25px\" width=\"175px\"/><img src=\"App_Images/calculadora/calc-bienes-raices.gif\" alt=\"Calculadora\" height=\"25px\" width=\"120\"/></div><div class=\"calctitle\">	ALQUILAR O COMPRAR <img src=\"App_Images/calculadora/orangearrow.gif\" height=\"9px\" width=\"6px\"/></div><div align=\"right\" style=\"float:left; width:291px; border-top:solid 2px #839DB8; background-color:#D5DBE7; padding:2px;\">	<table>	<tr>		<td style=\"font-size:9px; text-align:right\">Alquiler Actual:			</td>		<td style=\"font-size:9px;\">			<input type=\"text\" name=\"RENT\" size=\"14\" value=\"" + AA + "\" onFocus=\"document.rentbuy.RENT.select();					document.rentbuy.RENT.focus();\" onChange=\"rbbasicedit(document.rentbuy);this.value=formatCurrency(this.value);\" maxlength=\"6\">		</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Precio de compra del hogar:</td>		<td style=\"font-size:9px;\">			<input type=\"text\" name=\"PPRICE\" size=\"14\" value=\"" + CP + "\" onFocus=\"document.rentbuy.PPRICE.select();					document.rentbuy.PPRICE.focus();\" onChange=\"rbbasicedit(document.rentbuy);this.value=formatCurrency(this.value);\">					</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Pronto Pago (porcentaje):	</td>		<td>			<input type=\"text\" name=\"DOWN\" size=\"14\" value=\"" + PP + "\" onFocus=\"document.rentbuy.DOWN.select();document.rentbuy.DOWN.focus();\" onChange=\"rbbasicedit(document.rentbuy);this.value=addPct(this.value);\" maxlength=\"3\">		</td>	</tr>		<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Tasa de Inter&eacute;s:	</td>		<td>			<input type=\"text\" name=\"INT\" size=\"14\" value=\"" + TI + "\" onFocus=\"document.rentbuy.INT.select();					document.rentbuy.INT.focus();\" onChange=\"rbbasicedit(document.rentbuy);this.value=addPct(this.value);\" maxlength=\"5\">		</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">T&eacute;rmino del pr&eacute;stamo (a&ntilde;os):			</td>		<td style=\"font-size:9px;\">			<input type=\"text\" name=\"YR\" size=\"14\" value=\"" + AP + "\" onFocus=\"document.rentbuy.YR.select();					document.rentbuy.YR.focus();\" maxlength=\"6\">		</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">A&ntilde;os que vivirá en la casa:</td>		<td style=\"font-size:9px;\">			<input type=\"text\" name=\"TERM\" size=\"14\" value=\"" + AV + "\" onFocus=\"document.rentbuy.TERM.select();					document.rentbuy.TERM.focus();\" maxlength=\"6\">					</td>	</tr>	<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Tasa anual de contribuci&oacute;n territorial:	</td>		<td>			<input type=\"text\" name=\"PropTax\" size=\"14\" value=\"" + CT + "\" onFocus=\"document.rentbuy.PropTax.select();					document.rentbuy.PropTax.focus();\" onChange=\"rbbasicedit(document.rentbuy);this.value=addPct(this.value);\" maxlength=\"5\">		</td>	</tr>		<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Apreciaci&oacute;n anual de la casa:	</td>		<td>			<input type=\"text\" name=\"AnApp\" size=\"14\" value=\"" + AC + "\" onFocus=\"document.rentbuy.AnApp.select();					document.rentbuy.AnApp.focus();\" onChange=\"rbbasicedit(document.rentbuy);this.value=addPct(this.value);\" maxlength=\"5\" class=\"inputBox_small\">		</td>	</tr>				<tr>		<td colspan=\"2\" style=\"height:5px;\"></td>	</tr>	<tr>		<td colspan=\"2\" style=\"font-size:9px; text-align:right\">			<a href=\"javascript:calcRentBuy(document.rentbuy);\">				<img style=\"border:none;\" src=\"App_Images/calculadora/calcbutton.gif\" alt=\"Calcular\" width=\"110\" height=\"19\" />			</a>		</td>	  </tr>	</table></div><div  align=\"right\" style=\"float:left; width:291px; border-top:solid 2px #FFFFFF; background-color:#D5DBE7; padding:2px;\"><table>	<tr>		<td style=\"font-size:9px; \">&nbsp;</td>		<td style=\"font-size:9px; font-weight:bold; text-align:center\">Renta</td>		<td style=\"font-size:9px; font-weight:bold; text-align:center\">Propia</td>	</tr>	<tr>		<td colspan=\"3\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Total Inter&eacute;s Pagado:			</td>	  <td style=\"font-size:9px; background-color:#839DB8\">&nbsp;</td>		<td style=\"font-size:9px;\">			<input type=\"text\" name=\"TotalInt\" size=\"12\">		</td>	</tr>	<tr>		<td colspan=\"3\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\"> Total contribuciones territoriales pagadas:</td>	  <td style=\"font-size:9px; background-color:#839DB8\">&nbsp;</td>		<td style=\"font-size:9px;\">			<input type=\"text\" name=\"TotalPTax\" size=\"12\">		</td>	</tr>	<tr>		<td colspan=\"3\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Total ahorros de impuestos:	</td>	  <td style=\"font-size:9px; background-color:#839DB8\">&nbsp;</td>		<td>			<input type=\"text\" name=\"TotalTaxS\" size=\"12\">		</td>	</tr>		<tr>		<td colspan=\"3\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Total Pagos Mensuales:	</td>		<td>			<input type=\"text\" name=\"TotalRent\" size=\"12\">		</td>		<td>			<input type=\"text\" name=\"TotalOwn\" size=\"12\">		</td>	</tr>	<tr>		<td colspan=\"3\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Pago Mensual Promedio:			</td>		<td>			<input type=\"text\" name=\"AvgRent\" size=\"12\">				</td>		<td >			<input type=\"text\" name=\"AvgOwn\" size=\"12\">				</td>	</tr>	<tr>		<td colspan=\"3\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Apreciaci&oacute;n de la Casa:</td>	  <td style=\"background-color:#839DB8\">&nbsp;</td>		<td >			<input type=\"text\" name=\"Apprec\" size=\"12\">		</td>	</tr>	<tr>		<td colspan=\"3\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:right\">Ahorros (pronto pago invertido a 10%):	</td>		<td >			<input type=\"text\" name=\"Saving\" size=\"12\">		</td>		<td style=\"background-color:#839DB8;\">&nbsp;</td>	</tr>		<tr>		<td colspan=\"3\" style=\"height:5px;\"></td>	</tr>	<tr>		<td style=\"font-size:9px; text-align:center; background-color:#3A538C; color:#FFFFFF; font-weight:bold;\">Costo Total:	</td>		<td >			<input type=\"text\" name=\"RentTotal\" size=\"12\">				</td>		<td>			<input type=\"text\" name=\"OwnTotal\" size=\"12\">		</td>	</tr>				<tr>		<td colspan=\"3\" style=\"height:5px;\"></td>	</tr>	</table></div></form>" 
		
		var firefox = navigator.userAgent.indexOf("Firefox");
        
        if (firefox > -1 || window.opera)
        {
            parent.document.getElementById('frmCalc').style.height= 620 + 'px';
        }
        
	}
}

function replaceChar(entry) {
	out = "$"; 
	add = ""; 
	temp = "" + entry;
	while (temp.indexOf(out)>-1) {
		pos= temp.indexOf(out);
		temp = "" + (temp.substring(0, pos) + add + 
		temp.substring((pos + out.length), temp.length));
	}
	return temp;
}

function replacePct(entry) {
	out = "%"; 
	add = ""; 
	temp = "" + entry;
	while (temp.indexOf(out)>-1) {
		pos= temp.indexOf(out);
		temp = "" + (temp.substring(0, pos) + add + 
		temp.substring((pos + out.length), temp.length));
	}
	return temp;
}	
	
function replaceChars(entry) {
	out = ","; 
	add = ""; 
	temp = "" + entry;
	while (temp.indexOf(out)>-1) {
		pos= temp.indexOf(out);
		temp = "" + (temp.substring(0, pos) + add + 
		temp.substring((pos + out.length), temp.length));
	}
	return temp;
}

function formatCurrency(num) {			
			num=replaceChar(num);
			num=replaceChars(num);
		if ( checkForm(num));
	{
				num = num.toString().replace(/$|,/g,'');
				if(isNaN(num)) num = "0";
				num = Math.floor(num).toString();
			for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) 
				num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
				 
		return ('$' + num );	
	}
}

function IsMoney(val)
	{
		var number="0123456789$,.";

		for (var i=0;i<val.length;i++)
		{
			if (number.indexOf(val.charAt(i)) == -1)
			{
				alert('e');
				return false;
			}
		}
		return true;
	}

function IsNumber(val)
	{
		var number="0123456789.";

		for (var i=0;i<val.length;i++)
		{
			if (number.indexOf(val.charAt(i)) == -1)
			{
				return false;
			}
		}
		return true;
	}
	
function IsPct(val)
	{
		var number="0123456789.%,";

		for (var i=0;i<val.length;i++)
		{
			if (number.indexOf(val.charAt(i)) == -1)
			{
				return false;
			}
		}
		return true;
	}

function addPct(pct) {
			pct=replacePct(pct);
			pct=parseFloat(pct);		
		if (checkForm(pct));
	{
			return (pct + '%');
		}
}
// 2008-09-03   SS      Added function to resize Iframe
function resizeIframe1(frameid, containerid){
  
    var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
    var FFextraHeight=parseFloat(getFFVersion)>=0.1 && parseFloat(getFFVersion) < 3 ? 16 : 0; //extra height in px to add to iframe in FireFox 1.0+ browsers
    var safari = navigator.userAgent.indexOf("Safari");
    var firefox = navigator.userAgent.indexOf("Firefox");
    var currentfr=parent.document.getElementById(frameid);
    var extraSize = 12;
    
   
    //No es los mismo que style.Height!!!! esto me devuelve la altura
    var height = document.getElementById(containerid).clientHeight;

    if (currentfr)
    {
    
        currentfr.style.border = 'solid 1px #CCCCCC';
        currentfr.style.overflowX = 'hidden';
        currentfr.style.overflowY = 'hidden';
        currentfr.style.width = '100%';
        currentfr.style.display = 'block';
        
        if (!window.opera && safari == -1){
         
            currentfr.style.display="block";
           
            
            if ( typeof(currentfr.contentDocument) != 'undefined')
            {
                if (currentfr.contentDocument.body.offsetHeight) //ns6 syntax
                {
                    currentfr.style.height = height +  currentfr.contentDocument.body.offsetHeight + 'px'; 
                }
                else if (currentfr.contentDocument.body.scrollHeight)
                {
                   
                    var altura = '' +  currentfr.contentDocument.body.scrollHeight + FFextraHeight + 'px';

                    currentfr.style.height = height;//altura; 
                }
//                else
//                {
//                      //is fx, heigth is assigned when call the fx
//                }
            }
            else if (typeof(currentfr.Document) != 'undefined' && currentfr.Document.body.scrollHeight) //ie5+ syntax
            {
               //IE 
               var altura; 
               altura = currentfr.Document.body.offsetHeight + extraSize +  'px';
               currentfr.style.height = altura;
            }

        //2008-08-20    SS      Added support for safari browser and opera 
        }
        else 
        {
            if (height == 0)
            {
                if (safari != -1) // si es safari
                {
                    currentfr.style.display = "block"; 
                    currentfr.style.height = '0px';
                    currentfr.style.height = currentfr.contentDocument.body.scrollHeight + extraSize + 'px';
                }
//                else
//                {
//                    //is opera, heigth is assigned when call the fx
//                }
            }
            else
            {
                currentfr.style.display = "block"; 
                currentfr.style.height = height + "px";
            }
        }
    }
    else
    {
        currentfr.style.height = "0px";
        currentfr.style.display = "none"; 
        
    }
}