/*
	-- Global functions --
	
	-- Author: 		e950
	-- URL:			http://www.e950.lv/
*/

    var map = null;
    var geocoder = null;

    function initialize(adress) {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        geocoder = new GClientGeocoder();
        //map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        showAddress(adress);
        map.addControl(new GSmallMapControl());
      }
    }

    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);
            }
          }
        );
      }
    }




$(document).ready(function() {
	
	var base_url = $("#base_url").text();
	
	$("#place_selector #region, #place_selector #type").unbind('change').change(function() {
		$("#place_selector").submit();
	});
	
	$("#drink_type, #drink_discount, #drink_shop").unbind('change').change(function() {
		$("#drink_filter").submit();
	});
	
	if($("#map").attr('id')) {
		var address = $("#place_address").text();
		initialize(address);
	}
	

	
});
