var Lightbox=Class.create({showHtml:function(a){this.showLoadingState();this.content.update(a);this.doShow()},show:function(a){lightbox.getAndShowContentFromUrl(a)},hide:function(){lightbox.historyPolling.stop();if(this.isIE6()){window.scrollTo(this.scolloffset[0],this.scolloffset[1])}document.getElementsByTagName("html").item(0).style.overflow="auto";this.lightbox.hide();this.content.hide();this.overlay.hide();this.showPersistentObjects(true);this.content.update(" ");if(window.location.hash=="#modal"){history.back(1)}},load:function(){$$("a.lightbox").each(function(a){a.observe("click",function(c){c.stop();var b=Event.findElement(c,"a");if(b!=document){lightbox.show(b.getAttribute("href"))}})})},isVisible:function(){return $("lightbox").visible},initialize:function(){this.history=new Object();var m=document.getElementsByTagName("body").item(0);if(Prototype.Browser.IE){var j=document.createElement("iframe");j.setAttribute("id","lightbox-history-frame");j.style.display="block";j.style.visibility="hidden";j.src="/history-frame.php";j.style.position="absolute";j.style.top="0";j.style.left="0";j.style.width="1px";j.style.height="1px";m.appendChild(j);this.historyFrame=j}var b=document.createElement("div");b.setAttribute("id","lightbox");b.style.display="none";m.appendChild(b);var k=document.createElement("div");k.setAttribute("id","lightbox-overlay");k.style.display="none";b.appendChild(k);var e=document.createElement("div");e.setAttribute("id","lightbox-container");b.appendChild(e);var l=document.createElement("div");l.setAttribute("id","lightbox-close-container");e.appendChild(l);var i=document.createElement("a");i.setAttribute("id","lightbox-close");i.setAttribute("href","#");var h=document.createElement("span");i.appendChild(h);var f=document.createTextNode(getWord("lightbox.close"));h.appendChild(f);l.appendChild(i);var g=document.createElement("div");g.setAttribute("id","lightbox-start");e.appendChild(g);var d=document.createElement("div");d.setAttribute("id","lightbox-spinner");e.appendChild(d);var a=document.createElement("div");a.setAttribute("id","lightbox-content");a.style.display="none";e.appendChild(a);var c=document.createElement("div");c.setAttribute("id","lightbox-end");e.appendChild(c);b.appendChild(e);this.content=$("lightbox-content");this.lightbox=$("lightbox");this.overlay=$("lightbox-overlay");this.close=$("lightbox-close");this.close.observe("click",function(n){n.stop();lightbox.hide()});this.overlay.observe("click",function(n){n.stop();lightbox.hide()});if(Prototype.Browser.Gecko){this.overlay.setStyle({background:"url(/images/lightbox/ff-overlay-img.png)"})}else{this.overlay.setStyle({opacity:0.8})}},prepareHistory:function(){if(Prototype.Browser.IE){lightbox.historyFrame.src="/history-frame.php?modal"}else{window.location.hash="#modal"}lightbox.historyPolling=new PeriodicalExecuter(function(a){var d=false;if(Prototype.Browser.IE){var b=lightbox.historyFrame.contentWindow.document.title;if(b.indexOf("?modal")<0){d=true}}else{var c=window.location.hash;if(window.location.hash!="#modal"){d=true}}if(d){a.stop();if(lightbox.isVisible()){lightbox.hide()}}},1)},isIE6:function(){if(Prototype.Browser.IE&&navigator.appVersion.match(/MSIE 6\.0/)){return true}else{return false}},showPersistentObjects:function(a){$$("select","embed","object").each(function(b){if(a){b.style.visibility="visible"}else{b.style.visibility="hidden"}})},showLoadingState:function(){this.prepareHistory();this.showPersistentObjects(false);$("lightbox-spinner").show();$("lightbox-overlay").show();$("lightbox").show();this.scolloffset=document.viewport.getScrollOffsets();document.getElementsByTagName("html").item(0).style.overflow="hidden";if(Prototype.Browser.IE&&navigator.appVersion.match(/MSIE 6\.0/)){window.scrollTo(0,0)}this.loadingStarted=true},doShow:function(){if(!this.loadingStarted){this.showLoadingState()}$("lightbox-spinner").hide();$("lightbox-content").show()},getAndShowContentFromUrl:function(a){if(a==null){alert("No URL provided");return}this.showLoadingState();new Ajax.Request(a,{method:"get",onSuccess:function(b){$("lightbox-content").update(b.responseText);this.doShow()}.bind(this),onFailure:function(b){this.hide();alert("Could not connect to URL")}.bind(this)})}});
