$.extend({
	
	getImageSize : function(o){
		var ns = $.getNaturalSize(o);
		if(!ns){
			return {
				width : o.naturalWidth,
				height : o.naturalHeight
			};
		}
		var nWidth  = o.naturalWidth  || ns.width;
    var nHeight = o.naturalHeight || ns.height;
    return {
    	width : nWidth,
    	height : nHeight
    };
	},
	
	getNaturalSize : function(image){
		var w, h, key = "actual", run, mem;
		if(window.opera){}
		if (image[key] && image[key].src === image.src) {
			return image[key];
		}
		run = image.runtimeStyle;
		if(!run){
			return null;
		}
		mem = {
			"w" : run.width,
			"h" : run.height
		}; // keep runtimeStyle
		run.width  = "auto"; // override
		run.height = "auto";
		w = image.width;
		h = image.height;
		run.width  = mem.w; // restore
		run.height = mem.h;
		image[key] = {
			"width"  : w,
			"height" : h,
			"src"    : image.src
		};
		return image[key]; // bond
	}
	
});
