/* :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

	site : エフオーテクニカ
	file : googlemap.js

 : ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: */

//
//	Google Map
//
var map;
var initPoint;
var initZoom = 8;	// 表示倍率
var officeA;
var officeB;
var officeC;

//
function initGoogleMap() {
	if (GBrowserIsCompatible()){
		map = new GMap2(document.getElementById("googleMap"));
		if (!map) { return false; }
		
		// Create a Initial MAP
		initPoint = new GLatLng(32.170963, 131.292114);
		map.setCenter(initPoint, initZoom);
		map.addControl(new GLargeMapControl());

		// Create a base icon for all of our markers
		var baseIcon = new GIcon();
		baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
		baseIcon.iconSize = new GSize(20, 34);
		baseIcon.shadowSize = new GSize(37, 34);
		baseIcon.iconAnchor = new GPoint(9, 34);
		baseIcon.infoWindowAnchor = new GPoint(9, 2);
		baseIcon.infoShadowAnchor = new GPoint(18, 25);
		
		// Create a marker whose info window displays the letter corresponding to the given index.
		function createMarker(point, zoom, index, message) {
			// Create a lettered icon for this point using our icon class
			var letter = String.fromCharCode("A".charCodeAt(0) + index);
			var icon = new GIcon(baseIcon);
			icon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
			var marker = new GMarker(point, icon);
			
			GEvent.addListener(marker, "mouseover", function() {
				marker.openInfoWindowHtml(message);
			});
			
			GEvent.addListener(marker, "click", function() {
				map.setCenter(point);
				map.setZoom(zoom);
			});
			
			return marker;
		}

		// MARKER : 本社
		// LNG,LAT 31.89590248462051,131.42152279615402
		var pointA = new GLatLng(31.89590248462051,131.42152279615402);
		var zoomA = 17;
		var indexA = 0;
		var messageA = '<div class="officeInfo"><h3 class="tit">本社（宮崎）</h3>'
					 + '<p class="info">JR南宮崎駅より徒歩1分</p>'
					 + '<p class="nav"><a href="javascript:findMap(\'A\');">［地図を拡大］</a></p></div>';
		officeA = createMarker(pointA, zoomA, indexA, messageA);
		map.addOverlay(officeA);

/*
		// MARKER : 都城採用センター
		// LNG,LAT 31.734258177197432, 131.07313603162766
		var pointB = new GLatLng(31.734258177197432, 131.07313603162766);
		var zoomB = 17;
		var indexB = 1;
		var messageB = '<div class="officeInfo"><h3 class="tit">都城採用センター</h3>'
					 + '<p class="info">JR都城駅より徒歩3分</p>'
					 + '<p class="pic"><img src="/corporate/img/pic_office2.jpg" width="200" height="150" /></p>'
					 + '<p class="nav"><a href="javascript:findMap(\'B\');">［地図を拡大］</a></p></div>';
		officeB = createMarker(pointB, zoomB, indexB, messageB);
		map.addOverlay(officeB);
*/
		
		// MARKER : 延岡営業所
		// LNG,LAT 32.58665173228447, 131.67008310556412
		// sll=32.590611,131.673546&ll=32.586744,131.667055
		var pointC = new GLatLng(32.586744, 131.667055);
		var zoomC = 16;
		var indexC = 2;
		var messageC = '<div class="officeInfo"><h3 class="tit">延岡採用センター</h3>'
					 + '<p class="info">市立岡富小学校近く。</p>'
					 + '<p class="pic"><img src="/corporate/img/pic_office3.jpg" width="200" height="150" /></p>'
					 + '<p class="nav"><a href="javascript:findMap(\'C\');">［地図を拡大］</a></p></div>';
		officeC = createMarker(pointC, zoomC, indexC, messageC);
		map.addOverlay(officeC);

		return map;
	}
}

function findMap(marker) {
	switch (marker) {
	case 'A':
		map.setCenter(officeA.getPoint());
		map.setZoom(17);
		break;
	case 'B':
		map.setCenter(officeB.getPoint());
		map.setZoom(17);
		break;
	case 'C':
		map.setCenter(officeC.getPoint());
		map.setZoom(16);
		break;
	default:
		map.setCenter(initPoint);
		map.setZoom(initZoom);
		break;
	}
}

//
if (window.addEventListener){
	window.addEventListener("load", initGoogleMap, false);
} else if (window.attachEvent){
	window.attachEvent("onload", initGoogleMap);
}
