window.onload=function(){b();function b(){var i=$("nav");var h=i.getElements("a");var g=0;h.each(function(k){g+=k.getSize().x});var j=i.getWidth()-g;while(j>1){h.each(function(k){if(j>1){k.setStyle("padding-left",k.getStyle("padding-left").toInt()+1+"px");j--}if(j>1){k.setStyle("padding-right",k.getStyle("padding-right").toInt()+1+"px");j--}})}}if($("gallery")){var f=$("lastPopout");f.getElement(".arrow").style.top=f.measure(function(){return this.getSize().y})-24+"px";$("gallery").removeClass("gallery");var c=new CrossFadingPresentation("gallery",{transitionDuration:300,transitionInterval:5000,transitionType:Fx.Transitions.Quad.easeInOut})}var e=$$(".sliding-presentation");e.each(function(h){var g=new SlidingPresentation(h,{transitionDuration:500,transitionInterval:6000,transitionType:Fx.Transitions.Quad.easeInOut})});function d(){var x=document.getElementById("map");var t=x.childNodes;for(var q=t.length-1;q>-1;q--){x.removeChild(t[q])}var n=document.createElement("div");n.setAttribute("id","mapWrapper");x.appendChild(n);var g;var u=new google.maps.DirectionsService();var v=new google.maps.LatLng(51.4980677,-0.1020732);var l={zoom:13,center:v,mapTypeId:google.maps.MapTypeId.ROADMAP};g=new google.maps.Map(n,l);var o=new google.maps.MarkerImage("js/images/cerebMapPointer.png",new google.maps.Size(75,21),new google.maps.Point(0,0),new google.maps.Point(27,21));var s=new google.maps.MarkerImage("js/images/shadow-cerebMapPointer.png",new google.maps.Size(86,21),new google.maps.Point(0,0),new google.maps.Point(27,21));var p=new google.maps.Marker({position:v,map:g,shadow:s,icon:o,title:"CEREB"});google.maps.event.addListener(p,"click",function(){g.setZoom(12);g.setCenter(v)});var r=document.createElement("form");var j=document.createElement("label");var h=document.createElement("input");var k=document.createElement("input");r.setAttribute("id","directionsForm");j.setAttribute("for","startLocation");j.appendChild(document.createTextNode("For directions, enter an address below"));h.setAttribute("type","text");h.setAttribute("name","startLocation");h.setAttribute("id","startLocation");k.setAttribute("type","submit");k.setAttribute("name","submit");k.setAttribute("class","submit");k.setAttribute("value","Go");k.style.width="auto";k.style.marginTop="0em";k.style.marginBottom="0em";k.style.backgroundColor="#798f3a";k.style.color="#ffffff";r.appendChild(j);r.appendChild(h);r.appendChild(k);x.appendChild(r);var w=new google.maps.DirectionsRenderer();var m=false;k.onclick=function(){var i=document.getElementById("startLocation").value;var y=new google.maps.Geocoder();if(y){y.geocode({address:i},function(C,B){if(B==google.maps.GeocoderStatus.OK){var z=C[0].geometry.location;var G=v;var A={origin:z,destination:G,travelMode:google.maps.DirectionsTravelMode.WALKING};u.route(A,function(J,K){if(K==google.maps.DirectionsStatus.OK){if(m==true){var P=document.getElementById("errors");P.parentNode.removeChild(P);m=false}w.setMap(g);w.setDirections(J);a()}else{if(m==true){w.setMap(null);var P=document.getElementById("errors");var N=P.childNodes;for(var M=N.length-1;M>-1;M--){P.removeChild(N[M])}var O=new Array("Google wasn't able to pinpoint your starting point.","The most common reason for this is that somewhere in the world shares the same name as the starting point which you entered.","Try using a more specific address or the address of somewhere nearby as a starting point for your journey.","For example, if you are leaving from London Waterloo train station, try entering 'London Waterloo', rather than 'Waterloo' alone.");for(var M=0;M<O.length;M++){var L=document.createElement("p");L.appendChild(document.createTextNode(O[M]));P.appendChild(L)}x.appendChild(P);g.setZoom(12);g.setCenter(v);a()}else{w.setMap(null);m=true;var P=document.createElement("div");P.setAttribute("id","errors");var O=new Array("Google wasn't able to pinpoint your starting point.","The most common reason for this is that somewhere in the world shares the same name as the starting point which you entered.","Try using a more specific address or the address of somewhere nearby as a starting point for your journey.","For example, if you are leaving from London Waterloo train station, try entering 'London Waterloo', rather than 'Waterloo' alone.");for(var M=0;M<O.length;M++){var L=document.createElement("p");L.appendChild(document.createTextNode(O[M]));P.appendChild(L)}x.appendChild(P);g.setZoom(12);g.setCenter(v);a()}}})}else{if(m==true){w.setMap(null);var H=document.getElementById("errors");var F=H.childNodes;for(var D=F.length-1;D>-1;D--){H.removeChild(F[D])}var I=new Array("Sorry, we couldn't find the place you searched for.","Check your spelling and try again.","Alternatively, try the name of a different, nearby location.","Remember, you don't need to enter the full address. You can save time by entering just a postcode or town name.");for(var D=0;D<I.length;D++){var E=document.createElement("p");E.appendChild(document.createTextNode(I[D]));H.appendChild(E)}x.appendChild(H);g.setZoom(12);g.setCenter(v);a()}else{w.setMap(null);m=true;var H=document.createElement("div");H.setAttribute("id","errors");var I=new Array("Sorry, we couldn't find the place you searched for.","Check your spelling and try again.","Alternatively, try the name of a different, nearby location.","Remember, you don't need to enter the full address. You can save time by entering just a postcode or town name.");for(var D=0;D<I.length;D++){var E=document.createElement("p");E.appendChild(document.createTextNode(I[D]));H.appendChild(E)}x.appendChild(H);g.setZoom(12);g.setCenter(v);a()}}})}return false}}if($("map")){d()}};Element.implement({measure:function(e){var g=function(h){return !!(!h||h.offsetHeight||h.offsetWidth)};if(g(this)){return e.apply(this)}var d=this.getParent(),f=[],b=[];while(!g(d)&&d!=document.body){b.push(d.expose());d=d.getParent()}var c=this.expose();var a=e.apply(this);c();b.each(function(h){h()});return a},expose:function(){if(this.getStyle("display")!="none"){return $empty}var a=this.style.cssText;this.setStyles({display:"block",position:"absolute",visibility:"hidden"});return function(){this.style.cssText=a}.bind(this)},getDimensions:function(a){a=$merge({computeSize:false},a);var f={};var d=function(g,e){return(e.computeSize)?g.getComputedSize(e):g.getSize()};var b=this.getParent("body");if(b&&this.getStyle("display")=="none"){f=this.measure(function(){return d(this,a)})}else{if(b){try{f=d(this,a)}catch(c){}}else{f={x:0,y:0}}}return $chk(f.x)?$extend(f,{width:f.x,height:f.y}):$extend(f,{x:f.width,y:f.height})},getComputedSize:function(a){a=$merge({styles:["padding","border"],plains:{height:["top","bottom"],width:["left","right"]},mode:"both"},a);var c={width:0,height:0};switch(a.mode){case"vertical":delete c.width;delete a.plains.width;break;case"horizontal":delete c.height;delete a.plains.height;break}var b=[];$each(a.plains,function(g,f){g.each(function(h){a.styles.each(function(i){b.push((i=="border")?i+"-"+h+"-width":i+"-"+h)})})});var e={};b.each(function(f){e[f]=this.getComputedStyle(f)},this);var d=[];$each(a.plains,function(g,f){var h=f.capitalize();c["total"+h]=c["computed"+h]=0;g.each(function(i){c["computed"+i.capitalize()]=0;b.each(function(k,j){if(k.test(i)){e[k]=e[k].toInt()||0;c["total"+h]=c["total"+h]+e[k];c["computed"+i.capitalize()]=c["computed"+i.capitalize()]+e[k]}if(k.test(i)&&f!=k&&(k.test("border")||k.test("padding"))&&!d.contains(k)){d.push(k);c["computed"+h]=c["computed"+h]-e[k]}})})});["Width","Height"].each(function(g){var f=g.toLowerCase();if(!$chk(c[f])){return}c[f]=c[f]+this["offset"+g]+c["computed"+g];c["total"+g]=c[f]+c["total"+g];delete c["computed"+g]},this);return $extend(e,c)}});
