/**
 * @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;
			}
			switch (a_element.id) {
				case "fahrzeugtyp": case "marke": Form.setHiddenType(a_element); break;
			}
		}
	},
	
	checkCurrency: function (a_element) {
		a_element.setValue(a_element.value().replace(/\'/g, ""));
	},
	
	setHiddenType: function(a_element) {
		var hidden = new Element ('input', {
			'value': a_element.textValue(),
			'name': a_element.id,
			'type': 'hidden'
		});
		hidden.replaces($(a_element.id));
	}
}

function openWin () {
	var win = window.open("about:blank", 'resultWindow', 'width=930,height=270,resizable=no,scrollbars=no')	
}
