/* ======================================================================
DESC: Waste Control Systems' Savings Calculator JavaScript

PLATFORMS: IE3 through IEx

USAGE NOTES: Calculates savings with an Paint-Can Crusher
====================================================================== */
function cli()
	{
	checkForm();
	totalOne.innerHTML      = '$' + roundOff(tOne(), 2);
	totalTwo.innerHTML      = Math.round(tTwo());
	totalThree.innerHTML    = tThree();
	totalFour.innerHTML     = '$' + roundOff(tFour(), 2); 
	totalFive.innerHTML     = '$' + roundOff(tFive(), 2); 
	totalSix.innerHTML      = Math.round(tSix()); 
	totalSeven.innerHTML    = '$' + roundOff(tSeven(), 2);
	totalEight.innerHTML    = Math.round(tEight());
	totalNine.innerHTML     = tNine();
	totalTen.innerHTML      = '$' + roundOff(tTen(), 2);
	totalEleven.innerHTML   = '$' + roundOff(tEleven(), 2);
	totalTwelve.innerHTML   = Math.round(tTwelve()); 
	totalThirteen.innerHTML = '$' + roundOff(tThirteen(), 2);
   }
function tOne() {
	a = document.paintsave.hourPay.value*document.paintsave.benefit.value*1+document.paintsave.hourPay.value*1
	return a
	}


function tTwo() {
	b = 8000/document.paintsave.operation.value
	return b
}

function tThree() {
	c = 4
	return c
}

function tFour() {
	d = tTwo()*tOne()
	return d
}

function tFive() {
	e = tThree()*tOne()
	return e
}

function tSix() {
	f = tTwo()*1-tThree()*1
	return f
}

function tSeven() {
	g = tFour()*1-tFive()*1
	return g
}

function tEight() {
	h = 80000/document.paintsave.operation.value
	return h
}

function tNine() {
	i = 40
	return i
}

function tTen() {
	j = tEight()*tOne()
	return j
}

function tEleven() {
	k = tNine()*tOne()
	return k
}

function tTwelve() {
	l = tEight()*1-tNine()*1
	return l
}

function tThirteen() {
	m = tTen()*1-tEleven()*1
	return m
}

function checkForm() {
	if ( document.paintsave.operation.value == "default" ) {
		alert ("You have not specified a type of operation");
		document.paintsave.operation.focus();
		}
	if ( document.paintsave.benefit.value == "default" ) {
   	alert ("You have not specified a benefit value");
   	document.paintsave.benefit.focus();
		}
}

function roundOff(value, precision){
        value = "" + value //convert value to string
        precision = parseInt(precision);
        var whole = "" + Math.round(value * Math.pow(10, precision));
        var decPoint = whole.length - precision;        if(decPoint != 0)
        {                result = whole.substring(0, decPoint);
                result += ".";
                result += whole.substring(decPoint, whole.length);        }
        else        {                result = whole;        }
        return result;
}
