// ウィンドウイベント
window.onload	= load;
window.onunload	= unload;

// グローバル変数
var map		= null;
var mapProp	= null;
var area	= null;
var arySpot	= new Array();

// ロード時処理
function load()
{
	// ブラウザチェック
	if(!GBrowserIsCompatible())
	{
		return;
	}

	// 地図生成
	map = new GMap2(document.getElementById(mapProp.strID));

	// 位置・縮尺設定
	map.setCenter(area.position);
	map.setZoom(area.iZoom);

	// コントロール追加
	switch(mapProp.eMapCtrl)
	{
		case "LARGE":	// 移動・拡大縮小・スライダー
			map.addControl(new GLargeMapControl());
			break;
		case "SMALL":	// 移動・拡大縮小
			map.addControl(new GSmallMapControl());
			break;
		case "ZOOM":	// 拡大縮小
			map.addControl(new GSmallZoomControl());
			break;
	}
	if(mapProp.bScaleCtrl)
	{
		map.addControl(new GScaleControl());
	}
	if(mapProp.bMapTypeCtrl)
	{
		map.addControl(new GMapTypeControl());
	}

	for(var i in arySpot)
	{
		var spot	= arySpot[i];

		// マーカー生成
		var objOption	= new Object();
		objOption.title	= spot.strName;
		var marker		= new GMarker(spot.position, objOption);
		marker.strName	= spot.strName;
		marker.strUrl	= spot.strUrl;
		marker.image	= spot.image;

		// マーカー追加
		map.addOverlay(marker);

		// イベントバインド
		GEvent.bind(marker, "click",		marker, onMarkerClick);
		GEvent.bind(marker, "mouseover",	marker, onMarkerMouseOver);
	}
}

// アンロード時処理
function unload()
{
	// アンロード
	GUnload();
}

//// 地図プロパティクラス
// コンストラクタ
function MapProperty(strID, eMapCtrl, bScaleCtrl, bMapTypeCtrl)
{
	this.strID			= strID;
	this.eMapCtrl		= eMapCtrl;
	this.bScaleCtrl		= bScaleCtrl;
	this.bMapTypeCtrl	= bMapTypeCtrl;
}

//// エリアクラス
// コンストラクタ
function Area(fLatitude, fLongitude, iZoom)
{
	this.position	= new GLatLng(fLatitude, fLongitude);
	this.iZoom		= iZoom;
}

//// スポットクラス
// コンストラクタ
function Spot(fLatitude, fLongitude, strName, strUrl, image)
{
	this.position	= new GLatLng(fLatitude, fLongitude);
	this.strName	= strName;
	this.strUrl		= strUrl;
	this.image		= image;
}

//// イメージプロパティクラス
// コンストラクタ
function ImageProperty(strUrl, iHeight, iWidth)
{
	this.strUrl		= strUrl;
	this.iHeight	= iHeight;
	this.iWidth		= iWidth;
}
