
// http://www.sonofsofaman.com/hobbies/code/js/formatcurrency.asp
// Joel T. Anderson

function formatCurrency(strValue)
{
	strValue = strValue.toString().replace(/\$|\,/g,'');
	dblValue = parseFloat(strValue);

	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
		dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
		dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
}

function calcresidential(Atext, form)
{
var K = parseFloat(Atext);

if (K <= 500)
{
var x = K * 0.10199 + 12.07;
}
else
{
var x =  ((K - 500) * 0.10199) + (500 * 0.10876) + 12.07;
}

form.Answer.value = formatCurrency(x);
}

function calcallelectric(Atext, form)
{
var K = parseFloat(Atext);

if (K <= 500)
{
var x = K * 0.10199 + 12.07;
}
else
{
var x = ((K - 500) * 0.09992) + (500 * 0.10199) + 12.07;
}
form.Answer.value = formatCurrency(x);
}

function ClearForm(form)
{
form.input_A.value = "";
form.Answer.value = "";
}

function winload() {
var winload = window.open('../math/calculator.html','','scrollbars=no,menubar=no,height=600,width=500,resizable=yes,toolbar=no,location=no,status=no');
}




