var isCalculated;

function calcSavings(f,info,divId) {
	if(!isCalculated) {
		var infoBox = document.createElement("span");
		
		//ghetto way for now... will change to have feedback in the document instead of through cheesy alert windows.....................................
		if(f.input_1.length <= 0 || !(f.input_1.value)){
			alert("What is the amount of your paycheck?");
			f.input_1.focus();
			return;
		}
		if(f.payPeriod.length <= 0 || !(f.payPeriod.value)){
			alert("How often do you get paid?");
			f.payPeriod.focus();
			return;
		}
		if(f.cost.length <= 0 || !(f.cost.value)){
			alert("What does it cost you to cash your check(%)?");
			f.cost.focus();
			return;
		}
		if(f.moneyOrder.length <= 0 || !(f.moneyOrder.value)){
			alert("How many bills do you pay each month with a money order?");
			f.moneyOrder.focus();
			return;
		}
		if(f.input_5.length <= 0 || !(f.input_5.value)){
			alert("How much does each money order cost?");
			f.input_5.focus();
			return;
		}
		//var theInfoNode = document.createTextNode(info);
		//infoBox.appendChild(theInfoNode);
		f.input_1.disabled=true;
		f.payPeriod.disabled=true;
		f.cost.disabled=true;
		f.moneyOrder.disabled=true;
		f.input_5.disabled=true;
		
		var a = parseFloat(f.input_1.value);
		var b = parseFloat(f.payPeriod.value);
		var c = parseFloat(f.cost.value)/100;
		var d = parseFloat(f.moneyOrder.value);
		var e = parseFloat(f.input_5.value);
		
		var X = (a * c) * b;
		var Y = (d * 12) * e;
		var Z = X + Y;
		
		info = info.replace("^savings_cc^", X.toString());
		info = info.replace("^savings_mo^", Y.toString());
		info = info.replace("^savings_total^", Z.toString());
		
		
		infoBox.innerHTML = info;
		document.getElementById(divId).appendChild(infoBox);
	 	isCalculated = true;
	}
}