/**********************************************************************
* T.RAD MAP SCRIPT ver. 2.0
* create: 2007/8/27
* update: 2011/8/8
**********************************************************************/

var map = null;
var zoom;                  // 拡大率
var titles = new Array();  // ふきだしに表示される名前
var latlngs = new Array(); // 位置情報

/**
 * 地図ページを初期化
 */
function initialize_map()
{
	var map_location = document.getElementById( "map-location" );
	initialize_page( map_location.innerHTML );
	display_map( 0 );
}

/**
 * 地図ページの位置情報をセットする
 *
 * @param string page_tile
 */
function initialize_page( page_title )
{
	switch( page_title ) {
	case "tokyo":
		zoom = 17;
		titles.push( "本社" );
		latlngs.push( new google.maps.LatLng( 35.684638, 139.69236 ) );
		titles.push( "東京営業所" );
		latlngs.push( new google.maps.LatLng( 35.694609,139.76818 ) );
		titles.push( "町田営業所" );
		latlngs.push( new google.maps.LatLng( 35.541925,139.450659 ) );
		break;
	case "tochigi":
		zoom = 17;
		titles.push( "宇都宮営業所" );
		latlngs.push( new google.maps.LatLng( 36.557089,139.905733 ) );
		break;
	case "kanagawa":
		zoom = 17;
		titles.push( "秦野製作所<br />研究開発センター" );
		latlngs.push( new google.maps.LatLng( 35.38427, 139.210572 ) );
		break;
	case "shizuoka":
		zoom = 17;
		titles.push( "浜松営業所" );
		latlngs.push( new google.maps.LatLng( 34.696854,137.739308 ) );
		break;
	case "aichi":
		zoom = 16;
		titles.push( "名古屋製作所" );
		latlngs.push( new google.maps.LatLng( 34.945252, 136.969897 ) );
		titles.push( "研究開発センター<br />自動車営業部（笠寺駐在）<br />建産機営業部" );
		latlngs.push( new google.maps.LatLng( 35.100741, 136.9242 ) );
		break;
	case "shiga":
		zoom = 17;
		titles.push( "滋賀製作所<br />生産技術開発センター<br />空調営業部" );
		latlngs.push( new google.maps.LatLng( 35.093097, 136.230728 ) );
		break;
	case "osaka":
		zoom = 17;
		titles.push( "大阪営業所" );
		latlngs.push( new google.maps.LatLng( 34.705363, 135.496277 ) );
		break;
	case "north_america":
		zoom = 12;
		titles.push( "T.RAD North America Inc." );
		latlngs.push( new google.maps.LatLng( 36.826362, -87.439177 ) );
		break;
	case "europe":
		zoom = 12;
		titles.push( "Toyo-Behr Japanese Components GmbH" );
		latlngs.push( new google.maps.LatLng( 48.814808, 9.165087 ) );
		titles.push( "T.RAD ITALIA S.p.A" );
		latlngs.push( new google.maps.LatLng( 44.972844,7.714977 ) );
		titles.push( "OOO TRM." );
		latlngs.push( new google.maps.LatLng( 0, 0 ) );
		titles.push( "T.RAD Czech s.r.o." );
		latlngs.push( new google.maps.LatLng( 50.093164,14.135284 ) );
		break;
	case "china":
		/* データ無し */
		zoom = 9;
		titles.push( "Quingdao Toyo Heat-Exchanger Co.,Ltd." );
/*		latlngs.push( new google.maps.LatLng( 36.474307,120.561218 ) );*/
		latlngs.push( new google.maps.LatLng( 0, 0 ) );
		titles.push( "Quingdao Toyo Auto Radiator Inc." );
		latlngs.push( new google.maps.LatLng( 0, 0 ) );
		titles.push( "T.RAD(Zhongshan) Co.,Ltd." );
		latlngs.push( new google.maps.LatLng( 0, 0 ) );
		titles.push( "Rising Sun Heat Exchanger Industry Co.,Ltd." );
		latlngs.push( new google.maps.LatLng( 0, 0 ) );
		break;
	case "asia":
		/* データ無し */
		zoom = 12;
		titles.push( "Loads Ltd." );
		latlngs.push( new google.maps.LatLng( 0, 0 ) );
		titles.push( "PT.T.RAD INDONESIA." );
		latlngs.push( new google.maps.LatLng( 0, 0 ) );
		titles.push( "TATA Toyo Radiator Ltd." );
		latlngs.push( new google.maps.LatLng( 0, 0 ) );
		titles.push( "ALEXON.Co.,Ltd." );
		latlngs.push( new google.maps.LatLng( 0, 0 ) );
		titles.push( "TORC Co.,Ltd." );
		latlngs.push( new google.maps.LatLng( 0, 0 ) );
		titles.push( "T.RAD(Thailand) Co.,Ltd." );
		latlngs.push( new google.maps.LatLng( 0, 0 ) );
		titles.push( "PT.BATARASULA MULIA" );
		latlngs.push( new google.maps.LatLng( 0, 0 ) );
		break;
	}
}

/**
 * index に対応した位置の地図を表示
 *
 * @param number index
 */
function display_map( index )
{
	// 地図を表示
	var options = {
		zoom: zoom,
		center: latlngs[index],
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	map = new google.maps.Map(document.getElementById("map-main"), options);

	// マーカーを表示
	var marker = new google.maps.Marker({
		position: latlngs[index],
		map: map,
		title: titles[index]
	});

	// マーカーの上に吹き出しを表示
	var infowindow = new google.maps.InfoWindow({
    content: '<strong style="color:#999;">'+titles[index]+'</strong>'
	});
	infowindow.open(map, marker);
	google.maps.event.addListener(marker, 'click', function() {
		infowindow.open(map, marker);
	});
}

/**
 * index に対応した位置へパン
 *
 * @param number index
 */
function pan_to( index )
{
	display_map(index);
}


