/******************************/
/*         右タブ選択         */
/******************************/
function focusMainTab(obj) {
	obj.style.left = "10px";
}

/******************************/
/*       右タブ選択解除       */
/******************************/
function outFocusMainTab(obj) {
	obj.style.left = 0;
}

/******************************/
/*        店舗画像変更        */
/******************************/
function changeShopPhoto(newObj, viewid) {
	if (viewObj = document.getElementById(viewid)) {
		viewObj.src = newObj.src;
	}
}

/******************************/
/*         GoogleMaps         */
/******************************/
function googleMapInit(shop) {
	
	/*** 設定（Zoom,店舗緯度,店舗経度,中心地緯度,中心地経度,ルート始点緯度,ルート始点経度,ルート終点緯度,ルート終点経度) ***/
	/* 薬配 */
	var yakuhaiInfo = new Array(
			17,
			35.6882406, 139.6971669,
			35.68896890439038, 139.69936966896057,
			35.68926517699213, 139.70048010349274,
			35.68813236404544, 139.69724535942078
		);
	/* 鎌倉 */
	var kamakuraInfo = new Array(
			17,
			35.35356036133729, 139.53459069999997,
			35.354190388186716, 139.5333139685089,
			35.354499,139.532165,
			35.353668935463055,139.53464314341545
		);
	/* さいたま */
	var saitamaInfo = new Array(
			14,
			35.908378662604605, 139.650708,
			35.90858721954327, 139.6372754972534,
			35.91014602651259, 139.64928343892097,
			35.908378662604605, 139.650708
		);
	/* 元住吉 */
	var motosumiyoshiInfo = new Array(
			16,
			35.56682006182232, 139.65693190000002,
			35.565633148383064, 139.65576245686952,
			35.56485827226584, 139.6545036882162,
			35.56682006182232, 139.65693190000002
		);
	
	var info;
	switch (shop) {
		case "yakuhai": info = yakuhaiInfo; break;
		case "kamakura": info = kamakuraInfo; break;
		case "saitama": info = saitamaInfo; break;
		case "motosumiyoshi": info = motosumiyoshiInfo; break;
		default: info = yakuhaiInfo;
	}

	var myOptions = {
		zoom: info[0],
		center: new google.maps.LatLng(info[3], info[4]),
		mapTypeControl: false,
		scaleControl: false,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	}
	var map = new google.maps.Map(document.getElementById("mapShopByGoogle"),myOptions);

	/* 店舗 */
	var iconYakuhai = new google.maps.MarkerImage(
		"/info/img/icon4Gmap.png",
		new google.maps.Size(85.0, 68.0),
		new google.maps.Point(0, 0),
		new google.maps.Point(10.0, 68.0)
	);
	var iconYakuhaiShadow = new google.maps.MarkerImage(
		"/info/img/icon4GmapShadow.png",
		new google.maps.Size(120.0, 68.0),
		new google.maps.Point(0, 0),
		new google.maps.Point(10.0, 68.0)
	);
	var markerYakuhai = new google.maps.Marker({
		position: new google.maps.LatLng(info[1], info[2]),
		icon: iconYakuhai,
		shadow: iconYakuhaiShadow,
		map: map
	});

	/* ルート始点 */
	var iconRStart = new google.maps.MarkerImage(
		"/info/img/icon4GmapR_"+shop+".png",
		new google.maps.Size(85.0, 64.0),
		new google.maps.Point(0, 0),
		new google.maps.Point(79.0, 64.0)
	);
	var iconRStartShadow = new google.maps.MarkerImage(
		"/info/img/icon4GmapRShadow.png",
		new google.maps.Size(118.0, 64.0),
		new google.maps.Point(0, 0),
		new google.maps.Point(79.0, 64.0)
	);
	var routeStart = new google.maps.Marker({
		position: new google.maps.LatLng(info[5], info[6]),
		icon: iconRStart,
		shadow: iconRStartShadow,
		map: map
	});
	
	/* ルート表示 */
	var rendererOptions = 
	{
		draggable: false,
		preserveViewport:true
	};
	var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);
	directionsDisplay.setOptions(
	{
		suppressMarkers: true
	});
	var directionsService = new google.maps.DirectionsService();
	
	var request = {
		origin: new google.maps.LatLng(info[5], info[6]),
		destination: new google.maps.LatLng(info[7], info[8]),
		travelMode: google.maps.DirectionsTravelMode.WALKING
	};
	directionsService.route(request, function(response, status) {
		if (status == google.maps.DirectionsStatus.OK) {
			directionsDisplay.setDirections(response);
		}
	});
	
	directionsDisplay.setMap(map);
}

