//
// MA - Target Helpdesk ROI Calculator
//

function recalculate() {

	var v_total_techs = parseInt(document.getElementById("total_techs").value);
	var v_tech_cost = parseInt(document.getElementById("tech_cost").value);
	var v_clients_supported = parseInt(document.getElementById("clients_supported").value);
	var v_time_saving_percent = parseInt(document.getElementById("time_saving_percent").value);


	var v_additional_lics_required = v_total_techs - 2;

	var v_initial_price = 0;
	var v_lics_price = 0;
	var v_web_portal_price = 0;
	var v_purchase_price = 0;

	switch ( parseInt(document.getElementById("display0").value)) {
		case 1: document.getElementById("display0_currency").value = "\u20AC";
			  v_initial_price = 1750;
			  v_lics_price = 575;
			  v_web_portal_price = 1145;
			  break;

		case 2: document.getElementById("display0_currency").value = "\u00A3";
			  v_initial_price = 1195;
			  v_lics_price = 395;
			  v_web_portal_price = 795;
			  break;

		case 3: document.getElementById("display0_currency").value = "$";
			  v_initial_price = 2550;
			  v_lics_price = 795;
			  v_web_portal_price = 1585;
			  break;
	}


	var v_cost_of_support = (v_total_techs * v_tech_cost);
	var v_cost_of_support_per_client = Math.round(v_cost_of_support / v_clients_supported);
	document.getElementById("cost_of_support").value = document.getElementById("display0_currency").value + " " +  v_cost_of_support.toString();
	document.getElementById("cost_of_support_per_client").value = document.getElementById("display0_currency").value + " " +   v_cost_of_support_per_client.toString();	

	v_purchase_price = v_initial_price ;
	if (v_additional_lics_required > 0) {
		v_purchase_price = v_purchase_price + (v_lics_price * v_additional_lics_required);
	}
	v_purchase_price = Math.round(v_purchase_price * 1.16);

	//
	// with web portal
	//
	//v_purchase_price = v_purchase_price + Math.round(v_web_portal_price * 1.16);
	document.getElementById("purchase_price").value = document.getElementById("display0_currency").value + " " + v_purchase_price.toString();


	var v_estimated_savings = Math.round((v_cost_of_support / 100) * v_time_saving_percent);
	var v_estimated_savings_per_client = Math.round(v_estimated_savings / v_clients_supported);
	document.getElementById("estimated_savings_per_client").value = document.getElementById("display0_currency").value + " " +  v_estimated_savings_per_client;
	document.getElementById("estimated_savings").value = document.getElementById("display0_currency").value + " " + v_estimated_savings;

	var v_months_to_roi = Math.round(v_purchase_price / (v_estimated_savings / 12));
	document.getElementById("months_to_roi").value = v_months_to_roi;


}
