// Tax calculator functions

		function calc1 () {

			// Find the <input> element and get its value
			var inputEl = document.getElementById("tax1");
			var inputVal = inputEl.value.replace(/,/g,"").replace(/\$/,"");

			// Now find all the <p> elements with a class name of 'percent'

			var pEls = document.getElementsByTagName("p");

			for (var z in pEls) {
				var pEl = pEls[z];
				if (pEl.className != 'percent') {
					continue;
				}

				// get the percentage from the selected <p> tag
				var percentage = pEl.firstChild.nodeValue.replace(/%/,"");

				// compute resulting value

				var result = percentage * inputVal / 100;
				result = result.toFixed(0);

				// Find adjacent <td> cell (different in IE and others)

				var tdCell = pEl.parentNode.nextSibling;

				if (tdCell.nodeName != "TD") {
					tdCell = tdCell.nextSibling;
				}


				var resultCell = tdCell.firstChild.firstChild;
				resultCell.nodeValue = '$' + result.toString();

			}
		}

		// Function to calculate tax from assessment
		// Params are html input element as object and mil rate
		// Returns computed tax

		function calcTax (el, mil) {

			var inputVal = el.value.replace(/,/g,"").replace(/\$/,"");

			// compute resulting value

			var result = (inputVal * mil);
			result = result.toFixed(0);

			return result;

		}

		function calc2 () {

			// Enter mil rates here
			var mil1 = 21.11;			// 2009/2010 mil rate
			var mil2 = 22.11;			// theoretical reval mil rate
			var mil3 = 22.11;			// 2010/2011 mil rate

			// Compute mil rate in 1000th's

			mil1 = mil1 / 1000;
			mil2 = mil2 / 1000;
			mil3 = mil3 / 1000;

			// Find the two <input> elements and compute resultant tax for each year
			var el = document.getElementById("assess1");
			var oldTax = calcTax(el, mil1);

			el = document.getElementById("assess2");
			var revalTax = calcTax(el, mil2);
			var newTax = calcTax(el, mil3);

			// write calculated info back to page

			oldEl.firstChild.nodeValue = '$' + oldTax.toString();
			revalEl.firstChild.nodeValue = '$' + (revalTax - oldTax).toString();
			newEl.firstChild.nodeValue = '$' + newTax.toString();

			el = document.getElementById("tax1");
			el.value = newTax.toString();

			return;

		}
		
