
$(document).ready(function() {

	$(".shops_maplink").each(function(a) {

		$(this).click(function(){
			var myid	= $(this).attr('id');
			var num		= myid.substr('showmap'.length);
			var map		= $("#map" + num);
			
			// need to toggle mode before or the map isnt loaded correctly...
			map.toggle();
			
			if ('none' != map.css('display') && 0 == map.html().length) {
				// load google map
				loadGmap("map" + num, num);
			}

			if ('none' != map.css('display')) {
				$(this).html('（地図を隠す）');
			} else {
				$(this).html('（地図を表示）');
			}
		});
	});   
});

function loadGmap(id, i) {

	if (GBrowserIsCompatible()) {
	
		var map = new GMap2(document.getElementById(id));
		map.addControl(new GLargeMapControl());

		// start point for map
		map.setCenter(new GLatLng(wakasaimo[i][0], wakasaimo[i][1]), 14);

		var myicon = new GIcon();
		myicon.image = 'images/icons/map_icon_large_red.png';
		myicon.iconSize = new GSize(32, 32);
		myicon.iconAnchor = new GPoint(16, 16);
		
		// Set up our GMarkerOptions object
		markerOptions = {icon:myicon, title:wakasaimo[i][2]};

		var latlng = new GLatLng(wakasaimo[i][0], wakasaimo[i][1]);
		var marker = new GMarker(latlng, markerOptions);
		map.addOverlay(marker);
	}
}
