/* 
	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='images/indicator.gif' alt='loading...'/ > Loading..</div>");
});

jQuery.fn.easyThumb = function(opt) {
	opt = jQuery.extend({
     		width: 300, /* Width of the thumb*/
     		height: 0, /* Height of the thumb. (optional) */
     		makeLink: false, /* This will make a link to the original image */
     		toolTip: false /* 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");

  			obj.attr("src","bonus_thumbnail.php?image="+url+"&w="+opt.width)
			/*
         var pictW = obj.width();
         var pictH = obj.height();
         */

         var pictH = obj.height;
         var pictW = obj.width;

         if( pictH > pictW ){
            pictH = 110;
            pictW = 83;
         }

			obj.attr("width",opt.width);
         //obj.attr("width",pictW);
 
			if (opt.makeLink){
				obj.wrap("<a href=\""+url+"\" title=\""+alt+"\"></a>");
			}
  			if(opt.height > 0){
  				obj.css("height",opt.height);
  			}
			/* TODO */
  			if(opt.toolTip){}
  		});
		jQuery(this).removeClass("easyThumb").addClass("easyThumbview");
	});	
};