function getPageScroll(){var a;if(self.pageYOffset){a=self.pageYOffset}else if(document.documentElement&&document.documentElement.scrollTop){a=document.documentElement.scrollTop}else if(document.body){a=document.body.scrollTop}arrayPageScroll=new Array('',a)return arrayPageScroll}function getPageSize(){var a,yScroll;if(window.innerHeight&&window.scrollMaxY){a=document.body.scrollWidth;yScroll=window.innerHeight+window.scrollMaxY}else if(document.body.scrollHeight>document.body.offsetHeight){a=document.body.scrollWidth;yScroll=document.body.scrollHeight}else{a=document.body.offsetWidth;yScroll=document.body.offsetHeight}var b,windowHeight;if(self.innerHeight){b=self.innerWidth;windowHeight=self.innerHeight}else if(document.documentElement&&document.documentElement.clientHeight){b=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight}else if(document.body){b=document.body.clientWidth;windowHeight=document.body.clientHeight}if(yScroll<windowHeight){pageHeight=windowHeight}else{pageHeight=yScroll}if(a<b){pageWidth=b}else{pageWidth=a}arrayPageSize=new Array(pageWidth,pageHeight,b,windowHeight)return arrayPageSize}function pause(a){var b=new Date();var c=b.getTime()+a;while(true){b=new Date();if(b.getTime()>c)return}}function getKey(e){if(e==null){keycode=event.keyCode}else{keycode=e.which}key=String.fromCharCode(keycode).toLowerCase();if(key=='x'){hideLightbox()}}function listenKey(){document.onkeypress=getKey}function showLightbox(c){var d=document.getElementById('overlay');var e=document.getElementById('lightbox');var f=document.getElementById('lightboxCaption');var g=document.getElementById('lightboxImage');var h=document.getElementById('loadingImage');var i=getPageSize();var j=getPageScroll();if(h){h.style.top=(j[1]+((i[3]-35-h.height)/2)+'px');h.style.left=(((i[0]-20-h.width)/2)+'px');h.style.display='block'}d.style.height=(i[1]+'px');d.style.display='block';imgPreload=new Image();imgPreload.onload=function(){g.src=c.href;var a=j[1]+((i[3]-35-imgPreload.height)/2);var b=((i[0]-20-imgPreload.width)/2);e.style.top=(a<0)?"0px":a+"px";e.style.left=(b<0)?"0px":b+"px";if(c.getAttribute('title')){f.style.display='block';f.style.width=imgPreload.width+'px';f.innerHTML=c.getAttribute('title')}else{f.style.display='none'}if(navigator.appVersion.indexOf("MSIE")!=-1){pause(250)}if(h){h.style.display='none'}e.style.display='block';i=getPageSize();d.style.height=(i[1]+'px');listenKey();return false}imgPreload.src=c.href}function hideLightbox(){objOverlay=document.getElementById('overlay');objLightbox=document.getElementById('lightbox');objOverlay.style.display='none';objLightbox.style.display='none';document.onkeypress=''}function initLightbox(){if(!document.getElementsByTagName){return}var c=document.getElementsByTagName("a");for(var i=0;i<c.length;i++){var d=c[i];if(d.getAttribute("href")&&(d.getAttribute("rel")=="lightbox")){d.onclick=function(){showLightbox(this);return false}}}var e=document.getElementsByTagName("body").item(0);var f=document.createElement("div");f.setAttribute('id','overlay');f.style.display='none';f.style.position='absolute';f.style.top='0';f.style.left='0';f.style.zIndex='90';f.style.width='100%';e.insertBefore(f,e.firstChild);var g=getPageSize();var h=getPageScroll();var j=new Image();j.onload=function(){var a=document.createElement("a");a.setAttribute('href','#');a.onclick=function(){hideLightbox();return false}f.appendChild(a);var b=document.createElement("img");b.src=loadingImage;b.setAttribute('id','loadingImage');b.style.position='absolute';b.style.zIndex='150';a.appendChild(b);j.onload=function(){};return false}j.src=loadingImage;var k=document.createElement("div");k.setAttribute('id','lightbox');k.style.display='none';k.style.position='absolute';k.style.zIndex='100';e.insertBefore(k,f.nextSibling);var l=document.createElement("a");l.setAttribute('href','#');l.setAttribute('title','Click to close');l.onclick=function(){hideLightbox();return false}k.appendChild(l);var m=new Image();m.onload=function(){var a=document.createElement("img");a.src=closeButton;a.setAttribute('id','closeButton');a.style.position='absolute';a.style.zIndex='200';a.style.top='5px';a.style.right='5px';l.appendChild(a);return false}m.src=closeButton;var n=document.createElement("img");n.setAttribute('id','lightboxImage');l.appendChild(n);var o=document.createElement("div");o.setAttribute('id','lightboxCaption');o.style.display='none';k.appendChild(o)}function addLoadEvent(a){var b=window.onload;if(typeof window.onload!='function'){window.onload=a}else{window.onload=function(){b();a()}}}addLoadEvent(initLightbox);
