/*
 * 'imgResize' jQuery plugin
 *
 * @author Froniki
 * @description Resize imgs
 * @namespace jQuery.imgResize
 * @namespace jQuery.fn.imgResize
 * @version 1.0
 * 
 */

(function($){
    $.fn.imgResize = function(w,h){
    	var $elements=this;
    	$elements.each(function(){
			if(h && $(this).height()>h){
				$(this).width(Math.round((h/$(this).height())*$(this).width())).height(h).css("cursor","pointer").click(function(){
    				window.open($(this).attr('src'));
    			});
			}else{
				if($(this).width()>w){
					$(this).width(w).css("cursor","pointer").click(function(){
    					window.open($(this).attr('src'));
    				});
    			}
			}
		});
    }
})(jQuery);