$(document).ready(function () {

    $('.share_submit').live('click', function (e) {

        checkVal = checkValues2();

        if (checkVal == true) {
        }
        else {
            e.preventDefault();
            return false;
        }
    });
});

function checkValues2() {

    var checkForm = true;
    var checkText = true;
    var checkMail = true;
    var checkCaptcha = false;
    var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
    var colorError = "#FF0000";
    var colorOK = "#6F7173";

    $('.textBox').each(function () {

        if ($(this).val() == $(this).attr('alt') || $(this).val() == "" || $(this).val() == " ") {
            checkText = false;
            $(this).parent().prev().css("color", colorError);
        }
        else {

            checkForm = true;
            $(this).parent().prev().css("color", colorOK);
        }

    });
    $('.ap_email').each(function () {
        if (!emailReg.test($(this).val())) {
            $(this).parent().prev().css("color", colorError);
            checkMail = false;
        }
        else if ($(this).val() == "") {
            $(this).parent().prev().css("color", colorError);
            checkMail = false;
        }
        else {
            $(this).parent().prev().css("color", colorOK);
            checkMail = true;
        }
    });
    $('.share_captcha').each(function () {
        if ($(this).val() == "" || $(this).val() == " ") {
            checkCaptcha = false;
            $('#label_share_Captcha').css("color", colorError);
        }
        else {
            checkCaptcha = true;
            $('#label_share_Captcha').css("color", colorOK);
        }
    });

    if (checkText == true && checkMail == true && checkCaptcha == true) {
        checkForm = true;
        return true;
    }
    else {
        return false;
    }
}
