
//
var map;
var icons = new Array();
var markers = new Array();
var guidance;

// 
var isMacIE = navigator.platform.indexOf("Mac") >= 0 && navigator.userAgent.indexOf("MSIE") >= 0;

// 初期化して表示
function setMap(){

	// 
	if(isMacIE){
		displayMacIEError();
		return;
	}

	// 
	map = new GMap(document.getElementById("map"));
	map.addControl(new GLargeMapControl());

	//
	icons[0] = new GIcon();
	icons[0].image = "images/icon_kppi.png";
	icons[0].iconSize = new GSize(171, 63);
	icons[0].iconAnchor = new GPoint(89, 58);
	
	icons[1] = new GIcon();
	icons[1].image = "images/icon_station1.png";
	icons[1].iconSize = new GSize(64, 45);
	icons[1].iconAnchor = new GPoint(25, 0);
	
	icons[2] = new GIcon();
	icons[2].image = "images/icon_station2.png";
	icons[2].iconSize = new GSize(82, 45);
	icons[2].iconAnchor = new GPoint(33, 0);
	
	icons[3] = new GIcon();
	icons[3].image = "images/icon_station3.png";
	icons[3].iconSize = new GSize(71, 44);
	icons[3].iconAnchor = new GPoint(30, 0);
	
	icons[4] = new GIcon();
	icons[4].image = "images/icon_station4.png";
	icons[4].iconSize = new GSize(82, 45);
	icons[4].iconAnchor = new GPoint(30, 0);
	
	icons[5] = new GIcon();
	icons[5].image = "images/icon_station5.png";
	icons[5].iconSize = new GSize(53, 44);
	icons[5].iconAnchor = new GPoint(20, 0);
	
	//
	markers[0] = new GMarker(new GPoint(135.72316646575928, 34.9974534427174), icons[0], {clickable: false});
	markers[1] = new GMarker(new GPoint(135.758485, 34.984915), icons[1], {clickable: false});
	markers[2] = new GMarker(new GPoint(135.7596, 35.003724), icons[2], {clickable: false});
	markers[3] = new GMarker(new GPoint(135.73171, 35.0032802), icons[3], {clickable: false});
	markers[4] = new GMarker(new GPoint(135.71831971406937, 34.992388727618206), icons[4], {clickable: false});
	markers[5] = new GMarker(new GPoint(135.72687596082687, 34.995994485344575), icons[5], {clickable: false});

	//
	displayGuide1();

}

// 京都駅 → 地下鉄の場合
function displayGuide1(){
	
	scrollToTop();
	map.clearOverlays();
	map.centerAndZoom(new GPoint(135.72622418, 35.00265), 4);
	
	var points = [
		new GPoint(135.759773, 34.9863568),                // 京都駅
		new GPoint(135.7596, 35.00351311076226),           // 四条烏丸
		new GPoint(135.73002487421036, 35.00351311076226), // 四条佐井
		new GPoint(135.73002487421036, 35.00285399530848), // 南下
		new GPoint(135.72420375181198, 34.99749299240455), // 阪急沿いで南下
		new GPoint(135.72316646575928, 34.99749299240455), // 共同印刷工業の手前
		new GPoint(135.72316646575928, 34.9974534427174)   // 共同印刷工業
	];
	
	guidance = new GPolyline(points, "#3399FF", 6, 0.7);
	map.addOverlay(guidance);
	map.addOverlay(markers[1]);
	map.addOverlay(markers[2]);
	map.addOverlay(markers[3]);
	map.addOverlay(markers[0]);
	
}

// バス利用の場合
function displayGuide2(){

	scrollToTop();
	map.clearOverlays();
	map.centerAndZoom(new GPoint(135.72377264499664, 34.99686458955876), 1);
	
	var points = [
		new GPoint(135.72687596082687, 34.995994485344575), // バス亭
		new GPoint(135.72420448064804, 34.995994485344575), // 交差点
		new GPoint(135.72420448064804, 34.99613950335605),  // 交差点を北上 
		new GPoint(135.7226648926735, 34.99613950335605),   // 五条通の縦筋
		new GPoint(135.7226648926735, 34.99749299240455),   // 北上
		new GPoint(135.72316646575928, 34.99749299240455),  // 共同印刷工業の手前
		new GPoint(135.72316646575928, 34.9974534427174)    // 共同印刷工業
	];
	
	guidance = new GPolyline(points, "#3399FF", 6, 0.7);
	map.addOverlay(guidance);
	map.addOverlay(markers[5]);
	map.addOverlay(markers[0]);
	
}

// 阪急西院駅の場合
function displayGuide3(){

	scrollToTop();
	map.clearOverlays();
	map.centerAndZoom(new GPoint(135.7247006893158, 35.00001534407975), 2);
	
	var points = [
		new GPoint(135.73154032230377, 35.00336530780489), // 西院駅
		new GPoint(135.73154032230377, 35.00351530780489), // 四条通
		new GPoint(135.73002487421036, 35.00351311076226), // 四条佐井
		new GPoint(135.73002487421036, 35.00285399530848), // 南下
		new GPoint(135.72420375181198, 34.99749299240455), // 阪急沿いで南下
		new GPoint(135.72316646575928, 34.99749299240455), // 共同印刷工業の手前
		new GPoint(135.72316646575928, 34.9974534427174)   // 共同印刷工業
	];
	
	guidance = new GPolyline(points, "#3399FF", 6, 0.7);
	map.addOverlay(guidance);
	map.addOverlay(markers[3]);
	map.addOverlay(markers[0]);
	
}

// 阪急西京極駅の場合
function displayGuide4(){

	scrollToTop();
	map.clearOverlays();
	map.centerAndZoom(new GPoint(135.72114139795303, 34.995115582807344), 2);
	
	var points = [
		new GPoint(135.71831971406937, 34.992388727618206), // 西京極駅
		new GPoint(135.7184001803398, 34.99225249234117),   // 
		new GPoint(135.71884006261826, 34.99247002920773), // 
		new GPoint(135.71957767009735, 34.99247002920773), // 葛野大路通に出る
		new GPoint(135.71957767009735, 34.99749299240455), // 葛野大路通を北上
		new GPoint(135.72316646575928, 34.99749299240455), // 共同印刷工業の手前
		new GPoint(135.72316646575928, 34.9974534427174)   // 共同印刷工業
	];
	
	guidance = new GPolyline(points, "#3399FF", 6, 0.7);
	map.addOverlay(guidance);
	map.addOverlay(markers[4]);
	map.addOverlay(markers[0]);
	
}


function scrollToTop(){
	window.scroll(0, 200);	
}


function displayMacIEError(){
	
	var msg = "";
	msg += "<p style='text-align: left; margin-top: 30px;'>会社所在地図はお使いのブラウザ Internet Explorer ではご覧いただけません。<br>以下のブラウザをお使い下さい。</p>";
	msg += "<ul>";
	msg += "<li style='text-align: left;'><a href='http://www.apple.com/jp/safari/' target='_blank'>Safari</a></li>";
	msg += "<li style='text-align: left;'><a href='http://www.mozilla-japan.org/products/firefox/' target='_blank'>Firefox</a></li>";
	msg += "</ul>";
	
	document.getElementById("map").innerHTML = msg;
	
}


