function addMe(parent)
{
	getAllInputs();
	getTotal(parent);
}
function compareMe(parent)
{
	getAllCompareInputs();
	getTotal(parent);
}
function getAllInputs()
{
	var val = 0;
	var inputCollection = document.getElementById('collegeCalc').getElementsByTagName('input');
	for(i=0; i < inputCollection.length; i++){
		var num = Number(inputCollection[i].value);
		if(inputCollection[i].name == "neg"){
			val -= num;
		}
		else {
			val += num;
		}
	}
	if(isNaN(val)){
		document.getElementById('collegeCalcAllTotal').innerHTML= "Invalid Entry";
	}
	else {
		document.getElementById('collegeCalcAllTotal').innerHTML= "$" + val;
	}
}
function getAllNegInputs()
{
	var val = 0;
	var inputCollection = document.getElementById('collegeCalc').getElementsByTagName('input');
	for(i=0; i < inputCollection.length; i++){
		var num = Number(inputCollection[i].value);
		if(inputCollection[i].name == "neg"){
			val += num;
		}
	}
	if(isNaN(val)){
		document.getElementById('collegeCalcAllNegTotal').innerHTML= "Invalid Entry";
	}
	else {
		document.getElementById('collegeCalcAllNegTotal').innerHTML= "$" + val;
	}
}
function getAllCompareInputs()
{
	var numOfColleges = 3;
	for (i = 1; i < numOfColleges+1; i++){
		var val = 0;
		var cost = document.getElementById('college' + i + 'cost').getElementsByTagName('input');
		var finaid = document.getElementById('college' + i + 'FinAid').getElementsByTagName('input');
		var inputCollection = new Array(cost.length + finaid.length);
		var index = 0;
		for(j=0; j < cost.length; j++){
			var num = Number(cost[j].value);
			val += num;
		}
		for(x=0; x < finaid.length; x++){
			var num = Number(finaid[x].value);
			val -= num;
		}
		if(isNaN(val)){
			document.getElementById('college' + i + 'AllTotal').innerHTML= "Invalid Entry";
		}
		else {
			document.getElementById('college' + i + 'AllTotal').innerHTML= "$" + val;
		}
	}
}
function getTotal(parent)
{
	var val = 0;
	var inputCollection = document.getElementById(parent).getElementsByTagName('input');
	for(i=0; i < inputCollection.length; i++){
		var num = Number(inputCollection[i].value);
		if(inputCollection[i].name == "neg"){
			val -= num;
		}
		else {
			val += num;
		}
	}
	var subTotalHolder = document.getElementById(parent).getAttribute('rel');
	if(isNaN(val)){
		document.getElementById(subTotalHolder).innerHTML= "Invalid Entry";
	}
	else {
		document.getElementById(subTotalHolder).innerHTML= "$" + val;
	}
}
function numbersonly(e)
{
	var unicode = e.charCode ? e.charCode : e.keyCode;
	if( unicode > 9){
		if( unicode < 46 || unicode > 57 || unicode == 47) {
			return false;
		}
		else{
			return true;
		}
	}
	else {
		return true;
	}
}