var __inputs_to_check__ = [];

function testEmail(theEmail) {
	var addressPattern = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-zäöüÄÖÜ0-9]+)*\.[A-Za-z0-9]+$/;
	return addressPattern.test(theEmail);
}

function mySubmit(id) {
	// get form by dom id, because form element with name 'name' hides form name
	var theForm = document.getElementById( id );

	if (document.location.href.indexOf("/servlet/Show") >= 0)
		return;

	for (var i = 0; i < __inputs_to_check__.length;i++) {

		var fField = __inputs_to_check__[i];
		var fElem  = document.getElementById(fField.id);

		if ( fField.check == "EMAIL" && fField.type  == "text" && !testEmail(fElem.value)
		  || !fElem.value && (fField.type == "text" || fField.type == "textbox")  
		  || !fElem.checked && fField.type == "checkbox") 
		{
			alert(fField.msg);
			return false;
		}
	}

	var emburl  = new URL(document.location.href);

	// emburl.setParameter("action", "submit");
	emburl.removeAllParams();
	emburl.setParameter("foo", "" + Math.random());
	theForm.redirectTo.value=emburl.toString();
	theForm.submit();
}

