(function($){
	$.fn.extend({
		picfix: function(opt) {
			var defaults = {
				altImg: "images/nopic.jpg",
				onerror: function () {}
			};
			var options = $.extend(defaults, opt);
			return this.each(function() {
				//Creating a reference to the object
				var obj = $(this);
				obj.error( function () {
					jQuery(this).unbind("error");
					if( options.onerror !== "function () {}" ) {
						options.onerror.call();
					} else {
						obj.attr("src", options.altImg );
					}
				});
				// reload image
				obj.attr("src", obj.attr("src"));
			});
		}
	});
})(jQuery);
