var map;
var gdir;
var geocoder = new GClientGeocoder();
var mgr;
var query;

function loadMap(map_div_id, address)
{
	if (GBrowserIsCompatible()) {
		if (!$('#map-' + map_div_id).parent().is(':visible'))
		{
			$('.google-map').parent().hide();
			$('#map-' + map_div_id).parent().show();
			// create map
		  map = new GMap2(document.getElementById('map-' + map_div_id));
		  map.addControl(new GSmallMapControl());
		  geocoder.getLatLng(address, function(point){
	       map.setCenter(point, 13);
	       var marker = new GMarker(point);
	       map.addOverlay(marker);
		  });
		  
		 }
		 else
		 {
		 	$('#map-' + map_div_id).parent().hide();
		 	$('#print-directions-' + map_div_id).html('');
		 	$('#directions-' + map_div_id).html('');
		 }
	  
	}
}

function get_directions(map_div_id, location)
{
  query = "from: " + location + " to: 325 E Warm Springs Road Las Vegas, NV";

  gdir = new GDirections(map, document.getElementById("directions-" + map_div_id));	 	
  gdir.load(query); 
  GEvent.addListener(gdir, "addoverlay", function() {  	
	    $('#print-directions-' + map_div_id).html('<a href="http://local.google.com/maps?f=q&hl=en&q='+query+'&ie=UTF8&z=14&om=1&pw=2" target="_blank">Print directions</a>');	    
	  });  
}

function big_map_directions(location)
{
  query = "from: " + $('#directions-from').val() + " to: " + location;

  gdir = new GDirections(map, document.getElementById("directions"));	 	
  gdir.load(query); 
  GEvent.addListener(gdir, "addoverlay", function() {  	
	    $('#print-directions').html('<a href="http://local.google.com/maps?f=q&hl=en&q='+query+'&ie=UTF8&z=14&om=1&pw=2" target="_blank">Print directions</a>');	    
	  });  
}
