(function ($) {
	$(window).load(function () {
		var map1 = new google.maps.Map(document.getElementById("map_canvas"), {
			zoom: 12,
			mapTypeControl: false,
			center: new google.maps.LatLng(42.697625, 23.322292),
			mapTypeId: google.maps.MapTypeId.ROADMAP
		});

		var b = new google.maps.LatLngBounds(new google.maps.LatLng(42.697625, 23.322292), new google.maps.LatLng(42.697625, 23.322292));
		$("#map_points li").each(function () {
			$this = $(this);
			var point = $this.attr("rel").split(",");
			point[0] = parseFloat(point[0]);
			point[1] = parseFloat(point[1]);
			b.extend(new google.maps.LatLng( (point[0] + 0.01) , (point[1] + 0.01) ));
			b.extend(new google.maps.LatLng( (point[0] - 0.01) , (point[1] + 0.01) ));
			b.extend(new google.maps.LatLng( (point[0] + 0.01) , (point[1] - 0.01) ));
			b.extend(new google.maps.LatLng( (point[0] - 0.01) , (point[1] - 0.01) ));
			point = new google.maps.LatLng(point[0], point[1]);

			var mar = new google.maps.Marker({ 
				flat : true, 
				position: point, 
				map : map1, 
				title : $this.children("strong:eq(0)").text(),
				icon : new google.maps.MarkerImage(
					'http://static.celtic-phoenix.com/clover_s.png',
					new google.maps.Size(24, 23),
					new google.maps.Point(0,0),
					new google.maps.Point(12, 12)
				)
			});
			google.maps.event.addListener(mar, 'click', function() {
				//map1.setCenter(this.getPosition());
				var g = new google.maps.LatLngBounds();
				g.extend(this.getPosition());
				map1.fitBounds(g);
				$("#map_points li:contains('" + this.getTitle() + "')").parent().children(".selected").removeClass("selected").end().end().addClass("selected");
			});
			(function (m, p) {
				$this.click(function () {
					//m.setCenter(p);
					var g = new google.maps.LatLngBounds();
					g.extend(p);
					m.fitBounds(g);
					$(this).parent().children(".selected").removeClass("selected").end().end().addClass("selected");
				});
			})(map1, point);
		});
		map1.fitBounds(b);
	});
})(jQuery);
