var GAMap = Class.create({
	initialize: function(element, options){
		GAMap.Search = this;
		this.m_element  = {'container': $(element)};
		this.m_options  = options || {};
		this.m_scales   = [];
		this.m_window1  = null;
		this.m_window2  = null;
		this.m_text     = '';
		this.m_mode     = 0;
		this.m_radio    = 1;
		this.m_area     = {header:[], bottom:[]};
		this.m_point    = {};
		this.m_map      = null;
		this.m_slider   = null;
		this.m_max      = 0;
		this.m_param    = {};
		this.m_xml      = {};
		this.m_hanrei1  = '';
		this.m_hanrei2  = '';
		this.m_table_no = '';
		this.m_layer1   = '';
		this.m_layer2   = '';
		
		// オプションをチェック
		this.checkOption();
		
		// 公開／非公開 表示選択
		this.setArea();
		
		// XMLをチェック
		this.createXMLDom();
		
		// フォームパラメータを取得
		this.getParam();
		
		//--- area ---
		if(this.m_options.area===true){
			this.initElementArea();
		}
		//--- form ---
		if(this.m_options.form===true){
			this.initElementForm();
		}
		//--- map ---
		this.initElementMap();
		
		// 地図初期化
		this.initMap();
		
		//--- scale ---
		if(this.m_options.scale===true){
			this.initElementScale();
		}
		//--- enquete ---
		if(this.m_options.enquete===true){
			this.initElementEnquete();
		}
		//--- hanrei ---
		if(this.m_options.hanrei===true){
			this.initElementHanrei();
		}
		
		// スライダーバー初期化
		this.initSlider();
		
		// 地図描画
		this.setCenter(this.m_param.x, this.m_param.y, this.m_param.scale);
	},
	
	checkOption: function(){
		this.m_options.width  = parseInt(this.m_options.width ) || 510;
		this.m_options.height = parseInt(this.m_options.height) || 350;
		if(this.m_options.width < 200){
			this.m_options.width = 200;
		}else if(this.m_options.width > 1000){
			this.m_options.width = 1000;
		}
		if(this.m_options.height < 200){
			this.m_options.height = 200;
		}else if(this.m_options.height > 1000){
			this.m_options.height = 1000;
		}
		this.m_options.default_xcd = parseFloat(this.m_options.default_xcd) || 139.748348;
		this.m_options.default_ycd = parseFloat(this.m_options.default_ycd) || 35.664228;
		this.m_options.default_scale = parseInt(this.m_options.default_scale) || 320000;
		this.m_options.default_area = parseInt(this.m_options.default_area) || 3;
		this.m_options.default_scale_count = parseInt(this.m_options.default_scale_count) || 7;
		this.m_options.presite = (typeof(this.m_options.presite)=='boolean') ? this.m_options.presite: false;
	},
	
	setArea: function(){
		if(this.m_options.presite===true){
			this.m_hanrei1  = 
			  '<tr><td><div class="GAnoteBlock_" style="width:70px;height:25px;background:#fff;"><div style="width:70px;height:25px;background:#FF1F5F;filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;;"></div></div></td><td>2010年9月現在のサービス提供地域（下り最大7.2Mbps）</td></tr>'+
			  '<tr><td><div class="GAnoteBlock_" style="width:70px;height:25px;background:#fff;"><div style="width:70px;height:25px;background:#FFCC40;filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;;"></div></div></td><td>2010年12月末までのサービス拡大予定地域（下り最大7.2Mbps）</td></tr>';
			this.m_hanrei2  = 
			  '<tr><td><div class="GAnoteBlock_" style="width:70px;height:25px;background:#fff;"><div style="width:70px;height:25px;background:#6616FF;filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;;"></div></div></td><td>2010年9月現在の下り最大21Mbps提供地域</td></tr>';
			this.m_table_no = 'A';
			this.m_layer1   = '2;1;2;1;0;;FF1F5F;FF1F5F;0;;FFCC40;FFCC40;';
			this.m_layer2   = '1;4;1;0;;6616FF;6616FF;';
		}else{
			this.m_hanrei1  = 
			  '<tr><td><div class="GAnoteBlock_" style="width:70px;height:25px;background:#fff;"><div style="width:70px;height:25px;background:#FF1F5F;filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;;"></div></div></td><td>2010年8月現在のサービス提供地域（下り最大7.2Mbps）</td></tr>'+
			  '<tr><td><div class="GAnoteBlock_" style="width:70px;height:25px;background:#fff;"><div style="width:70px;height:25px;background:#FFCC40;filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;;"></div></div></td><td>2010年12月末までのサービス拡大予定地域（下り最大7.2Mbps）</td></tr>';
			this.m_hanrei2  = 
			  '<tr><td><div class="GAnoteBlock_" style="width:70px;height:25px;background:#fff;"><div style="width:70px;height:25px;background:#6616FF;filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;;"></div></div></td><td>2010年8月現在の下り最大21Mbps提供地域</td></tr>';
			this.m_table_no = 'B';
			this.m_layer1   = '2;1;2;1;0;;FF1F5F;FF1F5F;0;;FFCC40;FFCC40;';
			this.m_layer2   = '1;4;1;0;;6616FF;6616FF;';
		}
	},
	
	createXMLDom: function(){
		for(var key in GAMap.XML){
			var dom = GAMap.XMLParse(GAMap.XML[key]);
			if(dom!==null){
				var scales = dom.getElementsByTagName('scale');
				for(var i=0,l=scales.length; i<l; i++){
					if(i>=this.m_options.default_scale_count) scales[i].setAttribute('nobuild', 'true');
				}
			}
			GAMap.XMLDom[key] = dom;
		}
	},
	
	getParam: function(){
		var object = this;
		var param = location.search.substring(1).split('&');
		for(var i=0,l=param.length; i<l; i++){
			var temp = param[i].split('=');
			switch(temp[0].toLowerCase()){
				case 'xcd': this.m_param.x = parseFloat(temp[1]); break;
				case 'ycd': this.m_param.y = parseFloat(temp[1]); break;
				case 'scale': this.m_param.scale = parseInt(temp[1]); break;
				case 'area': this.m_param.area = parseInt(temp[1]); break;
			}
		}
		check('x', this.m_options.default_xcd);
		check('y', this.m_options.default_ycd);
		check('scale', this.m_options.default_scale);
		check('area', this.m_options.default_area);
		function check(key, value){
			if(isNaN(object.m_param[key])) object.m_param[key] = value;
		}
	},
	
	initElementForm: function(){
		var html = 
		'<div class="GAbox_">'+
		  '<form id="GAIDform1_">'+
		    '<div class="GAexample_"><img src="http://area.emobile.jp/map/images/title_search.gif" alt="フリーワード検索"><span id="GAIDexample_"></span></div>'+
		    '<div><input id="GAIDtext_" type="text" style="width:' + (this.m_options.width - 100) + 'px;" /><input type="submit" value="検索"style="margin-left:5px !important;width:100px;" /></div>'+
		    '<div class="GAradio_">'+
		      '<input id="GAIDradio1_" name="GAradio_" type="radio" value="1" /><label for="GAIDradio1_">住所</label>'+
		      '<input id="GAIDradio2_" name="GAradio_" type="radio" value="2" /><label for="GAIDradio2_">郵便番号</label>'+
		      '<input id="GAIDradio3_" name="GAradio_" type="radio" value="3" /><label for="GAIDradio3_">駅名</label>'+
		      '<input id="GAIDradio4_" name="GAradio_" type="radio" value="4" /><label for="GAIDradio4_">ランドマーク</label>'+
		    '</div>'+
		  '</form>'+
		'</div>';
		this.m_element['container'].insert(html);
		this.m_element['text'] = $('GAIDtext_');
		Event.observe($('GAIDform1_'), 'submit', this.search.bindAsEventListener(this));
		var example = new GAMap.Example($('GAIDexample_'), {
			onSelect: this.radio.bind(this)
		});
		example.add('GAIDradio1_', '（例：東京都港区）');
		example.add('GAIDradio2_', '（例：000-0000）');
		example.add('GAIDradio3_', '（例：虎ノ門）');
		example.add('GAIDradio4_', '（例：東京タワー）');
		example.set('GAIDradio1_');
		$('GAIDradio1_').checked = true;
	},
	
	initElementMap: function(){
		this.m_element['container'].addClassName('GAmap_');
		this.m_element['container'].setStyle({'width': (this.m_options.width + 40) + 'px'});
		var html = 
		'<p class="GAp_ GAdotL_">現在地：<span id="GAIDplace_"></span></p>'+
		'<table class="GAtable_">'+
		  '<tr>'+
		    '<td><a id="GAIDmoveUL_" href="javascript:void(0)"><img src="http://area.emobile.jp/map/images/move/UL.gif" alt="北西へ移動" title="北西へ移動" style="border:none;" /></a></td>'+
		    '<td style="text-align:center;"><a id="GAIDmoveU_" href="javascript:void(0)"><img src="http://area.emobile.jp/map/images/move/U.gif" alt="北へ移動" title="北へ移動" style="border:none;" /></a></td>'+
		    '<td><a id="GAIDmoveUR_" href="javascript:void(0)"><img src="http://area.emobile.jp/map/images/move/UR.gif" alt="北東へ移動" title="北東へ移動" style="border:none;" /></a></td>'+
		  '</tr>'+
		  '<tr>'+
		    '<td><a id="GAIDmoveML_" href="javascript:void(0)"><img src="http://area.emobile.jp/map/images/move/ML.gif" alt="西へ移動" title="西へ移動" style="border:none;" /></a></td>'+
		    '<td style="width:' + this.m_options.width + 'px;height:' + this.m_options.height + 'px;text-align:left;vertical-align:top">'+
		      '<div style="position:relative;width:' + this.m_options.width + 'px;height:' + this.m_options.height + 'px;">'+
		        '<div id="GAIDmap_" style="width:' + (this.m_options.width - 2) + 'px;height:' + (this.m_options.height - 2) + 'px;border:1px solid #999;">'+
		          '<div style="margin: -10px 0px 0px -10px !important;position:absolute;top:50%;left:50%;width:20px;height:20px;background:url(http://area.emobile.jp/map/images/center.gif) center no-repeat;z-index:100;"></div>'+
		          '<div id="GAIDloading1_" style="margin: -12px 0px 0px -100px !important;position:absolute;top:50%;left:50%;width:200px;height:24px;background:url(http://area.emobile.jp/map/images/loading.gif) center no-repeat;z-index:100;"></div>'+
		          '<div id="GAIDloading2_" style="margin: -12px 0px 0px -100px !important;position:absolute;top:50%;left:50%;width:200px;height:24px;background:url(http://area.emobile.jp/map/images/loading.gif) center no-repeat;z-index:100;"></div>'+
		        '</div>'+
		        '<div style="position:absolute;top:7px;left:7px;z-index:100;">'+
		          '<div id="GAIDzoomin_" title="詳細" style="background:url(http://area.emobile.jp/map/images/slider/zoomin.gif) center no-repeat;width:20px;height:20px;cursor:pointer;"></div>'+
		          '<div style="position:relative;width:20px;height:100px;">'+
		            '<div id="GAIDtrack_" style="position:absolute;top:2px;background:url(http://area.emobile.jp/map/images/slider/track.gif) no-repeat center;width:20px;height:96px;cursor:pointer;">'+
		              '<div id="GAIDhandle_" style="background:url(http://area.emobile.jp/map/images/slider/handle.gif) no-repeat center;width:20px;height:12px;cursor:pointer;" title="ドラッグして拡大"></div>'+
		            '</div>'+
		          '</div>'+
		          '<div id="GAIDzoomout_" title="広域" style="background:url(http://area.emobile.jp/map/images/slider/zoomout.gif) center no-repeat;width:20px;height:20px;cursor:pointer;"></div>'+
		        '</div>'+
		      '</div>'+
		    '</td>'+
		    '<td><a id="GAIDmoveMR_" href="javascript:void(0)"><img src="http://area.emobile.jp/map/images/move/MR.gif" alt="東へ移動" title="東へ移動" style="border:none;" /></a></td>'+
		  '</tr>'+
		  '<tr>'+
		    '<td><a id="GAIDmoveLL_" href="javascript:void(0)"><img src="http://area.emobile.jp/map/images/move/LL.gif" alt="南西へ移動" title="南西へ移動" style="border:none;" /></a></td>'+
		    '<td style="text-align:center;"><a id="GAIDmoveL_" href="javascript:void(0)"><img src="http://area.emobile.jp/map/images/move/L.gif" alt="南へ移動" title="南へ移動" style="border:none;" /></a></td>'+
		    '<td><a id="GAIDmoveLR_" href="javascript:void(0)"><img src="http://area.emobile.jp/map/images/move/LR.gif" alt="南東へ移動" title="南東へ移動" style="border:none;" /></a></td>'+
		  '</tr>'+
		'</table>';
		this.m_element['container'].insert(html);
		this.m_element['place'] = $('GAIDplace_');
		this.m_element['loading1'] = $('GAIDloading1_');
		this.m_element['loading2'] = $('GAIDloading2_');
		this.m_element['loading1'].hide();
		this.m_element['loading2'].hide();
		Event.observe($('GAIDzoomin_' ), 'click', this.zoom.bindAsEventListener(this, 'in'));
		Event.observe($('GAIDzoomout_'), 'click', this.zoom.bindAsEventListener(this, 'out'));
		Event.observe($('GAIDmoveUL_' ), 'click', this.move.bindAsEventListener(this, 'nw'));
		Event.observe($('GAIDmoveU_'  ), 'click', this.move.bindAsEventListener(this, 'n' ));
		Event.observe($('GAIDmoveUR_' ), 'click', this.move.bindAsEventListener(this, 'ne'));
		Event.observe($('GAIDmoveML_' ), 'click', this.move.bindAsEventListener(this, 'w' ));
		Event.observe($('GAIDmoveMR_' ), 'click', this.move.bindAsEventListener(this, 'e' ));
		Event.observe($('GAIDmoveLL_' ), 'click', this.move.bindAsEventListener(this, 'sw'));
		Event.observe($('GAIDmoveL_'  ), 'click', this.move.bindAsEventListener(this, 's' ));
		Event.observe($('GAIDmoveLR_' ), 'click', this.move.bindAsEventListener(this, 'se'));
	},
	
	initElementScale: function(){
		var object = this;
		var scales = this.m_scales.clone().reverse();
		var container = new Element('p', {'class':'GAp_ GAdotU_ GAcenter_ GAscale_'});
		this.m_element['container'].insert(container);
		var l = this.m_options.default_scale_count;
		if(l > scales.length) l = scales.length;
		for(var i=0; i<l; i++){
			if(i > 0) container.insert('&nbsp;|&nbsp;');
			container.insert(createScale(scales[i]));
		}
		function createScale(scale){
			var anchor = new Element('a', {'href':'javascript:void(0)'}).update('1/' + GAMap.formatNumber(scale));
			Event.observe(anchor, 'click', object.scale.bindAsEventListener(object, scale));
			return anchor;
		}
	},
	
	initElementEnquete: function(){
		var container = new Element('p', {'class':'GAp_ GAdotU_ GAcenter_'});
		this.m_element['container'].insert(container);
		var anchor = new Element('a', {'href':'javascript:void(0)', 'class':'GApopup_'}).update('サービスエリアに関するアンケート');
		Event.observe(anchor, 'click', this.enquete.bindAsEventListener(this));
		container.insert(anchor);
	},
	
	initElementHanrei: function(){
		var html = 
		'<div class="GAbox2_">'+
		  '<p class="GAmark_">凡例の説明</p>'+
		    '<table class="GAnote_">'+
		      this.m_hanrei1+
		      (this.m_options.hispeed === true ? this.m_hanrei2: '')+
		    '</table>'+
		'</div>';
		this.m_element['container'].insert(html);
	},
	
	initElementArea: function(){
		var object = this;
		var header = new Element('p', {'class':'GAtab_'});
		this.m_element['container'].insert(header);
		var i = 0;
		for(var area in GAMap.Area){
			var select = ((i+1)==this.m_param.area) ? true: false;
			var bottom = new Element('p', {'class':'GAp_ GAdotL_'});
			this.m_element['container'].insert(bottom);
			this.m_area.bottom.push(bottom);
			var elmArea = createArea(area, bottom, 'GAIDarea' + (i + 1) + '_');
			if(select){
				elmArea.addClassName('GAareaSelect_');
			}else{
				bottom.hide()
			}
			this.m_area.header.push(elmArea);
			header.insert(elmArea);
			var fkns = GAMap.Area[area];
			var j = 0;
			for(var fkn in fkns){
				var elmFkn = createFkn(fkn, fkns[fkn]);
				if(j > 0) bottom.insert('、');
				bottom.insert(elmFkn);
				j++;
			}
			i++;
		}
		header.insert(new Element('div', {'class':'GAline_'}));
		function createArea(text, element, id){
			var anchor = new Element('a', {'href':'javascript:void(0)', 'id':id}).update(text);
			Event.observe(anchor, 'click', object.show.bindAsEventListener(object, anchor, element));
			return anchor;
		}
		function createFkn(text, coord){
			var anchor = new Element('a', {'href':'javascript:void(0)'}).update(text);
			Event.observe(anchor, 'click', object.fkn.bindAsEventListener(object, coord.x, coord.y, coord.scale));
			return anchor;
		}
	},
	
	initMap: function(){
		this.m_map = new MapObject($('GAIDmap_'), {
			Layers: {'normal':['http://scr.info-mapping.com/emobile/scrollimages/2010040000000000/']},
			GALAY : 'normal'
		});
		GA.addListener(this.m_map, 'moveend', this.moveend.bind(this));
		GA.addListener(this.m_map, 'changescale', this.changescale.bind(this));
		if(true){
			this.m_map.addLayer(this.createLayer(1, 0.5, this.m_layer1));
		}
		if(true && this.m_options.hispeed===true){
			this.m_map.addLayer(this.createLayer(2, 0.5, this.m_layer2));
		}
		this.m_scales = this.m_map.scale.aryScale.clone().reverse();
	},
	
	initSlider: function(){
		this.m_max = this.m_scales.length - 1;
		this.m_slider = new Control.Slider($('GAIDhandle_'), $('GAIDtrack_'), {
			axis: 'vertical',
			range: $R(0, this.m_max),
			values: $R(0, this.m_max),
			sliderValue: this.index(),
			onChange: this.slider.bind(this)
		});
	},
	
	createLayer: function(number, opacity, renderer){
		var object = this;
		var loading = null;
		switch(number){
			case 1: loading = object.m_element['loading1']; break;
			case 2: loading = object.m_element['loading2']; break;
		}
		var layer = new GALayer({drawmove: true, opacity: opacity});
		GA.addListener(layer, 'render', function(){
			if(loading) loading.show();
			this.setSrc('http://area.emobile.jp/map/mapImage.asp' + 
				'?layer=' + number + 
				'&table_no=' + object.m_table_no + 
				'&renderer=' + renderer + 
				'&x=' + object.m_point.x + 
				'&y=' + object.m_point.y + 
				'&scale=' + object.m_map.getScale() + 
				'&width=' + object.m_options.width + 
				'&height=' + object.m_options.height
			);
		});
		GA.addListener(layer, 'load', function(){
			if(loading) loading.hide();
		});
		return layer;
	},
	
	getCenter: function(){
		return {x:this.m_point.x, y:this.m_point.y, scale:this.m_map.getScale()};
	},
	
	setCenter: function(x, y, scale){
		scale = parseInt(scale);
		if(isNaN(scale)){
			this.m_map.setCenter(new DPoint(x, y));
		}else{
			this.m_map.setCenter(new DPoint(x, y), scale);
		}
	},
	
	setScale: function(scale){
		this.m_map.setScale(scale);
	},
	
	slider: function(index){
		var scale = this.m_scales[index];
		if(scale!=this.m_map.getScale()) this.setScale(scale);
	},
	
	index: function(){
		return this.m_scales.indexOf(this.m_map.getScale());
	},
	
	moveend: function(){
		this.m_point = this.m_map.getCenter();
		this.place();
	},
	
	changescale: function(){
		this.m_slider.setValue(this.index());
	},
	
	enquete: function(e){
		e.stop();
		var param = '';
		var x = this.m_point.x;
		var y = this.m_point.y;
		if(x >= 122 && x <= 155 && y >= 18 && y <= 47){
			param = 
			'?xcd=' + this.m_point.x + 
			'&ycd=' + this.m_point.y + 
			'&scale=' + this.m_map.getScale();
		}
		var url = 'http://emobile.jp/area/enq/index.html' + param;
		this.m_window2 = window.open(url, 'windowGAenquete', 'width=600,height=600,resizable=1,scrollbars=yes');
		this.m_window2.focus();
	},
	
	show: function(e, anchor, bottom){
		e.stop();
		for(var i=0,l=this.m_area.header.length; i<l; i++){
			this.m_area.header[i].removeClassName('GAareaSelect_');
		}
		anchor.addClassName('GAareaSelect_');
		for(var i=0,l=this.m_area.bottom.length; i<l; i++){
			var element = this.m_area.bottom[i];
			if(element==bottom){
				element.show();
			}else{
				element.hide();
			}
		}
	},
	
	fkn: function(e, x, y, scale){
		e.stop();
		this.setCenter(x, y, scale);
	},
	
	scale: function(e, scale){
		e.stop();
		this.setScale(scale);
	},
	
	zoom: function(e, mode){
		e.stop();
		var index = this.m_slider.value;
		switch(mode){
			case 'in' : index--; break;
			case 'out': index++; break;
		}
		if(0<=index && index<=this.m_max) this.m_slider.setValue(index);
	},
	
	move: function(e, direction){
		e.stop();
		var ratio  = (2 / 3);
		var extent = this.m_map.getExtent();
		var x = this.m_point.x;
		var y = this.m_point.y;
		if(direction.indexOf('n', 0) >= 0) y += (Math.abs(extent.top    - y) * ratio);
		if(direction.indexOf('e', 0) >= 0) x += (Math.abs(extent.right  - x) * ratio);
		if(direction.indexOf('w', 0) >= 0) x -= (Math.abs(extent.left   - x) * ratio);
		if(direction.indexOf('s', 0) >= 0) y -= (Math.abs(extent.bottom - y) * ratio);
		this.m_map.scrollMove(new DPoint(x, y));
	},
	
	radio: function(value){
		this.m_radio = value;
	},
	
	search: function(e){
		e.stop();
		var text = this.m_element['text'].value;
		if(!text){
			alert('検索文字列を入力してください。');
			return;
		}
		var left = '';
		var width = screen.availWidth || screen.width;
		if(!isNaN(width)){
			width -= 290;
			left = ',left=' + ((width < 0) ? 0: width);
		}
		this.m_text = text;
		this.m_mode = this.m_radio;
		this.m_window1 = window.open('search.html', 'windowGAsearch', 'width=280,height=600,resizable=1,top=0' + left);
		this.m_window1.focus();
	},
	
	place: function(){
		var element = this.m_element['place'];
		var url = 'http://area.emobile.jp/map/getPlace.asp?x=' + this.m_point.x + '&y=' + this.m_point.y;
		GAMap.JSONP(url, function(address){
			element.update(address ? address + '付近 ': '');
		});
	}
	
});

GAMap.Example = Class.create({
	initialize: function(element, options){
		this.m_element = element;
		this.m_options = options || {};
		this.m_example = {};
	},
	add: function(id, text){
		this.m_example[id] = text;
		Event.observe($(id), 'click', this.set.bind(this, id));
	},
	set: function(id){
		this.m_element.innerHTML = this.m_example[id];
		if(this.m_options.onSelect) this.m_options.onSelect($(id).value);
	}
});

GAMap.Log = function(param){
	param = param || {};
	var ary = [];
	for(var key in param) ary.push(key + '=' + param[key]);
	param = ary.join('&');
	if(param.length > 0) param = '?' + param;
	GAMap.JSONP('http://area.emobile.jp/map/log.asp' + param, function(){});
};

GAMap.Area = {'北海道':{'道北':{x:142.250513,y:44.004777,scale:640000},'道央':{x:141.350472,y:43.061833,scale:320000},'道東':{x:144.053388,y:43.260698,scale:1280000},'道南':{x:140.732694,y:41.766111,scale:320000}},'東北':{'青森県':{x:140.743694,y:40.821694,scale:320000},'岩手県':{x:141.156222,y:39.700778,scale:320000},'宮城県':{x:140.875389,y:38.26575,scale:320000},'秋田県':{x:140.105314,y:39.715784,scale:320000},'山形県':{x:140.366806,y:38.237528,scale:320000},'福島県':{x:140.471056,y:37.747056,scale:320000}},'関東':{'茨城県':{x:140.450056,y:36.338278,scale:320000},'栃木県':{x:139.886806,y:36.562556,scale:320000},'群馬県':{x:139.064139,y:36.388056,scale:320000},'埼玉県':{x:139.652083,y:35.853694,scale:320000},'千葉県':{x:140.126444,y:35.601333,scale:320000},'東京都':{x:139.694944,y:35.686333,scale:320000},'神奈川県':{x:139.64575,y:35.444444,scale:320000},'山梨県':{x:138.5715,y:35.660722,scale:320000}},'信越':{'新潟県':{x:139.026778,y:37.899278,scale:320000},'長野県':{x:138.184111,y:36.648222,scale:320000}},'東海':{'静岡県':{x:138.385494,y:34.973524,scale:320000},'岐阜県':{x:136.725111,y:35.388,scale:320000},'愛知県':{x:136.909535,y:35.176583,scale:320000},'三重県':{x:136.5115,y:34.727,scale:320000}},'北陸':{'富山県':{x:137.213802,y:36.692103,scale:320000},'石川県':{x:136.66054,y:36.55954,scale:320000},'福井県':{x:136.224694,y:36.062139,scale:320000}},'関西':{'滋賀県':{x:135.871139,y:35.001167,scale:320000},'京都府':{x:135.758472,y:35.018056,scale:320000},'大阪府':{x:135.522806,y:34.683139,scale:320000},'兵庫県':{x:135.185778,y:34.688056,scale:320000},'奈良県':{x:135.835618,y:34.681707,scale:320000},'和歌山県':{x:135.170222,y:34.222694,scale:320000}},'中国':{'鳥取県':{x:134.240889,y:35.500556,scale:320000},'島根県':{x:133.053139,y:35.469083,scale:320000},'岡山県':{x:133.937261,y:34.658341,scale:320000},'広島県':{x:132.461889,y:34.393028,scale:320000},'山口県':{x:131.473833,y:34.182611,scale:320000}},'四国':{'徳島県':{x:134.562194,y:34.062417,scale:320000},'香川県':{x:134.046056,y:34.336889,scale:320000},'愛媛県':{x:132.768639,y:33.838333,scale:320000},'高知県':{x:133.533722,y:33.556389,scale:320000}},'九州':{'福岡県':{x:130.42083,y:33.603275,scale:320000},'佐賀県':{x:130.30192,y:33.246107,scale:320000},'長崎県':{x:129.875809,y:32.741665,scale:320000},'熊本県':{x:130.743639,y:32.786361,scale:320000},'大分県':{x:131.615028,y:33.234778,scale:320000},'宮崎県':{x:131.426222,y:31.9075,scale:320000},'鹿児島県':{x:130.560284,y:31.556663,scale:320000}},'沖縄':{'沖縄本島':{x:127.68275,y:26.208472,scale:320000}}};
GAMap.Search = {};
GAMap.XMLDom = {};
GAMap.XML = {};
GAMap.XML['normal'] = '<?xml version="1.0" encoding="shift_jis" ?><galay value="0000000000011111"><mmperpixel>0.25</mmperpixel><rasterformat>gif</rasterformat><rasterpixelsize>250</rasterpixelsize><switchlevel>2</switchlevel><scalelevel><scale level="0" nobuild="false">2560000</scale><scale level="1" nobuild="false">1280000</scale><scale level="2" nobuild="false">640000</scale><scale level="3" nobuild="false">320000</scale><scale level="4" nobuild="false">160000</scale><scale level="5" nobuild="false">80000</scale><scale level="6" nobuild="false">40000</scale><scale level="7" nobuild="false">20000</scale><scale level="8" nobuild="true" /><scale level="9" nobuild="true" /><scale level="10" nobuild="true" /><scale level="11" nobuild="true" /><scale level="12" nobuild="true" /><scale level="13" nobuild="true" /><scale level="14" nobuild="true" /><scale level="15" nobuild="true" /><scale level="16" nobuild="true" /><scale level="17" nobuild="true" /><scale level="18" nobuild="true" /><scale level="19" nobuild="true" /></scalelevel><kei no="0"><extentbl><l>120.00000000</l><b>18.00000000</b><r>156.00000000</r><t>48.00000000</t></extentbl><extentxy><l>120.00000000</l><b>18.00000000</b><r>156.00000000</r><t>48.00000000</t></extentxy></kei><kei no="1"><extentbl><l>127.12500000</l><b>25.91500000</b><r>133.25000000</r><t>35.80999291</t></extentbl><extentxy><l>-237940.98497293</l><b>-783014.79335931</b><r>375796.28007142</r><t>318142.85266061</t></extentxy></kei><kei no="2"><extentbl><l>128.25000000</l><b>29.00000000</b><r>135.00000000</r><t>37.70000000</t></extentbl><extentxy><l>-267953.39984814</l><b>-440269.26676975</b><r>389839.49623945</r><t>528881.39999327</t></extentxy></kei><kei no="3"><extentbl><l>129.62500000</l><b>32.50000000</b><r>136.12500000</r><t>37.70000000</t></extentbl><extentxy><l>-238838.67648653</l><b>-385317.41765027</b><r>372035.88107739</r><t>195998.78760525</t></extentxy></kei><kei no="4"><extentbl><l>130.87500000</l><b>31.50000000</b><r>138.00000000</r><t>37.00000000</t></extentbl><extentxy><l>-249366.44971221</l><b>-163316.84390634</b><r>427617.87912058</r><t>453149.76991064</t></extentxy></kei><kei no="5"><extentbl><l>132.00000000</l><b>33.00000000</b><r>138.00000000</r><t>37.70000000</t></extentbl><extentxy><l>-218034.46012461</l><b>-330307.41717983</b><r>342682.58984809</r><t>194950.21073547</t></extentxy></kei><kei no="6"><extentbl><l>133.75000000</l><b>32.20000000</b><r>140.00000000</r><t>39.00000000</t></extentbl><extentxy><l>-212124.07951552</l><b>-419205.83127190</b><r>377200.59900618</r><t>340510.73276236</t></extentxy></kei><kei no="7"><extentbl><l>135.00000000</l><b>32.20000000</b><r>141.00000000</r><t>39.66666700</t></extentbl><extentxy><l>-204265.97048900</l><b>-419367.30569490</b><r>361473.48709986</r><t>413920.49463644</t></extentxy></kei><kei no="8"><extentbl><l>136.25000000</l><b>33.00000000</b><r>143.00000000</r><t>41.00000000</t></extentbl><extentxy><l>-210245.84429417</l><b>-330477.17578359</b><r>420624.47754027</r><t>564679.74464066</t></extentxy></kei><kei no="9"><extentbl><l>137.25000000</l><b>28.20000000</b><r>144.00000000</r><t>42.83333300</t></extentbl><extentxy><l>-253623.33969243</l><b>-862056.89582308</b><r>409193.60600957</r><t>766932.29326527</t></extentxy></kei><kei no="10"><extentbl><l>138.00000000</l><b>36.58333300</b><r>145.00000000</r><t>45.00000000</t></extentbl><extentxy><l>-253543.69186507</l><b>-375440.46972665</b><r>372909.89095813</r><t>563751.41107615</t></extentxy></kei><kei no="11"><extentbl><l>138.00000000</l><b>40.20000000</b><r>145.00000000</r><t>47.00000000</t></extentbl><extentxy><l>-191540.58666276</l><b>-419569.47691032</b><r>404423.81580780</r><t>344315.17285120</t></extentxy></kei><kei no="12"><extentbl><l>139.87500000</l><b>40.83333300</b><r>149.00000000</r><t>47.00000000</t></extentbl><extentxy><l>-200287.86136376</l><b>-348969.02708833</b><r>569406.60751817</r><t>355511.93993673</t></extentxy></kei><kei no="13"><extentbl><l>141.62500000</l><b>41.08333300</b><r>150.00000000</r><t>47.00000000</t></extentbl><extentxy><l>-220538.52662666</l><b>-320605.45948488</b><r>483172.24238835</r><t>349423.82380668</t></extentxy></kei><kei no="14"><extentbl><l>138.00000000</l><b>23.00000000</b><r>144.00000000</r><t>30.41000000</t></extentbl><extentxy><l>-410234.00933744</l><b>-330831.60062841</b><r>205029.59502218</r><t>495430.02505697</t></extentxy></kei><kei no="15"><extentbl><l>125.25000000</l><b>24.70000000</b><r>130.00000000</r><t>29.00000000</t></extentbl><extentxy><l>-227674.88696165</l><b>-142113.93276873</b><r>252982.09218725</r><t>334944.93802354</t></extentxy></kei><kei no="16"><extentbl><l>121.75000000</l><b>23.00000000</b><r>129.00000000</r><t>28.00000000</t></extentbl><extentxy><l>-230666.99855746</l><b>-330459.90165063</b><r>512956.50097886</r><t>231658.44410608</t></extentxy></kei><kei no="17"><extentbl><l>130.00000000</l><b>24.33333300</b><r>133.00000000</r><t>27.00000000</t></extentbl><extentxy><l>-101469.30529309</l><b>-184223.69755823</b><r>202959.16895903</r><t>112346.54214329</t></extentxy></kei><kei no="18"><extentbl><l>135.00000000</l><b>19.00000000</b><r>138.00000000</r><t>21.66666700</t></extentbl><extentxy><l>-105273.39608075</l><b>-110376.96915859</b><r>210572.23898978</r><t>185822.26066079</t></extentxy></kei><kei no="19"><extentbl><l>152.00000000</l><b>23.00000000</b><r>155.00000000</r><t>25.66666700</t></extentbl><extentxy><l>-205029.59502167</l><b>-331880.65732571</b><r>102503.87588721</r><t>-35402.77822630</t></extentxy></kei></galay>';

GAMap.XMLParse = function(xml){
	var dom = null;
	try{
		if(typeof(ActiveXObject) != 'undefined'){
			dom = new ActiveXObject('Microsoft.XMLDOM');
			dom.loadXML(xml);
		}else{
			dom = new DOMParser().parseFromString(xml, 'text/xml');
		}
	}catch(e){
		dom = null;
	}
	return dom;
};

GAMap.JSONP = function(url, func, options){
	options = options || {};
	var element = document.getElementsByTagName('head').item(0);
	var id = 'id' + (new Date).getTime() + GAMap.JSONP.counter++;
	url += (url.indexOf('?') == -1 ? '?' : '&') + (options.callback || 'callback') + '=GAMap.JSONP.callback[\'' + id + '\']';
	var script = document.createElement('script');
	script.setAttribute('type', 'text/javascript');
	script.setAttribute('charset', options.charset || 'shift_jis');
	script.setAttribute('src', url);
	GAMap.JSONP.callback[id] = function(json){
		func(json);
		element.removeChild(script);
		delete GAMap.JSONP.callback[id];
	};
	element.appendChild(script);
};
GAMap.JSONP.counter = 1;
GAMap.JSONP.callback = [];

GAMap.formatNumber = function(value){
	if(isNaN(value)) return value;
	var ary = (value.toString()).split('.');
	var text = '';
	for(var i=ary[0].length-1,j=0; i>=0; i--){
		text = ary[0].charAt(i) + text;
		if(++j==3 && i>0 && !isNaN(ary[0].charAt(i-1))){
			text = ',' + text;
			j = 0;
		}
	}
	if(ary[1]) text += '.' + ary[1];
	return text;
};

XMLParam.prototype.load = function(GALAY){
	var dom = GAMap.XMLDom[GALAY];
	if(dom!==null){
		this.document = dom;
		this.mapObj.doccache[GALAY] = dom;
		this.init();
		return true;
	}else{
		alert('Parse error by configuration file.');
		return false;
	}
};
