(function(d) {
	d.fn.aeImageResize = function(a) {
		var i = 0, j = d.browser.msie && 6 == ~~d.browser.version;
		if (!a.height && !a.width)
			return this;
		if (a.height && a.width)
			i = a.width / a.height;
		return this
				.one(
						"load",
						function() {
							this.removeAttribute("height");
							this.removeAttribute("width");
							this.style.height = this.style.width = "";
							var pHeight = this.height, pWidth = this.width, pRatio = pWidth / pHeight, nHeight = a.height, nWidth = a.width, nRatio = i;
							nRatio || (nRatio = nHeight ? pRatio + 1 : pRatio - 1);
							if (nHeight || nWidth) {
								if (pRatio > nRatio)
									nHeight = ~~(pHeight / pWidth * nWidth);
								else
									nWidth = ~~(pWidth / pHeight * nHeight);
								this.height = nHeight;
								this.width = nWidth
							}
						}).each(function() {
					if (this.complete || j)
						d(this).trigger("load")
				})
	}
})(jQuery);
