function AreaSpotMarker(){}

AreaSpotMarker.prototype = {
	spotId: 0,
	latlng: null,
	selected: false,
	normal: 0,
	active: 0,
	scale: 0,


	/**
	 * マーカー作成
	 */
	createMarker: function(spot){
		this.spotId = spot.spotId;
		this.latlng = new GLatLng(spot.lat*1, spot.lng*1);
		this.scale = spot.scale*1;
		this.normal = new GMarker(this.latlng, this.createOption(spot.normal, 0));
		this.active = new GMarker(this.latlng, this.createOption(spot.active, 2));
		this.setEvent(this);
	},


	/**
	 * マーカーオプション作成
	 */
	createOption: function(param, zIndex){
		var icon = new GIcon();
		icon.image = param.imageURL;
		icon.iconSize = new GSize(param.width, param.height);
		icon.iconAnchor = new GPoint(param.placeX, param.placeY);

		var markerOption = new Object();
		markerOption.icon = icon;
		markerOption.zIndexProcess = function(){return zIndex;}
		return markerOption;
	},

	/**
	 * スポットID取得
	 */
	getSpotId: function(){
		return this.spotId;
	},

	/**
	 * 通常マーカー取得
	 */
	getNormal: function(){
		return this.normal;
	},

	/**
	 * アクティブマーカー取得
	 */
	getActive: function(){
		return this.active;
	},

	/**
	 * 動画ごとの尺度取得
	 */
	getScale: function(){
		return this.scale;
	},

	/**
	 * 経度緯度取得
	 */
	getLatLng: function(){
		return this.latlng;
	},

	/**
	 * 通常マーカーセット
	 */
	setNormal: function(){
		this.selected = false;
		this.normal.show();
		this.active.hide();
	},

	/**
	 * アクティブマーカーセット
	 */
	setActive: function(){
		this.selected = true;
		this.active.show();
		this.normal.hide();
	},

	/**
	 * マーカーイベント
	 */
	setEvent: function(marker){
		GEvent.addListener(marker.getNormal(), "click", function(){
			swfName("playListFlash").chActSpot(marker.spotId);
		});

		GEvent.addListener(marker.getActive(), "click", function(){
			AreaMap.map.panTo(marker.getLatLng());
		});
	}
}

//アクティブスポットリセット
function resetActive(){
	for(var i = 0; i < markerList.length; i++){
		if(markerList[i].selected){
			markerList[i].setNormal();
			break;
		}
	}
}

/**
 * Flashからの呼び出し用
 * 指定のスポットをアクティブに
 */
function setSpotActive(spotId){
	var length = markerList.length;
	for(var i = 0; i < length; i++){
		if(markerList[i].spotId==spotId){
			resetActive();
			if(AreaMap.map.getZoom() != markerList[i].getScale()*1 && !AreaMap.isChangedScale){
				AreaMap.map.setZoom(markerList[i].getScale()*1);
			}
			AreaMap.map.panTo(markerList[i].getLatLng());
			markerList[i].setActive();
			break;
		}
	}
}
