function Founder(B,A,C){this.setName(B);this.setOwnership(A);this.setId(C)}Founder.method("setName",function(A){this.name=A;return this});Founder.method("getName",function(){return this.name});Founder.method("setOwnership",function(A){if(A==33){A=100/3}this.ownership=A/100;return this});Founder.method("getOwnership",function(){return this.ownership});Founder.method("setOwnershipValue",function(A){this.ownershipValue=A;return this});Founder.method("getOwnershipValue",function(){return this.ownershipValue});Founder.method("getOwnershipDisplay",function(){return Math.round(this.getOwnership())+"%"});Founder.method("getId",function(){return this.id});Founder.method("setId",function(A){this.id=A;return this});Founder.method("calcValue",function(A){return Math.round(this.getOwnership()*(A.getPreInvestment()-A.calcEmployeeOwnershipValue()))});function AbstractRound(){this.isMouseDown=false;this.isConvDebt=false;this.isDownRnd=false;this.conversionPerc=0}AbstractRound.method("update",function(){var A=this.getPreviousRound();if(A){A.update()}this.updateRoundResults()});AbstractRound.method("updateRoundResults",function(){var D=Math.round(this.getEmployeeOwnership());var E=Math.round(this.calcInvestmentOwnership());var C=Math.round(this.calcAllFoundersOwnership());var G=this.isConvDebt?"N/A":_formatNumberTruncate(this.calcEmployeeOwnershipValue())+" / "+D+"%";var A=this.isConvDebt?"N/A":_formatNumberTruncate(this.calcInvestment())+" / "+E+"%";var F=this.isConvDebt?"N/A":_formatNumberTruncate(this.calcAllFoundersValue())+" / "+C+"%";var B=this.isConvDebt?"N/A":"$"+_formatNumber(this.calcPostValuation());_g(this.idPrefix+"EmpRes").innerHTML=G;_g(this.idPrefix+"InvRes").innerHTML=A;_g(this.idPrefix+"PostRes").innerHTML=B;_g(this.idPrefix+"FndrsRes").innerHTML=F;if(C<0){_g(this.idPrefix+"FndAlert").className="fndrAlert"}else{_g(this.idPrefix+"FndAlert").className="hidden"}});AbstractRound.method("setIdPrefix",function(A){this.idPrefix=A;return this});AbstractRound.method("getIdPrefix",function(){return this.idPrefix});AbstractRound.method("setPreviousRound",function(A){this.previousRound=A;return this});AbstractRound.method("setEmployeeOwnership",function(A){this.employeeOwnership=A;return this});AbstractRound.method("setInvestment",function(A){this.investment=A;return this});AbstractRound.method("setPreInvestment",function(A){this.preInvestment=A;return this});AbstractRound.method("setIsMouseDown",function(A){this.isMouseDown=A;return this});AbstractRound.method("setMaxVal",function(A){this.maxVal=A;return this});AbstractRound.method("setConversionPerc",function(A){this.conversionPerc=A;return this});AbstractRound.method("getPreviousRound",function(){return this.previousRound});AbstractRound.method("getEmployeeOwnership",function(){return this.employeeOwnership});AbstractRound.method("getInvestment",function(){return this.investment});AbstractRound.method("getPreInvestment",function(){return this.preInvestment});AbstractRound.method("getIsMouseDown",function(){return this.isMouseDown});AbstractRound.method("getMaxVal",function(){return this.maxVal});AbstractRound.method("getChartId",function(){return this.idPrefix+"Chart"});AbstractRound.method("getChartDivId",function(){return this.getChartId()+"Div"});AbstractRound.method("getConversionPerc",function(){return this.conversionPerc});AbstractRound.method("isConvertableDebt",function(){return this.isConvDebt});AbstractRound.method("setIsConvertableDebt",function(A){this.isConvDebt=A;return this});AbstractRound.method("isDownRndProtect",function(){return this.isDownRnd});AbstractRound.method("setIsDownRndProtect",function(A){this.isDownRnd=A;return this});AbstractRound.method("calcEmployeeOwnershipValue",function(){var A=this.calcPostValuation();var B=(this.getEmployeeOwnership()/100)*A;this.setEmployeeOwnership(A>0?(B/A*100):0);return B});AbstractRound.method("calcFounderValue",function(A){return A.getOwnership()*this.calcAllFoundersValue()});AbstractRound.method("calcFounderOwnership",function(B){var A=this.calcPostValuation();return A>0?(100*(this.calcFounderValue(B)/A)):0});AbstractRound.method("calcAllFoundersValue",function(B){var A=this.calcPostValuation();return(A-this.calcEmployeeOwnershipValue()-this.calcInvestment())});AbstractRound.method("calcAllFoundersOwnership",function(B){var A=this.calcPostValuation();return A>0?(100*(this.calcAllFoundersValue()/A)):0});AbstractRound.method("calcInvestment",function(){return this.getInvestment()});AbstractRound.method("calcInvestmentOwnership",function(){var A=this.calcPostValuation();return A>0?(100*(this.calcInvestment()/A)):0});AbstractRound.method("calcGrowth",function(){return this});AbstractRound.method("calcPostValuation",function(){return this.getInvestment()+this.getPreInvestment()});AbstractRound.method("addSliders",function(A){buildSlider(A,this,this.getIdPrefix()+"Pre",this.getMaxVal(),"PreInvestment");buildSlider(A,this,this.getIdPrefix()+"Inv",this.getMaxVal(),"Investment");buildSlider(A,this,this.getIdPrefix()+"Emp",30,"EmployeeOwnership",true);return this});function Round1(C,B,D,A,E){this.setEmployeeOwnership(B);this.setInvestment(D);this.setPreInvestment(A);this.setIdPrefix(C);this.setMaxVal(E);this.isConvertable=false;this.conversionPerc=20}Round1.inherits(AbstractRound);function RoundN(C,F,B,G,D){this.setInvestment(F);this.setPreInvestment(B);this.setPreviousRound(D);this.setIdPrefix(C);this.setMaxVal(G);var A=(D.calcEmployeeOwnershipValue()*this.calcGrowth());var E=A/(this.getPreInvestment()+this.getInvestment())*100;this.setEmployeeOwnership(E)}RoundN.inherits(AbstractRound);RoundN.method("calcInvestment",function(){var D,B,A=this.getPreviousRound();if(A.isDownRndProtect()){var C=A.calcInvestment()+A.getPreInvestment();if(this.getPreInvestment()<C){D=A.calcInvestment();if(A.isConvertableDebt()){D=D*(A.conversionPerc/100+1)}return D+this.getInvestment()}}D=(A.calcInvestment()*this.calcGrowth());if(A.isConvertableDebt()){D=A.calcInvestment()*(A.conversionPerc/100+1)}return D+this.getInvestment()});RoundN.method("calcGrowth",function(){var A=this.getPreviousRound();return this.getPreInvestment()/(A.getInvestment()+A.getPreInvestment())});function Controller(A,F){this.rounds=A;this._founders=F?F:[];this.charts=[];for(var B=0;B<A.length;B++){var D=A[B],E=D.getChartId();if(_g(D.getChartDivId())){var C=getChart(E);C.setDataXML("<chart></chart>");C.render(D.getChartDivId());this.charts.push(E)}}}Controller.method("setupPreInvestmentSlider",function(A,B){setupSlider(this,A,B,"PreInvestment");return this});Controller.method("setupInvestmentSlider",function(A,B){setupSlider(this,A,B,"Investment");return this});Controller.method("setupEmpPoolSlider",function(A,B){setupSlider(this,A,B,"EmployeeOwnership",true);return this});Controller.method("setRounds",function(A){this.rounds=A;return this});Controller.method("getRounds",function(){return this.rounds});Controller.method("setFounders",function(A){this._founders=A;this.init();return this});Controller.method("getFounders",function(){return this._founders});Controller.method("init",function(F,C){var A=this.rounds[this.rounds.length-1];A.update();this.resetFoundersForRounds();if(C){return }var E=F?false:true;for(var G=0;G<this.rounds.length;G++){var B=this.rounds[G];var I=B.getIdPrefix();if(F&&(F.getIdPrefix()==I)){E=true}var L;for(var D=0;D<this.charts.length;D++){var K=this.charts[D];if(K.substring(0,2)==I){L=K}}if(L&&E){var J=getChartFromId(L);if(J&&J.setDataXML&&isChartDivDisplayed(G+1)){var H="<chart></chart>";if(!B.isConvertableDebt()){H=_build3DPieChartXML(B,this.getFounders())}J.setDataXML(H)}}}return this});Controller.method("resetFoundersForRounds",function(){var A=this.getFounders();var B=this.getRounds();if(A&&B){for(var D=0;D<B.length;D++){var F=B[D];for(var E=0;E<A.length;E++){var C=A[E];var G=F.calcFounderValue(C);C.setOwnershipValue(G)}}}});Controller.method("toggleConvDebt",function(C){var B=this.getRounds()[0];var A=$(_g(B.getChartDivId())).toggleClass("msg");if(C.checked){B.setIsConvertableDebt(true);$("#r1OptP").show();$("#r1OptP")[0].childNodes[1].value=B.getConversionPerc();removeChart(B);A[0].innerHTML='Since you have chosen convertible debt financing, it is impossible to determine the share of the company that the investors own until the "conversion" occurs at the next round of financing.  Click the Convertible Debt <img src="res/1.0.0/style/images/info-sm.gif" alt="More Info" height="12" width="12" /> icon to learn more and see the following round\'s table for the impact of this type of financing on the ownership structure of the venture.';this.init(this.getRounds()[1])}else{$("#r1OptP").hide();B.setIsConvertableDebt(false);addChart(B)}});Controller.method("updateConversionRate",function(B){var A=this.getRounds()[0];A.setConversionPerc(B.value);this.init(A)});Controller.method("toggleDownRnd",function(C,B){var A=getRoundByIdPrefix(B);if(C.checked){A.isDownRnd=true}else{A.isDownRnd=false}this.init(A)});Controller.method("getStateJSON",function(){var E="{";for(var D=0;D<this.rounds.length;D++){var F=this.rounds[D];E+="'r"+(D+1)+"':{'o':"+F.getEmployeeOwnership()+",'pi':"+F.getPreInvestment()+",'i':"+F.getInvestment()+",'c':"+F.isConvertableDebt()+",'cp':"+F.getConversionPerc()+",'d':"+F.isDownRndProtect()+"},"}E+="'f':[";for(var D=0;D<this._founders.length;D++){var C=this._founders[D];var A=C.getOwnership();var B=C.getName();E+="{'n':'"+B+"','o':'"+(A*100)+"'}";if(D+1<this._founders.length){E+=","}}E+="]}";return E});

