(function(a){a.fn.fullsize=function(d){var c={shadow:true,zoomInSpeed:200,zoomOutSpeed:200,fadeInSpeed:250,fadeOutSpeed:250,leftOffset:0,topOffset:0,iconOffset:8,forceTitleBar:false,extraTrigger:false,parentSteps:0,destroy:false,start:function(){},end:function(){}},b=a.extend(c,d);b.destroy==true&&a("div.fullsize-icon").remove();a(document).keydown(function(c){if(c.keyCode==27){a("div.fullsize-wrapper, div.fullsize-sh-wrap").fadeOut(b.fadeOutSpeed,function(){a(this).remove()});b.end.call(this)}});return this.each(function(){if(b.destroy==true)a(this).unbind();else if(a(this).attr("longdesc")){var c=a(this),g=c.attr("title"),j=c.attr("longdesc"),d=a("<div></div>").addClass("fullsize-icon").css({display:"none"}),f;if(b.extraTrigger){for(var e=c,h=0;h<=b.parentSteps;h++)e=e.parent();f=e.find(b.extraTrigger)}c.add(f).hover(function(){var m=c.css("marginTop").slice(0,-2),j=c.css("marginLeft").slice(0,-2),l=c.css("marginLeft").slice(0,-2),k=c.css("marginLeft").slice(0,-2);if(m<0||j<0||l<0||k<0){var g=a(c),n=a(c).parents();a(n).each(function(){if(this.tagName=="BODY")return false;else if(a(this).css("overflow")=="hidden"){g=a(this);return false}});var h=g.offset(),f=parseInt(g.css("border-top-width")),e=parseInt(g.css("border-left-width"))}else var h=c.offset(),f=parseInt(c.css("border-top-width")),e=parseInt(c.css("border-left-width"));if(!f)f=0;if(!e)e=0;var i=false;a("div.fullsize-icon").each(function(){if(parseInt(a(this).css("top"))==h.top+b.iconOffset+f&&parseInt(a(this).css("left"))==h.left+b.iconOffset+e){i=true;curIcon=a(this)}});if(i==false){a(d).css({top:h.top+b.iconOffset+f,left:h.left+b.iconOffset+e});a("body").prepend(d)}a(d).show()},function(){a(d).hide()});a(d).hover(function(){a(this).show()},function(){a(this).hide()});a(d).click(function(){b.start.call(this);a("div.fullsize-wrapper, div.fullsize-sh-wrap").remove();var e=a(window).width(),d=a(window).height(),h=a(window).scrollTop(),f=a(window).scrollLeft();if(!a.support.opacity&&parseInt(a.browser.version.substr(0,1))<"8")var n=(e-b.leftOffset)/2+f-25,o=(d-b.topOffset)/2+h-25;else var n=(e+b.leftOffset)/2+f-25,o=(d+b.topOffset)/2+h-25;var k=a("<div></div>").addClass("fullsize-loading").css({"margin-left":n,"margin-top":o}),m=a("<div></div>").addClass("fullsize-loading-inner");a(k).prepend(m);a("body").prepend(k);var l=new Image;a(l).load(function(){a(this).hide();var n=c.offset();img_w=this.width;img_h=this.height;aspect=img_w/img_h;if(img_w+b.leftOffset+32>e){img_w=e-b.leftOffset-32;img_h=img_w/aspect}if(img_h+b.topOffset+36>d){img_h=d-b.topOffset-36;img_w=img_h*aspect}if(!a.support.opacity&&parseInt(a.browser.version.substr(0,1))<"8")var o=Math.round((e-b.leftOffset-img_w)/2+f),k=Math.round((d-b.topOffset-img_h)/2+h);else var o=Math.round((e+b.leftOffset-img_w)/2+f),k=Math.round((d+b.topOffset-img_h)/2+h);if(o<0)o=0;if(k<0)k=0;a(this).css({height:c.height()+"px",width:c.width()+"px"});a("div.fullsize-loading").remove();var j=a("<div></div>").addClass("fullsize-wrapper").css({display:"none","margin-top":n.top,"margin-left":n.left});a(j).prepend(this);if(g!=""||b.forceTitleBar==true){var B=a("<a></a>").addClass("fullsize-close"),q=a("<div></div>").addClass("fullsize-title").css({"max-width":img_w}),z=a("<div></div>").addClass("fullsize-title-text").text(g);a(q).prepend(B);a(q).prepend(z);a(j).prepend(q);a("body").prepend(j);if(k!=0)k=k-12}else{a(this).addClass("fullsize-close");a("body").prepend(j)}if(b.shadow==true)if(a.browser.safari||a.browser.mozilla&&a.browser.version.substr(0,5)>="1.9.1")a(j).css({"-webkit-box-shadow":"0 2px 16px #000","-moz-box-shadow":"0 2px 16px #000","box-shadow":"0 2px 16px #000"});else{var m=a("<div></div>").addClass("fullsize-sh-wrap").css({display:"none",width:c.width(),"margin-top":n.top,"margin-left":n.left}),s=a("<div></div>").addClass("fullsize-sh-top"),y=a("<div></div>").addClass("fullsize-sh-top-l"),w=a("<div></div>").addClass("fullsize-sh-top-m"),x=a("<div></div>").addClass("fullsize-sh-top-r");a(s).append(y).append(x).append(w);a(m).prepend(s);var p=a("<div></div>").addClass("fullsize-sh-body"),A=a("<div></div>").addClass("fullsize-sh-body-r");a(p).append(A);a(m).append(p);var r=a("<div></div>").addClass("fullsize-sh-bottom"),v=a("<div></div>").addClass("fullsize-sh-bottom-l"),t=a("<div></div>").addClass("fullsize-sh-bottom-m"),u=a("<div></div>").addClass("fullsize-sh-bottom-r");a(r).append(v).append(u).append(t);a(m).append(r);a("body").prepend(m);a(p).animate({height:parseInt(j.height())+img_h-22},{queue:false,duration:b.zoomInSpeed});a(m).fadeIn(b.fadeInSpeed).animate({height:parseInt(j.height())+img_h+22,width:img_w+22,marginTop:k-9,marginLeft:o-11},{queue:false,duration:b.zoomInSpeed})}a(this).fadeIn(b.fadeInSpeed).animate({height:img_h,width:img_w},{queue:false,duration:b.zoomInSpeed});a(j).fadeIn(b.fadeInSpeed).animate({width:img_w,marginTop:k,marginLeft:o},{queue:false,duration:b.zoomInSpeed});a(".fullsize-close").click(function(){i(l,j,c,a(this))})}).attr("src",j).addClass("fullsize-image")});function i(f,e,c,g){var d=c.offset();a(f).fadeOut(b.fadeOutSpeed).animate({height:c.height(),width:c.width()},{queue:false,duration:b.zoomOutSpeed});b.shadow==true&&a("div.fullsize-sh-wrap").remove();a(e).fadeOut(b.fadeOutSpeed).animate({width:c.width(),marginTop:d.top,marginLeft:d.left},{queue:false,duration:b.zoomOutSpeed,complete:function(){g.remove()}});b.end.call(this)}}})}})(jQuery);
