function isPosNumeric(b){if(b==""){return true}oneDecimal=false;inputStr=b.toString();for(var a=0;a<inputStr.length;a++){var c=inputStr.charAt(a);if(c=="."&&!oneDecimal){oneDecimal=true;continue}if(c<"0"||c>"9"){return false}}return true}function makeMoney(a){a=Math.round(a*100)/100;a=a+"";if(a!=""){isDec=a.indexOf(".");if(isDec<1){moneyFmt=a+".00"}else{isDec=a.length-isDec;if(isDec>3){moneyFmt=a}else{if(isDec==2){moneyFmt=a+"0"}else{if(isDec==1){moneyFmt=a+"00"}else{moneyFmt=a}}}}}else{moneyFmt=""}return moneyFmt}function clearAll(){document.greenpower.contribution.value="";document.greenpower.kWh.value="";document.greenpower.tons.value="";document.greenpower.autos.value="";document.greenpower.contribution.focus()}function clearMonth(){document.greenpower.contribution.value="";document.greenpower.kWh.value="";document.greenpower.tons.value="";document.greenpower.autos.value="";document.greenpower.contribution.focus()}function clearkWh(){document.greenpower.contribution.value="";document.greenpower.kWh.value="";document.greenpower.tons.value="";document.greenpower.autos.value="";document.greenpower.kWh.focus()}function calckWh(){contribution=document.greenpower.contribution.value;kWh=document.greenpower.kWh.value;var c=1;var b=105.222/c;var d=0.884/c;var a=0.152/c;if(kWh!=""){if(parseFloat(kWh)!=0){if(!isPosNumeric(kWh)){alert("Please type the kWh amount as a positive numeric number.");clearAll();return false}kWh=parseFloat(kWh);if(parseInt(kWh)!=kWh){kWh=makeMoney(kWh);document.greenpower.kWh.value=kWh}contribution=makeMoney((kWh/b)*1);tons=Math.round((contribution*d)*100)/100;autos=Math.round((contribution*a)*100)/100;document.greenpower.contribution.value=contribution;if(tons==1){document.greenpower.tons.value=tons+" ton"}else{document.greenpower.tons.value=tons+" tons"}document.greenpower.autos.value=autos}}else{clearkWh()}}function calcContribution(){contribution=document.greenpower.contribution.value;kWh=document.greenpower.kWh.value;var c=1;var b=105.222/c;var d=0.884/c;var a=0.152/c;if(contribution!=""){if(parseFloat(contribution)!=0){if(!isPosNumeric(contribution)){alert("Please type the Contribution Price ($) as a positive numeric number.");clearAll();return false}contribution=parseFloat(contribution);if(parseInt(contribution)!=contribution){contribution=makeMoney(contribution);document.greenpower.contribution.value=contribution}kWh=Math.round((contribution*b)*1)/1;tons=Math.round((contribution*d)*100)/100;autos=Math.round((contribution*a)*100)/100;document.greenpower.kWh.value=kWh;if(tons==1){document.greenpower.tons.value=tons+" ton"}else{document.greenpower.tons.value=tons+" tons"}document.greenpower.autos.value=autos}}else{clearMonth()}};
