function isValidEmailAddress(emailAddress) {
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
};

function updateInterestedIn() {
    var interested_in = "";

    var HRS = document.getElementById('HRS');
    HRS.value = "";
    if (HRS.checked)
        interested_in += "HR Solutions; ";
    var PPA = document.getElementById('PPA');
    PPA.value = "";
    if (PPA.checked)
        interested_in += "Payroll Processing and Administration; ";
    var HRIS = document.getElementById('HRIS');
    HRIS.value = "";
    if (HRIS.checked)
        interested_in += "Human Resource Information Systems; ";
    var TAS = document.getElementById('TAS');
    TAS.value = "";
    if (TAS.checked)
        interested_in += "Time and Attendance Systems; ";
    var PPHR = document.getElementById('PPHR');
    PPHR.value = "";
    if (PPHR.checked)
        interested_in += "PROXUS Pinnacle HR; ";
    var EB = document.getElementById('EB');
    EB.value = "";
    if (EB.checked)
        interested_in += "Employee Benefits";

    if (interested_in != "") {
        document.getElementById('interested_in').value = interested_in;
    }
};

function validate() {
    var nm = document.getElementById('contact_name').value;
    if (nm != null && nm.length < 2) {
        alert('Please enter your name');
        return false;
    }
    var eml = document.getElementById('contact_email').value;
    if (eml != null && !isValidEmailAddress(eml)) {
        alert('Please enter a valid email address');
        return false;
    }
    return true;
};

function validateAndSubmitInterestedIn() {
    updateInterestedIn();
    if (validate())
        document.forms['eml'].submit();
};

function validateAndSubmit() {
    if (validate())
        document.forms['eml'].submit();
};
