<!-- Begin Contact Form Validation

var arr_errors = [];

function checkForm(strForm)
{
    trimAll(strForm);

    var objFirstName = document.forms[strForm].elements['first_name'];
    var objLastName  = document.forms[strForm].elements['last_name'];
    var objEmail     = document.forms[strForm].elements['email'];
    var objMessage   = document.forms[strForm].elements['message'];
    var objCaptcha   = document.forms[strForm].elements['captcha'];

    arrErrors = [];  // reset errors array

    if (isBlank(objFirstName.value)) {
        catchError('first_name', 'Please enter your first name');
    }
   
    if (isBlank(objLastName.value)) {
        catchError('last_name', 'Please enter your last name');
    }
    
    if (!isValidEmail(objEmail.value)) {
        catchError('email', 'Please enter a valid email address.');
    }

    if (isBlank(objMessage.value)) {
        catchError('message', 'Please enter your message.');
    }

    if (isBlank(objCaptcha.value) || (objCaptcha.value == 'enter code here')) {
        catchError('captcha', 'Please enter the 6-character security code.');
    }

    if (arrErrors.length > 0) {
        displayErrors();
        return false;
    }

    return true;
}

function highlightField(strId, blnState)
{
    jQuery('#error').fadeOut('fast', function() {
        jQuery('#notice').fadeIn('fast');
    });
    jQuery('#' + strId).removeClass();

    if (blnState == 1) {
        jQuery('#' + strId).addClass('selected');
    }
}

function catchError(strId, strError)
{
    jQuery('#' + strId).addClass('invalid');
    arrErrors[arrErrors.length] = strError;
}

function displayErrors()
{
    if (arrErrors.length > 1) {
        jQuery('#error').text('Please check the form for missing information.');
    } else {
        jQuery('#error').text(arrErrors[0]);
    }
    jQuery('#notice').fadeOut('fast', function() {
        jQuery('#error').fadeIn('fast');
    });
}

// End Contact Form Validation -->