// for each of these built-in functions which breaks anti-aliasing on IE
;(function($) {
	if ($.browser.msie) {
		var fixes = ['fadeIn', 'fadeOut', 'toggle', 'show', 'hide', 'fadeTo'];
		var name;
		for (var i = 0, l = fixes.length; (i < l) && (name = fixes[i]); ++i) {
			// copy the old function into another name
			$.fn["fadeFix_" + name] = $.fn[name];

			// recreate the old function.
			$.fn[name] = (function(fnname) {  // this is creating a closure for the "name" variable
				return function() {
					var args = [],
						foundCallback = false,
						argc = arguments.length
					;
					if (argc > 0) {	// were any arguments passed to this function?
						for (var i = 0; i < argc; ++i) {	// loop through them to find which was the callback.
							if (!foundCallback && $.isFunction(arguments[i])) {
								// this one is a function, let's override it
								// with our own callback function which fixes the glitch
								// and then calls the original function.
								foundCallback = true;
								args.push(
									(function(callback) {	// another closure.
										return function() {
											this.style.removeAttribute('filter'); // this is what fixes the visual glitch in IE.
											return callback.call(this);
										};
									})(arguments[i])
								);
							} else {
								args.push(arguments[i]);	// copy regular args over.
							}
						}
						// no callback specified in the application code, so make our own.
						if (!foundCallback) {
							args.push(function() {
								this.style.removeAttribute('filter');
							});
						}
					}
					// call the original jQuery function with all the supplied (and modified) arguments.
					return this["fadeFix_" + fnname].apply(this, args);
				};
			})(name);
		}
	}
})(jQuery);
