(function(c){var a=[],b;c.fn.uBox=function(d){b=c.fn.uBox.settings;c.extend(b,d);c(window).resize(c.fn.uBox.resizeHandler);return this.each(function(e,f){while(typeof a[e]!="undefined"){e++}a[e]=null;c(f).hide();c.fn.uBox.prepare(e,f);c(this).bind("click",e,c.fn.uBox.clickHandler)})};c.fn.uBox.clickHandler=function(e){var d=a[e.data];if(c("#uBoxMagnified").size()>0){c("#uBoxMagnified").trigger("click");if(c("#uBoxMagnified").attr("src")==d.src){return}}var g=c("<img id='uBoxMagnified' />");c(g).attr("src",d.src);c(g).attr("alt",d.alt);c(g).css({width:d.thumbWidth,height:d.thumbHeight,position:"absolute",top:c(d.element).offset().top+"px",left:c(d.element).offset().left+"px",zIndex:1000,opacity:0.4,cursor:"pointer","-moz-box-shadow":b.shadow?"black 0px 0px 10px":"","-webkit-box-shadow":b.shadow?"black 0px 0px 10px":"",backgroundColor:"black",border:"1px solid #999",padding:"3px"});var f=c("<div id='uBoxMagnifiedAlt'>"+c(g).attr("alt")+"</div>");f.css({position:"absolute",width:d.originalWidth-16,height:25+"px",top:c(window).height()/2+d.originalHeight/2+c(window).scrollTop()-40+"px",left:c(window).width()/2-d.originalWidth/2+c(window).scrollLeft()+2+"px",backgroundColor:"black",opacity:0,zIndex:1001,color:"white",padding:"10px",cursor:"pointer"});f.click(function(){c("#uBoxMagnified").trigger("click")});c(g).bind("click",d,c.fn.uBox.dispose);c("body").prepend(g);c(g).animate({width:d.originalWidth,height:d.originalHeight,top:c(window).height()/2-d.originalHeight/2+c(window).scrollTop()+"px",left:c(window).width()/2-d.originalWidth/2+c(window).scrollLeft()+"px",opacity:1},b.showSpeed,b.showEasing,function(){c("body").append(f);b.showImageAlt?c(f).fadeTo(b.showImageAltSpeed,0.5):""})};c.fn.uBox.dispose=function(e){var d=e.data;c("#uBoxMagnifiedAlt").remove();c("#uBoxMagnified").animate({width:d.thumbWidth+"px",height:d.thumbHeight+"px",top:c(d.element).offset().top+"px",left:c(d.element).offset().left+"px",opacity:0},b.hideSpeed,b.hideEasing,function(){c(this).remove()})};c.fn.uBox.prepare=function(d,e){c(e).load(function(){var h=c(e).width();var f=c(e).height();var g=proportionalResize({width:h,height:f});c(e).css({width:g.width+"px",height:g.height+"px",cursor:"pointer",msInterpolationMode:"bicubic"});a[d]={originalWidth:h,originalHeight:f,thumbWidth:g.width,thumbHeight:g.height,src:c(e).attr("src"),alt:c(e).attr("alt"),element:e};c(e).show()})};c.fn.uBox.resizeHandler=function(){var d=c("#uBoxMagnified");if(d.size()>0){d.css({top:c(window).height()/2-d.height()/2+c(window).scrollTop()+"px",left:c(window).width()/2-d.width()/2+c(window).scrollLeft()+"px"});d.css({top:c(window).height()/2+d.height()/2+c(window).scrollTop()-40+"px",left:c(window).width()/2-d.width()/2+c(window).scrollLeft()+2+"px"})}};c.fn.uBox.settings={thumbWidth:100,thumbHeight:100,shadow:true,showSpeed:400,showEasing:"linear",hideSpeed:400,hideEasing:"linear",showImageAlt:false,showImageAltSpeed:800};proportionalResize=function(g){var f=g.width/g.height;var d=0,e=0;if(g.width>g.height){d=b.thumbWidth;e=b.thumbWidth/f}else{d=b.thumbHeight*f;e=b.thumbHeight}return{width:d,height:e}}})(jQuery);