(function($){

	$.fn.enabled = function(flag)
	{
	    if (flag) {
	        return $(this).removeAttr('disabled');
	    } else {
	        return $(this).attr('disabled', 'disabled');
	    }
	};
	
	$.fn.readonly = function(flag)
	{
		if (flag) {
			return $(this).attr('readonly', 'readonly');
		} else {
			return $(this).removeAttr('readonly');
		}
	};

	$.fn.id = function()
	{
		return $(this).attr('id') || null;
	};

	$.fn.bg = function(url)
	{
		if (url == undefined) {
			var bg = $(this).css('background-image');
			bg = bg.replace(/^url\(("|)/,'');
			bg = bg.replace(/("|)\)$/,'');
			return bg;
		} else {
			$(this).css('background-image', 'url("' + url + '")');
		}
	};

	$.fn.clickpress = function(func)
	{
		$(this).click(function(){ return func(); });
		$(this).keypress(function(e){
			var keyCode;
			if (e.keyCode) keyCode = e.keyCode;
			else if (e.which) keyCode = e.which;
			if (keyCode != 13 && keyCode != 32) return true;
			return func();
		});
		return $(this);
	};

})(jQuery);
