function missingmandatory() {
    result=false;
    
    result=result || (document.forms["register"]["realname"].value=="");
    result=result || (document.forms["register"]["nickname"].value=="");
    result=result || (document.forms["register"]["email"].value=="");
    result=result || (document.forms["register"]["password"].value=="");
    result=result || (document.forms["register"]["address1"].value=="");
    result=result || (document.forms["register"]["city"].value=="");
    result=result || (document.forms["register"]["county"].value=="");
    
    return result;
}

function clearterms() {
    msg = "";
    if (!document.forms["register"]["agreetoterms"].checked) {
        msg=addmsg(msg,"You must agree to the terms and conditions!");
    }
    if (document.forms["register"]["email"].value!=document.forms["register"]["confirmemail"].value) {
        msg=addmsg(msg,"The email addresses do not match!");
    }
    if (document.forms["register"]["password"].value!=document.forms["register"]["confirmpassword"].value) {
        msg=addmsg(msg,"The passwords do not match!");
    }
    
    if (document.forms["register"]["email"].value!="") {
        if (!validemailformat(document.forms["register"]["email"].value)) {
            msg=addmsg(msg,"The supplied email address is not valid!");
        }
    }
    
    if (missingmandatory()) {
        msg=addmsg(msg,"One or more mandatory fields are missing!");
    }
    
    if (msg=="") {
        document.forms["register"]["terms"].value="";        
        return true;
    } else {
        alert(msg);
        return false;
    }
}
