// form_scripts.js (c) Vechtwijk Automatisering

function show_alert(msg) {
	alert(msg);
}

function f_button(action) {
	if (action == "home" || action == "cancel") {
		document.orderform.f_action.value = action;
		document.orderform.submit();

	} else if (action == "submit") {
		email_pattern = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*\.([a-zA-Z])+$/;

		if (document.orderform.f_name.value == "") {
			show_alert("U heeft uw naam niet ingevoerd!");
			document.orderform.f_name.focus();

		} else if (!email_pattern.test(document.orderform.f_email.value)) {
			show_alert("U heeft geen geldig e-mail adres ingevoerd!");
			document.orderform.f_email.focus();
			document.orderform.f_email.select();

		} else if (document.orderform.f_imglist.value == "") {
			show_alert("U heeft geen fotonummers ingevoerd!");
			document.orderform.f_imglist.focus();

		} else {
			document.orderform.f_action.value = action;
			document.orderform.submit();

		}

	} else {
		document.orderform.f_action.value = "url"
		document.orderform.f_url.value = action;
		document.orderform.submit();
	}
}
