// JavaScript Document
<!--

//<script src="forms.js" type="text/javascript"></script>
//<script src="math.js" type="text/javascript"></script>


//global variables
var incsta_operating_income = new Number();
var vc_operating_income = new Number();
var financial_profile_interest_sensubdebt_total = new Number();


//set percentage first
function mws_setpercent (field) {
	
	//Income Statement
	if ((field == 'incsta.cost_goods_sold_perc_sales') || (field == 'all')) {
		//set: Gross profit
		incsta_cost_goods_sold = percent(getValue('incsta.sales'), getValue('incsta.cost_goods_sold_perc_sales'));
		setValue('incsta.cost_goods_sold',Math.round(incsta_cost_goods_sold));
	}
	else if ((field == 'incsta.sga_costs_perc_sales') || (field == 'all')) {
		//set: Sales & Marketing expenses
		incsta_sga_costs = percent(getValue('incsta.sales'), getValue('incsta.sga_costs_perc_sales'));
		setValue('incsta.sga_costs',Math.round(incsta_sga_costs));
	}
	else if ((field == 'incsta.genadm_perc_sales') || (field == 'all')) {
		//set: General & administrative expenses
		incsta_genadm = percent(getValue('incsta.sales'), getValue('incsta.genadm_perc_sales'));
		setValue('incsta.genadm',Math.round(incsta_genadm));
	}
	else if ((field == 'incsta.taxes_perc') || (field == 'all')) {
		//update rest of worksheet
		updateWorksheetSplash();
	
		//set: Taxes
		incsta_taxes = percent(getValue('incsta.taxes_perc'), incsta_operating_income - getValue('incsta.interest_exist'));
		setValue('incsta.taxes',Math.round(incsta_taxes));
	
		//update rest of worksheet
		updateWorksheetSplash();
	}
	
	
	//Balance Statement
	else if ((field == 'balshe.inventory_perc_sales') || (field == 'all')) {
		//set: Inventory
		balshe_inventory = percent(getValue('incsta.sales'), getValue('balshe.inventory_perc_sales'));
		setValue('balshe.inventory',Math.round(balshe_inventory));
	}
	else if ((field == 'balshe.accounts_receivable_perc_sales') || (field == 'all')) {
		//set: Accounts Receivables
		balshe_accounts_receivable = percent(getValue('incsta.sales'), getValue('balshe.accounts_receivable_perc_sales'));
		setValue('balshe.accounts_receivable',Math.round(balshe_accounts_receivable));
	}


	//VC
	else if ((field == 'vc.cost_goods_sold_perc_sales') || (field == 'all')) {
		//set: Gross profit
		vc_cost_goods_sold = percent(getValue('vc.sales'), getValue('vc.cost_goods_sold_perc_sales'));
		setValue('vc.cost_goods_sold',Math.round(vc_cost_goods_sold));
	}
	else if ((field == 'vc.sga_costs_perc_sales') || (field == 'all')) {
		//set: Sales & Marketing expenses
		vc_sga_costs = percent(getValue('vc.sales'), getValue('vc.sga_costs_perc_sales'));
		setValue('vc.sga_costs',Math.round(vc_sga_costs));
	}
	else if ((field == 'vc.genadm_perc_sales') || (field == 'all')) {
		//set: General & administrative expenses
		vc_genadm = percent(getValue('vc.sales'), getValue('vc.genadm_perc_sales'));
		setValue('vc.genadm',Math.round(vc_genadm));
	}
	else if ((field == 'vc.taxes_perc') || (field == 'all')) {
		//update rest of worksheet
		updateWorksheetSplash();
	
		//set: Taxes
		vc_taxes = percent(getValue('vc.taxes_perc'), vc_operating_income - getValue('vc.interest_exist'));
		setValue('vc.taxes',Math.round(vc_taxes));
	
		//update rest of worksheet
		updateWorksheetSplash();
	}
}


//calculate all values for worksheet on splash page
function  updateWorksheetSplash () {
	
	//
	// Income Statement
	//
	
	//set: Gross profit
	incsta_gross_profit = getValue('incsta.sales') - getValue('incsta.cost_goods_sold');
	replaceText('incsta.gross_profit',incsta_gross_profit);
		
	//set: Operating Income
	incsta_operating_income = incsta_gross_profit - getValue('incsta.sga_costs') - getValue('incsta.genadm') - getValue('incsta.depreciation');
	replaceText('incsta.operating_income',incsta_operating_income);
	
	//set: Pre-tax income
	var incsta_pretax_income = new Number();
	incsta_pretax_income = Number(incsta_operating_income)-Number(getValue('incsta.interest_exist'));
	replaceText('incsta.pretax_income',Math.round(incsta_pretax_income));
	
	//set: Net income
	incsta_net_income = incsta_operating_income - getValue('incsta.interest_exist') - getValue('incsta.taxes');
	replaceText('incsta.net_income',incsta_net_income);
	
	
	
	
	
	//
	// Balance Sheet 
	//
	
	
	
	
	
	var balshe_total_assets = new Number();
	balshe_total_assets = Number(getValue('balshe.inventory')) + Number(getValue('balshe.accounts_receivable')) + Number(getValue('balshe.equipment')) + Number(getValue('balshe.real_estate')) + Number(getValue('balshe.other_assets'));
	replaceText('balshe.total_assets',Math.round(balshe_total_assets));
	
	
	
	
	
	//
	// Existing Business 
	//
	
	
	
	
	
	//set total amount
	var existing_business_total_amount = new Number();
	existing_business_total_amount = Number(getValue('existing_business.inv_amount')) + Number(getValue('existing_business.ar_amount')) + Number(getValue('existing_business.eq_amount')) + Number(getValue('existing_business.re_amount')) + Number(getValue('existing_business.other_amount'));
	replaceText('existing_business.total_amount',Math.round(existing_business_total_amount));

	//set total senior debt
	var existing_business_total_sendebt = new Number();
	existing_business_total_sendebt = Number(getValue('existing_business.inv_sendebt')) + Number(getValue('existing_business.ar_sendebt')) + Number(getValue('existing_business.eq_sendebt')) + Number(getValue('existing_business.re_sendebt')) + Number(getValue('existing_business.other_sendebt'));
	replaceText('existing_business.total_sendebt',Math.round(existing_business_total_sendebt));
	
	//set total subordinated debt
	var existing_business_total_subdebt = new Number();
	existing_business_total_subdebt = Number(getValue('existing_business.inv_subdebt')) + Number(getValue('existing_business.ar_subdebt')) + Number(getValue('existing_business.eq_subdebt')) + Number(getValue('existing_business.re_subdebt')) + Number(getValue('existing_business.other_subdebt'));
	replaceText('existing_business.total_subdebt',Math.round(existing_business_total_subdebt));
	
	
	
	
	
	//
	// Financial Profile 
	//
	
	//alert('Check: '+document.getElementById('existing_business_checkbox').checked);
	
	
	
	
	//set: Senior debt capacity based on collateral
	//=+IF(C2=1,(0.5*C22+0.75*C23+0.5*C24+0.75*C25),(0.5*(C22+C31)+0.75*(C23+C32)+0.5*(C24+C33)+0.75*(C25+C34)))
	var financial_profile_sendebt_basedon_collateral_total = new Number();
	if (document.getElementById('existing_business_checkbox').checked == 1)
	{
		//existing business
		financial_profile_sendebt_basedon_collateral_total = 0.5*(Number(getValue('balshe.inventory'))+Number(getValue('existing_business.inv_amount'))) + 0.75*(Number(getValue('balshe.accounts_receivable'))+Number(getValue('existing_business.ar_amount'))) + 0.5*(Number(getValue('balshe.equipment'))+Number(getValue('existing_business.eq_amount'))) + 0.75*(Number(getValue('balshe.real_estate'))+Number(getValue('existing_business.re_amount'))) ;		
	}
	else
	{
		//new business
		financial_profile_sendebt_basedon_collateral_total = 0.5*Number(getValue('balshe.inventory')) + 0.75*Number(getValue('balshe.accounts_receivable')) + 0.5*Number(getValue('balshe.equipment')) + 0.75*Number(getValue('balshe.real_estate'));		
	}
	replaceText('financial_profile.sendebt_basedon_collateral_total',Math.round(financial_profile_sendebt_basedon_collateral_total));
	
	var financial_profile_sendebt_basedon_collateral_existing = new Number();
	financial_profile_sendebt_basedon_collateral_existing = Number(existing_business_total_sendebt);
	replaceText('financial_profile.sendebt_basedon_collateral_existing',Math.round(financial_profile_sendebt_basedon_collateral_existing));

	var financial_profile_sendebt_basedon_collateral_new = new Number();
	financial_profile_sendebt_basedon_collateral_new = Number(financial_profile_sendebt_basedon_collateral_total) - Number(financial_profile_sendebt_basedon_collateral_existing);
	replaceText('financial_profile.sendebt_basedon_collateral_new',Math.round(financial_profile_sendebt_basedon_collateral_new));


	//set: Senior debt capacity based on interest repayability
	//+(C16/1.25)/((B5)/100)
	var financial_profile_sendebt_basedon_interestrepayability_total = new Number();
	financial_profile_sendebt_basedon_interestrepayability_total = divZero((Number(incsta_operating_income)/1.25),(Number(getValue('existing_business.interestrate_sendebt'))/100));
	replaceText('financial_profile.sendebt_basedon_interestrepayability_total',Math.round(Number(financial_profile_sendebt_basedon_interestrepayability_total)));

	var financial_profile_sendebt_basedon_interestrepayability_existing = new Number();
	financial_profile_sendebt_basedon_interestrepayability_existing = Number(existing_business_total_sendebt)+Number(existing_business_total_subdebt);
	replaceText('financial_profile.sendebt_basedon_interestrepayability_existing',Math.round(financial_profile_sendebt_basedon_interestrepayability_existing));

	var financial_profile_sendebt_basedon_interestrepayability_new = new Number();
	financial_profile_sendebt_basedon_interestrepayability_new = Number(financial_profile_sendebt_basedon_interestrepayability_total)-Number(financial_profile_sendebt_basedon_interestrepayability_existing);
	replaceText('financial_profile.sendebt_basedon_interestrepayability_new',Math.round(financial_profile_sendebt_basedon_interestrepayability_new));


	//set: Senior debt based on lower of above
	var financial_profile_sendebt_basedon_lowerofabove_total = new Number();
	financial_profile_sendebt_basedon_lowerofabove_total = Math.min(financial_profile_sendebt_basedon_collateral_total,financial_profile_sendebt_basedon_interestrepayability_total);
	replaceText('financial_profile.sendebt_basedon_lowerofabove_total',Math.round(financial_profile_sendebt_basedon_lowerofabove_total));

	var financial_profile_sendebt_basedon_lowerofabove_existing = new Number();
	if (financial_profile_sendebt_basedon_collateral_total == financial_profile_sendebt_basedon_lowerofabove_total)
	{
		financial_profile_sendebt_basedon_lowerofabove_existing = financial_profile_sendebt_basedon_collateral_existing;
	}
	else
	{
		financial_profile_sendebt_basedon_lowerofabove_existing = financial_profile_sendebt_basedon_interestrepayability_existing;
	}
	replaceText('financial_profile.sendebt_basedon_lowerofabove_existing',Math.round(financial_profile_sendebt_basedon_lowerofabove_existing));

	var financial_profile_sendebt_basedon_lowerofabove_new = new Number();
	financial_profile_sendebt_basedon_lowerofabove_new = Number(financial_profile_sendebt_basedon_lowerofabove_total)-Number(financial_profile_sendebt_basedon_lowerofabove_existing);
	replaceText('financial_profile.sendebt_basedon_lowerofabove_new',Math.round(financial_profile_sendebt_basedon_lowerofabove_new));
	
	
	//set: Interest on senior debt
	var financial_profile_interest_sendebt_existing = new Number();
	financial_profile_interest_sendebt_existing = Number(getValue('existing_business.interest_owed_sendebt'));
	replaceText('financial_profile.interest_sendebt_existing',Math.round(financial_profile_interest_sendebt_existing));

	var financial_profile_interest_sendebt_new = new Number();
	financial_profile_interest_sendebt_new = financial_profile_sendebt_basedon_lowerofabove_new*(Number(getValue('existing_business.interestrate_sendebt'))/100);
	replaceText('financial_profile.interest_sendebt_new',Math.round(financial_profile_interest_sendebt_new));

	
	//set: Sub debt capacity based on collateral
	//=+IF(C2=1,(0.25*C24+0.15*C25),(0.25*(C24+C33)+0.15*(C25+C34)))
	var financial_profile_subdebt_basedon_collateral_total = new Number();
	if (document.getElementById('existing_business_checkbox').checked == 1)
	{
		//existing business
		financial_profile_subdebt_basedon_collateral_total = 0.25*(Number(getValue('balshe.equipment'))+Number(getValue('existing_business.eq_amount'))) + 0.15*(Number(getValue('balshe.real_estate'))+Number(getValue('existing_business.re_amount')));		
	}
	else
	{
		//new business
		financial_profile_subdebt_basedon_collateral_total = 0.25*Number(getValue('balshe.equipment')) + 0.15*Number(getValue('balshe.real_estate'));		

	}
	replaceText('financial_profile.subdebt_basedon_collateral_total',Math.round(financial_profile_subdebt_basedon_collateral_total));
	
	var financial_profile_subdebt_basedon_collateral_existing = new Number();
	financial_profile_subdebt_basedon_collateral_existing = Number(existing_business_total_subdebt);
	replaceText('financial_profile.subdebt_basedon_collateral_existing',Math.round(financial_profile_subdebt_basedon_collateral_existing));

	var financial_profile_subdebt_basedon_collateral_new = new Number();
	financial_profile_subdebt_basedon_collateral_new = Number(financial_profile_subdebt_basedon_collateral_total) - Number(financial_profile_subdebt_basedon_collateral_existing);
	replaceText('financial_profile.subdebt_basedon_collateral_new',Math.round(financial_profile_subdebt_basedon_collateral_new));


	//set: Sub debt capacity  based on interest repayability
	var financial_profile_subdebt_basedon_interestrepayability_total = new Number();
	financial_profile_subdebt_basedon_interestrepayability_total = divZero(((Number(incsta_operating_income)-Number(getValue('existing_business.interest_owed_sendebt'))-Number(getValue('existing_business.interest_owed_subdebt'))-Number(financial_profile_interest_sendebt_new))/1.25),(Number(getValue('existing_business.interestrate_subdebt'))/100));
	replaceText('financial_profile.subdebt_basedon_interestrepayability_total',Math.round(financial_profile_subdebt_basedon_interestrepayability_total));

	var financial_profile_subdebt_basedon_interestrepayability_existing = new Number();
	financial_profile_subdebt_basedon_interestrepayability_existing = Number(existing_business_total_subdebt);
	replaceText('financial_profile.subdebt_basedon_interestrepayability_existing',Math.round(financial_profile_subdebt_basedon_interestrepayability_existing));

	var financial_profile_subdebt_basedon_interestrepayability_new = new Number();
	financial_profile_subdebt_basedon_interestrepayability_new = Number(financial_profile_subdebt_basedon_interestrepayability_total)-Number(financial_profile_subdebt_basedon_interestrepayability_existing);
	replaceText('financial_profile.subdebt_basedon_interestrepayability_new',Math.round(financial_profile_subdebt_basedon_interestrepayability_new));

	
	//set: Max. sub debt (lower of above)
	var financial_profile_maxsubdebt_total = new Number();
	financial_profile_maxsubdebt_total = Math.min(financial_profile_subdebt_basedon_collateral_total,financial_profile_subdebt_basedon_interestrepayability_total);
	replaceText('financial_profile.maxsubdebt_total',Math.round(financial_profile_maxsubdebt_total));

	var financial_profile_maxsubdebt_existing = new Number();
	if (financial_profile_maxsubdebt_total==financial_profile_subdebt_basedon_collateral_total)
	{
		financial_profile_maxsubdebt_existing = Number(financial_profile_subdebt_basedon_collateral_existing);
	}
	else
	{
		financial_profile_maxsubdebt_existing = Number(financial_profile_subdebt_basedon_interestrepayability_existing);
	}
	replaceText('financial_profile.maxsubdebt_existing',Math.round(financial_profile_maxsubdebt_existing));

	var financial_profile_maxsubdebt_new = new Number();
	financial_profile_maxsubdebt_new = Number(financial_profile_maxsubdebt_total)-Number(financial_profile_maxsubdebt_existing);
	replaceText('financial_profile.maxsubdebt_new',Math.round(financial_profile_maxsubdebt_new));
	
	
	//set: Interest on subordinated debt
	var financial_profile_interest_subdebt_existing = new Number();
	financial_profile_interest_subdebt_existing = Number(getValue('existing_business.interest_owed_subdebt'));
	replaceText('financial_profile.interest_subdebt_existing',Math.round(financial_profile_interest_subdebt_existing));

	var financial_profile_interest_subdebt_new = new Number();
	financial_profile_interest_subdebt_new = Number(financial_profile_maxsubdebt_new)*(Number(getValue('existing_business.interestrate_subdebt'))/100);
	replaceText('financial_profile.interest_subdebt_new',Math.round(financial_profile_interest_subdebt_new));

	
	//set: Total of Sr. & Sub Debt
	var financial_profile_total_sensubdebt_total = new Number();
	financial_profile_total_sensubdebt_total = Number(financial_profile_sendebt_basedon_lowerofabove_total)+Number(financial_profile_maxsubdebt_total);
	replaceText('financial_profile.total_sensubdebt_total',Math.round(financial_profile_total_sensubdebt_total));

	var financial_profile_total_sensubdebt_existing = new Number();
	financial_profile_total_sensubdebt_existing = Number(existing_business_total_sendebt)+Number(existing_business_total_subdebt);
	replaceText('financial_profile.total_sensubdebt_existing',Math.round(financial_profile_total_sensubdebt_existing));

	var financial_profile_total_sensubdebt_new = new Number();
	financial_profile_total_sensubdebt_new = Number(financial_profile_total_sensubdebt_total)-Number(financial_profile_total_sensubdebt_existing);
	replaceText('financial_profile.total_sensubdebt_new',Math.round(financial_profile_total_sensubdebt_new));

	
	//set: Interest on Sr. and Sub Debt
	financial_profile_interest_sensubdebt_total = Number(financial_profile_interest_sendebt_existing)+Number(financial_profile_interest_sendebt_new)+Number(financial_profile_interest_subdebt_existing)+Number(financial_profile_interest_subdebt_new);
	replaceText('financial_profile.interest_sensubdebt_total',Math.round(financial_profile_interest_sensubdebt_total));

	var financial_profile_interest_sensubdebt_existing = new Number();
	financial_profile_interest_sensubdebt_existing = Number(financial_profile_interest_sendebt_existing)+Number(financial_profile_interest_subdebt_existing);
	replaceText('financial_profile.interest_sensubdebt_existing',Math.round(financial_profile_interest_sensubdebt_existing));

	var financial_profile_interest_sensubdebt_new = new Number();
	financial_profile_interest_sensubdebt_new = Number(financial_profile_interest_sensubdebt_total)-Number(financial_profile_interest_sensubdebt_existing);
	replaceText('financial_profile.interest_sensubdebt_new',Math.round(financial_profile_interest_sensubdebt_new));

	
	//set: Principal repayments
	var financial_profile_principal_repayments_maxpotl = new Number();
	financial_profile_principal_repayments_maxpotl = Number(incsta_net_income)+Number(getValue('incsta.depreciation'));
	replaceText('financial_profile.principal_repayments_maxpotl',Math.round(financial_profile_principal_repayments_maxpotl));

	var financial_profile_principal_repayments_existing = new Number();
	financial_profile_principal_repayments_existing = Number(getValue('existing_business.principal_owed_sendebt'))+Number(getValue('existing_business.principal_owed_subdebt'));
	replaceText('financial_profile.principal_repayments_existing',Math.round(financial_profile_principal_repayments_existing));

	var financial_profile_principal_repayments_available = new Number();
	financial_profile_principal_repayments_available = Number(financial_profile_principal_repayments_maxpotl)-Number(financial_profile_principal_repayments_existing);
	replaceText('financial_profile.principal_repayments_available',Math.round(financial_profile_principal_repayments_available));

	
	//set: Max. suggested total debt based on debt/assets limit
	var financial_profile_max_sugg_debt_maxpoptl = new Number();
	financial_profile_max_sugg_debt_maxpoptl = (Number(balshe_total_assets)+Number(existing_business_total_amount))*Number(getValue('financial_profile.maxdebt_debtassets_perc'))/100;
	replaceText('financial_profile.max_sugg_debt_maxpoptl',Math.round(financial_profile_max_sugg_debt_maxpoptl));

	var financial_profile_max_sugg_debt_existing = new Number();
	financial_profile_max_sugg_debt_existing = Number(existing_business_total_sendebt)+Number(existing_business_total_subdebt);
	replaceText('financial_profile.max_sugg_debt_existing',Math.round(financial_profile_max_sugg_debt_existing));
	
	var financial_profile_max_sugg_debt_available = new Number();
	financial_profile_max_sugg_debt_available = Number(financial_profile_max_sugg_debt_maxpoptl)-Number(financial_profile_max_sugg_debt_existing);
	replaceText('financial_profile.max_sugg_debt_available',Math.round(financial_profile_max_sugg_debt_available));
	
	
	
	
	
	
	//
	// Venture Capital 
	//






	//set: Gross profit
	var vc_gross_profit = new Number();
	vc_gross_profit = Number(getValue('vc.sales'))-Number(getValue('vc.cost_goods_sold'));
	replaceText('vc.gropss_profit',Math.round(vc_gross_profit));
	
	
	//set: Operating Income
	//var  = new Number();
	vc_operating_income = Number(vc_gross_profit)-Number(getValue('vc.sga_costs'))-Number(getValue('vc.genadm'))-Number(getValue('vc.depreciation'));
	replaceText('vc.operating_income',Math.round(vc_operating_income));
	
	//set: Pre-tax income
	var vc_pretax_income = new Number();
	vc_pretax_income = Number(vc_operating_income)-Number(getValue('vc.interest_exist'));
	replaceText('vc.pretax_income',Math.round(vc_pretax_income));
	
	//set: Net income
	var vc_net_income = new Number();
	vc_net_income = Number(vc_pretax_income)-Number(getValue('vc.taxes'));
	replaceText('vc.net_income',Math.round(vc_net_income));
	
	
	//set: Current venture valuation
	//=+(E20*E5)/((1+E6/100)^5)
	var vc_current_venture_valuation = new Number();
	vc_current_venture_valuation = divZero((Number(vc_net_income)*Number(getValue('vc.pe'))),Math.pow((1+(Number(getValue('vc.irr'))/100.0)),Number(getValue('vc.exityear'))));
	replaceText('vc.current_venture_valuation',Math.round(vc_current_venture_valuation));
	
	
	//set: Percent of venture to be offered
	var vc_perc_venture_offered = new Number();
	vc_perc_venture_offered = divZero(Number(getValue('vc.equity_invest')),Number(vc_current_venture_valuation)) * 100;
	//vc_perc_venture_offered = divZero(Number(getValue('vc.equity_invest')),Number(getValue('vc.equity_invest'))+Number(vc_current_venture_valuation)) * 100;
	replaceText('vc.perc_venture_offered',vc_perc_venture_offered.toFixed(1)+" %");
	
	
	//set fields red if negative
	setRedIfNegative('incsta.sales');
	setRedIfNegative('incsta.cost_goods_sold');
	setRedIfNegative('incsta.sga_costs');
	setRedIfNegative('incsta.genadm');
	setRedIfNegative('incsta.depreciation');
	setRedIfNegative('incsta.interest_exist');
	setRedIfNegative('incsta.cost_goods_sold_perc_sales');
	setRedIfNegative('incsta.sga_costs_perc_sales');
	setRedIfNegative('incsta.genadm_perc_sales');
	setRedIfNegative('incsta.taxes_perc');
	setRedIfNegative('balshe.inventory');
	setRedIfNegative('balshe.accounts_receivable');
	setRedIfNegative('balshe.equipment');
	setRedIfNegative('balshe.real_estate');
	setRedIfNegative('balshe.other_assets');
	setRedIfNegative('existing_business.inv_amount');
	setRedIfNegative('existing_business.inv_sendebt');
	setRedIfNegative('existing_business.inv_subdebt');
	setRedIfNegative('existing_business.ar_amount');
	setRedIfNegative('existing_business.ar_sendebt');
	setRedIfNegative('existing_business.ar_subdebt');
	setRedIfNegative('existing_business.eq_amount');
	setRedIfNegative('existing_business.eq_sendebt');
	setRedIfNegative('existing_business.eq_subdebt');
	setRedIfNegative('existing_business.re_amount');
	setRedIfNegative('existing_business.re_sendebt');
	setRedIfNegative('existing_business.re_subdebt');
	setRedIfNegative('existing_business.other_amount');
	setRedIfNegative('existing_business.other_sendebt');
	setRedIfNegative('existing_business.other_subdebt');
	setRedIfNegative('existing_business.interest_owed_sendebt');
	setRedIfNegative('existing_business.interest_owed_subdebt');
	setRedIfNegative('existing_business.principal_owed_sendebt');
	setRedIfNegative('existing_business.principal_owed_subdebt');
	setRedIfNegative('existing_business.interestrate_sendebt');
	setRedIfNegative('existing_business.interestrate_subdebt');
	setRedIfNegative('financial_profile.maxdebt_debtassets_perc');
	setRedIfNegative('vc.pe');
	setRedIfNegative('vc.irr');
	setRedIfNegative('vc.exityear');
	setRedIfNegative('vc.sales');
	setRedIfNegative('vc.cost_goods_sold_perc_sales');
	setRedIfNegative('vc.cost_goods_sold');
	setRedIfNegative('vc.sga_costs_perc_sales');
	setRedIfNegative('vc.sga_costs');
	setRedIfNegative('vc.genadm_perc_sales');
	setRedIfNegative('vc.genadm');
	setRedIfNegative('vc.depreciation');
	setRedIfNegative('vc.interest_exist');
	setRedIfNegative('vc.equity_invest');
}


//set values after calculation
function mws_setlast (field) {
	
	//update rest of worksheet
	updateWorksheetSplash();

	//Income Statement
	if (field == 'incsta.interest_exist') {
		//set: Interest from below
		incsta_interest_exist = financial_profile_interest_sensubdebt_total;
		setValue('incsta.interest_exist',Math.round(incsta_interest_exist));
	}
}


//load all cookies for the mini-worksheet
function mws_loadCookies() {
	cookie = readCookie('if_mws_incsta_sales');
	if (cookie) {
		document.getElementById('incsta.sales').value = cookie;
	}
	cookie = readCookie('if_mws_incsta_cost_goods_sold_perc_sales');
	if (cookie) {
		document.getElementById('incsta.cost_goods_sold_perc_sales').value = cookie;
	}
	cookie = readCookie('if_mws_incsta_cost_goods_sold');
	if (cookie) {
		document.getElementById('incsta.cost_goods_sold').value = cookie;
	}
	cookie = readCookie('if_mws_incsta_sga_costs_perc_sales');
	if (cookie) {
		document.getElementById('incsta.sga_costs_perc_sales').value = cookie;
	}
	cookie = readCookie('if_mws_incsta_sga_costs');
	if (cookie) {
		document.getElementById('incsta.sga_costs').value = cookie;
	}
	cookie = readCookie('if_mws_incsta_genadm_perc_sales');
	if (cookie) {
		document.getElementById('incsta.genadm_perc_sales').value = cookie;
	}
	cookie = readCookie('if_mws_incsta_genadm');
	if (cookie) {
		document.getElementById('incsta.genadm').value = cookie;
	}
	cookie = readCookie('if_mws_incsta_depreciation');
	if (cookie) {
		document.getElementById('incsta.depreciation').value = cookie;
	}
	cookie = readCookie('if_mws_incsta_interest_exist');
	if (cookie) {
		document.getElementById('incsta.interest_exist').value = cookie;
	}
	cookie = readCookie('if_mws_incsta_taxes_perc');
	if (cookie) {
		document.getElementById('incsta.taxes_perc').value = cookie;
	}
	cookie = readCookie('if_mws_incsta_taxes');
	if (cookie) {
		document.getElementById('incsta.taxes').value = cookie;
	}
	cookie = readCookie('if_mws_balshe_inventory_perc_sales');
	if (cookie) {
		document.getElementById('balshe.inventory_perc_sales').value = cookie;
	}
	cookie = readCookie('if_mws_balshe_inventory');
	if (cookie) {
		document.getElementById('balshe.inventory').value = cookie;
	}
	cookie = readCookie('if_mws_balshe_accounts_receivable_perc_sales');
	if (cookie) {
		document.getElementById('balshe.accounts_receivable_perc_sales').value = cookie;
	}
	cookie = readCookie('if_mws_balshe_accounts_receivable');
	if (cookie) {
		document.getElementById('balshe.accounts_receivable').value = cookie;
	}
	cookie = readCookie('if_mws_balshe_equipment');
	if (cookie) {
		document.getElementById('balshe.equipment').value = cookie;
	}
	cookie = readCookie('if_mws_balshe_real_estate');
	if (cookie) {
		document.getElementById('balshe.real_estate').value = cookie;
	}
	cookie = readCookie('if_mws_balshe_other_assets');
	if (cookie) {
		document.getElementById('balshe.other_assets').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_inv_amount');
	if (cookie) {
		document.getElementById('existing_business.inv_amount').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_inv_sendebt');
	if (cookie) {
		document.getElementById('existing_business.inv_sendebt').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_inv_subdebt');
	if (cookie) {
		document.getElementById('existing_business.inv_subdebt').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_ar_amount');
	if (cookie) {
		document.getElementById('existing_business.ar_amount').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_ar_sendebt');
	if (cookie) {
		document.getElementById('existing_business.ar_sendebt').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_ar_subdebt');
	if (cookie) {
		document.getElementById('existing_business.ar_subdebt').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_eq_amount');
	if (cookie) {
		document.getElementById('existing_business.eq_amount').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_eq_sendebt');
	if (cookie) {
		document.getElementById('existing_business.eq_sendebt').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_eq_subdebt');
	if (cookie) {
		document.getElementById('existing_business.eq_subdebt').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_re_amount');
	if (cookie) {
		document.getElementById('existing_business.re_amount').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_re_sendebt');
	if (cookie) {
		document.getElementById('existing_business.re_sendebt').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_re_subdebt');
	if (cookie) {
		document.getElementById('existing_business.re_subdebt').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_other_amount');
	if (cookie) {
		document.getElementById('existing_business.other_amount').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_other_sendebt');
	if (cookie) {
		document.getElementById('existing_business.other_sendebt').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_other_subdebt');
	if (cookie) {
		document.getElementById('existing_business.other_subdebt').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_interest_owed_sendebt');
	if (cookie) {
		document.getElementById('existing_business.interest_owed_sendebt').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_interest_owed_subdebt');
	if (cookie) {
		document.getElementById('existing_business.interest_owed_subdebt').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_principal_owed_sendebt');
	if (cookie) {
		document.getElementById('existing_business.principal_owed_sendebt').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_principal_owed_subdebt');
	if (cookie) {
		document.getElementById('existing_business.principal_owed_subdebt').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_interestrate_sendebt');
	if (cookie) {
		document.getElementById('existing_business.interestrate_sendebt').value = cookie;
	}
	cookie = readCookie('if_mws_existing_business_interestrate_subdebt');
	if (cookie) {
		document.getElementById('existing_business.interestrate_subdebt').value = cookie;
	}
	cookie = readCookie('if_mws_financial_profile_maxdebt_debtassets_perc');
	if (cookie) {
		document.getElementById('financial_profile.maxdebt_debtassets_perc').value = cookie;
	}
	cookie = readCookie('if_mws_vc_pe');
	if (cookie) {
		document.getElementById('vc.pe').value = cookie;
	}
	cookie = readCookie('if_mws_vc_irr');
	if (cookie) {
		document.getElementById('vc.irr').value = cookie;
	}
	cookie = readCookie('if_mws_vc_exityear');
	if (cookie) {
		document.getElementById('vc.exityear').value = cookie;
	}
	cookie = readCookie('if_mws_vc_sales');
	if (cookie) {
		document.getElementById('vc.sales').value = cookie;
	}
	cookie = readCookie('if_mws_vc_cost_goods_sold_perc_sales');
	if (cookie) {
		document.getElementById('vc.cost_goods_sold_perc_sales').value = cookie;
	}
	cookie = readCookie('if_mws_vc_cost_goods_sold');
	if (cookie) {
		document.getElementById('vc.cost_goods_sold').value = cookie;
	}
	cookie = readCookie('if_mws_vc_sga_costs_perc_sales');
	if (cookie) {
		document.getElementById('vc.sga_costs_perc_sales').value = cookie;
	}
	cookie = readCookie('if_mws_vc_sga_costs');
	if (cookie) {
		document.getElementById('vc.sga_costs').value = cookie;
	}
	cookie = readCookie('if_mws_vc_genadm_perc_sales');
	if (cookie) {
		document.getElementById('vc.genadm_perc_sales').value = cookie;
	}
	cookie = readCookie('if_mws_vc_genadm');
	if (cookie) {
		document.getElementById('vc.genadm').value = cookie;
	}
	cookie = readCookie('if_mws_vc_depreciation');
	if (cookie) {
		document.getElementById('vc.depreciation').value = cookie;
	}
	cookie = readCookie('if_mws_vc_interest_exist');
	if (cookie) {
		document.getElementById('vc.interest_exist').value = cookie;
	}
	cookie = readCookie('if_mws_vc_taxes_perc');
	if (cookie) {
		document.getElementById('vc.taxes_perc').value = cookie;
	}
	cookie = readCookie('if_mws_vc_taxes');
	if (cookie) {
		document.getElementById('vc.taxes').value = cookie;
	}
	cookie = readCookie('if_mws_vc_equity_invest');
	if (cookie) {
		document.getElementById('vc.equity_invest').value = cookie;
	}
	cookie = readCookie('if_mws_mail_name');
	if (cookie) {
		document.getElementById('mail.name').value = cookie;
	}
	cookie = readCookie('if_mws_mail_state');
	if (cookie) {
		document.getElementById('mail.state').value = cookie;
	}
	cookie = readCookie('if_mws_mail_email');
	if (cookie) {
		document.getElementById('mail.email').value = cookie;
	}
	cookie = readCookie('if_mws_mail_phone');
	if (cookie) {
		document.getElementById('mail.phone').value = cookie;
	}
}


function mws_resetCookies() {
	eraseCookie('if_mws_incsta_sales');
	eraseCookie('if_mws_incsta_cost_goods_sold_perc_sales');
	eraseCookie('if_mws_incsta_cost_goods_sold');
	eraseCookie('if_mws_incsta_sga_costs_perc_sales');
	eraseCookie('if_mws_incsta_sga_costs');
	eraseCookie('if_mws_incsta_genadm_perc_sales');
	eraseCookie('if_mws_incsta_genadm');
	eraseCookie('if_mws_incsta_depreciation');
	eraseCookie('if_mws_incsta_interest_exist');
	eraseCookie('if_mws_incsta_taxes_perc');
	eraseCookie('if_mws_incsta_taxes');
	eraseCookie('if_mws_balshe_inventory_perc_sales');
	eraseCookie('if_mws_balshe_inventory');
	eraseCookie('if_mws_balshe_accounts_receivable_perc_sales');
	eraseCookie('if_mws_balshe_accounts_receivable');
	eraseCookie('if_mws_balshe_equipment');
	eraseCookie('if_mws_balshe_real_estate');
	eraseCookie('if_mws_balshe_other_assets');
	eraseCookie('if_mws_existing_business_inv_amount');
	eraseCookie('if_mws_existing_business_inv_sendebt');
	eraseCookie('if_mws_existing_business_inv_subdebt');
	eraseCookie('if_mws_existing_business_ar_amount');
	eraseCookie('if_mws_existing_business_ar_sendebt');
	eraseCookie('if_mws_existing_business_ar_subdebt');
	eraseCookie('if_mws_existing_business_eq_amount');
	eraseCookie('if_mws_existing_business_eq_sendebt');
	eraseCookie('if_mws_existing_business_eq_subdebt');
	eraseCookie('if_mws_existing_business_re_amount');
	eraseCookie('if_mws_existing_business_re_sendebt');
	eraseCookie('if_mws_existing_business_re_subdebt');
	eraseCookie('if_mws_existing_business_other_amount');
	eraseCookie('if_mws_existing_business_other_sendebt');
	eraseCookie('if_mws_existing_business_other_subdebt');
	eraseCookie('if_mws_existing_business_interest_owed_sendebt');
	eraseCookie('if_mws_existing_business_interest_owed_subdebt');
	eraseCookie('if_mws_existing_business_principal_owed_sendebt');
	eraseCookie('if_mws_existing_business_principal_owed_subdebt');
	eraseCookie('if_mws_existing_business_interestrate_sendebt');
	eraseCookie('if_mws_existing_business_interestrate_subdebt');
	eraseCookie('if_mws_financial_profile_maxdebt_debtassets_perc');
	eraseCookie('if_mws_vc_pe');
	eraseCookie('if_mws_vc_irr');
	eraseCookie('if_mws_vc_exityear');
	eraseCookie('if_mws_vc_sales');
	eraseCookie('if_mws_vc_cost_goods_sold_perc_sales');
	eraseCookie('if_mws_vc_cost_goods_sold');
	eraseCookie('if_mws_vc_sga_costs_perc_sales');
	eraseCookie('if_mws_vc_sga_costs');
	eraseCookie('if_mws_vc_genadm_perc_sales');
	eraseCookie('if_mws_vc_genadm');
	eraseCookie('if_mws_vc_depreciation');
	eraseCookie('if_mws_vc_interest_exist');
	eraseCookie('if_mws_vc_taxes_perc');
	eraseCookie('if_mws_vc_taxes');
	eraseCookie('if_mws_vc_equity_invest');
	eraseCookie('if_mws_mail_name');
	eraseCookie('if_mws_mail_state');
	eraseCookie('if_mws_mail_email');
	eraseCookie('if_mws_mail_phone');
}


//-->












