function addEvent(a,b,c){if(a.addEventListener){a.addEventListener(b,c,false)}else if(a.attachEvent){a.attachEvent(['on',b].join(''),c)}else{a[['on',b].join('')]=c}}function WindowSize(){this.w=0;this.h=0;return this.update()}WindowSize.prototype.update=function(){var d=document;this.w=(window.innerWidth)?window.innerWidth:(d.documentElement&&d.documentElement.clientWidth)?d.documentElement.clientWidth:d.body.clientWidth;this.h=(window.innerHeight)?window.innerHeight:(d.documentElement&&d.documentElement.clientHeight)?d.documentElement.clientHeight:d.body.clientHeight;return this};function PageSize(){this.win=new WindowSize();this.w=0;this.h=0;return this.update()}PageSize.prototype.update=function(){var d=document;this.w=(window.innerWidth&&window.scrollMaxX)?window.innerWidth+window.scrollMaxX:(d.body.scrollWidth>d.body.offsetWidth)?d.body.scrollWidth:d.body.offsetWidt;this.h=(window.innerHeight&&window.scrollMaxY)?window.innerHeight+window.scrollMaxY:(d.body.scrollHeight>d.body.offsetHeight)?d.body.scrollHeight:d.body.offsetHeight;this.win.update();if(this.w<this.win.w)this.w=this.win.w;if(this.h<this.win.h)this.h=this.win.h;return this};function PagePos(){this.x=0;this.y=0;return this.update()}PagePos.prototype.update=function(){var d=document;this.x=(window.pageXOffset)?window.pageXOffset:(d.documentElement&&d.documentElement.scrollLeft)?d.documentElement.scrollLeft:(d.body)?d.body.scrollLeft:0;this.y=(window.pageYOffset)?window.pageYOffset:(d.documentElement&&d.documentElement.scrollTop)?d.documentElement.scrollTop:(d.body)?d.body.scrollTop:0;return this};function UserAgent(){var a=navigator.userAgent;this.isWinIE=this.isMacIE=false;this.isGecko=a.match(/Gecko\//);this.isSafari=a.match(/AppleWebKit/);this.isOpera=window.opera;if(document.all&&!this.isGecko&&!this.isSafari&&!this.isOpera){this.isWinIE=a.match(/Win/);this.isMacIE=a.match(/Mac/);this.isNewIE=(a.match(/MSIE 5\.5/)||a.match(/MSIE 6\.0/))}return this}function LightBox(a){var b=this;b._imgs=new Array();b._wrap=null;b._box=null;b._open=-1;b._page=new PageSize();b._pos=new PagePos();b._ua=new UserAgent();b._expandable=false;b._expanded=false;b._expand=a.expandimg;b._shrink=a.shrinkimg;return b._init(a)}LightBox.prototype={_init:function(a){var b=this;var d=document;if(!d.getElementsByTagName)return;var c=d.getElementsByTagName("a");for(var i=0;i<c.length;i++){var e=c[i];var f=b._imgs.length;if(!e.getAttribute("href")||e.getAttribute("rel")!="lightbox")continue;b._imgs[f]={src:e.getAttribute("href"),w:-1,h:-1,title:'',cls:e.className};if(e.getAttribute("title"))b._imgs[f].title=e.getAttribute("title");else if(e.firstChild&&e.firstChild.getAttribute&&e.firstChild.getAttribute("title"))b._imgs[f].title=e.firstChild.getAttribute("title");e.onclick=b._genOpener(f)}var g=d.getElementsByTagName("body")[0];b._wrap=b._createWrapOn(g,a.loadingimg);b._box=b._createBoxOn(g,a);return b},_genOpener:function(a){var b=this;return function(){b._show(a);return false}},_createWrapOn:function(b,c){var d=this;if(!b)return null;var e=document.createElement('div');e.id='overlay';with(e.style){display='none';position='fixed';top='0px';left='0px';zIndex='50';width='100%';height='100%'}if(d._ua.isWinIE)e.style.position='absolute';addEvent(e,"click",function(){d._close()});b.appendChild(e);var f=new Image;f.onload=function(){var a=document.createElement('img');a.id='loadingImage';a.src=f.src;a.style.position='relative';d._set_cursor(a);addEvent(a,'click',function(){d._close()});e.appendChild(a);f.onload=function(){}};if(c!='')f.src=c;return e},_createBoxOn:function(b,c){var d=this;if(!b)return null;var e=document.createElement('div');e.id='lightbox';with(e.style){display='none';position='absolute';zIndex='60'}b.appendChild(e);var f=document.createElement('img');f.id='lightboxImage';d._set_cursor(f);addEvent(f,'click',function(){d._close()});addEvent(f,'mouseover',function(){d._show_action()});addEvent(f,'mouseout',function(){d._hide_action()});e.appendChild(f);var g=document.createElement('img');g.id='actionImage';with(g.style){display='none';position='absolute';top='15px';left='15px';zIndex='70'}d._set_cursor(g);g.src=d._expand;addEvent(g,'mouseover',function(){d._show_action()});addEvent(g,'click',function(){d._zoom()});e.appendChild(g);addEvent(window,'resize',function(){d._set_size(true)});if(c.closeimg){var h=document.createElement('img');h.id='closeButton';with(h.style){display='inline';position='absolute';right='10px';top='10px';zIndex='80'}h.src=c.closeimg;d._set_cursor(h);addEvent(h,'click',function(){d._close()});e.appendChild(h)}var i=document.createElement('span');i.id='lightboxCaption';with(i.style){display='none';position='absolute';zIndex='80'}e.appendChild(i);if(!c.effectpos)c.effectpos={x:0,y:0};else{if(c.effectpos.x=='')c.effectpos.x=0;if(c.effectpos.y=='')c.effectpos.y=0}var j=new Image;j.onload=function(){var a=document.createElement('img');a.id='effectImage';a.src=j.src;if(c.effectclass)a.className=c.effectclass;with(a.style){position='absolute';display='none';left=[c.effectpos.x,'px'].join('');top=[c.effectpos.y,'px'].join('');zIndex='90'}d._set_cursor(a);addEvent(a,'click',function(){a.style.display='none'});e.appendChild(a)};if(c.effectimg!='')j.src=c.effectimg;return e},_set_photo_size:function(){var a=this;if(a._open==-1)return;var b=a._box.firstChild;var c={w:a._page.win.w-30,h:a._page.win.h-30};var d={w:a._imgs[a._open].w,h:a._imgs[a._open].h};var e=1.0;if((d.w>=c.w||d.h>=c.h)&&d.h&&d.w)e=((c.w/d.w)<(c.h/d.h))?c.w/d.w:c.h/d.h;b.width=Math.floor(d.w*e);b.height=Math.floor(d.h*e);a._expandable=(e<1.0)?true:false;if(a._ua.isWinIE)a._box.style.display="block";a._box.style.top=[a._pos.y+(a._page.win.h-b.height-30)/2,'px'].join('');a._box.style.left=[((a._page.win.w-b.width-30)/2),'px'].join('');a._show_caption(true)},_set_size:function(a){var b=this;if(b._open==-1)return;b._page.update();b._pos.update();var c=b._wrap.firstChild;if(c){var d=(b._page.win.h-c.height)/2;if(b._wrap.style.position=='absolute')d+=b._pos.y;c.style.top=[d,'px'].join('');c.style.left=[(b._page.win.w-c.width-30)/2,'px'].join('')}if(b._ua.isWinIE){b._wrap.style.width=[b._page.win.w,'px'].join('');b._wrap.style.height=[b._page.h,'px'].join('')}if(a)b._set_photo_size()},_show_action:function(){var a=this;if(a._open==-1||!a._expandable)return;var b=document.getElementById('actionImage');if(!b)return;b.src=(a._expanded)?a._shrink:a._expand;b.style.display='inline'},_hide_action:function(){var a=this;var b=document.getElementById('actionImage');if(b)b.style.display='none'},_zoom:function(){var a=this;if(a._expanded){a._set_photo_size();a._expanded=false}else if(a._open>-1){var b=a._box.firstChild;a._box.style.top=[a._pos.y,'px'].join('');a._box.style.left='0px';b.width=a._imgs[a._open].w;b.height=a._imgs[a._open].h;a._show_caption(false);a._expanded=true}a._show_action()},_show_caption:function(a){var b=this;var c=document.getElementById('lightboxCaption');if(!c)return;if(c.innerHTML.length==0||!a){c.style.display='none'}else{var d=b._box.firstChild;with(c.style){top=[d.height+10,'px'].join('');left='0px';width=[d.width+20,'px'].join('');height='1.2em';display='block'}}},_show:function(a){var b=this;var c=new Image;if(a<0||a>=b._imgs.length)return;var d=document.getElementById('loadingImage');var e=document.getElementById('lightboxCaption');var f=document.getElementById('effectImage');b._open=a;b._set_size(false);b._wrap.style.display="block";if(d)d.style.display='inline';c.onload=function(){if(b._imgs[b._open].w==-1){b._imgs[b._open].w=c.width;b._imgs[b._open].h=c.height}if(f){f.style.display=(!f.className||b._imgs[b._open].cls==f.className)?'block':'none'}if(e)e.innerHTML=b._imgs[b._open].title;b._set_photo_size();b._hide_action();b._box.style.display="block";b._box.firstChild.src=c.src;b._box.firstChild.setAttribute('title',b._imgs[b._open].title);if(d)d.style.display='none'};b._expandable=false;b._expanded=false;c.src=b._imgs[b._open].src},_set_cursor:function(a){var b=this;if(b._ua.isWinIE&&!b._ua.isNewIE)return;a.style.cursor='pointer'},_close:function(){var a=this;a._open=-1;a._hide_action();a._wrap.style.display="none";a._box.style.display="none"}};addEvent(window,"load",function(){var a=new LightBox({loadingimg:'gallery/layout/loading.gif',expandimg:'gallery/layout/expand.gif',shrinkimg:'gallery/layout/shrink.gif',effectimg:'gallery/layout/watermark.png',effectpos:{x:-15,y:-15},effectclass:'effectable',closeimg:'gallery/layout/close.gif'})});