﻿function HasValue(box) {
    return jQuery.trim(box.val()) != "";
}

function ChangeColour(box, message, action) {
    if (action == "blur") {
        if (HasValue(box) == 0) {
            $(box).addClass("text_input_focus");
            $(box).next().show().text(message);
            $(box).next("span").addClass("error_message");
        }
        else {
            $(box).removeClass("text_input_focus");
            $(box).next().hide();
        }
    }
    else {
        $(box).next("span").removeClass("error_message");
        $(box).next().hide();
        $(box).next().show().text(message);
        $(box).addClass("text_input_focus");
    }
}

function EmailAddressValid(box) {
    if (HasValue(box)) {
        var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
        return emailReg.test($(box).val());
    }
    else {
        return false;
    }
}
