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

function isvalidemail(e)
{
	var emailptn = /[^@]+@\w{2,}\.\w{2,4}/;
	return emailptn.test( e );
}

function verify(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.type == "textarea")) && !e.optional) {
            // first check if the field is empty
            if ((e.value == null) || (e.value == "") || isblank(e.value)) {
                empty_fields += "\n          " + e.name;
                continue;
            }
         }
         if ( e.name == "email" && !isvalidemail( e.value ) ) {
				errors += "E-mail does not appear to be a valid e-mail address.\n";
//			} else if ( e.value.indexOf(',') >= 0 || e.value.indexOf(';') >= 0 || e.value.indexOf('@',e.value.indexOf('@')+1) >= 0 ) {
//					errors += "Email appears to contain more than one e-mail address. You may only specify a single e-mail address.\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 = "";
    if (empty_fields) {
        msg += "- The following required field(s) are empty:" 
                + empty_fields + "\n";
        if (errors) msg += "\n";
    }
    msg += errors;
    msg += "\n_________________________________________\n"
    msg += "The form was not submitted because of these\n";
    msg += "error(s). Please correct and re-submit.\n";
    msg += "___________________________________________\n\n"

    alert(msg);
    return false;
}

