$.easing.quart = function (x, t, b, c, d) {
	return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b
};

$(document).ready(function(){
	var area_list = [
		{id: 'marinoa', name: 'マリノアシティ福岡', position: new google.maps.LatLng(33.595436, 130.321316)},
		{id: 'evergreen', name: 'エバーグリーンマリノア', position: new google.maps.LatLng(33.595832,130.323182)},
		{id: 'marinatown', name: 'ショッパーズモールマリナタウン', position: new google.maps.LatLng(33.589192,130.334394)},
		{id: 'atago', name: '鷲尾愛宕神社（日本三大愛宕）', position: new google.maps.LatLng(33.584913,130.334603)},
		{id: 'tower', name: '福岡タワー', position: new google.maps.LatLng(33.593301,130.35149)},
		{id: 'museum', name: '福岡市博物館', position: new google.maps.LatLng(33.58975,130.353068)},
		{id: 'twins', name: 'ホテルツインズももち', position: new google.maps.LatLng(33.592092,130.355535)},
		{id: 'hyatt', name: 'ハイアット・レジデンシャルスイート・福岡', position: new google.maps.LatLng(33.59017,130.355299)},
		{id: 'yahoo', name: '福岡 Yahoo!JAPANドーム', position: new google.maps.LatLng(33.59532,130.36209)},
		{id: 'hawkstown', name: 'ホークスタウン', position: new google.maps.LatLng(33.59291,130.363858)},
		{id: 'tenjin', name: '天神商業エリア', position: new google.maps.LatLng(33.589151,130.399698)},
		{id: 'qurega', name: 'Hotel Qurega Tenjin（ホテル クレガ天神）', position: new google.maps.LatLng(33.589151,130.399698)},
		{id: 'canal', name: 'キャナルシティ博多', position: new google.maps.LatLng(33.589741,130.411014)},
		{id: 'grandhyattfukuoka', name: 'グランド・ハイアット・福岡', position: new google.maps.LatLng(33.58977,130.410397)},
		{id: 'riverain', name: '博多リバレイン', position: new google.maps.LatLng(33.595108,130.405824)},
		{id: 'baysideplace', name: 'ベイサイドプレイス博多', position: new google.maps.LatLng(33.603763,130.39866)},
		{id: 'hyattregencyfukuoka', name: 'ハイアットリージェンシー福岡', position: new google.maps.LatLng(33.589096,130.426855)},
		{id: 'slh', name: 'サンライフホテル1・2・3', position: new google.maps.LatLng(33.591104,130.422086)},
		{id: 'uminaka', name: '国営海の中道海浜公園', position: new google.maps.LatLng(33.664577,130.365851)},
		{id: 'noko', name: '能古島', position: new google.maps.LatLng(33.620762,130.303629)}
	];

	var myOptions = {
		zoom: 12,
		center: area_list[0].position,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	var map = new google.maps.Map(document.getElementById("areaMap"), myOptions);

	var info_list = [];
	$.each(area_list, function(){
		var marker = new google.maps.Marker({
			position: this.position,
			map: map
		});

		var content = '';
		if (this.id === 'marinoa') {
			content = this.name;
		} else {
			content = '<p>' + this.name + ' <a href="javascript:void(0)" onclick="$.scrollTo(\'#' + this.id + '_info\', 1000, {easing: \'quart\'})">詳細へ</a></p>';
		}

		var info = new google.maps.InfoWindow({
			content: content
		});
		info_list.push(info);

		google.maps.event.addListener(marker, 'click', function() {
			$(info_list).each(function(){
				this.close();
			});
			info.open(map, marker);
		});

		if (this.id === 'marinoa') {
			info.open(map, marker);
		} else {
			$('#' + this.id + '_map').bind('click', {position: this.position}, function(event){
				$(info_list).each(function(){
					this.close();
				});
				$.scrollTo($('#heading'), 1000, {easing: 'quart'});
				info.open(map, marker);
				map.panTo(event.data.position);
			}).attr('href', 'javascript:void(0)');
		}
	});

	map.panTo(new google.maps.LatLng(33.611331,130.328064))

	$.each(['odo', 'momochi', 'tenjin', 'hakata', 'etc'], function(){
		$('#' + this + '_button').bind('click', {id: this}, function(event){
			$(window).scrollTo('#' + event.data.id + '_title', 1000, {easing: 'quart'});
		});
	});
});
