var activeColor="#00e1ff";var inactiveColor="#FFF";var stfWrapper;var stfDiv;var linkDiv;String.implement({getHostname:function(){var A=new RegExp("^(?:f|ht)tp(?:s)?://([^/]+)","im");return this.match(A)?this.match(A)[1]:false;}});var cleanSiblings=function(){if($("header").getElement("ul li.active")){$("header").getElement("ul li.active").getPrevious().firstChild.style.borderRight="none";$("header").getElement("ul li.active").style.position="relative";$("header").getElement("ul li.active").style.left="1px";}if((document.getElement("body").id=="location"||document.getElement("body").id=="getting-here")&&document.getElement("body").hasClass("en")){$("header").getElement("ul li.location").getPrevious().firstChild.style.borderRight="none";$("header").getElement("ul li.location").style.position="relative";$("header").getElement("ul li.location").style.left="1px";}if(document.getElement("body").id=="history-architecture"){$("header").getElement("ul li.history-architecture").getPrevious().firstChild.style.borderRight="none";$("header").getElement("ul li.history-architecture").style.position="relative";$("header").getElement("ul li.history-architecture").style.left="1px";}};var initNav=function(){$$("#leftNav li.level2 ul").each(function(A){A.style.display="none";});langSel=document.getElement("form#languageSelector select");if(document.getElement("body").id!="home"){$$("li.level2 > a").each(function(A){if(A.getParent().hasClass("selected")){toggleUl(A.getNext());}A.addEvent("click",function(B){ul=B.target.getNext();if(ul){B.preventDefault();toggleUl(ul);}});});}};var toggleUl=function(A){$$("#leftNav li ul").each(function(B){deactivateUl(B);});if(A&&A.style.display=="none"){activateUl(A);}else{deactivateUl(A);}};var activateUl=function(A){if(A&&document.getElement("body").id!=="home"){deactivateAll();A.parentNode.getElement("a").addClass("selected");A.reveal();}};var deactivateUl=function(A){if(A&&document.getElement("body").id!=="home"){A.getParent().getElement("a").className="";if(A.getStyle("display")!=="none"){A.dissolve();}}};var deactivateAll=function(){$$("#leftNav li.level2 > a").each(function(A){A.className="";A.parentNode.className="";});};var initLanguageListener=function(){languageList=new Element("ul",{id:"languageSelectorReplacement"});masterLang=new Element("li");$$("option").each(function(A){a=new Element("a",{"class":A.get("class"),html:A.get("html"),lang:A.get("lang"),"xml:lang":A.get("xml:lang"),href:"/"+A.get("lang")+"/location"});lang=masterLang.clone();lang.set("class",A.get("class"));lang.grab(a);languageList.grab(lang,A.get("selected")?"top":"bottom");});$("languageSelector").dispose();$("container").grab(languageList,"bottom");languageList.addEvent("mouseenter",function(){languageList.set("class","active");});languageList.addEvent("mouseleave",function(){languageList.set("class",null);});};var initPrintPage=function(){li=new Element("li",{"class":"first print"});a=new Element("a",{html:"Print This Page",href:"#"});li.grab(a,"top");a.addEvent("click",function(A){A.preventDefault();window.print();});$("page-options").grab(li,"top");};var initBackToTop=function(){checkBackToTopVisibility();link=$("backToTop").getElement("a");link.addEvent("click",function(A){A.preventDefault();new Fx.Scroll(window).toTop();});window.addEvent("resize",function(){checkBackToTopVisibility();});};var checkBackToTopVisibility=function(){link=$("backToTop").getElement("a");if($("container").getSize().y<=window.getSize().y){link.fade("hide");}else{link.fade("show");}};var initSendToFriend=function(){stfWrapper=new Element("div",{id:"stf-wrapper"});oBody=window.document.body;oBody.grab(stfWrapper,"bottom");stfDiv=new Element("div",{id:"stf"});oBody.grab(stfDiv,"bottom");stfLink=document.getElement("ul#page-options li.send-to-friend a");stfLink.addEvent("click",function(A){A.preventDefault();req=new Request.HTML({update:stfDiv,evalScripts:true}).get("/ajax-send-to-a-friend?url="+window.location);drawStfLightbox();stfWrapper.addEvent("click",function(){killStfLightBox();});});};var killStfLightbox=function(){killOverlay();stfDiv.set("id","stf");stfDiv.set("html","");};var killOverlay=function(){stfWrapper.set("id","stf-wrapper");stfWrapper.setStyle("height",0);};var drawStfLightbox=function(){drawOverlay();new Fx.Scroll(window).toTop();stfDiv.fade("hide");stfDiv.set("id","stf-active");stfDiv.fade("show");stfWrapper.addEvent("click",function(A){killStfLightbox();});};var drawOverlay=function(){stfWrapper.fade("hide");if($("container").getSize().y>document.getElement("body").getSize().y){height=$("container").getSize().y;}else{height=document.getElement("body").getSize().y;}stfWrapper.setStyle("height",height);stfWrapper.set("id","stf-wrapper-active");stfWrapper.set("opacity",0.5);};Element.implement({externalLink:function(){if($defined(this.get("href"))&&this.get("href").getHostname()&&this.get("href").getHostname()!==document.domain){this.addEvent("click",function(A){if(Cookie.read("links")=="new"){this.set("target","_blank");}else{if(Cookie.read("links")=="same"){return ;}else{A.preventDefault();triggerLinkLightbox(this);}}});}}});var initExternalLinks=function(){oBody=window.document.body;linkDiv=new Element("div",{id:"external-link"});oBody.grab(linkDiv,"bottom");$$("a").each(function(A){A.externalLink();});};var triggerLinkLightbox=function(A){drawOverlay();linkDiv.fade("hide");linkDiv.grab(new Element("p",{html:"You're about to leave the Covent Garden London website and launch:"}));linkDiv.grab(new Element("p",{html:"<strong>"+A.get("href")+"</strong>",styles:{"text-align":"center"}}));linkDiv.grab(new Element("p",{html:"Please choose whether you'd like to launch the new website in this window or a new one:"}));p=new Element("p",{styles:{"text-align":"center"}});sameWindow=new Element("a",{html:"Use this window",href:A.get("href"),"class":"button"});sameWindow.addEvent("click",function(){Cookie.write("links","same",{domain:document.domain,path:"/"});killLinkLightbox();});newWindow=new Element("a",{html:"Open a new window",href:A.get("href"),target:"_blank","class":"button"});newWindow.addEvent("click",function(){Cookie.write("links","new",{domain:document.domain,path:"/"});killLinkLightbox();});p.grab(sameWindow);p.appendText(" ");p.grab(newWindow);linkDiv.grab(p);linkDiv.set("id","external-link-active");linkDiv.fade("show");linkDiv.setStyle("top",window.getScroll().y+(window.getSize().y/2)-100);stfWrapper.addEvent("click",function(){killLinkLightbox();});};var killLinkLightbox=function(){killOverlay();linkDiv.set("id","external-link");linkDiv.set("html","");};window.addEvent("domready",function(){cleanSiblings();initNav();initLanguageListener();initSendToFriend();initPrintPage();initBackToTop();initExternalLinks();});var k=0;var l=0;document.addEvent("keyup",function(A){if((A.key=="up"&&k==0)||(A.key=="up"&&k==1&&l=="up")||(A.key=="down"&&k==2&&l=="up")||(A.key=="down"&&k==3&&l=="down")||(A.key=="left"&&k==4&&l=="down")||(A.key=="right"&&k==5&&l=="left")||(A.key=="left"&&k==6&&l=="right")||(A.key=="right"&&k==7&&l=="left")||(A.key=="b"&&k==8&&l=="right")||(A.key=="a"&&k==9&&l=="b")||(A.key=="enter"&&k==10&&l=="a")){k++;l=A.key;}else{l=0;k=0;}if(k==10){document.getElement("body").setStyles({"background-image":"url(/images/hamster.gif)","background-color":"#FFF"});}});