;
(function($) {
    $(document).ready(function() {

    $('#ContactFormEmployee_ContactFormEmployee_action_SendContactForm').live('click', function() {
        
        checkForEmpty('errorname', 'ContactFormEmployee_ContactFormEmployee_Name', false);
        checkForEmpty('erroremail', 'ContactFormEmployee_ContactFormEmployee_Email', false);
        checkForEmpty('errorcomments', 'ContactFormEmployee_ContactFormEmployee_Comments', false);
        checkForEmpty('errorsecuritycode', 'ContactFormEmployee_ContactFormEmployee_SecurityCode', false);

        $('#ContactFormEmployee_ContactFormEmployee').submit();
    });
    
    $("#ContactFormEmployee_ContactFormEmployee_Name").focus(function(){
         checkForEmpty('errorname', 'ContactFormEmployee_ContactFormEmployeem_Name', true);
    });
    
    $("#ContactFormEmployee_ContactFormEmployee_Email").focus(function(){
        checkForEmpty('erroremail', 'ContactFormEmployee_ContactFormEmployee_Email', true);
    });
    
    $("#ContactFormEmployee_ContactFormEmployee_Comments").focus(function(){
        checkForEmpty('errorcomments', 'ContactFormEmployee_ContactFormEmployee_Comments', true);
    });
    
    $("#ContactFormEmployee_ContactFormEmployee_SecurityCode").focus(function(){
        checkForEmpty('errorsecuritycode', 'ContactFormEmployee_ContactFormEmployee_SecurityCode', true);
    });  
    
    if($('#ContactFormEmployee_ContactFormEmployee').length > 0) {
        var isError = false;
        if($('#errorname').html().length>0 && ($('#ContactFormEmployee_ContactFormEmployee_Name').hasClass('holder-required') || $('#ContactFormEmployee_ContactFormEmployee_Name').hasClass('holder-validation'))) {
            $('#ContactFormEmployee_ContactFormEmployee_Name').addClass('error');
            isError = true;
        }
        if($('#erroremail').html().length>0 && ($('#ContactFormEmployee_ContactFormEmployee_Email').hasClass('holder-required') || $('#ContactFormEmployee_ContactFormEmployee_Email').hasClass('holder-validation'))) {
            $('#ContactFormEmployee_ContactFormEmployee_Email').addClass('error');
            isError = true;
        }
        if($('#errorcomments').html().length>0 && ($('#ContactFormEmployee_ContactFormEmployee_Comments').hasClass('holder-required') || $('#ContactFormEmployee_ContactFormEmployee_Comments').hasClass('holder-validation'))) {
            $('#ContactFormEmployee_ContactFormEmployee_Comments').addClass('error');
            isError = true;
        }
        if($('#errorsecuritycode').html().length>0 && ($('#ContactFormEmployee_ContactFormEmployee_SecurityCode').hasClass('holder-required') || $('#ContactFormEmployee_ContactFormEmployee_SecurityCode').hasClass('holder-validation'))) {
            $('#ContactFormEmployee_ContactFormEmployee_SecurityCode').addClass('error');
            isError = true;
        }
        if(isError) {
            $('#errorbox').show();
        } else if(isError==false && $('#errorbox').is(':visible')) {
            $('#errorbox').hide();
        }
    }

    });
    
function checkForEmpty(errorcont, field, removeclass) {
    
    
    if($('#'+errorcont).html().length>0 && $('#'+errorcont).html()==$('#'+field).val()) {
        //$('#'+field).val('');
        if(removeclass) $('#'+field).removeClass('error');
    }
    return false;
}
})(jQuery);