var map;var directionsPanel;var viewportWidth;var viewportHeight;if(typeof window.innerWidth!='undefined'){viewportWidth=window.innerWidth;viewportHeight=window.innerHeight}else if(typeof document.documentElement!='undefined'&&typeof document.documentElement.clientWidth!='undefined'&&document.documentElement.clientWidth!=0){viewportWidth=document.documentElement.clientWidth;viewportHeight=document.documentElement.clientHeight}else{viewportWidth=document.getElementsByTagName('body')[0].clientWidth;viewportHeight=document.getElementsByTagName('body')[0].clientHeight}var mapBox=document.getElementById("map");mapBox.style.height=(viewportHeight-15-mapBox.offsetTop)+"px";map=new GMap2(mapBox);map.setUIToDefault();var point=new GLatLng(53.79667770714534,-1.5319141745567322);var addressMarker=new GMarker(point);map.setCenter(point,15);map.addOverlay(addressMarker);var errorBox=document.getElementById("error");errorBox.style.display="none";directionsPanel=document.getElementById("directions");directionsPanel.style.height=(viewportHeight-117-directionsPanel.offsetTop)+"px";var directions=new GDirections(map,directionsPanel);GEvent.addListener(directions,"load",function(){document.getElementById("init").style.display="none";document.getElementById("error").style.display="none";document.getElementById("print").style.display="block";map.removeOverlay(addressMarker)});GEvent.addListener(directions,"error",function(){var code=directions.getStatus().code;if(code==G_GEO_UNKNOWN_ADDRESS)errorMessage("Sorry, the address you entered could not be found. Try writing the address in full, e.g. 80 York St, Leeds");else if(code==G_GEO_SERVER_ERROR)errorMessage("An error has occured on the Google Maps server. If you have sat nav, please program it for LS9 8AA");else alert("An unknown error has occured. If you have sat nav, please program it for LS9 8AA")});GEvent.addListener(directions,"addoverlay",function(){directionsPanel.innerHTML=directionsPanel.innerHTML.replace(/_graybg/g,"")});function errorMessage(message){errorBox.innerHTML=message;errorBox.style.display="block"}function directionsFromStation(){directions.load("from: New Station St, Leeds, Leeds, LS1, UK (Leeds City Station) to: 80 York St, Leeds, Leeds, LS9 8AA",{travelMode:G_TRAVEL_MODE_WALKING})}function getDirections(){var address=document.getElementById("from").value;address=address.replace(/([A-PR-UWYZ][A-HK-Y0-9][A-HJKSTUW0-9]?[ABEHMNPRVWXY0-9]?) +([0-9][ABD-HJLN-UW-Z]{2})/i,'$1$2');directions.load("from: "+address+", UK to: 80 York St, Leeds, Leeds, LS9 8AA",{travelMode:G_TRAVEL_MODE_DRIVING})}
