$(function() {
	var tokyo = new google.maps.LatLng(35.64, 139.77),
		pointToMoveTo,
		first = true,
		curMarker = new google.maps.Marker({}),
		$el;

	var WideMap = {
		zoom: 10,
		center: tokyo,
		mapTypeId: google.maps.MapTypeId.TERRAIN
	};

	var ZoomMap = {
		zoom: 14,
		center: tokyo,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};

	var map = new google.maps.Map($("#map_canvas")[0], WideMap);

	// Put pins on All lesson area
	var LOC = 80;
	var LP = new Array(LOC);

	//東京北部・埼玉エリア
	LP[0] = new google.maps.LatLng(35.801922, 139.717583);			//川口駅
	LP[1] = new google.maps.LatLng(35.778051, 139.720856);			//赤羽駅
	LP[2] = new google.maps.LatLng(35.788515, 139.612343);			//和光市駅
	LP[40] = new google.maps.LatLng(35.746044, 139.719523);			//板橋駅
	LP[52] = new google.maps.LatLng(35.906992, 139.482894);			//川越駅
	LP[53] = new google.maps.LatLng(35.858482, 139.657087);			//浦和駅
	LP[54] = new google.maps.LatLng(35.906295, 139.623999);			//大宮駅
	LP[69] = new google.maps.LatLng(35.875186, 139.789905);			//新越谷駅
	LP[70] = new google.maps.LatLng(35.828487, 139.803472);			//草加駅

	//東京西部エリア
	LP[35] = new google.maps.LatLng(35.702811, 139.579804);			//吉祥寺駅
	LP[4] = new google.maps.LatLng(35.706032, 139.665652);			//中野駅
	LP[48] = new google.maps.LatLng(35.70228, 139.54489);			//武蔵境駅
	LP[49] = new google.maps.LatLng(35.704632, 139.619981);			//荻窪駅
	LP[59] = new google.maps.LatLng(35.705385, 139.649867);			//高円寺駅
	LP[60] = new google.maps.LatLng(35.702708, 139.560831);			//三鷹駅
	LP[67] = new google.maps.LatLng(35.700256, 139.480257);			//国分寺駅
	LP[68] = new google.maps.LatLng(35.697899, 139.413957);			//立川駅
	LP[50] = new google.maps.LatLng(35.71074, 139.686337);			//落合駅
	LP[51] = new google.maps.LatLng(35.715065, 139.687264);			//中井駅

	//山手エリア
	LP[3] = new google.maps.LatLng(35.728926, 139.71038);			//池袋駅
	LP[5] = new google.maps.LatLng(35.690921, 139.700258);			//新宿駅
	LP[6] = new google.maps.LatLng(35.658517, 139.701334);			//渋谷駅
	LP[42] = new google.maps.LatLng(35.633998, 139.715828);			//目黒駅
	LP[11] = new google.maps.LatLng(35.626446, 139.723444);			//五反田駅
	LP[12] = new google.maps.LatLng(35.630152, 139.74044);			//品川駅
	LP[20] = new google.maps.LatLng(35.681382, 139.766084);			//東京駅
	LP[22] = new google.maps.LatLng(35.69169, 139.770883);			//神田駅
	LP[23] = new google.maps.LatLng(35.698683, 139.774219);			//秋葉原駅
	LP[24] = new google.maps.LatLng(35.707438, 139.774632);			//御徒町駅
	LP[25] = new google.maps.LatLng(35.713768, 139.777254);			//上野駅
	LP[26] = new google.maps.LatLng(35.727772, 139.770987);			//日暮里駅
	LP[27] = new google.maps.LatLng(35.732135, 139.766787);			//西日暮里駅
	LP[28] = new google.maps.LatLng(35.738062, 139.76086);			//田端駅
	LP[41] = new google.maps.LatLng(35.733492, 139.739345);			//巣鴨駅
	LP[46] = new google.maps.LatLng(35.721204, 139.706587);			//目白駅
	LP[47] = new google.maps.LatLng(35.712285, 139.703782);			//高田馬場駅

	LP[16] = new google.maps.LatLng(35.686014, 139.730667);			//四ツ谷駅
	LP[18] = new google.maps.LatLng(35.699855, 139.763786);			//御茶ノ水駅
	LP[63] = new google.maps.LatLng(35.702065, 139.745015);			//飯田橋駅
	LP[61] = new google.maps.LatLng(35.711844, 139.718919);			//早稲田駅
	LP[62] = new google.maps.LatLng(35.703904, 139.734238);			//神楽坂駅
	LP[21] = new google.maps.LatLng(35.684801, 139.766086);			//大手町駅
	LP[13] = new google.maps.LatLng(35.673838, 139.750899);			//霞ヶ関駅
	LP[14] = new google.maps.LatLng(35.672371, 139.736539);			//赤坂駅
	LP[15] = new google.maps.LatLng(35.677021, 139.737047);			//赤坂見附駅
	LP[17] = new google.maps.LatLng(35.687958, 139.720103);			//四谷三丁目駅
	LP[19] = new google.maps.LatLng(35.671989, 139.763965);			//銀座駅
	LP[37] = new google.maps.LatLng(35.662978, 139.745069);			//神谷町駅
	LP[38] = new google.maps.LatLng(35.662836, 139.731443);			//六本木駅

	//東京東部・千葉エリア
	LP[36] = new google.maps.LatLng(35.729277, 139.907809);			//市川駅
	LP[29] = new google.maps.LatLng(35.749412, 139.805108);			//北千住駅
	LP[71] = new google.maps.LatLng(35.733336, 139.799171);			//南千住駅
	LP[30] = new google.maps.LatLng(35.784344, 139.900666);			//松戸駅
	LP[31] = new google.maps.LatLng(35.696437, 139.813949);			//錦糸町駅
	LP[32] = new google.maps.LatLng(35.712074, 139.79843);			//浅草駅
	LP[56] = new google.maps.LatLng(35.697587, 139.826078);			//亀戸駅
	LP[33] = new google.maps.LatLng(35.612858, 140.11434);			//千葉駅
	LP[34] = new google.maps.LatLng(35.659386, 140.057949);			//幕張駅
	LP[57] = new google.maps.LatLng(35.701735, 139.985218);			//船橋駅
	LP[58] = new google.maps.LatLng(35.691228, 140.020476);			//津田沼駅

	//東京南部・神奈川エリア
	LP[64] = new google.maps.LatLng(35.68123, 139.686354);			//初台駅
	LP[65] = new google.maps.LatLng(35.673747, 139.667262);			//笹塚駅
	LP[66] = new google.maps.LatLng(35.66843, 139.650447);			//明大前駅
	LP[7] = new google.maps.LatLng(35.607577, 139.669094);			//自由が丘駅
	LP[55] = new google.maps.LatLng(35.633471, 139.661702);			//駒沢大学駅
	LP[8] = new google.maps.LatLng(35.611499, 139.626624);			//二子玉川駅
	LP[10] = new google.maps.LatLng(35.562479, 139.716051);			//蒲田駅
	LP[43] = new google.maps.LatLng(35.531328, 139.696899);			//川崎駅
	LP[44] = new google.maps.LatLng(35.575741, 139.659664);			//武蔵小杉駅
	LP[45] = new google.maps.LatLng(35.508565, 139.676018);			//鶴見駅
	LP[9] = new google.maps.LatLng(35.466188, 139.622715);			//横浜駅

	for (iCnt=0; iCnt < LP.length; iCnt++) {
		var LsnArea = new google.maps.Marker({
			position: LP[iCnt],
			map: map,
			icon: "./img/pin_red.png"
		});
	};

	// Mouse Over and Click Actions
	$("div#locations div.station").mouseenter(function() {
		$el = $(this);

		if (!$el.hasClass("hover")) {
			$("div#locations div.station").removeClass("hover");
			$el.addClass("hover");

			if (!first) {
				// Clear current marker
				curMarker.setMap(); 

				// Set zoom back to Tokyo level
				map.setZoom(10);
				map.setMapTypeId(google.maps.MapTypeId.TERRAIN);
			}

			// Move (pan) map to new location
			pointToMoveTo = new google.maps.LatLng($el.attr("data-geo-lat"), $el.attr("data-geo-long"));
			map.panTo(pointToMoveTo);

			// Get marker position
			curMarker = new google.maps.Marker({
				position: pointToMoveTo,
				map: map,
				icon: "./img/pin_green.png"
			});

			// On click, zoom map
			google.maps.event.addListener(curMarker, 'click', function() {
				map.setZoom(14);
				map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
			});

			// Fill more info area
			// Set h3.text to #more-info.h2
			$("#more-info h2").html($el.children("h3").html());

			// Set p.longdesc.contents to #more-info.p
			$("#more-info p").html($el.children("p.longdesc").html());

			// No longer the first time through (re: marker clearing)
			first = false;
		}
	});
	// $("#locations li:first").trigger("mouseenter");
});

