<!-- 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 checkLogin(strForm)
{
    trimAll(strForm);

    var objUsername = document.forms[strForm].elements['username'];
    var objPassword = document.forms[strForm].elements['password'];

    arrErrors = [];  // reset errors array

    if (isBlank(objUsername.value)) {
        catchError('username', 'Please enter your username');
    }
   
    if (isBlank(objPassword.value)) {
        catchError('password', 'Please enter your password');
    }

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

    return true;
}


function highlightField(strId, blnState)
{
    jQuery('#form-error').hide();
    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('#form-error').text('Please check the form for missing information.');
    } else {
        jQuery('#form-error').text(arrErrors[0]);
    }
    jQuery('#form-error').show();
}

// End Contact Form Validation -->