$.extend({
	lock: function(count, callback) {		
		var count = count;
		return function(e) {if (--count == 0) callback();}
	},
	isIE6: function() {return (($.browser.msie) && ($.browser.version == 6.0));}
});

$.fn.extend({
	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'
				});
	                }
		});
	}
});

$(function(){
	if ($.isIE6()) {
		$('div.filter').ie6TransparentBackground();
		$('img.filter').ie6TransparentImage();
	}
});

