/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * Thanks to: Michael Geary (http://mg.to/) for some help
 */

/* Updated to NOT overwrite other unload handlers.
 *
 * Currently jQuery does not take care of cleaning
 * up after IE with events. This means that if you
 * use lots of events, IE will leak memory and
 * after a while your site will become unusable
 * in IE. This script helps jQuery help IE
 * in collecting the garbage.
 * http://brandonaaron.net/articles/2006/09/30/fixing-jquerys-memory-leak
 */
if ($.browser.msie) $(window).unload(function() { // clean events
	var event = jQuery.event, global = event.global;
	for (var type in global) {
 		var els = global[type], i = els.length;
		if (i>0) do if (type != 'unload') event.remove(els[i-1], type); while (--i);
	}
});