$(document).ready(function()
{ 
 
$('#showmap-btn').toggle(function() {
  $('#show-map').show();
  initialize();
  //initializedirection();
}, function() {
  $('#show-map').hide();
});
 
 
});



var map = null;
var geocoder = null;
var directionsPanel;
var directions;
    //initialize();
	
	
    function initialize() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        //map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
       
        geocoder = new GClientGeocoder();
       
       if(document.getElementById('address').value!='')	      showAddress(document.getElementById('address').value);
      }
    }
    
  function initializedirection() {
 
  map = new GMap2(document.getElementById("map_canvas"));
  map.setCenter(new GLatLng(42.351505,-71.094455), 15);
  directionsPanel = document.getElementById("route");
  directions = new GDirections(map, directionsPanel);
  directions.load("from: Kochi, Kerala, IN to: Trivandrum, Kerala, IN");
}     
    
    function showAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 8);//13
              var marker = new GMarker(point);
              map.addOverlay(marker);
             
              address = address.substr(0,address.indexOf(" ")+1);
              marker.openInfoWindowHtml(address);
            }
          }
        );
      }
    }