//<![CDATA[

// {{{ addInfo(m, a, c, date, destination, image, isOpen)
function addInfo(m,a,c,date,destination,image, isOpen) {
	//吹き出し内のHTML(要カスタマイズ)
	var text;
	var comment = '';
	if(c) {
		comment = c + '<br clear="all" />';
	}
	var thumbnail = '';
	if(image) {
		//サムネイル画像を取得
		thumbnail_uri = image+'&mode=thumbnail';
		//サムネイルの最大高さ（または最大横幅）は250pxなので250x250の箱にimgタグを埋め込む
		thumbnail = '<a href="'+image+'" rel="lightbox" onclick="myLightbox.start(this); return false;"><img border="0" width="100" src="'+thumbnail_uri+'" hspace="10" align="left" /></a>';
	}
	text = '<table><tr><td><div style="width:300px;"><img src="http://tokyosanpo.jp/img/ico.gif" /><span style="color:#565043; font-size:medium;"><strong>'+a+'さん</strong></span><hr /><div style="background-color:#fdf8ce;padding:3px 3px 3px 3px;margin-bottom:10px;color:#565043;font-size:medium;font-weight:bold;">'+destination+'</div><div style="margin-bottom:10px;">'+thumbnail+comment+'</div><hr /><div style="font-size:small;text-align:right;">'+date+'</div></div></td></tr></table>';

	if(isOpen) {
		//吹き出しをオープン
		m.openInfoWindowHtml(text);
	}
	//クリック時に吹き出しがオープンするように設定
	GEvent.addListener(m, "click", function() {
		m.openInfoWindowHtml(text);
	});
}
// }}}

/*
 * GPS アイコンをクリックしたときの吹き出しに表示する HTML
 *
 * 	addMissionInfo() と openMissionWindow() で同じ吹き出し内容にするための関数
 *
 */
function getMissionInfoText(destination, address, note){
	var text;
	text = destination + '<br />' + address;
	if( note ){
		text += '<br />' + note;
	}
	return text;
}

/*
 * GoogleMap 上の GPS アイコンをクリックしたときに吹き出しを表示する設定
 */
function addMissionInfo(m, destination, address, note){
	var text;
        GEvent.addListener(m, "click", function() {
                text = getMissionInfoText(destination, address, note);
                m.openInfoWindowHtml(text);
        });
}
/*
 * Flash から指定した id のGPSアイコンに吹き出しを出す関数
 *      引数： id = Ittemia のスポットID(mission_id ではなく ts_ittemia_spots.id の意味)
 */
function openMissionWindow(id){
        request_url = goal_url + '/' + id;
        http = new JKL.ParseXML( request_url );
        var goalData = http.parse();
        if( !goalData.kml.Document.Placemark ){
                text = 'no info';
        } else {
                var placemark = goalData.kml.Document.Placemark;
                text = getMissionInfoText(placemark.name, placemark.address, placemark.note);
        }
        missionMarker[id].openInfoWindowHtml(text);
}

/*
 * GoogleMap 上の GPS アイコンをクリックしたときに吹き出しを表示する設定
 */
function addCourseInfo(m, destination, address, note){
        var text;
        GEvent.addListener(m, "click", function() {
                text = getMissionInfoText(destination, address, note); /* Course も共通で使える */
                m.openInfoWindowHtml(text);
        });
}
/*
 * Flash から指定した id のGPSアイコンに吹き出しを出す関数
 *      引数： id = スポットID(ts_spots.id の意味)
 */
function openCourseWindow(id){
        request_url = spot_url + '/' + id;
        http = new JKL.ParseXML( request_url );
        var goalData = http.parse();
        if( !goalData.kml.Document.Placemark ){
                text = 'no info';
        } else {
                var placemark = goalData.kml.Document.Placemark;
                text = getMissionInfoText(placemark.name, placemark.address, placemark.note); /* Course も共通で使える */
        }
        courseMarker[id].openInfoWindowHtml(text);
}

//]]>
