	function ClearForm() {
		document.getElementById("cell_a").value = "";
		document.getElementById("cell_b").value = "";
		document.getElementById("cell_c").value = "";
		document.getElementById("cell_d").value = "";
		document.getElementById("cell_e").value = "";
		document.getElementById("results").style.display = "none";
	}
	function checkDigit(who) {
		var objRegExp  = /[^0123456789\.\-]+/;
		var q = who;
		q.value = q.value.replace(objRegExp, "");
		q.value = parseFloat(q.value);
		if (isNaN(q.value))	{
			q.value = "";
		}
	}
	function Calculate() {
		o = document.getElementById("results");
		a = parseFloat(document.getElementById("cell_a").value);
		b = parseFloat(document.getElementById("cell_b").value);
		c = parseFloat(document.getElementById("cell_c").value);
		d = parseFloat(document.getElementById("cell_d").value);
		e = parseFloat(document.getElementById("cell_e").value);
		if (!(isNaN(a) && isNaN(b) && isNaN(c) && isNaN(d) && isNaN(e))) {
			if (isNaN(a)) { a = 0; }
			if (isNaN(b)) { b = 0; }
			if (isNaN(c)) { c = 0; }
			if (isNaN(d)) { d = 0; }
			if (isNaN(e)) { e = 0; }
			// Calculating
			f = (a*b/100)/12;
			g = f * c;
			h = a * d / 100;
			i = f * e;
			j = a - h - i;
			// Feeding
			document.getElementById("cell_f").value = ""+addCommas(f.toFixed(2));
			document.getElementById("cell_g").value = ""+addCommas(g.toFixed(2));
			document.getElementById("cell_h").value = ""+addCommas(h.toFixed(2));
			document.getElementById("cell_i").value = ""+addCommas(i.toFixed(2));
			document.getElementById("cell_j").value = ""+addCommas(j.toFixed(2));
			// Opening the result box
			if (o.style.display != "") {
				o.style.display = "";
			}
		}
	}
	function addCommas(nStr)
	{
		nStr += '';
		x = nStr.split('.');
		x1 = x[0];
		x2 = x.length > 1 ? '.' + x[1] : '';
		var rgx = /(\d+)(\d{3})/;
		while (rgx.test(x1)) {
			x1 = x1.replace(rgx, '$1' + ',' + '$2');
		}
		return x1 + x2;
	}
