<!-- Begin Comments Validation

var arr_errors = [];

function processForm(strForm)
{
    trimAll(strForm);

    var objAccountId = document.forms[strForm].elements['account_id'];
    var objBlogId    = document.forms[strForm].elements['blog_id'];
    var objAuthor    = document.forms[strForm].elements['author'];
    var objEmail     = document.forms[strForm].elements['email'];
    var objWebsite   = document.forms[strForm].elements['website'];
    var objCaptcha   = document.forms[strForm].elements['captcha'];
    var objComments  = document.forms[strForm].elements['comments'];

    arrErrors = [];  // reset errors array

    if (isBlank(objAuthor.value)) {
        catchError('reply-author', 'Please enter your name or alias');
    }
   
    if (!isValidEmail(objEmail.value)) {
        catchError('reply-email', 'Please enter a valid email address.');
    }

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

    if (isBlank(objComments.value)) {
        catchError('reply-comments', 'Please enter your comments.');
    }

    if (arrErrors.length > 0) {
        displayErrors();
    } else {
        jQuery.post(
            '/blog/comment',
            {
                account_id: objAccountId.value,
                blog_id: objBlogId.value,
                author: objAuthor.value,
                email: objEmail.value,
                website: objWebsite.value,
                captcha: objCaptcha.value,
                content: objComments.value
            },
            function(strResponse) {
                if (strResponse.substring(0, 6) == 'ERROR:') {
                    catchError('reply-captcha', strResponse.substring(6));
                    displayErrors();
                } else {
                    document.getElementById('reply').innerHTML = strResponse;
                }
            }
        );
    }
}

function highlightField(strId, blnState)
{
    jQuery('#error').fadeOut('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('#error').fadeIn('fast');
}

// End Comments Validation -->