/**
 * @author buenger
 */
var Form = {
	
	elements: new Array(),
	idMap: new Hash(),
	
	addElement: function (a_element) {
		this.elements.push(a_element);
		this.idMap.set(a_element.id, a_element);
	},
	
	getElement: function (a_id) {
		return this.idMap.get(a_id);
	},
	
	checkForm: function () {
		this.elements.each(this.checkElement);
		$('formular').action = URL_MAP['submit'];
		$('formular').submit();
	},
	
	checkElement: function (a_element, a_index) {
		if (a_element.type != "FormElement") return;
		else if (a_element.getCheckable() == false) {
			a_element.remove();
			return;
		} else {
			switch (a_element.name) {
				case "CurrencyInput": Form.checkCurrency(a_element); break;
			}
		}
	},
	
	checkCurrency: function (a_element) {
		a_element.setValue(a_element.value().replace(/\'/g, ""));
	}
}

function $E (a_id) {
	return Form.getElement(a_id);
}

