var isC = false;
var errormsg = '';
var checkedResult = true;
	//init
var Sasklandinflationafterparity ;
var ManagementFeeonNAV  ;
var AcquisitionFee  ;
var Carry  ;
var CommissionsonFundsRaised ;
var PropertyTaxes  ;
var Opex  ;
var FundsRaised ;

var startPrice =new Array(700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700);
var annualROI =new Array(40,44.2,48.2,51.8,55.3,58.5,61.6,64.5,67.2,69.9,72.4,74.8,77.1,79.4,81.5,83.6,85.6,87.6,89.4,91.3,93);

function PMT(IR ,NP , PV) {
  var PMT = -1* (PV * IR) / (1 - Math.pow(1 + IR, -NP));
  return PMT;
}

function init(value)
{

var temp = new Array(); 
	temp =  value.split('%');
	Sasklandinflationafterparity = temp[0];
	ManagementFeeonNAV = temp[1];
	AcquisitionFee = temp[2];
	Carry = temp[3];
	CommissionsonFundsRaised = temp[4];
	PropertyTaxes = temp[5];
	Opex = temp[6];
	FundsRaised = temp[7];
	curcookie=readCookie('disclaimer');
	if (curcookie == "yes")
	{
		document.f1.disclaimer[0].checked=true;
	}
	else
		document.f1.disclaimer[1].checked=true;
}

function Calculator(){
	
	if (! document.f1.disclaimer[0].checked )
	{	
		createCookie("disclaimer","no",10);
		document.f1.Selllandinyear.value = '';
		document.f1.ROIPerAnnum.value = '';
		return ;
	}	
	createCookie("disclaimer","yes",10);
	
	//check start
	errormsg = '<br />';
	checkedResult = true;
	
	if (!checkInputError(document.f1.SaskStartPrice,"Agcapita Land Purchase Price/Acre",true))
		checkedResult = false;
	if (!checkInputError(document.f1.ComparableLandStartPrice,"Comparable Land Start Price/Acre",true))
		checkedResult = false;	
	if (!checkInputError(document.f1.YearsforSaskParitytoComparableLandtype,"Years for Agcapita Land to Reach Parity to Comparable Land",false))
		checkedResult = false;
	else if (parseFloat(document.f1.YearsforSaskParitytoComparableLandtype.value) < 5 || parseFloat(document.f1.YearsforSaskParitytoComparableLandtype.value) > 7)
	{
		errormsg+="\"Years for Agcapita Land to Reach Parity to Comparable Land\" must be between 5 to 7 .  <br />";
		document.f1.YearsforSaskParitytoComparableLandtype.style.color="#ff0000";
		if (checkedResult)
			document.f1.YearsforSaskParitytoComparableLandtype.focus();
		checkedResult = false;
	}
	if (!checkInputError(document.f1.ComparableLandPriceIncrease,"Inflation/Year",true))
		checkedResult = false;
	if (!checkInputError(document.f1.RentalIncomepa,"Rental Income/Year",true))
		checkedResult = false;	
	if (!checkInputError(document.f1.Interestpa,"Mortgage Interest/Year",true))
		checkedResult = false;	
	if (!checkInputError(document.f1.ConstantGearing,"Percent of Land Financed with Debt",false))
		checkedResult = false;
	else if (parseFloat(document.f1.ConstantGearing.value) < 25 || parseFloat(document.f1.ConstantGearing.value) > 50)
	{
		errormsg+="\"Percent of Land Financed with Debt\" must be between 25% to 50% .  <br />";
		document.f1.ConstantGearing.style.color="#ff0000";
		if (checkedResult)
			document.f1.ConstantGearing.focus();
		checkedResult = false;
	}
	if (checkedResult == false)
	{
		document.f1.Selllandinyear.value = '';
		document.f1.ROIPerAnnum.value = '';
		document.getElementById("errormsg").className = "errormsg";
		document.getElementById("errormsg").innerHTML = errormsg + "<br />";
		return;
	}
	//check end
	
	//Geared Funds Net of Commissions
	var ComparableLandStartPrice = document.f1.ComparableLandStartPrice.value.toString().replace(/\$|\,/g,'');
	var SaskStartPrice = document.f1.SaskStartPrice.value.toString().replace(/\$|\,/g,'');
	
	var GearedFundsNetofCommissions =(1+(parseFloat(document.f1.ConstantGearing.value)*0.01/(1-parseFloat(document.f1.ConstantGearing.value)*0.01)))*(parseFloat(FundsRaised)*(1-parseFloat(CommissionsonFundsRaised)*0.01));
	
	var ROItoParityYear = (Math.pow(((parseFloat(ComparableLandStartPrice)*(Math.pow((1+parseFloat(document.f1.ComparableLandPriceIncrease.value)*0.01),parseFloat(document.f1.YearsforSaskParitytoComparableLandtype.value))))/parseFloat(SaskStartPrice)),1/parseFloat(document.f1.YearsforSaskParitytoComparableLandtype.value))-1)*100;

	//--1--////////////////////////////
	// table 1 
	//Debt financing in year @ constant gearing
	var Debt1 = (((parseFloat(FundsRaised)*(1-parseFloat(CommissionsonFundsRaised)*0.01))/(1-parseFloat(document.f1.ConstantGearing.value)*0.01)))-(parseFloat(FundsRaised)*(1-parseFloat(CommissionsonFundsRaised)*0.01));
	
	//table 3
	//Amortisation Period
	var Amortisation1 = 25;	
	
	
	//Cumulative Geared Funds Net of Commissions
	var Cumulative1 = GearedFundsNetofCommissions;

	//Income
	var Income1 = Cumulative1 * parseFloat(document.f1.RentalIncomepa.value)*0.01;
	
	
	//table 3
	//Mortgage Payment Table
	var Mortgage11 = PMT(parseFloat(document.f1.Interestpa.value)*0.01,parseFloat(Amortisation1),parseFloat(Debt1));	
	var Mortgage12 =Mortgage11 ;
	var Mortgage13 =Mortgage11 ;
	var Mortgage14 =Mortgage11 ;
	var Mortgage15 =Mortgage11 ;
	var Mortgage16 =Mortgage11 ;
	var Mortgage17 =Mortgage11 ;
	
	//table 1
	//Mortgage Payment(wait)
	var Mortgage1 = Mortgage11;
	
	//Management Fee
	var Management1 =  -1*parseFloat(FundsRaised)*parseFloat(ManagementFeeonNAV)*0.01;
	
	//Opex
	var Opex1 = -1*Income1*parseFloat(Opex)*0.01;
	
	//Acquisition Fee
	var Acquisition1 = -1*GearedFundsNetofCommissions*parseFloat(AcquisitionFee)*0.01;
	
	//Property Taxes
	var Property1 = -1* parseFloat(PropertyTaxes)*0.01 * GearedFundsNetofCommissions;
	
	//DSCR
	//DSCR1 = parseFloat(Income1+Management1+Opex1+Property1)/(-1*Mortgage1);
	var DSCR1 = (parseInt(Income1)+parseInt(Management1)+parseInt(Opex1)+parseInt(Property1))/(-1*parseInt(Mortgage1));
	
	//Carry payment if exit year
	var Carry1 = '';
	
	//table 2
	sum1=parseFloat(Income1)+parseFloat(Mortgage1)+parseFloat(Management1)+parseFloat(Opex1)+parseFloat(Acquisition1)+parseFloat(Property1);
	var LPs11 = parseFloat(FundsRaised)*-1 +sum1;
	var LPs21 = LPs11;
	var LPs31 = LPs11;
	var Cash1;
	if (sum1<0)
		Cash1 = 0;
	else
		Cash1 = (sum1/parseFloat(FundsRaised))*100 ;
	
	//table 1
	var NAV1 = (parseFloat(GearedFundsNetofCommissions) + sum1) *(1 + parseFloat(ROItoParityYear)*0.01);

	//--2--////////////////////////////
	var Debt2 = (parseFloat(NAV1)*parseFloat(document.f1.ConstantGearing.value)*0.01)-parseFloat(Debt1);
	var Cumulative2 = parseFloat(Debt2)+parseFloat(Cumulative1);
	var Income2 = parseFloat(document.f1.RentalIncomepa.value)*0.01*parseFloat(NAV1);
	
	var Mortgage21 = '';
	var Mortgage22 = PMT(parseFloat(document.f1.Interestpa.value)*0.01,parseFloat(Amortisation1),parseFloat(Debt2));
	var Mortgage23 = Mortgage22;
	var Mortgage24 = Mortgage22;
	var Mortgage25 = Mortgage22;
	var Mortgage26 = Mortgage22;
	var Mortgage27 = Mortgage22;
	var Mortgage2 = parseFloat(Mortgage12) + parseFloat(Mortgage22);
	
	var Management2 = ((-1) * parseFloat(ManagementFeeonNAV)*0.01) * (parseFloat(NAV1)-parseFloat(Debt1));	
	var Opex2 = (-1) *parseFloat(Income2) * parseFloat(Opex)*0.01;
	var Acquisition2 = 0 ;// null value
	var Property2 = (-1) * parseFloat(NAV1) * parseFloat(PropertyTaxes)*0.01;
	var DSCR2 = (parseInt(Income2) + parseInt(Management2) + parseInt(Opex2) + parseInt(Property2))/((-1) *parseInt(Mortgage2));
	var Carry2 = '';
	sum2=parseFloat(Income2)+parseFloat(Mortgage2)+parseFloat(Management2)+parseFloat(Opex2)+parseFloat(Acquisition2)+parseFloat(Property2);
	var LPs12 = sum2;
	var LPs22 = LPs12;
	var LPs32 = LPs12;
	var Cash2;
	if (sum2<0)
		Cash2 = 0;
	else
		Cash2 = (sum2/parseFloat(FundsRaised))*100 ;
	curNum = 2;
	var NAV2;
	if (curNum <= parseFloat(document.f1.YearsforSaskParitytoComparableLandtype.value))
		if (sum2<0)
			NAV2 = (parseFloat(NAV1)+parseFloat(Debt2)+sum2)*(1+parseFloat(ROItoParityYear)*0.01);
		else
			NAV2 = (parseFloat(NAV1) + parseFloat(Debt2))*(1+parseFloat(ROItoParityYear)*0.01);
	else
		NAV2 = (1+parseFloat(Sasklandinflationafterparity)*0.01)*parseFloat(NAV1);


	//--3--////////////////////////////
	var Debt3 = (parseFloat(NAV2)*parseFloat(document.f1.ConstantGearing.value)*0.01)-parseFloat(Debt1)-parseFloat(Debt2);
	var Cumulative3 = parseFloat(Debt3)+parseFloat(Cumulative2);
	var Income3 = parseFloat(document.f1.RentalIncomepa.value)*0.01*parseFloat(NAV2);
	
	var Mortgage31 = '';
	var Mortgage32 = '';	
	var Mortgage33 = PMT(parseFloat(document.f1.Interestpa.value)*0.01,parseFloat(Amortisation1),parseFloat(Debt3));	
	var Mortgage34 = Mortgage33;
	var Mortgage35 = Mortgage33;
	var Mortgage36 = Mortgage33;
	var Mortgage37 = Mortgage33;
	var Mortgage3 = parseFloat(Mortgage13) + parseFloat(Mortgage23) + parseFloat(Mortgage33);
	
	var Management3 = ((-1) * parseFloat(ManagementFeeonNAV)*0.01) * (parseFloat(NAV2)-parseFloat(Debt1)-parseFloat(Debt2));
	var Opex3 = (-1) *parseFloat(Income3) * parseFloat(Opex)*0.01;
	var Acquisition3 = 0 ;// null value
	var Property3 = (-1) * parseFloat(NAV2) * parseFloat(PropertyTaxes)*0.01;
	var DSCR3 = (parseFloat(Income3) + parseFloat(Management3) + parseFloat(Opex3) + parseFloat(Property3))/((-1) *parseFloat(Mortgage3));
	var Carry3 = '';
	
	sum3=parseFloat(Income3)+parseFloat(Mortgage3)+parseFloat(Management3)+parseFloat(Opex3)+parseFloat(Acquisition3)+parseFloat(Property3);
	var LPs13 = sum3;
	var LPs23 = LPs13;
	var LPs33 = LPs13;
	var Cash3;
	if (sum3<0)
		Cash3 = 0;
	else
		Cash3 = (sum3/parseFloat(FundsRaised))*100 ;
	curNum = 3;
	var NAV3;
	if (curNum <= parseFloat(document.f1.YearsforSaskParitytoComparableLandtype.value))
		if (sum3<0)
			NAV3 = (parseFloat(NAV2)+parseFloat(Debt3)+sum3)*(1+parseFloat(ROItoParityYear)*0.01);
		else
			NAV3 = (parseFloat(NAV2) + parseFloat(Debt3))*(1+parseFloat(ROItoParityYear)*0.01);
	else
		NAV3 = (1+parseFloat(Sasklandinflationafterparity)*0.01)*parseFloat(NAV2);
	
	//--4--////////////////////////////
	var Debt4 = (parseFloat(NAV3)*parseFloat(document.f1.ConstantGearing.value)*0.01)-parseFloat(Debt1)-parseFloat(Debt2)-parseFloat(Debt3);
	var Cumulative4 = parseFloat(Debt4)+parseFloat(Cumulative3);
	var Income4 = parseFloat(document.f1.RentalIncomepa.value)*0.01*parseFloat(NAV3);
	
	var Mortgage41 = '';
	var Mortgage42 = '';
	var Mortgage43 = '';	
	var Mortgage44 = PMT(parseFloat(document.f1.Interestpa.value)*0.01,parseFloat(Amortisation1),parseFloat(Debt4));	
	var Mortgage45 = Mortgage44;
	var Mortgage46 = Mortgage44;
	var Mortgage47 = Mortgage44;
	var Mortgage4 = parseFloat(Mortgage14) + parseFloat(Mortgage24) + parseFloat(Mortgage34)+ parseFloat(Mortgage44);
	
	var Management4 = ((-1) * parseFloat(ManagementFeeonNAV)*0.01) * (parseFloat(NAV3)-parseFloat(Debt1)-parseFloat(Debt2)-parseFloat(Debt3));
	var Opex4 = (-1) *parseFloat(Income4) * parseFloat(Opex)*0.01;
	var Acquisition4 = 0 ;// null value
	var Property4 = (-1) * parseFloat(NAV3) * parseFloat(PropertyTaxes)*0.01;
	var DSCR4 = (parseFloat(Income4) + parseFloat(Management4) + parseFloat(Opex4) + parseFloat(Property4))/((-1) *parseFloat(Mortgage4));
	var Carry4 = '';
	
	sum4=parseFloat(Income4)+parseFloat(Mortgage4)+parseFloat(Management4)+parseFloat(Opex4)+parseFloat(Acquisition4)+parseFloat(Property4);
	var LPs14 = sum4;
	var LPs24 = LPs14;
	var LPs34 = LPs14;
	var Cash4;
	if (sum4<0)
		Cash4 = 0;
	else
		Cash4 = (sum4/parseFloat(FundsRaised))*100 ;
	curNum = 4;
	var NAV4;
	if (curNum <= parseFloat(document.f1.YearsforSaskParitytoComparableLandtype.value))
		if (sum4<0)
			NAV4 = (parseFloat(NAV3)+parseFloat(Debt4)+sum4)*(1+parseFloat(ROItoParityYear)*0.01);
		else
			NAV4 = (parseFloat(NAV3) + parseFloat(Debt4))*(1+parseFloat(ROItoParityYear)*0.01);
	else
		NAV4 = (1+parseFloat(Sasklandinflationafterparity)*0.01)*parseFloat(NAV3);
	
	//--5--////////////////////////////
	var Debt5 = (parseFloat(NAV4)*parseFloat(document.f1.ConstantGearing.value)*0.01)-parseFloat(Debt1)-parseFloat(Debt2)-parseFloat(Debt3)-parseFloat(Debt4);
	var Cumulative5 = parseFloat(Debt5)+parseFloat(Cumulative4);
	var Income5 = parseFloat(document.f1.RentalIncomepa.value)*0.01*parseFloat(NAV4);
	
	var Mortgage51 = '';
	var Mortgage52 = '';
	var Mortgage53 = '';	
	var Mortgage54 = '';
	var Mortgage55 = PMT(parseFloat(document.f1.Interestpa.value)*0.01,parseFloat(Amortisation1),parseFloat(Debt5));	
	var Mortgage56 = Mortgage55;
	var Mortgage57 = Mortgage55;
	var Mortgage5 = parseFloat(Mortgage15) + parseFloat(Mortgage25) + parseFloat(Mortgage35)+ parseFloat(Mortgage45)+ parseFloat(Mortgage55);
	
	var Management5 = ((-1) * parseFloat(ManagementFeeonNAV)*0.01) * (parseFloat(NAV4)-parseFloat(Debt1)-parseFloat(Debt2)-parseFloat(Debt3)-parseFloat(Debt4));
	var Opex5 = (-1) *parseFloat(Income5) * parseFloat(Opex)*0.01;
	var Acquisition5 = 0 ;// null value
	var Property5 = (-1) * parseFloat(NAV4) * parseFloat(PropertyTaxes)*0.01;
	var DSCR5 = (parseFloat(Income5) + parseFloat(Management5) + parseFloat(Opex5) + parseFloat(Property5))/((-1) *parseFloat(Mortgage5));
	
	sum5=parseFloat(Income5)+parseFloat(Mortgage5)+parseFloat(Management5)+parseFloat(Opex5)+parseFloat(Acquisition5)+parseFloat(Property5);
	var LPs25 = sum5;
	var LPs35 = LPs25;
	var Cash5;
	if (sum5<0)
		Cash5 = 0;
	else
		Cash5 = (sum5/parseFloat(FundsRaised))*100 ;
	curNum = 5;
	var NAV5;
	if (curNum <= parseFloat(document.f1.YearsforSaskParitytoComparableLandtype.value))
		if (sum5<0)
			NAV5 = (parseFloat(NAV4)+parseFloat(Debt5)+sum5)*(1+parseFloat(ROItoParityYear)*0.01);
		else
			NAV5 = (parseFloat(NAV4) + parseFloat(Debt5))*(1+parseFloat(ROItoParityYear)*0.01);
	else
		NAV5 = (1+parseFloat(Sasklandinflationafterparity)*0.01)*parseFloat(NAV4);
	
	var Carry5 = (parseFloat(NAV5) - (parseFloat(Cumulative5)+parseFloat(CommissionsonFundsRaised)*0.01*parseFloat(FundsRaised)))*parseFloat(Carry)*0.01;
	
	var LPs15 = (parseFloat(FundsRaised) + ( parseFloat(NAV5) - parseFloat(Cumulative5) - parseFloat(FundsRaised)*CommissionsonFundsRaised*0.01 - parseFloat(Carry5) )); 

	//--6--////////////////////////////
	var Debt6 = (parseFloat(NAV5)*parseFloat(document.f1.ConstantGearing.value)*0.01)-parseFloat(Debt1)-parseFloat(Debt2)-parseFloat(Debt3)-parseFloat(Debt4)-parseFloat(Debt5);
	var Cumulative6 = parseFloat(Debt6)+parseFloat(Cumulative5);
	var Income6 = parseFloat(document.f1.RentalIncomepa.value)*0.01*parseFloat(NAV5);
	
	var Mortgage61 = '';
	var Mortgage62 = '';
	var Mortgage63 = '';	
	var Mortgage64 = '';
	var Mortgage65 = '';
	var Mortgage66 = PMT(parseFloat(document.f1.Interestpa.value)*0.01,parseFloat(Amortisation1),parseFloat(Debt6));	
	var Mortgage67 = Mortgage66;
	var Mortgage6 = parseFloat(Mortgage16) + parseFloat(Mortgage26) + parseFloat(Mortgage36)+ parseFloat(Mortgage46)+ parseFloat(Mortgage56)+ parseFloat(Mortgage66);
	
	var Management6 = ((-1) * parseFloat(ManagementFeeonNAV)*0.01) * (parseFloat(NAV5)-parseFloat(Debt1)-parseFloat(Debt2)-parseFloat(Debt3)-parseFloat(Debt4)-parseFloat(Debt5));
	var Opex6 = (-1) *parseFloat(Income6) * parseFloat(Opex)*0.01;
	var Acquisition6 = 0 ;// null value
	var Property6 = (-1) * parseFloat(NAV5) * parseFloat(PropertyTaxes)*0.01;
	var DSCR6 = (parseFloat(Income6) + parseFloat(Management6) + parseFloat(Opex6) + parseFloat(Property6))/((-1) *parseFloat(Mortgage6));

	sum6=parseFloat(Income6)+parseFloat(Mortgage6)+parseFloat(Management6)+parseFloat(Opex6)+parseFloat(Acquisition6)+parseFloat(Property6);
	var LPs36 = sum6;
	var Cash6;
	if (sum6<0)
		Cash6 = 0;
	else
		Cash6 = (sum6/parseFloat(FundsRaised))*100 ;
	curNum = 6;
	var NAV6;
	if (curNum <= parseFloat(document.f1.YearsforSaskParitytoComparableLandtype.value))
		if (sum6<0)
			NAV6 = (parseFloat(NAV5)+parseFloat(Debt6)+sum6)*(1+parseFloat(ROItoParityYear)*0.01);
		else
			NAV6 = (parseFloat(NAV5) + parseFloat(Debt6))*(1+parseFloat(ROItoParityYear)*0.01);
	else
		NAV6 = (1+parseFloat(Sasklandinflationafterparity)*0.01)*parseFloat(NAV5);
	
	var Carry6 = (parseFloat(NAV6) - (parseFloat(Cumulative6)+parseFloat(CommissionsonFundsRaised)*0.01*parseFloat(FundsRaised)))*parseFloat(Carry)*0.01;

	var LPs26 = (parseFloat(FundsRaised) + ( parseFloat(NAV6) - parseFloat(Cumulative6) - parseFloat(FundsRaised)*CommissionsonFundsRaised*0.01 - parseFloat(Carry6) )); 

	//--7--////////////////////////////
	var Debt7 = (parseFloat(NAV6)*parseFloat(document.f1.ConstantGearing.value)*0.01)-parseFloat(Debt1)-parseFloat(Debt2)-parseFloat(Debt3)-parseFloat(Debt4)-parseFloat(Debt5)-parseFloat(Debt6);
	var Cumulative7 = parseFloat(Debt7)+parseFloat(Cumulative6);
	var Income7 = parseFloat(document.f1.RentalIncomepa.value)*0.01*parseFloat(NAV6);
	
	var Mortgage71 = '';
	var Mortgage72 = '';
	var Mortgage73 = '';	
	var Mortgage74 = '';
	var Mortgage75 = '';
	var Mortgage76 = '';
	var Mortgage77 = PMT(parseFloat(document.f1.Interestpa.value)*0.01,parseFloat(Amortisation1),parseFloat(Debt7));	
	var Mortgage7 = parseFloat(Mortgage17) + parseFloat(Mortgage27) + parseFloat(Mortgage37)+ parseFloat(Mortgage47)+ parseFloat(Mortgage57)+ parseFloat(Mortgage67)+ parseFloat(Mortgage77);
	
	var Management7 = ((-1) * parseFloat(ManagementFeeonNAV)*0.01) * (parseFloat(NAV6)-parseFloat(Debt1)-parseFloat(Debt2)-parseFloat(Debt3)-parseFloat(Debt4)-parseFloat(Debt5)-parseFloat(Debt6));
	var Opex7 = (-1) *parseFloat(Income7) * parseFloat(Opex)*0.01;
	var Acquisition7 = 0 ;// null value
	var Property7 = (-1) * parseFloat(NAV6) * parseFloat(PropertyTaxes)*0.01;
	var DSCR7 = (parseFloat(Income7) + parseFloat(Management7) + parseFloat(Opex7) + parseFloat(Property7))/((-1) *parseFloat(Mortgage7));
	
	sum7=parseFloat(Income7)+parseFloat(Mortgage7)+parseFloat(Management7)+parseFloat(Opex7)+parseFloat(Acquisition7)+parseFloat(Property7);
	var Cash7;
	if (sum7<0)
		Cash7 = 0;
	else
		Cash7 = (sum7/parseFloat(FundsRaised))*100 ;
	curNum = 7;
	var NAV7;
	if (curNum <= parseFloat(document.f1.YearsforSaskParitytoComparableLandtype.value))
		if (sum7<0)
			NAV7 = (parseFloat(NAV6)+parseFloat(Debt7)+sum7)*(1+parseFloat(ROItoParityYear)*0.01);
		else
			NAV7 = (parseFloat(NAV6) + parseFloat(Debt7))*(1+parseFloat(ROItoParityYear)*0.01);
	else
		NAV7 = (1+parseFloat(Sasklandinflationafterparity)*0.01)*parseFloat(NAV6);

	var Carry7 = (parseFloat(NAV7) - (parseFloat(Cumulative7)+parseFloat(CommissionsonFundsRaised)*0.01*parseFloat(FundsRaised)))*parseFloat(Carry)*0.01;
	
	var LPs37 = (parseFloat(FundsRaised) + ( parseFloat(NAV7) - parseFloat(Cumulative7) - parseFloat(FundsRaised)*CommissionsonFundsRaised*0.01 - parseFloat(Carry7) )); 

	//
	curStr = LPs11 + ";" + LPs12 + ";" + LPs13 + ";" + LPs14 + ";" + LPs15 + "%" + '1' ;
	x_process(curStr,process);
	curStr = LPs21 + ";" + LPs22 + ";" + LPs23 + ";" + LPs24 + ";" + LPs25 + ";" + LPs26 + "%" + '2' ;
	x_process(curStr,process);
	curStr = LPs31 + ";" + LPs32 + ";" + LPs33 + ";" + LPs34 + ";" + LPs35 + ";" + LPs36 + ";" + LPs37 + "%" + '3' ;
	x_process(curStr,process);	
	
	/*
	//table 4
	curyears = parseFloat(document.f1.YearsforSaskParitytoComparableLandtype.value);
	/////document.f1.years.value = document.f1.YearsforSaskParitytoComparableLandtype.value + ' years';	
	curstartprice = parseFloat(ComparableLandStartPrice);
	/////document.f1.startprice.value = "$" + ComparableLandStartPrice ;	

	
	for(i=0;i<=20;i++)
	{
		//eval("tmpstartprice=document.f1."+'startprice'+(i+1));
		//eval("tmpendprice=document.f1."+'endprice'+(i+1));
		var tmpendprice = roundNumber(parseFloat(startPrice[i]) * Math.pow((1+parseFloat(document.f1.ComparableLandPriceIncrease.value)*0.01),parseFloat(document.f1.YearsforSaskParitytoComparableLandtype.value)),0);
		/////tmpendprice.value = roundNumber(parseFloat(tmpstartprice.value) * Math.pow((1+parseFloat(document.f1.ComparableLandPriceIncrease.value)*0.01),parseFloat(document.f1.YearsforSaskParitytoComparableLandtype.value)),0);
		if (parseFloat(startPrice[i]) == curstartprice)
			;/////document.f1.endprice.value = roundNumber(tmpendprice,0);
	}	
	*/
	
	/*
		//assign value /////hidden
	/////document.f1.GearedFundsNetofCommissions.value = roundNumber(GearedFundsNetofCommissions,0);
	/////document.f1.ROItoParityYear.value = roundNumber(ROItoParityYear,0);
	document.f1.Debt1.value = roundNumber(Debt1,0);
	/////document.f1.Amortisation1.value = Amortisation1 + " years";
	document.f1.Cumulative1.value = roundNumber(Cumulative1,0);
	document.f1.Income1.value = roundNumber(Income1,0);
	document.f1.Mortgage11.value =roundNumber(Mortgage11,2);
	document.f1.Mortgage12.value =roundNumber(Mortgage12,2);
	document.f1.Mortgage13.value =roundNumber(Mortgage13,2);
	document.f1.Mortgage14.value =roundNumber(Mortgage14,2);
	document.f1.Mortgage15.value =roundNumber(Mortgage15,2);
	document.f1.Mortgage16.value =roundNumber(Mortgage16,2);
	document.f1.Mortgage17.value =roundNumber(Mortgage17,2);
	document.f1.Mortgage1.value =roundNumber(Mortgage1,0);
	document.f1.Management1.value = roundNumber(Management1,0);
	document.f1.Opex1.value = roundNumber(Opex1,0);
	document.f1.Acquisition1.value = roundNumber(Acquisition1,0);
	document.f1.Property1.value = roundNumber(Property1,0);
	document.f1.DSCR1.value = roundNumber(DSCR1,2);
	document.f1.Carry1.value = Carry1;
	/////document.f1.LPs11.value = roundNumber(LPs11,0);
	/////document.f1.LPs21.value = roundNumber(LPs21,0);
	/////document.f1.LPs31.value = roundNumber(LPs31,0);
	document.f1.Cash1.value = roundNumber(Cash1,1)+ '%';
	/////document.f1.NAV1.value = roundNumber(NAV1,0);
	
	document.f1.Debt2.value = roundNumber(Debt2,0);
	document.f1.Cumulative2.value = roundNumber(Cumulative2,0);
	document.f1.Income2.value = roundNumber(Income2,0);
	document.f1.Mortgage21.value =Mortgage21;
	document.f1.Mortgage22.value =roundNumber(Mortgage22,2);
	document.f1.Mortgage23.value =roundNumber(Mortgage23,2);
	document.f1.Mortgage24.value =roundNumber(Mortgage24,2);
	document.f1.Mortgage25.value =roundNumber(Mortgage25,2);
	document.f1.Mortgage26.value =roundNumber(Mortgage26,2);
	document.f1.Mortgage27.value =roundNumber(Mortgage27,2);
	document.f1.Mortgage2.value =roundNumber(Mortgage2,0);
	document.f1.Management2.value = roundNumber(Management2,0);
	document.f1.Opex2.value = roundNumber(Opex2,0);
	document.f1.Acquisition2.value = roundNumber(Acquisition2,0);
	document.f1.Property2.value = roundNumber(Property2,0);
	document.f1.DSCR2.value = roundNumber(DSCR2,2);
	document.f1.Carry2.value = Carry2;
	/////document.f1.LPs12.value = roundNumber(LPs12,0);
	/////document.f1.LPs22.value = roundNumber(LPs22,0);
	/////document.f1.LPs32.value = roundNumber(LPs32,0);
	document.f1.Cash2.value = roundNumber(Cash2,1)+ '%';
	/////document.f1.NAV2.value = roundNumber(NAV2,0);
	
	document.f1.Debt3.value = roundNumber(Debt3,0);
	document.f1.Cumulative3.value = roundNumber(Cumulative3,0);
	document.f1.Income3.value = roundNumber(Income3,0);
	document.f1.Mortgage31.value =Mortgage31;
	document.f1.Mortgage32.value =Mortgage32;
	document.f1.Mortgage33.value =roundNumber(Mortgage33,2);
	document.f1.Mortgage34.value =roundNumber(Mortgage34,2);
	document.f1.Mortgage35.value =roundNumber(Mortgage35,2);
	document.f1.Mortgage36.value =roundNumber(Mortgage36,2);
	document.f1.Mortgage37.value =roundNumber(Mortgage37,2);
	document.f1.Mortgage3.value =roundNumber(Mortgage3,0);
	document.f1.Management3.value = roundNumber(Management3,0);
	document.f1.Opex3.value = roundNumber(Opex3,0);
	document.f1.Acquisition3.value = roundNumber(Acquisition3,0);
	document.f1.Property3.value = roundNumber(Property3,0);
	document.f1.DSCR3.value = roundNumber(DSCR3,2);
	document.f1.Carry3.value = Carry3;
	/////document.f1.LPs13.value = roundNumber(LPs13,0);
	/////document.f1.LPs23.value = roundNumber(LPs23,0);
	/////document.f1.LPs33.value = roundNumber(LPs33,0);
	document.f1.Cash3.value = roundNumber(Cash3,1)+ '%';
	/////document.f1.NAV3.value = roundNumber(NAV3,0);
	
	document.f1.Debt4.value = roundNumber(Debt4,0);
	document.f1.Cumulative4.value = roundNumber(Cumulative4,0);
	document.f1.Income4.value = roundNumber(Income4,0);
	document.f1.Mortgage41.value =Mortgage41 ;
	document.f1.Mortgage42.value =Mortgage42 ;
	document.f1.Mortgage43.value =Mortgage43 ;
	document.f1.Mortgage44.value =roundNumber(Mortgage44,2);
	document.f1.Mortgage45.value =roundNumber(Mortgage45,2);
	document.f1.Mortgage46.value =roundNumber(Mortgage46,2);
	document.f1.Mortgage47.value =roundNumber(Mortgage47,2);
	document.f1.Mortgage4.value =roundNumber(Mortgage4,0);
	document.f1.Management4.value = roundNumber(Management4,0);
	document.f1.Opex4.value = roundNumber(Opex4,0);
	document.f1.Acquisition4.value = roundNumber(Acquisition4,0);
	document.f1.Property4.value = roundNumber(Property4,0);
	document.f1.DSCR4.value = roundNumber(DSCR4,2);
	document.f1.Carry4.value = Carry4;
	/////document.f1.LPs14.value = roundNumber(LPs14,0);
	/////document.f1.LPs24.value = roundNumber(LPs24,0);
	/////document.f1.LPs34.value = roundNumber(LPs34,0);
	document.f1.Cash4.value = roundNumber(Cash4,1)+ '%';
	/////document.f1.NAV4.value = roundNumber(NAV4,0);
	
	document.f1.Debt5.value = roundNumber(Debt5,0);
	document.f1.Cumulative5.value = roundNumber(Cumulative5,0);
	document.f1.Income5.value = roundNumber(Income5,0);
	document.f1.Mortgage51.value =Mortgage51 ;
	document.f1.Mortgage52.value =Mortgage52 ;
	document.f1.Mortgage53.value =Mortgage53 ;
	document.f1.Mortgage54.value =Mortgage54 ;
	document.f1.Mortgage55.value =roundNumber(Mortgage55,2);
	document.f1.Mortgage56.value =roundNumber(Mortgage56,2);
	document.f1.Mortgage57.value =roundNumber(Mortgage57,2);
	document.f1.Mortgage5.value =roundNumber(Mortgage5,0);
	document.f1.Management5.value = roundNumber(Management5,0);
	document.f1.Opex5.value = roundNumber(Opex5,0);
	document.f1.Acquisition5.value = roundNumber(Acquisition5,0);
	document.f1.Property5.value = roundNumber(Property5,0);
	document.f1.DSCR5.value = roundNumber(DSCR5,2);
	document.f1.Carry5.value = roundNumber(Carry5,0);
	/////document.f1.LPs15.value = roundNumber(LPs15,0);
	/////document.f1.LPs25.value = roundNumber(LPs25,0);
	/////document.f1.LPs35.value = roundNumber(LPs35,0);
	document.f1.Cash5.value = roundNumber(Cash5,1)+ '%';
	/////document.f1.NAV5.value = roundNumber(NAV5,0);
	
	document.f1.Debt6.value = roundNumber(Debt6,0);
	document.f1.Cumulative6.value = roundNumber(Cumulative6,0);
	document.f1.Income6.value = roundNumber(Income6,0);
	document.f1.Mortgage61.value =Mortgage61 ;
	document.f1.Mortgage62.value =Mortgage62 ;
	document.f1.Mortgage63.value =Mortgage63 ;
	document.f1.Mortgage64.value =Mortgage64 ;
	document.f1.Mortgage65.value =Mortgage65 ;
	document.f1.Mortgage66.value =roundNumber(Mortgage66,2);
	document.f1.Mortgage67.value =roundNumber(Mortgage67,2);
	document.f1.Mortgage6.value =roundNumber(Mortgage6,0);
	document.f1.Management6.value = roundNumber(Management6,0);
	document.f1.Opex6.value = roundNumber(Opex6,0);
	document.f1.Acquisition6.value = roundNumber(Acquisition6,0);
	document.f1.Property6.value = roundNumber(Property6,0);
	document.f1.DSCR6.value = roundNumber(DSCR6,2);
	document.f1.Carry6.value = roundNumber(Carry6,0);
	//document.f1.LPs16.value = roundNumber(LPs16,0);
	/////document.f1.LPs26.value = roundNumber(LPs26,0);
	/////document.f1.LPs36.value = roundNumber(LPs36,0);
	document.f1.Cash6.value = roundNumber(Cash6,1)+ '%';
	/////document.f1.NAV6.value = roundNumber(NAV6,0);
	
	document.f1.Debt7.value = roundNumber(Debt7,0);
	document.f1.Cumulative7.value = roundNumber(Cumulative7,0);
	document.f1.Income7.value = roundNumber(Income7,0);
	document.f1.Mortgage71.value =Mortgage71 ;
	document.f1.Mortgage72.value =Mortgage72 ;
	document.f1.Mortgage73.value =Mortgage73 ;
	document.f1.Mortgage74.value =Mortgage74 ;
	document.f1.Mortgage75.value =Mortgage75 ;
	document.f1.Mortgage76.value =Mortgage76 ;
	document.f1.Mortgage77.value =roundNumber(Mortgage77,2);
	document.f1.Mortgage7.value =roundNumber(Mortgage7,0);
	document.f1.Management7.value = roundNumber(Management7,0);
	document.f1.Opex7.value = roundNumber(Opex7,0);
	document.f1.Acquisition7.value = roundNumber(Acquisition7,0);
	document.f1.Property7.value = roundNumber(Property7,0);
	document.f1.DSCR7.value = roundNumber(DSCR7,2);
	document.f1.Carry7.value = roundNumber(Carry7,0);
	//document.f1.LPs17.value = roundNumber(LPs17,0);
	//document.f1.LPs27.value = roundNumber(LPs27,0);
	/////document.f1.LPs37.value = roundNumber(LPs37,0);
	document.f1.Cash7.value = roundNumber(Cash7,1)+ '%';
	/////document.f1.NAV7.value = roundNumber(NAV7,0);	
	*/
	
	document.getElementById("errormsg").innerHTML="";
	document.getElementById('errormsg').className = "";
	isC =true;
}

function process(value)
{
	var temp = new Array(); 
	temp =  value.split('%');
	curyears = parseFloat(document.f1.YearsforSaskParitytoComparableLandtype.value);	
	switch (parseInt(temp[1]))
	{
		case 1:
			/////document.f1.ROIPerAnnum1.value = roundNumber(parseFloat(temp[0]) * 100 ,0);
			var ROIPerAnnum1 = roundNumber(parseFloat(temp[0]) * 100 ,0);
			if (curyears==5)
			{
				/////document.f1.annualROI.value = roundNumber(ROIPerAnnum1,0);
				document.f1.Selllandinyear.value = curyears;
				document.f1.ROIPerAnnum.value = roundNumber(parseFloat(temp[0]) * 100 ,0);
			}
			break;
		case 2:
			/////document.f1.ROIPerAnnum2.value = roundNumber(parseFloat(temp[0]) * 100 ,0);
			var ROIPerAnnum2 = roundNumber(parseFloat(temp[0]) * 100 ,0);
			if (curyears==6)
			{
				/////document.f1.annualROI.value = roundNumber(ROIPerAnnum2,0);
				document.f1.Selllandinyear.value = curyears;
				document.f1.ROIPerAnnum.value = roundNumber(parseFloat(temp[0]) * 100 ,0);
			}
			break;
		case 3:
			/////document.f1.ROIPerAnnum3.value = roundNumber(parseFloat(temp[0]) * 100 ,0);
			var ROIPerAnnum3 = roundNumber(parseFloat(temp[0]) * 100 ,0);
			if (curyears==7)
			{
				/////document.f1.annualROI.value = roundNumber(ROIPerAnnum3,0);
				document.f1.Selllandinyear.value = curyears;
				document.f1.ROIPerAnnum.value = roundNumber(parseFloat(temp[0]) * 100 ,0);
			}
			break;
	}
}

function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

function check()
{
	if (! document.f1.disclaimer[0].checked )
	{	
		return false;
	}
	if (!isC)
	{
		alert("you need calculator first.");
		return false;
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function commaSplit(srcNumber,fieldName)  {
	txtNumber = srcNumber.toString().replace(/\$|\,/g,'');
	if (isNaN(txtNumber) || txtNumber == "") {
		//fieldName.focus();
		return srcNumber;
	}
	else {
		var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])');
		var arrNumber = txtNumber.split('.');
		arrNumber[0] += '.';
		do {
			arrNumber[0] = arrNumber[0].replace(rxSplit, '$1,$2');
		} 
		while (rxSplit.test(arrNumber[0]));
		if (arrNumber.length > 1) {
			return arrNumber.join('');
		}
		else {
			return arrNumber[0].split('.')[0];
		}
  }
}

function checkInputError(field,errorstr,needpositive){
	txtNumber = field.value.toString().replace(/\$|\,/g,'');
	if(! /^(\+|-)?(0|[1-9]\d*)(\.\d*[1-9])?$/.test(txtNumber)){
		errormsg += "\"" + errorstr + "\" does not appear to be a valid number.  <br />";		
		field.style.color="#ff0000";
		if (checkedResult)
			field.focus();
		return false;
	}
	if (needpositive && parseFloat(txtNumber) <= 0){
		errormsg += "\"" + errorstr + "\" must be greater then zero.  <br />";
		field.style.color="#ff0000";
		if (checkedResult)
			field.focus();
		return false;
	}
	field.style.color="#000000";
	return true;
}

/*
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}
*/