/*
	jQuery EasyThumb 1.0 Plugin
	Check www.hverven.net (For updates, etc)
	Updated: 06.01.08
*/

jQuery(function(){
//	jQuery(".easyThumb").prepend("<div class='loading'><img src='http://dev.jquery.com/export/1859/trunk/plugins/autocomplete/indicator.gif' alt='loading...'/ > Loading..</div>");
});

jQuery.fn.easyThumb = function(opt) {
	opt = jQuery.extend({
		width: 100, /* Width of the thumb*/
		height: 0, /* Height of the thumb. (optional) */
		makeLink: true, /* This will make a link to the original image */
		prefix: 'include/' /* Show a tooltip with the ALT-text*/
	},opt);

	return this.each( function() {
		//jQuery(this).find(".loading").remove();

		jQuery(this).find("li").each(function(n) {
			var obj = jQuery(this).find("img");
			var url = obj.attr("src");
			var alt = obj.attr("alt");
	
			if (url) {
				image = url.substring(url.lastIndexOf("/", url.lastIndexOf("/") -1) + 1,url.length);
				//obj.attr("src","include/thumbnail_generator.php?image=/images/listing_photos/" + image + "&w=" + opt.width)
				var pictW = obj.width();
				var pictH = obj.height();
				obj.attr("width",opt.width);
	
				if (opt.makeLink) {
					obj.wrap("<a class=\"listing-thumb\" href=\"javascript:imgswap('" + url + "');\" title=\"" + alt + "\"></a>");
				}
				if(opt.height > 0) {
					obj.css("height",opt.height);
				}
			} else {
				obj.css("display", "none");
			}
		});
		//jQuery(this).removeClass("easyThumb").addClass("easyThumbview");
	});
};