﻿// JavaScript Document
// Google Map 本社地図 v1003
// gMap api v3 対応
// 西日本の情報追加　10/08/03

var map;

// 座標 
var latlngOffice = new google.maps.LatLng(35.70002, 139.75752); // 東京本社 
var latlngStudio = new google.maps.LatLng(35.700252, 139.757845); // スタジオ
var latlngNishinihon = new google.maps.LatLng(34.699109, 135.496838); // 大阪
// var latlngDeffault = new google.maps.LatLng(35.69898710037577 , 139.75699692964554); // デフォルトのセンター (旧）
var latlngDeffault = new google.maps.LatLng(35.69943755195899 , 139.756540954113); // デフォルトのセンター 

// 地図初期値
var mapOpts = {
	zoom : 17,
	center : latlngDeffault,
	mapTypeControl : false,
	mapTypeId : google.maps.MapTypeId.ROADMAP
}

// マーカーの設定 
var iconOffice = "image/marker_gigavision.png";
var iconStudio = "image/marker_studio.png";
var iconShadow = "image/mapicon_shadow.png";

var markerOffice = new google.maps.Marker({ // 事務所のマーカー
	position : latlngOffice,
	map : map,
	icon : iconOffice
});

var markerStudio = new google.maps.Marker({ // スタジオのマーカー
	position : latlngStudio,
	map : map,
	icon : iconStudio
});	

var markerNishinihon = new google.maps.Marker({ // 西日本のマーカー
	position : latlngNishinihon,
	map : map,
	icon : iconOffice
});	

// インフォメーションウインドウ
var infoOffice = new google.maps.InfoWindow({
	content : '<div class="information" id="tokyo"><h1>ギガビジョン株式会社 本社事務所</h1><address>東京都千代田区猿楽町2-7-3 川崎パークビル3F</address></div>'
});

var infoStudio = new google.maps.InfoWindow({
	content : '<div class="information" id="studio"><h1>制作スタジオ「Clear」</h1><address>東京都千代田区猿楽町2-7-17 織本ビル1F・2F</address></div>'
});

var infoNishinihon = new google.maps.InfoWindow({
	content : '<div class="information" id="studio"><h1>西日本営業室</h1><address>大阪府大阪市北区梅田1-3-1 大阪駅前第1ビル3F 300</address></div>'
});

$(document).ready(function() {
	map = new google.maps.Map(document.getElementById("gMap"), mapOpts); // 地図を描画
	markerOffice.setMap(map);
	markerStudio.setMap(map);
	markerNishinihon.setMap(map);
	infoOffice.open(map, markerOffice);

//$("span#office").click(function(){
//		if ($(this).attr("class")!="active") {
//			$(this).toggleClass("active");
//			$("span#studio").removeClass("active");
//			infoStudio.close();
//			infoOffice.open(map, markerOffice);
//		}
//	});
//
//$("span#studio").click(function(){
//		if ($(this).attr("class")!="active") {
//			$("span#office").removeClass("active");
//			$(this).toggleClass("active");
//			infoOffice.close();
//			infoStudio.open(map, markerStudio);
//		}
//	});

	$("p#switchMap span").click(function(){
		if ($(this).attr("class")!="active") {
				$("p#switchMap span").removeClass("active");
				$(this).addClass("active");
				infoOffice.close();
				infoStudio.close();
				infoNishinihon.close();
				var mapId = $(this).attr("id");
				switch(mapId){
					case "office" : infoOffice.open(map, markerOffice); map.setOptions({center:latlngOffice});  break;
					case "studio" : infoStudio.open(map, markerStudio); map.setOptions({center:latlngStudio}); break;
					case "nishinihon" : infoNishinihon.open(map, markerNishinihon); map.setOptions({center:latlngNishinihon}); break;
				}
			}
		});
});
