function leer(s) {
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}

// This is the function that performs form verification. It is invoked
// from the onsubmit event handler. The handler should return whatever
// value this function returns.
function check(f) {
    var msg;
    var empty_fields = "";
    var errors = "";

    for(var i = 0; i < f.length; i++) {
        var e = f.elements[i];
        if ((e.type == "text") && !e.optional) {
            // first check if the field is empty
            if ((e.value == null) || (e.value == "") || leer(e.value))	{
                empty_fields += "\n          " + e.name;
                continue;
            }
        }
		if (e.type == "text") {
			//Email testen
			if (e.name == "email")	{
				if (e.value.indexOf("@")==-1)	{
					errors += "The @ is missing in your email address.\n";
				}
				if (e.value.indexOf(".")==-1)	{
					errors += "The point is missing in your email address.\n";
				}
			}
		}
		/*if (e.type == "checkbox") {
			if (e.checked == false)	{
				errors += "\n Please accept the mentioned conditions.\n";
			}
		}*/
    }

    // Now, if there were any errors, display the messages, and
    // return false to prevent the form from being submitted. 
    // Otherwise return true.
    if (!empty_fields && !errors) return true;

    msg  = "______________________________________________________\n\n"
    msg += "Some entries are wrong. Please check your entries\n";
	msg += "and send the form again.\n";
    msg += "______________________________________________________\n\n"

    if (empty_fields) {
        msg += "The following fields are empty:" 
                + empty_fields + "\n";
        if (errors) msg += "\n";
    }
    msg += errors;
    alert(msg);
    return false;
}