
var co = new Object;

var eedecreg=new RegExp("[.]","g");
var eethreg=new RegExp(",","g");
var eedec=".";
var eeth=",";
var eeparseFloatVreg=new RegExp("^ *-?[0-9.]+ *$");
var fmtdate5=new Array(34,25,2);
var fmtdate6=new Array(2,35,6,35,11);
var fmtdate7=new Array(34,25,2);
var fmtdate8=new Array(34,25,0);


function recalc_onclick(ctl) {
  if (true) {
//alert("ss");
co.loan_amount=eeparseFloatTh(document.a1_form.loan_amount.value);
//alert(co.loan_amount);
co.p1E8=eeparsePercent(document.a1_form.p1E8.value);
co.term=eeparseFloat(document.a1_form.payment.value);
//alert(co.term);
//alert(document.a1_form.p1A25.value);
//co.p1A25=eeparseFloatV(document.a1_form.p1A25.value);
//alert(co.p1A25);
//calc(co);
//alert(calc(co));
//alert(co.rate);
document.a1_form.p1E8.value=eedisplayPercentND(co.p1E8,3);
//alert(eedisplayPercentND(co.rate,3));
document.a1_form.payment.value=eedatefmt(fmtdate5,co.term);
//alert(document.a1_form.payment.value);
//document.a1_form.p1E17.value=eedisplayFloat(co.p1E17);
//alert(document.a1_form.p1E17.value);
//document.a1_form.p1E18.value=eedatefmt(fmtdate5,co.p1E18);
document.a1_form.p1E19.value=eedatefmt(fmtdate5,co.p1E19);
//document.a1_form.p1F24.value=eedatefmt(fmtdate7,co.p1F24);

/*document.a1_form.p1B25.value=eeisnumber(co.p1B25)?eedatefmt(fmtdate6,co.p1B25):co.p1B25;
document.a1_form.p1C25.value=eeisnumber(co.p1C25)?eedisplayFloatNDTh(co.p1C25,2):co.p1C25;
document.a1_form.p1D25.value=eeisnumber(co.p1D25)?eedisplayFloatNDTh(co.p1D25,2):co.p1D25;
document.a1_form.p1E25.value=eeisnumber(co.p1E25)?eedisplayFloatNDTh(co.p1E25,2):co.p1E25;
document.a1_form.p1F25.value=eeisnumber(co.p1F25)?eedisplayFloatNDTh(co.p1F25,2):co.p1F25;*/

//alert(document.a1_form.p1F25.value);

//document.a1_form.p1A26.value=eeisnumber(co.p1A26)?eedisplayFloat(co.p1A26):co.p1A26;document.a1_form.p1B26.value=eeisnumber(co.p1B26)?eedatefmt(fmtdate6,co.p1B26):co.p1B26;document.a1_form.p1C26.value=eeisnumber(co.p1C26)?eedisplayFloatNDTh(co.p1C26,2):co.p1C26;document.a1_form.p1D26.value=eeisnumber(co.p1D26)?eedisplayFloatNDTh(co.p1D26,2):co.p1D26;document.a1_form.p1E26.value=eeisnumber(co.p1E26)?eedisplayFloatNDTh(co.p1E26,2):co.p1E26;document.a1_form.p1F26.value=eeisnumber(co.p1F26)?eedisplayFloatNDTh(co.p1F26,2):co.p1F26;
var sTable ='';
for(var i=1;i<=5; i++){
/*var p1A = "p1A" + i;
var p1B = "p1B" + i;
var p1C = "p1C" + i;
var p1D = "p1D" + i;
var p1E = "p1E" + i;
var p1F = "p1F" + i;*/
//alert(p1F);
//alert(eeisnumber(co.p1A));
//alert(eedisplayFloat(co.p1A));
//alert(co.p1A);
alert(eeisnumber(2)?eedisplayFloat(2):2);
alert(eval('sTable+=eeisnumber(co.p1A' + i + ')?eedisplayFloat(co.p1A' + i + '):co.p1A' + i ));
eval('sTable+=eeisnumber(co.p1A' + i + ')?eedisplayFloat(co.p1A' + i + '):co.p1A' + i );
sTable += '<br />';

/*document.a1_form.p1B.value=eeisnumber(co.p1C)?eedatefmt(fmtdate6,co.p1C):co.p1C;
document.a1_form.p1C.value=eeisnumber(co.p1C)?eedisplayFloatNDTh(co.p1C,2):co.p1C;
document.a1_form.p1D.value=eeisnumber(co.p1D)?eedisplayFloatNDTh(co.p1D,2):co.p1D;
document.a1_form.p1E.value=eeisnumber(co.p1E)?eedisplayFloatNDTh(co.p1E,2):co.p1E;
document.a1_form.p1F.value=eeisnumber(co.p1F)?eedisplayFloatNDTh(co.p1F,2):co.p1F;*/
//alert(document.a1_form.p1F.value);
}
alert(sTable);
document.getElementById('divTable').innerHTML = sTable;
  }
}


function eedisplayFloatND(x,nd)
{
	if(myIsNaN(x))
	{return Number.NaN;}
	else
	{
		var res=round(x,nd);
		if(nd>0)
		{
			var str=String(res);
			if(str.indexOf('e')!=-1)
				return str;
			if(str.indexOf('E')!=-1)
				return str;
			
			var parts=str.split('.');
			
			if(parts.length<2)
			{
				var decimals=('00000000000000').substring(0,nd);
				return(parts[0]).toString()+eedec+decimals;
			}
			else
			{
				var decimals=((parts[1]).toString()+'00000000000000').substring(0,nd);
				return(parts[0]).toString()+eedec+decimals;
			}
		}
		else{return res;}
	}
};

function eeisnumber(v)
{
	if(isNaN(v)||v==Number.NEGATIVE_INFINITY||v==Number.POSITIVE_INFINITY)
	{
		return false;
	}
	else
	{
		switch(typeof v)
		{
			case "number":return true;
			case "object":return v.constructor==Number;
			default:return false;
		}
	}
};

function eedisplayPercentND(x,nd)
{
	if(myIsNaN(x))
	{
		return Number.NaN;
	}
	else
	{
		return eedisplayFloatND(x*100,nd)+'%';
	}
}

function eeparseFloatTh(str)
{
	//alert("ss");
	str=String(str).replace(eethreg,"");
	str=String(str).replace(eedecreg,".");
	//alert(str);
	var res=parseFloat(str);
	//alert(res);
	if(isNaN(res)){return 0;}
	else{return res;}
	
};

function myIsNaN(x)
{
	//alert("Nan");
	return(isNaN(x)||(typeof x=='number'&&!isFinite(x)));
};

function eedisplayFloatNDTh(x,nd){
	//alert("ss");
	
	if(myIsNaN(x))
	{
		
		return Number.NaN;
	}
	else
	{
		//alert(round(x,nd));
		var res=round(x,nd);
		//alert("ee");

		if(nd>0)
		{
			//alert("ee");
			var str=String(res);
			if(str.indexOf('e')!=-1)
				return str;
			if(str.indexOf('E')!=-1)
				return str;
			var parts=str.split('.');
			//alert(eeinsertThousand(parts[0].toString()));
			var res2=eeinsertThousand(parts[0].toString());
			
			if(parts.length<2)
			{
				var decimals=('00000000000000').substring(0,nd);
				return(res2+eedec+decimals);
			}
			else
			{
				var decimals=((parts[1]).toString()+'00000000000000').substring(0,nd);
				return(res2+eedec+decimals);
			}
		}
		else
		{
			//alert("ee");
			//alert(res.toString());
			//alert(eeinsertThousand(res.toString()));
			return(eeinsertThousand(res.toString()));
		}
	}
};

function round(n,nd)
{
	if(isFinite(n)&&isFinite(nd))
	{
		//alert(isFinite(n));
		//alert(isFinite(nd));
		var sign_n=(n<0)?-1:1;
		var abs_n=Math.abs(n);
		var factor=Math.pow(10,nd);
		//alert(sign_n*Math.round(abs_n*factor)/factor);
		return sign_n*Math.round(abs_n*factor)/factor;
	}
	else{return NaN;}
};

function eeinsertThousand(whole)
{
	//alert(whole);
	if(whole==""||whole.indexOf("e")>=0)
	{return whole;}
	else
	{
		var minus_sign="";
		if(whole.charAt(0)=="-")
		{
			minus_sign="-";
			whole=whole.substring(1);
		};
		
		var res="";
		var str_length=whole.length-1;
		for(var ii=0;ii<=str_length;ii++)
		{
			if(ii>0&&ii%3==0)
			{res=eeth+res;};
			res=whole.charAt(str_length-ii)+res;
		};
		//alert("ss");
		return minus_sign+res;
	}
};

function eeparsePercent(str)
{
	var parts=String(str).split('%');
	var tmp=String(parts[0]).replace(eedecreg,".");
	var res=parseFloat(tmp)/100;
	
	if(isNaN(res)){return 0;}
	else{return res;}
};

function eeparseFloat(str)
{
	str=String(str).replace(eedecreg,".");
	var res=parseFloat(str);
	
	if(isNaN(res)){return 0;}
	else{return res;}
};

function eeparseFloatV(str)
{
	//alert(str);
	if(str=="")return str;
	str=String(str).replace(eedecreg,".");
	
	if(!eeparseFloatVreg.test(str)){return str;};
	
	var res=parseFloat(str);
	
	if(isNaN(res)){return str;}
	else{return res;}
};

function eedisplayFloat(x)
{
	if(myIsNaN(x)){return Number.NaN;}
	else{return String(x).replace(/\./g,eedec);}
};

function eedatefmt(fmt,x){if(!isFinite(x))return Number.NaN;var tmp=0;var res="";var len=fmt.length;for(var ii=0;ii<len;ii++){if(fmt[ii]>31){res+=fmtstrings[fmt[ii]-32];}else{switch(fmt[ii]){case 2:res+=eemonth(x);break;case 3:tmp=eemonth(x);if(tmp<10){res+="0";};res+=tmp;break;case 4:res+=fmtmonthnamesshort[eemonth(x)-1];break;case 5:res+=fmtmonthnameslong[eemonth(x)-1];break;case 6:res+=eeday(x);break;case 7:tmp=eeday(x);if(tmp<10){res+="0";};res+=tmp;break;case 8:res+=fmtdaynamesshort[weekday(x,1)-1];break;case 9:res+=fmtdaynameslong[weekday(x,1)-1];break;case 10:tmp=year(x)%100;if(tmp<10){res+="0";};res+=tmp;break;case 11:res+=year(x);break;case 12:res+=hour(x);break;case 13:tmp=hour(x);if(tmp<10){res+="0";};res+=tmp;break;case 14:tmp=hour(x)%12;if(tmp==0){res+="12";}else{res+=tmp%12;};break;case 15:tmp=hour(x)%12;if(tmp==0){res+="12";}else{if(tmp<10){res+="0";};res+=tmp;};break;case 16:res+=minute(x);break;case 17:tmp=minute(x);if(tmp<10){res+="0";};res+=tmp;break;case 18:res+=second(x);break;case 19:tmp=second(x);if(tmp<10){res+="0";};res+=tmp;break;case 21:case 22:if(hour(x)<12){res+="AM";}else{res+="PM";};break;case 23:res+=eedisplayFloat(x);break;case 24:tmp=fmt[++ii];res+=eedisplayFloatND(x,tmp);break;case 25:tmp=fmt[++ii];res+=eedisplayFloatNDTh(x,tmp);break;case 26:res+=eedisplayPercent(x);break;case 27:tmp=fmt[++ii];res+=eedisplayPercentND(x,tmp);break;case 28:tmp=fmt[++ii];res+=eedisplayPercentNDTh(x,tmp);break;case 29:tmp=fmt[++ii];res+=eedisplayScientific(x,tmp);break;};};};return res;};


