
/* - eva.js - */
// http://www.enviroaccounts.com.au/portal_javascripts/eva.js?original=1
function formatcurrency(amount){var i=parseFloat(amount);if(isNaN(i)){i=0.00}
var minus='';if(i<0){minus='-'}
i=Math.abs(i);i=parseInt((i+.005) * 100);i=i/100;s=new String(i);if(s.indexOf('.')<0){s+='.00'}
if(s.indexOf('.')==(s.length-2)){s+='0'}
s=minus+s;return s}
function formatcomma(amount){var delimiter=",";var a=amount.split('.',2)
var d=a[1];var i=parseInt(a[0]);if(isNaN(i)){return ''}
var minus='';if(i<0){minus='-'}
i=Math.abs(i);var n=new String(i);var a=[];while(n.length>3){var nn=n.substr(n.length-3);a.unshift(nn);n=n.substr(0,n.length-3)}
if(n.length>0){a.unshift(n)}
n=a.join(delimiter);if(d.length<1){amount=n}
else{amount=n+'.'+d}
amount=minus+amount;return amount}
var evap=[[3.2267,8.47,14,20,23,26,28,28,28,28]];var cp=20;var setup=3000;var c=0.2;
function isNumeric(elem){var numericExpression=/^[0-9]+$/;if(elem.value.match(numericExpression)){return true}else{elem.value=elem.value.substring(0,elem.value.length-1);return false}}
function updateAcres(){hectares=document.getElementById("hectares");acres=document.getElementById("acres");if(!isNumeric(hectares)){returnvalue=false;return false}
acres.value=formatcurrency(hectarestoacres(hectares.value));calcLandCam();totals()}
function updateHectares(){acres=document.getElementById("acres");if(!isNumeric(acres)){returnvalue=false;return false}
hectares=document.getElementById("hectares");hectares.value=formatcurrency(acrestohectares(acres.value));calcLandCam();totals()}
function acrestohectares(amount){var conv=0.40468564;return amount*conv}
function hectarestoacres(amount){var conv=0.40468564;return amount/conv}
function setupLandCam(){if(!updateHectares()){calcLandCam();totals()}}
function calcLandCam(){var totalcost=document.getElementById("totalcost");var hectares=document.getElementById("hectares");totalcost.innerHTML="$"+formatcomma(formatcurrency(parseFloat(hectares.value)*1032))}
function totals(){var h=parseFloat(document.getElementById("hectares").value);for(var i=0;i<10;++i){var g=evap[0][i]*cp*h;var s=setup+(g*c);document.getElementById("evag"+(i+1)).innerHTML='$'+formatcomma(formatcurrency(g));document.getElementById("evas"+(i+1)).innerHTML='$'+formatcomma(formatcurrency(s));document.getElementById("evan"+(i+1)).innerHTML='$'+formatcomma(formatcurrency(g-s))}}


