
function prepare_calculator() {
	if (!document.getElementById) return false;
	if (!document.getElementById('save_form')) return false;
	
	var $form = document.getElementById('save_form');
	$form.onsubmit = function() {
		var $currency = document.getElementById('save_field-currency').value;
		var $property_value = document.getElementById('save_field-property_value').value;
		var $agent_commission = document.getElementById('save_field-agent_commission').value;
		if (!$property_value) {
			alert('A property value must be submitted');
			return false;
		}
		if (!$agent_commission) {
			alert('A agent commission value must be submitted');
			return false;
		}
		var $saving = ($property_value/100)*$agent_commission;
		var $tfoot = this.getElementsByTagName('tfoot')[0];
		if (document.getElementById('save_form-result')) $tfoot.removeChild(document.getElementById('save_form-result'));
		var $tr = document.createElement('tr');
		var $td = document.createElement('td');
		var $text = document.createTextNode('You could save '+$currency+$saving+'!');
		$td.setAttribute('colspan','4');
		$tr.setAttribute('id','save_form-result');
		$td.appendChild($text);
		$tr.appendChild($td);
		$tfoot.appendChild($tr);
		return false;
	}
}
addLoadEvent(prepare_calculator);