(function ($) {
	
	$.hasFocus = null;
	$.lastFocused = null;
	
	$.fn.hasFocus = function () {
		return ($.hasFocus == $(this).get(0));
	};
	$.fn.lastFocused = function () {
		return ($.lastFocused == $(this).get(0));
	};
	$(function () {
		$("input, textarea, select, a, button").each(function () {
			$(this)
				.focus(function () {
					$.hasFocus = this;
					$.lastFocused = this;
				})
				.blur(function() {
					$.hasFocus = false;
				});
		});
	});
})(jQuery);
