function inputNumber(input, character) {

// inputs characters from calculator buttons

var str = document.calcForm.filesize.value;
var char = character;

if(input.value == null || input.value == "0") { // first digit
	input.value = character
}

else {   
	// ignore subsequent entries of '+'
	if((character == "+") && (str.lastIndexOf('+') == (str.length - 1))) {
		window.alert("Cannot enter 2 subsequest plus signs.");
	}
	else {
		// ignore subsequent entries of '.'
		if((character == ".") && (str.lastIndexOf('.') == (str.length - 1))) {
		window.alert("Cannot enter 2 subsequest '.' characters.");
	}
		
	else {
		input.value += character
	}
}
}
}

function addNumbers(expr) {

// checks to see if the input consists of '+' signs and numbers and adds the numbers in the calculator window

var string1 = document.calcForm.filesize.value;
var numstring = replaceString("+","",string1);  // remove all plus signs
var numstring1 = replaceString(".","",numstring);  // remove all '.' characters

// if the resulting string is a number - correct input
if (isNaN(numstring1)) { 
	window.alert("WRONG INPUT. The calculator window should only contain plus signs and float or integer numbers.");
}

else {
	document.calcForm.filesize.value = eval(expr);
}


}


function replaceString(oldS,newS,fullS) {

// Replaces oldS with newS in the string fullS   
	
	for (var i=0; i<fullS.length; i++) {      
		if (fullS.substring(i,i+oldS.length) == oldS) {         
			fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length)      
		}   
	}   
return fullS
}


function resetCalc(){
// reset calculator display
document.calcForm.filesize.value = 0
}