var input_cash;
var input_value;
var input_loan;


function computevalue () {

	input_cash = parseInt(document.getElementById("cash_amt").value);
	input_value = parseInt(document.getElementById("value_amt").value);
	input_loan = parseInt(document.getElementById("loan_amt").value);

	var resultAmt;
	
	
	if(input_cash !="" ) {
	// && input_value !="" && input_loan !="" ) {
	
	resultAmt = (input_cash / 0.38) + (input_value *  0.7) - input_loan;
		
	resultAmt = Math.round(resultAmt/1000) * 1000;
		
	}
	if(isNaN(resultAmt)) {
		resultAmt=0;		
	}
	document.getElementById("comp_value").innerHTML = FComma(resultAmt);	
	
	if(resultAmt > 0 && resultAmt < 500000){
		document.getElementById("conclude").innerHTML = "However, there is so much competition for Commercial Property under $500,000 that you rarely get value for money. It is possible to buy small strata Offices or Factoriettes; but you will generally have a fairly high turnover rate with your tenants. <br /><br /> Therefore, you may be better advised to join a Private Syndicate - and own part of a better quality of property, in the $3 to $5 million price range.";
	} else if (resultAmt > 500001 && resultAmt < 1000000) {
		document.getElementById("conclude").innerHTML = "However, demand is very strong for Commercial Properties in the $500,000 to $1 million price range. With some research, and using good Tools for your analysis, you could probably acquire something worthwhile. <br /><br /> Alternatively, you may consider dividing your available equity between a couple of Property Syndicates - and thereby, own part of several quality properties, in the $3 to $5 million price range.";
	} else if (resultAmt > 1000001 && resultAmt < 2000000) {
		document.getElementById("conclude").innerHTML = "And you'll find that your selection of good properties widens, once you enter the $1 to $2 million price range. Your choice could include a strata Office; a modern Warehouse; or perhaps a good suburban Shop. <br /><br />You will need to do your homework; and make sure you have the right Tools for property analysis.";
	} else if (resultAmt > 2000001 && resultAmt < 5000000) {
		document.getElementById("conclude").innerHTML = "And once you enter the $2 to $5 million price bracket, you start to see some good investment opportunities emerge - with solid tenants, on longer leases. <br /><br /> However, you will need to undertake some thorough financial analysis and proper due diligence - to ensure you're buying a property that improves in value.";
	} else if (resultAmt > 5000001 && resultAmt < 10000000) {
		document.getElementById("conclude").innerHTML = "And being able to buy in the $5 to $10 million price bracket ... means you can secure some quality properties, offering you better returns - plus, good growth prospects. <br /><br /> However, you will need to do your homework, with respect to: Analysis, Due Diligence and locking in your Finance.";
	} else if (resultAmt > 10000001) { 
		document.getElementById("conclude").innerHTML = "And clearly, you're in the league of the \"Serious Investor\" - once you're able to buy in the $10 million+ bracket. <br /><br /> However, to be truly successful, you do need to ensure you have a foolproof System to ... Analyse, Verify and Finance whatever you purchase. And that may end up being several properties in the $3 to $5 million price bracket.";
	} else {
		document.getElementById("conclude").innerHTML = "Insufficient details provided.";
	}
	
	
}



function FComma(SS) {
    var T = "", S = String(SS), L = S.length - 1, C, j, P = S.indexOf(".") - 1;
    if (P < 0) {
        P = L;
    }
    for (j = 0; j <= L; j++) {
        T += C = S.charAt(j);
        if (j < P && (P - j) % 3 == 0 && (C != "-")) {
            T += ", ";
        }
    }
    return T;
}


function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		
		alert(helperMsg);
		elem.value="0";
		elem.focus();
		return false;
	}
}
