/* Author: 

*/
Image.prototype.getImageSize = function(cb) {
	if (typeof cb != 'function') return;
	var image = new Image();
	image.src = this.src;
	if ((!image.width) && (!image.height)) {
		image.onload = function(image,orig) {
			return function(){
				cb.apply(orig,[image.width,image.height]);
			}
		}(image,this);
	} else {
		cb.apply(this,[image.width,image.height]);
	}
}
for (i in document.images) {
	document.images[i].getImageSize = Image.prototype.getImageSize;
}

$(function() {
	$('div#left figure').each(function() {
		var img = $(this).find('img').get(0);
		img.getImageSize(function(w,h) {
			$(this).parent().css('width',w+'px');
		});
	});
	
	$('button').click(function() {
		$(this).parents('form').get(0).submit();
	})
});


