//<![CDATA[
var map = null;
var geocoder = null;

var directionsPanel;
var directions;


function load(address) 
{
  if (GBrowserIsCompatible()) 
  {
    map = new GMap2(document.getElementById("Map"));
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.addControl(new google.maps.LocalSearch(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10, 20)));

    //map.setMapType(G_HYBRID_MAP);
    //map.setCenter(new GLatLng(90.416335,38.552380), 13);
    geocoder = new GClientGeocoder();
    showAddress(address);
  }
}

function loadCoords(lat, lng, address)
{
  if (GBrowserIsCompatible())
  {
    map = new GMap2(document.getElementById("Map"));
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.addControl(new google.maps.LocalSearch(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10, 20)));

    map.setCenter(new GLatLng(lat, lng), 13);

    if (address != '' && address != null)
    {
      geocoder = new GClientGeocoder();
      showAddress(address);
    }
  }
}



//GSearch.setOnLoadCallback(load);
function showAddress(address) 
{
  if (geocoder) 
  {
    geocoder.getLatLng(
      address,
      function(point) 
      {
        if (!point) 
        {
          alert(address + " not found");
        }
        else
        {
          map.setCenter(point, 13);
          var marker = new GMarker(point);
          map.addOverlay(marker);
          marker.openInfoWindowHtml(address);
        }
      }
    );
  }
}


function directions(addresses)
{
  map = new GMap2(document.getElementById("Map"));
  directionsPanel = document.getElementById("Route");
  directions = new GDirections(map, directionsPanel);
  directions.load(addresses);
}
//]]>