if(GBrowserIsCompatible()){var gmarkers=[];var htmls=[];var i=0;var to_htmls=[];var from_htmls=[];function createMarker(point,name,html){var marker=new GMarker(point);to_htmls[i]='<strong>'+name+'</strong><br />'+html+'<br />Directions: <strong>To here</strong> - <a href="javascript:fromhere('+i+')">From here</a><form style="margin:0;" action="javascript:getDirections()"><table><tr><td>Start address:</td><td><input type="text" size="40" name="saddr" id="saddr" value="" /></td></tr><tr><td colspan="2"><input value="Get Directions" type="submit"><input type="hidden" id="daddr" value="'+name+"@"+point.lat()+','+point.lng()+'" /></td></tr></table></form>';from_htmls[i]='<strong>'+name+'</strong><br />'+html+'<br />Directions: <a href="javascript:tohere('+i+')">To here</a> - <strong>From here</strong><form style="margin:0;" action="javascript:getDirections()"><table><tr><td>End address:</td><td><input type="text" size="40" name="daddr" id="daddr" value="" /></td></tr><tr><td colspan="2"><input value="Get Directions" type="submit"><input type="hidden" id="saddr" value="'+name+"@"+point.lat()+','+point.lng()+'" /></td></tr></table></form>';html='<strong>'+name+'</strong><br />'+html+'<br />Directions: <a href="javascript:tohere('+i+')">To here</a> - <a href="javascript:fromhere('+i+')">From here</a>';GEvent.addListener(marker,"click",function(){marker.openInfoWindowHtml(html);});gmarkers[i]=marker;htmls[i]=html;i++;return marker;}
function getDirections(){var saddr=document.getElementById("saddr").value
var daddr=document.getElementById("daddr").value
gdir.load("from: "+saddr+" to: "+daddr);}
function myclick(i){gmarkers[i].openInfoWindowHtml(htmls[i]);}
function tohere(i){gmarkers[i].openInfoWindowHtml(to_htmls[i]);}
function fromhere(i){gmarkers[i].openInfoWindowHtml(from_htmls[i]);}
var map=new GMap2(document.getElementById("map"));map.addControl(new GLargeMapControl());map.addControl(new GMapTypeControl());map.setCenter(new GLatLng(36.127892,-80.233154),10);var gdir=new GDirections(map,document.getElementById("DirectionsTable"));var reasons=[];reasons[G_GEO_SUCCESS]="Success";reasons[G_GEO_MISSING_ADDRESS]="Missing Address: The address was either missing or had no value.";reasons[G_GEO_UNKNOWN_ADDRESS]="Unknown Address:  No corresponding geographic location could be found for the specified address.";reasons[G_GEO_UNAVAILABLE_ADDRESS]="Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";reasons[G_GEO_BAD_KEY]="Bad Key: The API key is either invalid or does not match the domain for which it was given";reasons[G_GEO_TOO_MANY_QUERIES]="Too Many Queries: The daily geocoding quota for this site has been exceeded.";reasons[G_GEO_SERVER_ERROR]="Server error: The geocoding request could not be successfully processed.";reasons[G_GEO_BAD_REQUEST]="A directions request could not be successfully parsed.";reasons[G_GEO_MISSING_QUERY]="No query was specified in the input.";reasons[G_GEO_UNKNOWN_DIRECTIONS]="The GDirections object could not compute directions between the points.";GEvent.addListener(gdir,"error",function(){var code=gdir.getStatus().code;var reason="Code "+code;if(reasons[code]){reason=reasons[code]}alert("Failed to obtain directions, "+reason);});var request=GXmlHttp.create();request.open("GET","./feed/markers.xml",true);request.onreadystatechange=function(){if(request.readyState==4){var xmlDoc=GXml.parse(request.responseText);var markers=xmlDoc.documentElement.getElementsByTagName("marker");for(var i=0;i<markers.length;i++){var lat=parseFloat(markers[i].getAttribute("lat"));var lng=parseFloat(markers[i].getAttribute("lng"));var point=new GLatLng(lat,lng);var html=markers[i].getAttribute("html");var label=markers[i].getAttribute("label");var marker=createMarker(point,label,html);map.addOverlay(marker);}}}
request.send(null);}else{alert("Sorry, the Google Maps API is not compatible with this browser");}