;(function(){$.extend($.fn,{showBoxyImage:function(imgName)
{$(new Image()).attr({src:"/skins/common/images/nav-previous-arrow.png",src:"/skins/common/images/nav-previous-arrow-active.png",src:"/skins/common/images/nav-previous-arrow-hover.png",src:"/skins/common/images/nav-next-arrow.png",src:"/skins/common/images/nav-next-arrow-hover.png",src:"/skins/common/images/nav-next-arrow-active.png"});sbip.bic=$("#boxyImgCenter");sbip.maxH=0;sbip.maxW=sbip.bic.prev().children("h2").width()+ 30;sbip.boxyImg=$(new Image()).attr({onLoad:"$.fn.BoxyImgOnLoad(); return true;",src:imgName});return true;},BoxyImgOnLoad:function(){sbip.bic.find('p').remove();sbip.bic.parent().css({"background-color":"transparent"});sbip.bic.parents(".boxy-wrapper").css("display","block");sbip.bic.before($(document.createElement("div")).attr('id','boxyImgBgDiv').addClass('showBoxyFullsizeBg'));$.fn.showBoxyImageLoaded();},showBoxyImageEx:function(imgName,isNextSrc)
{(isNextSrc)?sbip.eventSrc=sbip.nextUrlSrc:sbip.eventSrc=sbip.prevUrlSrc;sbip.boxyImg=$(new Image()).attr({onLoad:"$.fn.showBoxyImageLoaded();",src:imgName});return true;},showBoxyImageLoaded:function()
{$.fn.showBoxyGalleryControls();var bh=document.documentElement.clientHeight;var bw=document.body.clientWidth;var nw=ow=sbip.boxyImg.attr('width');var nh=oh=sbip.boxyImg.attr('height');if(nw>bw-30)
{nw=bw- 30;nh=oh*(nw/ow);}
if(nh>bh-60)
{nh=bh- 60;nw=ow*(nh/oh);}
if(nh>sbip.maxH)
sbip.maxH=nh;if(nw>sbip.maxW)
sbip.maxW=nw;var fullsizeImg=$(document.createElement('img')).attr({src:sbip.boxyImg.attr('src'),onClick:'Boxy.get(this).hideAndUnload(); return false;',width:nw,height:nh,id:"fullsizeImg"}).css("margin-top",((sbip.maxH-nh)/2)+"px").css("filter","alpha(opacity=100)");sbip.bic.append(fullsizeImg);if(boxyWidth=parseInt($(".showBoxyFullsizePrev").css("width")))
boxyWidth=boxyWidth*2+ sbip.maxW;else
boxyWidth=sbip.maxW;sbip.bic.width(boxyWidth).height(sbip.maxH);sbip.bic.prev().width(boxyWidth).height(sbip.maxH);navbuttonHeight=parseInt($(".showBoxyFullsizePrev").css("height"));$(".showBoxyFullsizePrev").css("margin-top",(sbip.maxH/2- navbuttonHeight/2)+"px");$(".showBoxyFullsizeNext").css("margin-top",(sbip.maxH/2- navbuttonHeight/2)+"px");sbi.boxyInst.setTitle('Viewing '+ fullsizeImg.attr('src').substr(fullsizeImg.attr('src').lastIndexOf('/')+1)).center();return true;},showBoxyGalleryControls:function()
{if(sbip.eventSrc.parents("table.gallery").find("img").length>1)
{nextUrlSrc=sbip.eventSrc.parents(".gallerybox").parent().next().find("img");nextUrl=nextUrlSrc.attr("src");if(!nextUrl)
{nextUrlSrc=sbip.eventSrc.parents(".gallerybox").parent().parent().next().find("img:first");nextUrl=nextUrlSrc.attr("src");if(!nextUrl)
{nextUrlSrc=sbip.eventSrc.parents("table.gallery").find("img:first");nextUrl=nextUrlSrc.attr("src");}}
nextUrl=$.fn.fixThumbUrl(nextUrl);sbip.nextUrlSrc=nextUrlSrc;prevUrlSrc=sbip.eventSrc.parents(".gallerybox").parent().prev().find("img");prevUrl=prevUrlSrc.attr("src");if(!prevUrl)
{prevUrlSrc=sbip.eventSrc.parents(".gallerybox").parent().parent().prev().find("img:last");prevUrl=prevUrlSrc.attr("src");if(!prevUrl)
{prevUrlSrc=sbip.eventSrc.parents("table.gallery").find("img:last");prevUrl=prevUrlSrc.attr("src");}}
prevUrl=$.fn.fixThumbUrl(prevUrl);sbip.prevUrlSrc=prevUrlSrc;prevImg=document.createElement("img");$(prevImg).attr({src:"/skins/common/images/spacer.png",className:"showBoxyFullsizePrev",onClick:"$.fn.showBoxyImageEx('"+ prevUrl+"', false); return true;"});nextImg=document.createElement("img");$(nextImg).attr({src:"/skins/common/images/spacer.png",className:"showBoxyFullsizeNext",onClick:"$.fn.showBoxyImageEx('"+ nextUrl+"',true); return true;"});sbip.bic.find("img").remove();sbip.bic.append(prevImg).append(nextImg);}},fixThumbUrl:function(thumbUrl)
{if(thumbUrl.indexOf("/thumb")>=0)
return thumbUrl.replace(/\/thumb/,"").replace(/\/[0-9]+px-.*$/,"");else
return thumbUrl;}});var sbi=$.fn.showBoxyImage;var sbip=sbi.properties={maxW:0,maxH:0};})();$(function(){$('a.image img').click(function(e){var fileLink=/^\/File:.+\.?[png|jpg|jpeg|gif|svg]$/;if(fileLink.test($(this).parent().attr("href")))
{var imgName=$.fn.fixThumbUrl($(this).attr("src"));$.fn.showBoxyImage.boxyInst=new Boxy('<center id="boxyImgCenter" style="padding:0;"><p class="loadingNote">Loading the image...</p></center>',{title:'Viewing '+ imgName.substr(imgName.lastIndexOf('/')+1),closeable:true,modal:true,closeText:'<b class="closebox">&nbsp;&Chi;&nbsp;<b>'});$.fn.showBoxyImage.properties.eventSrc=$(e.target);$.fn.showBoxyImage(imgName);}
return false;});});
