(function($) {
	$.fn.imgResize = function(params) {
		var ratio;
		var width;
		var height;

		$(this).removeAttr('width').removeAttr('height');
		//$(this).css('width', 'auto').css('height', 'auto');

		width = $(this).width();
		height = $(this).height();

		if (height > params.height) {
			ratio = params.height / height;
			height = params.height;
			width = width * ratio;
		}

		if(width > params.width) {
			ratio = params.width / width;
			height = height * ratio;
			width = params.width;
		}

		$(this).attr('height', height);
		$(this).attr('width', width);

		return $(this);
	};
})( jQuery );
