var map;
var geocoder;
var dk_location;

function initialize() {
  if(document.getElementById("map_canvas")){
	  map = new GMap2(document.getElementById("map_canvas"));
	  map.setCenter(new GLatLng(47.22,19.5), 6);
	  map.setUIToDefault();
	  geocoder = new GClientGeocoder();
	  showLocation(dk_location);
  }
}

// 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) {
	document.getElementById("map_canvas").style.display = 'none';
	document.getElementById("map_canvas_td").style.display = 'none';
  } else {

	// Create our "tiny" marker icon
	var blueIcon = new GIcon(G_DEFAULT_ICON);
	
    blueIcon.image = "images_new/horseshoe.png";
    blueIcon.shadow = "images_new/shadow-horseshoe.png";
    blueIcon.iconSize = new GSize(50.0, 47.0);
    blueIcon.shadowSize = new GSize(74.0, 47.0);
    blueIcon.iconAnchor = new GPoint(25.0, 23.0);
    blueIcon.infoWindowAnchor = new GPoint(25.0, 23.0);
        
    	
	// Set up our GMarkerOptions object
	markerOptions = { icon:blueIcon };

	
	place = response.Placemark[0];
	point = new GLatLng(place.Point.coordinates[1],
						place.Point.coordinates[0]);
	marker = new GMarker(point, markerOptions);
	map.addOverlay(marker);
	//marker.openInfoWindowHtml(place.address + '<br>' +
	  //'<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
  }
}

// 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() {
  var address = document.forms[0].q.value;
  geocoder.getLocations(address, addAddressToMap);
}

function showLocation(address) {
  geocoder.getLocations(address, addAddressToMap);
}

// findLocation() is used to enter the sample addresses into the form.
function findLocation(address) {
  document.forms[0].q.value = address;
  showLocation();
}
