Object.extend(String.prototype,{ensureEndsWith:function(a){return this.endsWith(a)?this:this+a;},px:function(){return this.ensureEndsWith("px");}});Object.extend(Number.prototype,{px:function(){return this.toString().px();}});var Window={size:function(){var c=window.innerWidth||(window.document.documentElement.clientWidth||window.document.body.clientWidth);var b=window.innerHeight||(window.document.documentElement.clientHeight||window.document.body.clientHeight);var a=window.pageXOffset||(window.document.documentElement.scrollLeft||window.document.body.scrollLeft);var d=window.pageYOffset||(window.document.documentElement.scrollTop||window.document.body.scrollTop);return{width:c,height:b,x:a,y:d};}};var FancyZoomBox={directory:"img",zooming:false,setup:false,init:function(c){if(FancyZoomBox.setup){return;}FancyZoomBox.setup=true;var e=navigator.userAgent.match(/MSIE\s(\d)+/);if(e){var b=parseInt(e[1]);Prototype.Browser["IE"+b.toString()]=true;Prototype.Browser.ltIE7=(b<7)?true:false;}var d='<div id="zoom" style="display:none;">                   <table id="zoom_table" style="border-collapse:collapse; width:100%; height:100%;">                     <tbody>                       <tr>                         <td class="tl" style="background:url('+FancyZoomBox.directory+'/tl.png) 0 0 no-repeat; width:20px height:20px; overflow:hidden;" />                         <td class="tm" style="background:url('+FancyZoomBox.directory+'/tm.png) 0 0 repeat-x; height:20px; overflow:hidden;" />                         <td class="tr" style="background:url('+FancyZoomBox.directory+'/tr.png) 100% 0 no-repeat; width:20px height:20px; overflow:hidden;" />                       </tr>                       <tr>                         <td class="ml" style="background:url('+FancyZoomBox.directory+'/ml.png) 0 0 repeat-y; width:20px; overflow:hidden;" />                         <td class="mm" style="background:#fff; vertical-align:top; padding:10px;">                           <div id="zoom_content">                           </div>                         </td>                         <td class="mr" style="background:url('+FancyZoomBox.directory+'/mr.png) 100% 0 repeat-y;  width:20px; overflow:hidden;" />                       </tr>                       <tr>                         <td class="bl" style="background:url('+FancyZoomBox.directory+'/bl.png) 0 100% no-repeat; width:20px height:20px; overflow:hidden;" />                         <td class="bm" style="background:url('+FancyZoomBox.directory+'/bm.png) 0 100% repeat-x; height:20px; overflow:hidden;" />                         <td class="br" style="background:url('+FancyZoomBox.directory+'/br.png) 100% 100% no-repeat; width:20px height:20px; overflow:hidden;" />                       </tr>                     </tbody>                   </table>                   <a href="#" title="Close" id="zoom_close" style="position:absolute; top:0; left:0;">                     <img src="'+FancyZoomBox.directory+'/closebox.png" alt="Close" style="border:none; margin:0; padding:0;" />                   </a>                 </div>';var a=$$("body").first();a.insert(d);FancyZoomBox.zoom=$("zoom");FancyZoomBox.zoom_table=$("zoom_table");FancyZoomBox.zoom_close=$("zoom_close");FancyZoomBox.zoom_content=$("zoom_content");FancyZoomBox.zoom_close.observe("click",FancyZoomBox.hide);FancyZoomBox.middle_row=$A([$$("td.ml"),$$("td.mm"),$$("td.mr")]).flatten();FancyZoomBox.cells=FancyZoomBox.zoom_table.select("td");$$("html").first().observe("click",function(h){var g=h.findElement("#zoom"),f=FancyZoomBox.zoom.getStyle("display");if(f=="block"&&!g){FancyZoomBox.hide(h);}});$(document).observe("keyup",function(g){var f=FancyZoomBox.zoom.getStyle("display");if(g.keyCode==Event.KEY_ESC&&f=="block"){FancyZoomBox.hide(g);}});if(Prototype.Browser.ltIE7){FancyZoomBox.switchBackgroundImagesTo("gif");}},show:function(g){g.stop();if(FancyZoomBox.zooming){return;}FancyZoomBox.zooming=true;var c=g.findElement("a");var f=c.content_div;var a=(c.zoom_width||f.getWidth())+60;var k=(c.zoom_height||f.getHeight())+60;var h=Window.size();var b=document.viewport.getScrollOffsets()[1];var i=Math.max((h.height/2)-(k/2)+b,0);var j=(h.width/2)-(a/2);FancyZoomBox.curTop=g.pointerY();FancyZoomBox.curLeft=g.pointerX();FancyZoomBox.moveX=-(FancyZoomBox.curLeft-j);FancyZoomBox.moveY=-(FancyZoomBox.curTop-i);FancyZoomBox.zoom.hide().setStyle({position:"absolute",top:FancyZoomBox.curTop.px(),left:FancyZoomBox.curLeft.px()});new Effect.Parallel([new Effect.Appear(FancyZoomBox.zoom,{sync:true}),new Effect.Move(FancyZoomBox.zoom,{x:FancyZoomBox.moveX,y:FancyZoomBox.moveY,sync:true}),new Effect.Morph(FancyZoomBox.zoom,{style:{width:a.px(),height:k.px()},sync:true,beforeStart:function(d){if(Prototype.Browser.IE){FancyZoomBox.middle_row.invoke("setStyle",{height:(k-40).px()});}FancyZoomBox.fixBackgroundsForIE();},afterFinish:function(d){FancyZoomBox.zoom_content.innerHTML=f.innerHTML;FancyZoomBox.unfixBackgroundsForIE();FancyZoomBox.zoom_close.show();FancyZoomBox.zooming=false;}})],{duration:0.5});},hide:function(a){a.stop();if(FancyZoomBox.zooming){return;}FancyZoomBox.zooming=true;new Effect.Parallel([new Effect.Move(FancyZoomBox.zoom,{x:FancyZoomBox.moveX*-1,y:FancyZoomBox.moveY*-1,sync:true}),new Effect.Morph(FancyZoomBox.zoom,{style:{width:"1".px(),height:"1".px()},sync:true,beforeStart:function(b){FancyZoomBox.fixBackgroundsForIE();FancyZoomBox.zoom_content.innerHTML="";FancyZoomBox.zoom_close.hide();},afterFinish:function(b){FancyZoomBox.unfixBackgroundsForIE();FancyZoomBox.zooming=false;}}),new Effect.Fade(FancyZoomBox.zoom,{sync:true})],{duration:0.5});},switchBackgroundImagesTo:function(c){FancyZoomBox.cells.each(function(e){var d=e.getStyle("background-image").gsub(/\.(png|gif|none)\)$/,"."+c+")");e.setStyle("background-image: "+d);});var b=FancyZoomBox.zoom_close.firstDescendant();var a=b.readAttribute("src").gsub(/\.(png|gif|none)$/,"."+c);b.writeAttribute("src",a);},fixBackgroundsForIE:function(){if(Prototype.Browser.IE7){FancyZoomBox.switchBackgroundImagesTo("gif");}},unfixBackgroundsForIE:function(){if(Prototype.Browser.IE7){FancyZoomBox.switchBackgroundImagesTo("png");}}};var FancyZoom=Class.create({initialize:function(a){this.options=arguments.length>1?arguments[1]:{};FancyZoomBox.init();this.element=$(a);if(this.element){this.element.content_div=$(this.element.readAttribute("href").gsub(/^#/,""));this.element.content_div.hide();this.element.zoom_width=this.options.width;this.element.zoom_height=this.options.height;this.element.observe("click",FancyZoomBox.show);}}});
