function isEmpty(id) {
    if ($("#" + id).val() + "" == "")
        return true;
    else
        return false;
}

function highlight(id) {
    $("#" + id).addClass("Highlight");
}

function hasNumbers(t) {
    var regex = /\d/g;
    return regex.test($("#" + t).val() + "");
}

function hasChars(t) {
    return !(hasNumbers(t));
}

function hasLength(t, l) {
    if (t.length == l)
        return true;
    else
        return false;
}

(function($) {

    $.fn.extend({

        Box: function(options) {

            var defaults = {
                type: "warning",
                title: "Warning: ",
                msg: "Something has gone wrong!",
                append: true
            }

            var options = $.extend(defaults, options);

            return this.each(function() {

                var obj = $(this);

                //Create references to the options
                var type = options.type;
                var title = options.title;
                var msg = options.msg;
                var append = options.append;

                if (type == "warning") {
                    var boxDiv = "<div class='ui-widget'><div class='ui-state-highlight ui-corner-all' style='padding: 0 .7em;'>"
				             + "<p><span class='ui-icon ui-icon-info' style='float: left; margin-right: .3em;'></span><span><strong>"
							 + title + "</span></strong><span class='msg'>" + msg + "</span></p></div></div>";
                }
                else {
                    var boxDiv = "<div class='ui-widget'><div class='ui-state-error ui-corner-all' style='padding: 0 .7em;'>"
				             + "<p><span class='ui-icon ui-icon-alert' style='float: left; margin-right: .3em;'></span><span><strong>"
							 + title + "</span></strong><span class='msg'>" + msg + "</span></p></div></div>";
                }

                //Check if "append" is set to true, otherwise prepend the "box" 
                if (append) {
                    obj.append(boxDiv);
                }
                else {
                    obj.prepend(boxDiv);
                }

                //Auto size the box to length of msg
                var totalWidth = 30;

                obj.find("span").each(function(i) {
                    totalWidth = totalWidth + parseInt($(this).attr("offsetWidth"));
                });
                obj.css("width", totalWidth + "px");

            });
        }
    });

})(jQuery);
