var numAccts=0;var best=999;var bestAcct;// on rate changes update waiver amounts in setWaiver functionvar acct1=new Account("execClub1",4.00,4000.0,0.7,0.7,0.7,0.7,0.7,0.7,10,1.5,0);var acct2=new Account("execClub2",9.00,4000.0,0.7,0.7,0.7,0.7,0.7,0.7,20,1.5,0);var acct3=new Account("execClub3",11.00,4000.0,0.7,0.7,0.7,0.7,0.7,0.7,40,1.5,0);var acct4=new Account("execClub4",13.00,"n/a",0.0,0.0,0.0,0.0,0.0,0.0,999,1.5,3);var acct5=new Account("execClub5",18.00,"n/a",0.0,0.0,0.0,0.0,0.0,0.0,999,1.5,5);function Account(k,b,w,ibw,chq,dp,atm,aft,pnt,dbts,otherATM,otherATM_free){	this.key=k;	this.base=b;	this.waiver=w;	this.Withdr=ibw;	this.cheque=chq;	this.directPay=dp;	this.atmTransact=atm;	this.AFT=aft;	this.phoneNetTransfer=pnt;	this.freeDebits=dbts;	this.other_atm=otherATM;	this.other_atm_free=otherATM_free;	numAccts++;			}			function getHeightInPixels(max_num, num){	height = Math.round(num) / Math.round(max_num) * 300;	return Math.round(height);}function setChart(){	best=999;	acct_fee_list = calculate_fees();	max_fee = 0;	for(i=0;i<acct_fee_list.length;i++){		if(acct_fee_list[i] > max_fee)			max_fee = acct_fee_list[i];	}	for(i=1;i<=numAccts;i++){		var table=calculate(eval("acct"+i));		var base=eval("acct"+i+".base");		if(base==0){			eval("document.getElementById('barP"+i+"a').style.backgroundColor='#006752'");			eval("document.getElementById('barP"+i+"a').style.height='1px'");				}		else{			eval("document.getElementById('barP"+i+"a').style.backgroundColor='#003082'");			eval("document.getElementById('barP"+i+"a').style.height=getHeightInPixels(max_fee, base)+'px'");				}		if(table>base){			eval("document.getElementById('barP"+i+"').style.backgroundColor='#006752'");			eval("document.getElementById('barP"+i+"b').style.height=getHeightInPixels(max_fee, (table-base))+'px'");				}		else{			eval("document.getElementById('barP"+i+"b').style.height='1px'");			eval("document.getElementById('barP"+i+"').style.backgroundColor='transparent'");			eval("document.getElementById('barP"+i+"b').style.backgroundColor='transparent'");			eval("document.getElementById('barP"+i+"a').style.backgroundColor='#003082'");				}		if(table<1){			eval("document.getElementById('barP"+i+"').style.backgroundColor='transparent'");			eval("document.getElementById('barP"+i+"a').style.backgroundColor='transparent'");			//eval("document.getElementById('barP"+i+"').style.borderBottom='1px solid red'");			}	}	setMessage();		}		function calculate_fees(){	fee_array = new Array();	for(i=0;i<numAccts;i++){		fee_array[i] = calculate(eval("acct"+(i+1)));	}	return fee_array;}		function setWaiver(){	var d=document.calcForm;	var min=d.monthlyMin.options[d.monthlyMin.options.selectedIndex].value;	(min>=4000)?acct1.base=0:acct1.base=3.95;	(min>=4000)?acct2.base=0:acct2.base=8.95;	(min>=4000)?acct3.base=0:acct3.base=10.95;	//(min>=5000)?acct4.base=0:acct4.base=12.95;	//(min>=6000)?acct5.base=0:acct5.base=17.95;	setChart();		}function calculate(t){	var debitCount=countDebits();	var debitsCharged=0;	var debitsCharged_cheq=0;	var debitsCharged_notCheq=0;	var fee = 0;	var cheqNum = 0;	var regExp=/\D/;	var d=document.calcForm;	var f=t.base;	if(debitCount>t.freeDebits){							// if there is a charge for transactions		if(!regExp.test(d.cheq.value))						// if tranactions include cheques			cheqNum = parseInt(d.cheq.value);				// get number of cheques		debitsCharged = (debitCount-t.freeDebits);			// get number of debits charged		debitCount_notCheq = debitCount - cheqNum;			// get number of non-cheque debits		if(debitCount_notCheq > debitsCharged){			fee = debitsCharged * .6;		}		else{			debitCount_cheq = debitsCharged - debitCount_notCheq;			fee = (debitCount_notCheq * .6) + (debitCount_cheq * t.cheque);		}	}	f += fee;	/*if(!regExp.test(d.withdraw.value))		f+=(t.Withdr*d.withdraw.value);	if(!regExp.test(d.cheq.value))		f+=(t.cheque*d.cheq.value);	if(!regExp.test(d.dirPay.value))ue))debits+=parseInt(d.dirPay.value);		f+=(t.directPay*d.dirPay.value);	if(!regExp.test(d.atmTrans.value))		f+=(t.atmTransact*d.atmTrans.value);	if(!regExp.test(d.afts.value))		f+=(t.AFT*d.afts.value);	if(!regExp.test(d.net.value))		f+=(t.phoneNetTransfer*d.net.value);*/	if( !regExp.test( d.otherAtmTrans.value ) ){		if(d.otherAtmTrans.value > t.other_atm_free){			otherAtmTrans_lessFree = d.otherAtmTrans.value- t.other_atm_free;			f += t.other_atm * parseInt(otherAtmTrans_lessFree);		}	}	eval("document.getElementById('total"+t.key+"').innerHTML='$'+checkZero(f)");	if(best>f){		best=f;		bestAcct=t.key;	}	return f;			}			function countDebits(){		var debits=0;		var regExp=/\D/;		var d=document.calcForm;		if(!regExp.test(d.withdraw.value))debits+=parseInt(d.withdraw.value);		if(!regExp.test(d.cheq.value))debits+=parseInt(d.cheq.value);		if(!regExp.test(d.dirPay.value))debits+=parseInt(d.dirPay.value);		if(!regExp.test(d.atmTrans.value))debits+=parseInt(d.atmTrans.value);		if(!regExp.test(d.afts.value))debits+=parseInt(d.afts.value);		if(!regExp.test(d.net.value))debits+=parseInt(d.net.value);		return debits;		}		function setMessage(){	var name;	if(bestAcct=="execClub1"){		name="I";		pkg_id = "P1";	}	else if(bestAcct=="execClub2"){		name="II";		pkg_id = "P2";	}	else if(bestAcct=="execClub3"){		name="III";		pkg_id = "P3";	}	else if(bestAcct=="execClub4"){		name="IV";		pkg_id = "P4";	}	else if(bestAcct=="execClub5"){		name="V";		pkg_id = "P5";	}	var msg="** Based on your selections, Executive Club Package "+name+" is your best value. **";	clear_bgrnds();	document.getElementById('message').innerHTML=msg;	document.getElementById(pkg_id + "a").className = "hiLite";	document.getElementById(pkg_id + "b").className = "hiLite";	document.getElementById(pkg_id + "c").className = "hiLite";	//document.getElementById(bars_id + "b").style.class = "orange";	//alert(best);		}		function clear_bgrnds(){	if(document.getElementById("P1b") && document.getElementById("P1b").className && document.getElementById("P1b").className == "hiLite"){		document.getElementById("P1a").className = "white";		document.getElementById("P1b").className = "white";		document.getElementById("P1c").className = "white";	}	if(document.getElementById("P2b") && document.getElementById("P2b").className && document.getElementById("P2b").className == "hiLite"){		document.getElementById("P2a").className = "shaded";		document.getElementById("P2b").className = "shaded";		document.getElementById("P2c").className = "shaded";	}	if(document.getElementById("P3b") && document.getElementById("P3b").className && document.getElementById("P3b").className == "hiLite"){		document.getElementById("P3a").className = "white";		document.getElementById("P3b").className = "white";		document.getElementById("P3c").className = "white";	}	if(document.getElementById("P4b") && document.getElementById("P4b").className && document.getElementById("P4b").className == "hiLite"){		document.getElementById("P4a").className = "shaded";		document.getElementById("P4b").className = "shaded";		document.getElementById("P4c").className = "shaded";	}	if(document.getElementById("P5b") && document.getElementById("P5b").className && document.getElementById("P5b").className == "hiLite"){		document.getElementById("P5a").className = "white";		document.getElementById("P5b").className = "white";		document.getElementById("P5c").className = "white";	}}function checkZero(z){	if(z<0)z=0;	z=(Math.round(z*100))/100;	z=z.toString();	if(z.indexOf(".")==-1)		return(z+".00");	else if(z!="0"&&z!="NaN"){		zx=z.indexOf(".");		decz=z.substring(zx+1,z.length);		if(decz.length<2)			z=z+"0";				return(z);			}	else		return(z);			}
