$.extend({
	lock: function(count, callback) {		
		var count = count;
		return function(e) {if (--count == 0) callback();};
	},
	isIE6: function() {return (($.browser.msie) && ($.browser.version == 6.0));},
	generateId: function() {return arguments.callee.prefix + arguments.callee.count++;}
});

$.generateId.prefix = 'jq';
$.generateId.count = 0;

$.fn.extend({
	pause: function(duration) {
	    $(this).animate({ dummy: 1 }, duration);
	    return this;
	},
	ie6TransparentImage: function() {
		return this.each(function() {
			var div = $(document.createElement('div'));
			div.css({
				'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + $(this).attr('src') + "', sizingMethod='crop');",
				'width': $(this).attr('width') + 'px',
				'height': $(this).attr('height') + 'px'
			}).attr('id', $(this).attr('id'));
			$(this).replaceWith(div);
		});
	},
	ie6TransparentBackground: function() {
		return this.each(function() {
        	        var re = /url\("http:\/\/[^\/]*([^"]*)"\)/;
	                m = re.exec($(this).css('background-image'));
	                if (m != null) {
	                        $(this).css({
					'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + m[1] + "', sizingMethod='crop');",
					'backgroundImage': 'none'
				});
	                }
		});
	},
	generateId: function() {
	  return this.each(function() {
	    if (this.id == '')
        this.id = $.generateId();
    });
	}
});

/*
 * So, I know I should use feature detection, but it's not a case of
 * "can it do it?". It's more a case of "can it do it without screwing up?"
 * 
 * If it's IE6, IE7 or surprisingly even IE8, no it can't.
 */
if (($.browser.msie) && ($.browser.version < 9.0)) {
	// canHasToys = false
	$.fn.extend({			
		fxpSlideDown: $.fn.show,
		fxpSlideUp: $.fn.hide,
		fxpFadeOut: $.fn.hide,
		fxpFadeIn: $.fn.show
	});
} else {
	$.fn.extend({
		fxpSlideDown: $.fn.slideDown,
		fxpSlideUp: $.fn.slideUp,
		fxpFadeOut: $.fn.fadeOut,
		fxpFadeIn: $.fn.fadeIn
	});
}

