//
//
var map, obj;
var width, height;
// 座標デフォルト 空港
var vLat = -8.746311540158215;
var vLng = 115.16924858093262;
vLiquidHeight = -100;

Init();

// 初期化
function Init(){
	window.onload=load;
}
function load(){
	//Error
	var mapMsg = "";
	if( typeof( GBrowserIsCompatible ) == "undefined" ){ mapMsg = "マップを利用するにはインターネットに接続されている必要があります。";}
	else if( !GBrowserIsCompatible() ){ mapMsg = "ご使用の環境ではマップを利用することはできません。"; }
	if (mapMsg !='') { f_HTML_write( "map-msg" , mapMsg ); return; }
	
	var mark = 1;	//Marker
	//var mtype = 1;	//Map Type
	var str ='';	//Text
	var zoom = 15;	//Zoom
	
	//QueryString URLの引数
	if( location.search ){
		if( location.search.match( /(?=.*[&\?]x=([0-9\.-]+))(?=.*[&\?]y=([0-9\.-]+))/ ) ){
			vLat = parseFloat( RegExp.$1 );
			vLng = parseFloat( RegExp.$2 );
		}
		//if( location.search.match( /[&\?]n=([a-zA-Z0-9_\.-]+)/ ) ){
		//	vName   = RegExp.$1;
		//}
		if( location.search.match( /[&\?]f=([0-9]{1,2})/ ) ){
			mark    = parseInt( RegExp.$1 );
		}
		//if( location.search.match( /[&\?]m=([0-9]{1,2})/ ) ){
		//	mtype    = parseInt( RegExp.$1 );
		//}
		if( location.search.match( /[&\?]s=([0-9]{1,2})/ ) ){
			zoom    = parseInt( RegExp.$1 );
		}
		if( location.search.match( /[&\?]t=([^&\?]+)/ ) ){
			str = unescape( RegExp.$1);
			//str = fHTMLencode( str );			//エンコード
			str = str.replace( "|" , "<br />" );				// | を改行に変換
		}
	}
	obj=document.getElementById("map");
	//f_resize();

	var check_flame_set = function(){
		if(!parent.document.getElementById("TB_window")){
			clearInterval(timerID);
			show_map();
		}else if(parent.document.getElementById("TB_window").style.display=="block"){
			clearInterval(timerID);
			show_map();
		}
	}
	var timerID = setInterval(check_flame_set, 500);
	var show_map = function(){
    map = new GMap2(obj);
	var center = new GLatLng(vLat, vLng);
	map.setCenter(center, zoom);
	map.setMapType(G_HYBRID_MAP);
	map.addControl(new GLargeMapControl());
	map.addControl( new GMapTypeControl() );
	if (mark==1){var marker = new GMarker(center); map.addOverlay(marker);}
        else {map.openInfoWindowHtml( center , str );}

	window.unload=GUnload;
	window.onresize=f_resize;
	}
}

function f_HTML_write( id , html ){
	if( !id || !document.getElementById( id ) ){ return false; }
	document.getElementById( id ).innerHTML = html;
	return true;
}
function f_resize(){
	if(window.innerWidth){
		width=window.innerWidth;
		height=window.innerHeight;
	}else if(document.documentElement && document.documentElement.clientWidth){
		width=document.documentElement.clientWidth;
		height=document.documentElement.clientHeight;
	}else if(document.body && document.body.clientWidth){
		width=document.body.clientWidth;
		height=document.body.clientHeight;
	}
	height += vLiquidHeight;
	obj.style.width=width+"px";
	obj.style.height=height+"px";
}
function goMove() {
	map.panTo(new GLatLng(vLat, vLng));
}

//

