
mapState={'dropbox':false,'gdir':null}
function showDropBox(e,t,o){if(!mapState.dropbox){var input=Ext.get(t);var parent=input.findParent('.dropwrapper',10,true);var list=parent.child('.dropdown');list.slideIn('t');list.setVisible(true);list.on('mouseleave',hideDropBox)
mapState.dropbox=true;}else{hideDropBox(e,t,o);}}
function hideDropBox(e,t,o){if(mapState.dropbox){var input=Ext.get(t);var parent=input.findParent('.dropwrapper',10,true);var list=parent.child('.dropdown');list.slideOut('t');mapState.dropbox=false;}}
function setFromLocation(e,t,o){e.stopEvent();var litem=Ext.get(t);var parent=litem.findParent('.dropwrapper',10,true);var input=parent.child('input');var label=t.innerHTML;input.dom.value=label;getDirections({from:label});}
function setDirections(e,t,o){var litem=Ext.get(t);var parent=litem.findParent('.dropwrapper',10,true);var input=parent.child('input');getDirections({from:input.getValue()});}
function clearDirections(e,t,o){window.map.clearOverlays();if(mapState.gdir){mapState.gdir.clear();}
window.map.returnToSavedPosition()
var latlng=new GLatLng(39.946118,-105.164956);window.map.addOverlay(new GMarker(latlng));e.stopEvent();}
function getDirections(opts){window.map.clearOverlays();var obj={to:"39.946118,-105.164956",from:"Denver International Airport"}
obj=Ext.apply(obj,opts);if(mapState.gdir==null){mapState.gdir=new GDirections(window.map);}
mapState.gdir.clear();var query=" from "+obj.from+" to "+obj.to;mapState.gdir.load(query);GEvent.addListener(mapState.gdir,"error",directionsError);var sadr=Ext.get('saddr');sadr.dom.value=obj.from;showLink();}
function showLink(){Ext.select('.directions_link').setVisible(true);Ext.select('.directions_link').on('click',gotoGoogle)}
function gotoGoogle(e,v,t){e.stopEvent();document.viewmapform.submit();}
function directionsError(){}
Ext.onReady(function(){var from=Ext.get('directions_from');var drop=Ext.get('dropdown_button');var clr=Ext.get('clear_directions');clr.on('click',clearDirections);from.on('click',showDropBox);from.on('keydown',function(e,v,t){if(mapState.dropbox){hideDropBox(e,v,t);}
if(e.getKey()==13){setDirections(e,v,t);}})
drop.on('click',showDropBox);Ext.select('.dropdown a').on('click',setFromLocation);Ext.select('.dropwrapper #get_directions').on('click',setDirections);if(GBrowserIsCompatible()){window.map=new GMap2(document.getElementById("map_canvas"));window.map.setCenter(new GLatLng(39.946118,-105.164956),13);window.map.setUIToDefault();var latlng=new GLatLng(39.946118,-105.164956);window.map.addOverlay(new GMarker(latlng));var bnds=window.map.getBounds();window.map.savePosition();}});
