/**
 * Managing the events
 *
 * @author Wolfram Huesken <woh@lieblingsagentur.tv>
 * @version 0.2 <2008-04-21 1:00>
 */
window.addEvent('domready', function() {
	// Set status var for calculator window
	document.calc_open = false;
	
	$('qform').addEvent('submit', function(e) {
		this.send({
			onComplete : function() {
				alert("Wir haben Ihre Daten erhalten und werden uns bald bei Ihnen melden!");
			}
		});
	});
	
	$('calc').addEvent('click', function(e) {
		vo_calc_open();	
	});

	$('cmd_page12').addEvent('click', function(e) {
		vo_calc_next("ContentPage1", "ContentPage2");
	});
	
	$('cmd_page21').addEvent('click', function(e) {
		vo_calc_next("ContentPage2", "ContentPage1");
	});

	$('cmd_page23').addEvent('click', function(e) {
		vo_calc_next("ContentPage2", "ContentPage3");
	});

	$('cmd_page32').addEvent('click', function(e) {
		vo_calc_next("ContentPage3", "ContentPage2");
	});

	$('cmd_page34').addEvent('click', function(e) {
		vo_calc_next("ContentPage3", "ContentPage4");
	});

	$('cmd_page43').addEvent('click', function(e) {
		vo_calc_next("ContentPage4", "ContentPage3");
	});

	$('cmd_page45').addEvent('click', function(e) {
		calc_Ov();
		vo_calc_next("ContentPage4", "ContentPage5");
	});

	$('cmd_page54').addEvent('click', function(e) {
		vo_calc_next("ContentPage5", "ContentPage4");
	});

	// Add a leave field event to every input field of the calculator
	var Inputs = $$('input');
	for (var i=0; i<Inputs.length; i++) {
		var Input = Inputs[i];
		if (Input.className != null && Input.className == "calcInput") {
			Input.addEvent('blur', function(e) {
				processField(this);
			});
		}
 	}

});

