var map;
var geocoder;

function initialize() {
	
	$(".address-loc br").remove();
	
      map = new GMap2(document.getElementById("map"));
      map.setCenter(new GLatLng(34, 0), 13);
      geocoder = new GClientGeocoder();
	var mapControl = new GMapTypeControl();
	map.addControl(mapControl);
	map.addControl(new GLargeMapControl());
	
	var panel = document.getElementById("panel");
		var dir = new GDirections(map, panel);
		dir.load(new GLatLng(34, 0), 13);

}


function setLocation(coords){
	map.setCenter(new GLatLng(coords), 10);
}


    // addAddressToMap() is called when the geocoder returns an
    // answer.  It adds a marker to the map with an open info window
    // showing the nicely formatted version of the address and the country code.
    function addAddressToMap(response) {
      map.clearOverlays();
      if (!response || response.Status.code != 200) {
        alert("Sorry, we were unable to geocode that address");
      } else {
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
        marker = new GMarker(point);
        map.addOverlay(marker);
        marker.openInfoWindowHtml(place.address + "<br /> <a href='http://maps.google.com/maps?f=d&source=s_d&saddr=&daddr="+escape(place.address)+"&hl=en&geocode=%3BFZ5-WQIdI21s-yl_iawgrRfIiTH0CYzrMV_r0w&mra=ls&sll=39.41955,-76.780253&sspn=0.10715,0.308647&ie=UTF8&z=7' target='_blank'>Get Directions</a>");
		
		$("#directions").attr("href","http://maps.google.com/maps?f=d&source=s_d&saddr=&daddr="+escape(place.address)+"&hl=en&geocode=%3BFZ5-WQIdI21s-yl_iawgrRfIiTH0CYzrMV_r0w&mra=ls&sll=39.41955,-76.780253&sspn=0.10715,0.308647&ie=UTF8&z=7")
		
		var panel = document.getElementById("panel");
		var dir = new GDirections(map, panel);
		dir.load(place);


	//setLocation(place.Point.coordinates[1],place.Point.coordinates[0]);
		veg.utils.setHeights();
      }
    }

    // showLocation() is called when you click on the Search button
    // in the form.  It geocodes the address entered into the form
    // and adds a marker to the map at that location.
    function showLocation(address) {
      geocoder.getLocations(address, addAddressToMap);
    }

   // findLocation() is used to enter the sample addresses into the form.
    function findLocation(address) {
      showLocation(address);
    }

