function calculate(){
	var Loan_Portfolio_as_GTFM = document.getElementById("Loan_Portfolio_as_GTFM").value;
	var Months = document.getElementById("Months").value;
	//Deals_per_month = document.getElementById("Deals_per_month").innerHTML;
	
	var Upfront_payment_per_deal = document.getElementById("Upfront_payment_per_deal").value;
	var Ongoing_Monthly_deal = document.getElementById("Ongoing_Monthly_deal").value;
	
	var Upfront_payment_per_deal2 = document.getElementById("Upfront_payment_per_deal2").value;
	var Ongoing_Monthly_deal2 = document.getElementById("Ongoing_Monthly_deal2").value;
	
	//results01 = document.getElementById("results01").innerHTML;	
	
	//Flat_Monthly_Fee = document.getElementById("Flat_Monthly_Fee").value;	
	//Flat_Monthly_Fee2 = document.getElementById("Flat_Monthly_Fee2").value;	
	
	//total_Fee_Per_Deal = document.getElementById("total_Fee_Per_Deal").innerHTML;	
	//total_Flat_Monthly_Fee = document.getElementById("total_Flat_Monthly_Fee").innerHTML;	
	
	//result_amount = document.getElementById("result_amount").innerHTML;
	//diff = document.getElementById("diff").innerHTML;
	var Fee_Per_Deal = parseInt(Upfront_payment_per_deal) * parseInt(Loan_Portfolio_as_GTFM);
	var Fee_Per_Deal2 = parseInt(Ongoing_Monthly_deal) * parseInt(Months*Loan_Portfolio_as_GTFM);
	var Flat_Monthly_Fee = parseInt(Months) * parseInt(Upfront_payment_per_deal2);
	var Flat_Monthly_Fee2 = parseInt(Ongoing_Monthly_deal2) * parseInt(Months);
	document.getElementById("Fee_Per_Deal").innerHTML = "$ " + Fee_Per_Deal;
	document.getElementById("Fee_Per_Deal2").innerHTML = "$ " + Fee_Per_Deal2;
	document.getElementById("Flat_Monthly_Fee").innerHTML = "$ " + Flat_Monthly_Fee;
	document.getElementById("Flat_Monthly_Fee2").innerHTML = "$ " + Flat_Monthly_Fee2;
	
	var total_Fee_Per_Deal = Fee_Per_Deal + Fee_Per_Deal2;
	var total_Flat_Monthly_Fee = Flat_Monthly_Fee + Flat_Monthly_Fee2;
	document.getElementById("total_Fee_Per_Deal").innerHTML = "$ " + total_Fee_Per_Deal;
	document.getElementById("total_Flat_Monthly_Fee").innerHTML = "$ " + total_Flat_Monthly_Fee;
		
	if (total_Flat_Monthly_Fee < total_Fee_Per_Deal)
		document.getElementById("results01").innerHTML= "Broker solutions plus is better by";
	else if (total_Fee_Per_Deal < total_Flat_Monthly_Fee)
		document.getElementById("results01").innerHTML = "Fee Per Deal is better by";
	else
		document.getElementById("results01").innerHTML = "Options are equal";
		
	var results01 = document.getElementById("results01").innerHTML;
	if (results01 == "Fee Per Deal is better by")
		var result_amount = + total_Flat_Monthly_Fee - total_Fee_Per_Deal;
	else if (results01 == "Broker solutions plus is better by")
		var result_amount = - total_Flat_Monthly_Fee + total_Fee_Per_Deal;
	else
		var result_amount = "";
	document.getElementById("result_amount").innerHTML = "$ " + result_amount;
	document.getElementById("Months2").innerHTML = Months;
	
	var Total_Portfolio = parseFloat(document.getElementById("Average_Loan_Amount").value) * parseFloat(document.getElementById("Loan_Portfolio_as_GTFM").value);
	document.getElementById("Total_Portfolio").innerHTML = "$ " + Math.round(Total_Portfolio*Math.pow(10,2))/Math.pow(10,2);
	
	var Funder_Upfront = Total_Portfolio * parseFloat(document.getElementById("Funder_upfront_per").value) / 100;
	document.getElementById("Funder_Upfront").innerHTML = "$ "+ Math.round(Funder_Upfront*Math.pow(10,2))/Math.pow(10,2);
	
	var Aggregator_Upfront_Cut = Funder_Upfront * parseFloat(document.getElementById("Aggregator_Upfront_Cut_per").value) / 100;
	document.getElementById("Aggregator_Upfront_Cut").innerHTML = "$ "+ Math.round(Aggregator_Upfront_Cut*Math.pow(10,2))/Math.pow(10,2);
	
	var Funder_Trail = Total_Portfolio * parseFloat(document.getElementById("Funder_Trail_per").value) / 100 / 12 * parseFloat(Months);
	document.getElementById("Funder_Trail").innerHTML = "$ " + Math.round(Funder_Trail*Math.pow(10,2))/Math.pow(10,2);
	
	var Aggregator_Trail_Cut = Funder_Trail * parseFloat(document.getElementById("Aggregator_Trail_Cut_per").value) / 100;
	document.getElementById("Aggregator_Trail_Cut").innerHTML = "$ " + Math.round(Aggregator_Trail_Cut*Math.pow(10,2))/Math.pow(10,2);
	
	//Net_to_Broker = parseFloat(Funder_Upfront) - parseFloat(Aggregator_Upfront_Cut) + parseFloat(Funder_Trail) - parseFloat(Aggregator_Trail_Cut);
	var Net_to_Broker = parseFloat(Funder_Upfront - Aggregator_Upfront_Cut + Funder_Trail - Aggregator_Trail_Cut);
	document.getElementById("Net_to_Broker").innerHTML = "$ " + Math.round(Net_to_Broker*Math.pow(10,2))/Math.pow(10,2);
	
	if (total_Fee_Per_Deal<total_Flat_Monthly_Fee)
		var result_amount2 = Aggregator_Upfront_Cut + Aggregator_Trail_Cut - total_Fee_Per_Deal;
	else
		var result_amount2 = Aggregator_Upfront_Cut + Aggregator_Trail_Cut - total_Flat_Monthly_Fee;
	document.getElementById("result_amount2").innerHTML = "$ " + result_amount2;
	
	if (total_Fee_Per_Deal<total_Flat_Monthly_Fee)
		var diff = total_Fee_Per_Deal;
	else if (total_Flat_Monthly_Fee<total_Fee_Per_Deal)
		var diff = total_Flat_Monthly_Fee;
	else if (total_Fee_Per_Deal=total_Flat_Monthly_Fee)
		var diff = total_Fee_Per_Deal;
	else
		var diff = 0;
		
	document.getElementById("diff").innerHTML = "$ " + diff;
}

/*function isNumeric(elem){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}
	else{
		alert("Please enter numeric value for \""+elem.title+"\"");
		elem.focus();
		return false;
	}
}*/