/*------------------------------------------------------------
	Script Shops
------------------------------------------------------------*/
(function($){
google.load('maps', '2');
google.setOnLoadCallback(function(){
	$.embedGMaps();
	$(window).unload(google.maps.Unload);
});

var shopList = {
	headOffice  : { lat : 35.811598, lng : 140.127344, marker : '/about/shops/images/headOffice_marker_01.png', anchor : '#anchorHeadOffice' },
	nishinohara : { lat : 35.806305, lng : 140.147696, marker : '/about/shops/images/nishinohara_marker_01.png', anchor : '#anchorNishinohara' },
	abiko       : { lat : 35.865198, lng : 140.093149, marker : '/about/shops/images/abiko_marker_01.png', anchor : '#anchorAbiko' },
	bighop      : { lat : 35.80185,  lng : 140.16054,  marker : '/about/shops/images/bighop_marker_01.png', anchor : '#anchorBighop' }
};


$.extend({
	embedGMaps : function() {
		var map = new google.maps.Map2(document.getElementById('mapArea'));
		map.addControl(new google.maps.MapTypeControl());
		map.addControl(new google.maps.SmallMapControl());
		//map.enableScrollWheelZoom();
		map.setCenter(new google.maps.LatLng(35.832845, 140.130615), 12);

		var markerSize = new google.maps.Size(80, 43);
		var markerAnchor= new google.maps.Point(0, 30);

		$.each(shopList, function(key, val){
			shopList[key].icon = new google.maps.Icon();
			shopList[key].icon.image = shopList[key].marker;
			shopList[key].icon.iconSize = markerSize;
			shopList[key].icon.iconAnchor = markerAnchor;
			var markerPoint = new google.maps.LatLng(shopList[key].lat, shopList[key].lng);
			var marker = new google.maps.Marker(markerPoint, shopList[key].icon);
			google.maps.Event.addListener(marker, 'click', function() {
				$.scrollFor(shopList[key].anchor);
			});
			map.addOverlay(marker);
		});

	}
});
})($jq['1.3.2']);