function check_form(the_form) {
	var return_val = false;
	var error_text = '';
	var empty_field = '';
	var empty_field_counter = 0;
	var label_name = document.getElementsByTagName('label');		
	var email_regex = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/;
	var password_regex = /^[\w]{6,20}$/;

	for (var i = 0; i < document.forms[0].elements.length; i++) {
		if (document.forms[0].elements[i].type == 'text' || document.forms[0].elements[i].type == 'password' || document.forms[0].elements[i].type == 'textarea') {
			if (document.forms[0].elements[i].value == '') {
				empty_field += label_name[i].firstChild.firstChild.nodeValue+'\n';
				empty_field_counter += 1;	
			} 
		}
	}
			
		if (empty_field_counter > 0) {
			error_text += 'You must enter the following info:\n'+empty_field;
			alert(error_text);
		} else {
			return_val = true;
		}
		
		if (error_text == '') {
			if (the_form.form_email != null) {	
				error_text += 'The following has occurred:\n';
				if (the_form.form_email.value.search(email_regex) == -1) {
				alert('You must enter a valid email address');
				the_form.form_email.value = '';
				if (the_form.con_email != null) {
					the_form.con_email.value = '';
				}
				the_form.form_email.focus();
				return_val = false;
				} 
				if (the_form.con_email != null) {
					if (the_form.form_email.value != the_form.con_email.value) {
						error_text += '(*)Email does not match!\n';
						the_form.con_email.value = '';
						the_form.con_email.focus();
						return_val = false;
					}
				}
			if (the_form.form_password != null) {
				if (the_form.form_password.value.search(password_regex) == -1) {
					alert('You must enter a valid password');
					the_form.form_password.value = '';
					if (the_form.con_password != null) {
						the_form.con_password.value = '';
					}
					the_form.form_password.focus();
					return_val = false;
				} 
				if (the_form.form_password.value != the_form.con_password.value) {
					error_text += '(*)The passwords do not match!\n';
					the_form.con_password.value = '';
					the_form.con_password.focus();
					return_val = false;
				}
			}
				var t = error_text.indexOf("*");
				if (t != -1)
				{
					alert(error_text);
				}
			}
		}
		
	return return_val;
}