Number.prototype.formatMoney=function(e,t,a){var r=this,n=(e=isNaN(e=Math.abs(e))?2:e,t=null==t?".":t,a=null==a?",":a,r<0?"-":""),i=parseInt(r=Math.abs(+r||0).toFixed(e))+"",o=(o=i.length)>3?o%3:0;return n+(o?i.substr(0,o)+a:"")+i.substr(o).replace(/(\d{3})(?=\d)/g,"$1"+a)+(e?t+Math.abs(r-i).toFixed(e).slice(2):"")};var compound__calculator={init:function(){new AutoNumeric("#ivc_monthly_rate",{currencySymbol:" %",digitGroupSeparator:",",decimalPlaces:2,decimalCharacter:".",decimalPlacesOverride:0,minimumValue:-100,maximumValue:100,currencySymbolPlacement:"s"}),new AutoNumeric("#ivc_years",{currencySymbol:"",digitGroupSeparator:",",decimalPlaces:0,decimalCharacter:".",decimalPlacesOverride:0,minimumValue:-0,maximumValue:100}),new AutoNumeric("#ivc_starting_investment",{currencySymbol:"$ ",decimalPlaces:0,digitGroupSeparator:",",decimalCharacter:".",decimalPlacesOverride:0,minimumValue:-0,maximumValue:9999999999,currencySymbolPlacement:"p"}),new AutoNumeric("#ivc_contribution_value",{currencySymbol:"$ ",decimalPlaces:0,digitGroupSeparator:",",decimalCharacter:".",decimalPlacesOverride:0,minimumValue:-0,maximumValue:9999999999,currencySymbolPlacement:"p"}),jQuery(".iv-calculator select").select2({minimumResultsForSearch:-1,width:"100%"}),this.listener(),this.calculate(),this.bar_chart([700,1e3,1200,1500],[200,250,300,350],[150,200,250,300],[2021,2022,2023,2024]),this.pie_chart(5e3,200,300)},listener:function(){jQuery(".ivc-inputs_ico").mouseenter(function(){jQuery(this).parent(".ivc-inputs_label").find(".ivc-inputs_tooltip").css("display","block")}),jQuery(".ivc-inputs_ico").mouseleave(function(){jQuery(this).parent(".ivc-inputs_label").find(".ivc-inputs_tooltip").css("display","none")}),jQuery(".iv-calculator input").keydown(function(){jQuery(this).css("color","#444444")}),jQuery(".iv-calculator input").change(function(){compound__calculator.calculate()}),jQuery(".iv-calculator select").change(function(){compound__calculator.calculate()})},calculate:function(){var e={start:parseFloat(AutoNumeric.getNumber("#ivc_starting_investment"))||0,years:parseFloat(AutoNumeric.getNumber("#ivc_years"))||0,contribution:parseFloat(AutoNumeric.getNumber("#ivc_contribution_value"))||0,rate:parseFloat(AutoNumeric.getNumber("#ivc_monthly_rate"))/100||0,Payment_Periods_Year:parseInt(jQuery("#ivc_contribution_term option:selected").val()),Interest_Payments_Year:parseInt(jQuery("#ivc_compound_term option:selected").val()),chart_ti:[],chart_cie:[],chart_sie:[],chart_years:[],current:(new Date).getFullYear()};function t(t,a){for(var r=t*e.Payment_Periods_Year,n=[],i=[],o=[],l=[],s=[],c=[],u=e.rate/e.Interest_Payments_Year,p=Math.pow(1+u,e.Interest_Payments_Year/e.Payment_Periods_Year)-1,m=Math.pow(1+e.rate,1/e.Payment_Periods_Year)-1,d=0;d$"+this.y.formatMoney(0,".",",")+""}}})},bar_chart:function(e,t,a,r){Highcharts.chart("ivc_chart_growth",{chart:{type:"column",spacingLeft:0,spacingRight:0,height:270,pinchType:"",panning:!1},subtitle:{text:null},navigator:{enabled:!1},rangeSelector:{enabled:!1},scrollbar:{enabled:!1},xAxis:{categories:r,tickLength:1,tickInterval:1,lineColor:"#e5e5e5",title:{style:{color:"#e5e5e5",fontSize:14}},labels:{formatter:function(){return this.value},enabled:!0,style:{color:"#adabab"}}},tooltip:{backgroundColor:"rgba(255,255,255,1)",borderColor:"#888888",useHTML:!0,zIndex:1200,crosshairs:!0,label:{attr:{zIndex:1200}},shared:!0,formatter:function(){if(this.points.length<3)return!1;var e="",t=this.points[2].y.formatMoney(0,".",","),a=this.points[1].y.formatMoney(0,".",","),r=this.points[0].y.formatMoney(0,".",","),n=Number(this.points[0].y)+Number(this.points[1].y)+Number(this.points[2].y);return e+="In the year "+this.x+",",e+=" Total Investment $"+t+" Compound Interest Earned $"+a+" Simple Interest Earned $"+r+"",e+="Ending Amount $"+n.formatMoney(0,".",",")+"",e+=""}},yAxis:{title:{text:null},showLastLabel:!0,opposite:!1,offset:35,tickPixelInterval:50,minorGridLineColor:"#e5e5e5",majorGridLineColor:"#e5e5e5",gridLineColor:"#e5e5e5",labels:{formatter:function(){return"$"+this.axis.defaultLabelFormatter.call(this)},align:"left",x:0,y:2,style:{color:"#adabab"},enabled:!0}},plotOptions:{column:{animation:!0,borderWidth:0,lineColor:"#ffffff",stacking:"normal",states:{hover:{brightness:-.15,enabled:!0}}}},credits:{enabled:!1},legend:{symbolWidth:5,symbolHeight:8.5,enabled:!0,itemStyle:{font:"6pt Trebuchet MS, Verdana, sans-serif",color:"#7b7a7a"},reversed:!0},title:{text:""},series:[{name:"Simple Interest Earned",color:"rgba(125 ,248, 196,1)",fillOpacity:1,type:"column",data:a},{name:"Compound Interest Earned",color:"rgba(27,131, 129,1)",fillOpacity:1,type:"column",data:t},{name:"Total Investment",color:"rgba(0 ,205, 169,1)",fillOpacity:1,type:"column",data:e}]})}};compound__calculator.init();