//<![CDATA[
//*===============================================================
//○Zg呼出
//*===============================================================
var Zg = function( argId ) {
	if ( window == this || !this.initialize ) {
		return new Zg( argId );
	}
	return this.initialize( argId );
};
Zg.c = {
	//■ID名
	DIV_GMAP		: ''				,
	DUMMY_END		: 0					
};
Zg.p = {
	//■GoogleMapsオブジェクト
	gMap			: null				,	//GoogleMapオブジェクト
	gWindow			: null				,	//別ウィンドウ
	//■オブジェクト表示
	gIcon			: []				,	//アイコンオブジェクト
	DUMMY_END		: 0					
};
//*===============================================================
//○Zg初期化
//*===============================================================
Zg.prototype.initialize = function( argId ) {
//GLog.write('initialize');
	Zg.c.DIV_GMAP = '#' + argId;
	this.gElement = document.getElementById( argId );
	return this;
};
//*===============================================================
//○初期化
//*===============================================================
$( document ).ready(
	function() {
		Zg( 'ObjectMapDetail' ).start();
		
		hs.registerOverlay( {
			thumbnailId		: null,
			overlayId		: 'controlbar',
			position		: 'top right',
			hideOnMouseOut	: true
			} );
		
	    hs.graphicsDir = '../module/graphics/';
	    hs.outlineType = 'rounded-white';
	}
);
//*===============================================================
//○初期処理
//*===============================================================
Zg.prototype.start = function() {
//GLog.write('start');
	//◆Google Mapを構築済みならアンロード
	if ( Zg.p.gMap != null ) {
		GUnload();
	}
	//◆Google Mapsが利用できるブラウザかどうか判断
	if ( GBrowserIsCompatible() ) {
		//◇利用可能
		//□地図のインスタンスを作成
		Zg.p.gMap = new GMap2( $( Zg.c.DIV_GMAP ).gid()	, G_NORMAL_MAP );
		//□移動/縮尺ボタンをつける
		Zg.p.gMap.addControl(
			new GLargeMapControl() ,
			new GControlPosition( G_ANCHOR_TOP_LEFT  , new GSize( 4 , 32 ) )
		);
		//□地図/衛星写真/地形 切り替え
		Zg.p.gMap.addControl(
			new GMenuMapTypeControl( true , false ) ,
			new GControlPosition( G_ANCHOR_TOP_LEFT  , new GSize( 2 , 2 ) )
		);
		Zg.p.gMap.addMapType( G_PHYSICAL_MAP ); 
		//□ズームイン時にスムーズ
		Zg.p.gMap.enableContinuousZoom();
		//□ダブルクリック時にズームイン
		Zg.p.gMap.enableDoubleClickZoom();
		//□初期表示位置を設定
		Zg.p.gMap.setCenter( new GLatLng( parseFloat( o_latitude ) , parseFloat( o_longitude ) ) , parseInt( o_zoom , 10 ) );
		//□マウススクロール時にズームイン・ズームアウト
		Zg.p.gMap.enableScrollWheelZoom();
		GEvent.addDomListener( $( Zg.c.DIV_GMAP ).gid() , 'DOMMouseScroll' , this.cancelEventMouse );
		GEvent.addDomListener( $( Zg.c.DIV_GMAP ).gid() , 'mousewheel'     , this.cancelEventMouse );
		
		//□初期化
		this.clearAllParameter();
		//□アイコン作成
		this.makeIcon();
		
		//□マーカーの設置
		var marker = new GMarker(
			new GLatLng(
				parseFloat( o_latitude	),
				parseFloat( o_longitude	)
			) ,
			Zg.p.gIcon[o_genre]
		);
		Zg.p.gMap.addOverlay	( marker	);
	}
};
//*===============================================================
//○マウススクロールキャンセル処理
//*===============================================================
Zg.prototype.cancelEventMouse = function( argEvent ) {
//GLog.write('cancelEventMouse');
	var e	= argEvent;
	if (typeof e.preventDefault  == 'function') {
		e.preventDefault();
	}
	if (typeof e.stopPropagation == 'function') {
		e.stopPropagation();
	}
	if ( window.event ) {
		window.event.cancelBubble	= true;
		window.event.returnValue	= false;
	}
};
//*===============================================================
//○変数初期化
//*===============================================================
Zg.prototype.clearAllParameter = function() {
//GLog.write('clearAllParameter');
	Zg.p.gMap.clearOverlays();
	Zg.p.gIcon					= new Array();
};
//*===============================================================
//○別ウインドウを開く
//*===============================================================
Zg.prototype.openwin = function( argUrl , argWidth , argHeight ) {
	if ( window.gWindow ) {
		Zg.p.gWindow.close();
	}
	Zg.p.gWindow = window.open( argUrl , 'win' , 'width=' + argWidth + ',height=' + argHeight + ',status=no,scrollbars=yes,directories=no,menubar=no,resizable=yes,toolbar=no' );
};
//*===============================================================
//○別PG画面を開く
//*===============================================================
Zg.prototype.openPG = function( argPG ) {
	var url = this.makeRequestSelect( argPG );
	window.location.href = url;
};
//*===============================================================
//○アイコン作成
//*===============================================================
Zg.prototype.makeIcon = function( argPG ) {
//GLog.write('makeIcon');
	//アイコン
	for( var idx = 101; idx <= 103; idx++ ) {
		Zg.p.gIcon[idx]					= new GIcon();
		Zg.p.gIcon[idx].image			= 'parts/gmapicon' + idx + '.png';
		Zg.p.gIcon[idx].iconSize		= new GSize (32 , 42);
		Zg.p.gIcon[idx].iconAnchor		= new GPoint(16 , 21);
		Zg.p.gIcon[idx].shadow    	 	= 'parts/gmapicon_shadow.png';
		Zg.p.gIcon[idx].shadowSize		= new GSize (34 , 50);
		Zg.p.gIcon[idx].infoWindowAnchor= new GPoint(16 , 21);
	}
};
//]]>
