google.load("maps", "2");
Search = {
	tasks: [],
	dictionary: {},
	content: {},
	marker: {},
	addAddress: function(id, address, content) {
		Search.geocoder.getLatLng(address, function(point) {
			if (point) {
				Search.dictionary[address] = point;
				Search.content[address] = content;
				Search.marker[address] = new GMarker(point);
				Search.map.setCenter(point, 9);
				Search.map.addOverlay(Search.marker[address]);
				GEvent.addListener(Search.marker[address], 'click', function() {
					Search.marker[address].openInfoWindowHtml(Search.content[address]);
				});
				try {
					transport = new XMLHttpRequest();
					transport.open('post', 'fileadmin/templates/inc/savegeocode.php?', true);
					transport.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
					transport.setRequestHeader('Connection', 'close');
					transport.send('garageid=' + id + '&pointx=' + point.x + '&pointy=' + point.y);
				} catch (exception) {}
			}
		});
	},
	addPoint: function(point, address, content) {
		Search.dictionary[address] = point;
		Search.content[address] = content;
		Search.marker[address] = new GMarker(point);
		Search.map.setCenter(point, 9);
		Search.map.addOverlay(Search.marker[address]);
		GEvent.addListener(Search.marker[address], 'click', function() {
			Search.marker[address].openInfoWindowHtml(Search.content[address]);
		});
	},
	centerAddress: function(address) {
		Search.map.setCenter(new GLatLng(Search.dictionary[address].y, Search.dictionary[address].x), 13);
		Search.marker[address].openInfoWindowHtml(Search.content[address]);
	}
};
google.setOnLoadCallback(function() {
//	if (document.getElementById("search_map") && Search.tasks.length && GBrowserIsCompatible()) {
		Search.map = new google.maps.Map2(document.getElementById("search_map"));
		Search.geocoder = new GClientGeocoder();
		for (var i = 0; i < Search.tasks.length; ++i)
			Search[Search.tasks[i].method].apply(Search, Search.tasks[i].args);
 		Search.map.setUIToDefault();
//	}
});