function form_init() {
	$$('form.generic-form').each(function(f) { f.onsubmit = submit_form })
}

function handle_response(r) {
	eval(r.responseText)
}
function submit_form() {
	var values = Form.getElements(this).collect(function(f) { return get_label_value_pair(this.id, f) }).compact()
	Form.disable(this)
	new Ajax.Request('form2.php', {method:'post', onSuccess:handle_response, postBody:values.collect(function(f) { return f.join("=") }).join("&")})
	return false
}

function get_label_value_pair(form_id, field) {
	if ((field.type != "button") && (field.type != "submit") && (field.type != "file"))
	return $A([get_label_for(form_id, field), get_value_for(form_id, field)])
}

function get_label_for(form_id, field) {
	var label = field.name
	$$('#' + form_id + ' label').each(function(f) { if (f.htmlFor == field.id) label = f.innerHTML })
	return label
}

function get_value_for(form_id, field) {
	return field.value
}

window.onload = form_init