var sitetile = "全国地価探索";
var sitedesc = "　地図をドラッグして全国の地価を探索　";
var cmarker = jdclick = jdhidden = jdpoint = jdstart = jdzoom = latlng = map = mob = nowpoint = numold = popup = "";
var sq = 1;
var tmpsql = new Array(), tmpnear = new Array(), popups = new Array(), overlays = new Array();
var querySql = {"prefid": "", "areaid": "", "rank": "", "sort1": "", "sort2": ""};
function load(id) {
	aMapFileLoad('', 1, 1);
	latlng = new google.maps.LatLng(prefdata.all[12].lat, prefdata.all[12].lng);
	aMapSet(14);
	aMapEchoPref(1);
}
function load1(id) {
	mob = 1;
	latlng = new google.maps.LatLng(prefdata.all[12].lat, prefdata.all[12].lng);
	aMapSet(14);
	if(window.google || google.gears) {
		try {
			var geo = google.gears.factory.create("beta.geolocation");
			geo.getCurrentPosition(GetLocal);
		}catch(e) {
			aMapMovePoint(prefdata.all[12].lat, prefdata.all[12].lng, 1);
		}
	}
}
function GetLocal(e) {
	aMapMovePoint(e.latitude, e.longitude, 1);
}
function aMapAddQuerySort(add) {
	return querySql.sort2 + "&" + add;
}
function aMapAddQuery(add) {
	var sk = new Array();
	for(key in querySql) {
		if(key!="sort2") {
			sk.push(key + "="+ querySql[key]);
		}
	}
	if(!add) {
		return sk.join("&");
	}else {
		add += (querySql.rank || querySql.rank2) ? "&rank=&rank2=" : "";
		return sk.join("&") + "&" + add;
	}
}
function aMapHidden(jd) {
	var h = (jd==1) ? "visible" : "hidden";
	if(overlays.length>0) {
		for(var i=0; i<overlays.length; i++) {
			$("tikapoint" + i).style.visibility = h;
		}
	}
	aMapHiddenEcho();
}
function aMapHiddenEcho(jd) {
	jdhidden = (jd!=1 && jdhidden!=1) ? 1 : 0;
	$("hiddens").innerHTML = "<a href=\"javascript:void(0);\" onclick=\"aMapHidden(" + jdhidden + ");\" title=\"坪単価の表示非表示を切り替える\"><img src=\"./img/close.png\" /></a>";
}
function aMapClear() {
	if(overlays.length>0) {
		for(var i=0; i<overlays.length; i++) {
			overlays[i].onRemove();
		}
		overlays = new Array();
	}
	popups = new Array();
	if(popup) {
		popup.close();
	}
	if(cmarker) {
		cmarker.setMap(null);
	}
	jdclick = jdhidden = jdpoint = jdzoom = numold = "";
}
function aMapEchoArea(data) {
	data = data.item;
	var areas = new Array();
	for(var i=0; i<data.length; i++) {
		var sd = (querySql.areaid==data[i].area) ? " selected=\"selected\"" : "";
		areas.push("<option value=\"" + data[i].area + "\"" + sd + ">" + data[i].areaname + "</option>");
	}
	$("earea").innerHTML = "<select name=\"areaid\" onchange=\"return aMapEchoPrefList(this, 1);\" title=\"市区町村で絞り込む\"><option value=\"0\">=市区町村=</option>" + areas.join("") + "</select>";
}
function aMapEchoJson(data) {
	cmarker = new google.maps.Marker({
		position: map.getCenter(),
		map: map,
		clickable: false
	});
	tmpnear = new Array();
	var tmpnears = new Array();
	data = data.item;
	nowpoint = sitetile + " - " + prefdata.all[data[0].pref-1].pref + data[0].areaname + " 付近";
	document.title = nowpoint;
	for(var i=0; i<data.length; i++) {
		var msg = new Array();
		var ido = data[i].ido/1000000;
		var keido = data[i].keido/1000000;
		var tit = "中心からの直線距離" + data[i].km + "m (" + data[i].adr + ")";
		var tatemono = Math.round(data[i].kper/100*data[i].km2*data[i].yper/100*0.3025);
		var tvla = (data[i].km2*data[i].val+tatemono*500000)*0.05/12;
		var m2 = (tatemono) ? tatemono : Math.round(data[i].km2*0.3025);
		msg.push("住所:" + data[i].adr);
		var zadd = (map.getZoom()>16) ? "" : " <a href=\"javascript:void(0);\" onclick=\"aMapMovePoint(" + ido + ", " + keido + ");\" title=\"ズームインして表示する\">[zoom]</a>";
		msg.push(zadd);
		msg.push("<br /><strong>地価:" + chVal(data[i].val/0.3025) + "円/坪</strong>");
		msg.push("（建" + data[i].kper + "%・容" + data[i].yper + "%)<br />");
		msg.push("土地:" + chVal(data[i].km2*data[i].val) + "円");
		msg.push("(" + Math.round(data[i].km2*0.3025) + "坪。" + data[i].youto + ")<br />");
		msg.push("建物:" + chVal(tatemono*500000) + "円(" + tatemono + "坪。" + data[i].riyou + " " + data[i].kouzou + ")<br />");
		msg.push("賃料:" + chVal(tvla) + "円(月額)、" + chVal(tvla/m2) + "円/坪(月額)");
		tmpnear.push({"no":i, "val":data[i].val, "adr":data[i].adr, "ido":data[i].ido, "keido":data[i].keido, "km2":data[i].km2, "km":data[i].km, "pref":data[i].pref, "area":data[i].area, "areaname":data[i].areaname, "kper":data[i].kper, "yper":data[i].yper});
		tmpnears.push("<div id=\"tikalist" + i + "\"><a href=\"javascript:void(0);\" onclick=\"aMapLabelClick(" + i + ");\" title=\"" + tit + "\">" + chVal(data[i].val/0.3025) + "円/坪</a></div>");
		overlays[i] = new aMapAddOverlay(ido, keido, i, data[i].adr, msg.join(""), Math.round(data[i].val/0.3025));
	}
	aMapSortEcho(0, tmpnears.join(""), data[0]);
}
function aMapAddOverlay(lat, lng, id, tit, msg, tubo) {
	this.lat_ = lat;
	this.lng_ = lng;
	this.id_ = id;
	this.tit_ = tit;
	this.msg_ = msg;
	this.tubo_ = tubo;
	this.setMap(map);
}
aMapAddOverlay.prototype = new google.maps.OverlayView();
aMapAddOverlay.prototype.draw = function() {
	if(!this.div_) {
		this.div_ = document.createElement("div");
	}
	var div = this.div_;
	var id = this.id_;
	var panes = this.getPanes();
	panes.overlayLayer.appendChild(div);
	var ll = new google.maps.LatLng(this.lat_, this.lng_);
	var point = this.getProjection().fromLatLngToDivPixel(ll);
	var val = chVal(this.tubo_) + "円/坪";
	div.id = "tikapoint" + id;
	div.title = val + " (" + this.tit_ + ")";
	div.innerHTML = val;
	div.style.display = "block";
	div.style.position = "absolute";
	div.style.fontSize = "10px";
	div.style.width = "50px";
	div.style.padding = "1px";
	div.style.border = "1px solid #666";
	div.style.background = "#fffffe";
	div.style.cursor = "pointer";
	div.style.left = point.x + 'px';
	div.style.top = point.y + 'px';
	google.maps.event.trigger(div, 'click');
	popups[id] = new google.maps.InfoWindow({
		content: this.msg_,
		pixelOffset: new google.maps.Size(20, 2),
		position: ll
	});
	if(!id && jdpoint & mob!=1) {
		aMapLabelClick(id, 1);
	}
	google.maps.event.addDomListener(div, 'click', function() {
		aMapLabelClick(id, 1);
	});
/*
	google.maps.event.addDomListener(div, 'mouseover', function() {
		aMapLabelBackground(id)
	});
*/
}
aMapAddOverlay.prototype.onRemove = function() {
	this.div_.parentNode.removeChild(this.div_);
	this.div_ = null;
}
function aMapEchoPref(jd) {
	var prefs = new Array();
	for(var i=0; i<prefdata.all.length; i++) {
		var sd = (querySql.prefid==i+1 && !jd) ? " selected=\"selected\"" : "";
		prefs.push("<option value=\"" + (i+1) + "\"" + sd + ">" + prefdata.all[i].pref + "</option>");
	}
	var dx = "<select name=\"prefid\" id=\"prefid\" onchange=\"return aMapEchoPrefList(this);\" title=\"都道府県で絞り込んで地価ランキングを表示する\"><option value=\"0\">=都道府県=</option>" + prefs.join("") + "</select>";
	if(jd!=1) {
		$("epref").innerHTML = "<strong>【検索】</strong> " + dx;
		if(querySql.prefid) {
			aMapFileLoad('gp=1&prefid=' + querySql.prefid, 2);
		}
	}else {
		$("sidetop").innerHTML = "<div style=\"line-height:1.8em;\"><h1>" + sitetile + "</h1><a href=\"javascript:void(0);\" onclick=\"aMapNoticeEcho(); ContentView();\" title=\"このサイトの使い方等を確認する\">使い方等</a>" + dx + "<div id=\"mpoint\"></div></div>";
	}
}
function aMapEchoPrefList(obj, jd) {
	var id = obj.options[obj.selectedIndex].value;
	var n = (!jd) ? "prefid" : "areaid" ;
	if(jd==1 && id==0) {
		var v = "prefid=" + querySql.prefid;
		querySql.areaid = "";
	}else {
		var v = n + "=" + id;
	}
	aMapFileLoad(v + "&sort2=" + querySql.sort2, 1);
}
function aMapFileLoad(furl, id, iid) {
	if(iid) {
		querySql = {"prefid": "", "areaid": "", "rank": "", "sort1": "", "sort2": ""};
	}
	if(id) {
		document.title = sitetile + " - 地価ランキング";
		if(furl) {
			var arr = furl.split("&");
			for(var i=0; i<arr.length; i++) {
				var ars = arr[i].split("=");
				for(key in querySql) {
					if(key==ars[0]) {
						querySql[key] = ars[1];
					}
				}
			}
		}
	}
	var ids = (id!=1) ? "gea5" : "jdi2";
	furl = "./xml/?id=" + ids + "&" + furl;
	var hObj = createXMLHttpRequest();
	if(hObj) {
		hObj.abort();
		hObj.open("GET", furl, true);
		hObj.onreadystatechange = function() {
			if(hObj.readyState==4) {
				var t = hObj.responseText;
				var data = eval("(" + t + ")");
				if(!data || data==null) {
					$("sidebar").innerHTML = "<div class=\"cc\">[付近の地価]</div>*見つかりません";
				}
				return (id==1) ? aMapListEcho(data) : ((id==2) ? aMapEchoArea(data) : aMapEchoJson(data));
			}
		}
		hObj.send(null);
	}
}
function aMapLabelClick(num, jd) {
	if(!popups[num]) {
		return;
	}
	popups[num].open(map);
	aMapLabelBackground(num);
	if(popup) {
		popup.close();
	}
	popup = popups[num];
	if(jd!=1) {
		jdclick = 1;
	}
	jdpoint = "";
}
function aMapLabelBackground(num) {
	if($("tikalist" + num)) {
		$("tikalist" + num).style.background = "pink";
		$("tikalist" + num).style.fontWeight = "bold";
	}
	if($("tikapoint" + num)) {
		$("tikapoint" + num).style.zIndex = 1;
		$("tikapoint" + num).style.background = "pink";
	}
	aMapLabelBackgroundNo(num);
}
function aMapLabelBackgroundNo(num) {
	if(numold) {
		if($("tikalist" + (numold-1))) {
			$("tikalist" + (numold-1)).style.background = "#fffffe";
			$("tikalist" + (numold-1)).style.fontWeight = "normal";
		}
		if($("tikapoint" + (numold-1))) {
			$("tikapoint" + (numold-1)).style.zIndex = "-200000";
			$("tikapoint" + (numold-1)).style.background = "#fffffe";
		}
	}
	numold = Math.round(num + 1);
}
function aMapListEcho(data, jd, sid) {
	var text = new Array(), nojd = 0, s, title0;
	jd = (jd) ? jd : 0;
	if(data==1) {
		if(sid) {
			sq = (sq==1) ? 0 : 1;
			var jdx = (jd==1) ? 0 : 1;
			aMapSortData(sid, jdx);
		}
		data = (jd==1) ? tmpnear : tmpsql;
		s = oXs(jd);
	}else {
		nojd = 1;
		data = (data!=null) ? data.item : data;
		tmpsql = data;
		s = oXs(1);
	}
	s.x = new Array();
	if(data!=null) {
		var len = (data.length>50) ? 50 : data.length;
		for(var i=0; i<len; i++) {
			var ido = data[i].ido/1000000;
			var keido = data[i].keido/1000000;
			var km2 = Math.round(data[i].km2*0.3025);
			var tatemono = Math.round(data[i].kper/100*data[i].yper/100*km2);
			var pid = data[i].pref - 1;
			var nos = (nojd==1) ? i : data[i].no;
			var jjd = (jd!=1) ? "aMapMovePoint(" + ido + ", " + keido + ", 1)" : "aMapLabelClick(" + nos + ")";
			var tvla = data[i].val/0.3025*km2+tatemono*500000;
			var m2 = (tatemono) ? tatemono : km2;
			s.x.push({"no":nos, "val":data[i].val, "adr":data[i].adr, "ido":data[i].ido, "keido":data[i].keido, "km2":data[i].km2, "km":data[i].km, "pref":data[i].pref, "area":data[i].area, "areaname":data[i].areaname,  "kper":data[i].kper, "yper":data[i].yper});
			text.push("<tr>");
			text.push("<td>" + (i+1) + "</td>");
			var ep = (querySql.prefid || querySql.areaid) ? ["",""] : ["<a href=\"javascript:void(0);\" onclick=\"aMapFileLoad('" + aMapAddQuerySort("prefid=" + (pid+1)) + "',1);\" title=\"この都道府県で絞り込む\">", "</a>"];
			text.push("<td class=\"l\">"  + ep[0] + prefdata.all[pid].pref + ep[1] + "</td>");
			var ap = (querySql.areaid) ? ["",""] : ["<a href=\"javascript:void(0);\" onclick=\"aMapFileLoad('" + aMapAddQuerySort("areaid=" + data[i].area) + "',1);\" title=\"この市区町村で絞り込む\">", "</a>"];
			text.push("<td class=\"l\">" + ap[0] + data[i].areaname + ap[1] + "</td>");
			text.push("<td class=\"l\"><img src=\"./img/reds.png\" /><a href=\"javascript:void(0);\" onclick=\"" + jjd + "; ContentView(1);\" title=\"この物件を表示する\">" + data[i].adr + "</a></td>");
			text.push("<td>" + chVal(data[i].val/0.3025) + "円</td>");
			text.push("<td>" + chVal(data[i].val/0.3025*km2) + "円</td>");
			text.push("<td>" + km2 + "坪</td>");
			text.push("<td>" + chVal(tatemono*500000) + "円</td>");
			text.push("<td>" + tatemono + "坪</td>");
			text.push("<td>" + chVal(tvla) + "円</td>");
			text.push("<td>" + chVal(tvla*0.05/12) + "円</td>");
			text.push("<td>" + chVal(tvla*0.05/12/m2) + "円</td>");
			text.push("</tr>");
		}
	}else {
		text.push("<tr><td colspan=\"12\" class=\"l\" style=\"padding:20px;\">*見つかりませんでした</td></tr>");
	}
	var title1 = (jd==1) ? "一覧リスト" : "ランキング";
	var addc = (!jdstart) ? "" : "　<a href=\"javascript:void(0);\" onclick=\"ContentView(1);\" title=\"地価" + title1 + "を閉じる\"><img src=\"./img/close.png\" />閉じる</a>";
	var addd = "<p>" + sitedesc  +"<a href=\"javascript:void(0);\" onclick=\"aMapNoticeEcho();\">使い方等を確認する</a></p>";
	if(jd==1) {
		title0 = "<h1>" + nowpoint + addc + "</h1>" + addd;
	}else {
		var ch = (querySql.rank) ? " checked=\"checked\"" : "";
		var ch1 = (querySql.rank) ? "" : "rank=1";
		var ch2 = (querySql.rank) ? "全国ランキング" : "都道府県単位";
		var lk = "<label for=\"x1\" title=\"" + ch2 + "に切り替える\"><input type=\"checkbox\" onclick=\"aMapFileLoad('" + ch1 + "',1,1);\" name=\"x1\" id=\"x1\"" + ch + " /> 都道府県単位</label>";
		var bs = [["上位",""],["下位",'sort2=1']];
		var lm = new Array();
		for(var i=0; i<2; i++) {
			var ch = ((!querySql.sort2 && i==0) || (querySql.sort2 && i==1)) ? " checked=\"checked\"" : "";
			lm.push("<label for=\"x2" + i + "\" title=\"" + bs[i][0] + "順に並び替える\"><input type=\"radio\" onclick=\"aMapFileLoad('" + aMapAddQuery(bs[i][1]) + "',1,1);\" name=\"x2\" id=\"x2" + i + "\"" + ch + " />" + bs[i][0] + "</label>");
		}
		title0 = "<h1>" + sitetile + " - 地価" + title1 + addc + "</h1>" +addd + "<p><span id=\"epref\"></span><span id=\"earea\"></span>" + lm.join("") + "　 　（" + lk + "）</p>";
	}
	aMapListEchos(jd, sq, title0, text.join(""));
	if(jd!=1) {
		aMapEchoPref();
	}
	ContentView();
}
function aMapListEchos(jd, sq, title0, text) {
	var ta = new Array();
	ta.push("<table><tr>");
	ta.push("<th>No</th>");
	ta.push("<th colspan=\"2\">エリア</th>");
	ta.push("<th>所在地</th>");
	ta.push("<th><a href=\"javascript:void(0);\" onclick=\"aMapListEcho(1, " + jd + ", " + (1+sq) + ");\" title=\"坪単価で並び替える\">坪単価</a></th>");
	ta.push("<th colspan=\"2\"><a href=\"javascript:void(0);\" onclick=\"aMapListEcho(1, " + jd + ", " + (3+sq) + ");\" title=\"土地評価で並び替える\">土地評価</a></th>");
	ta.push("<th colspan=\"2\"><a href=\"javascript:void(0);\" onclick=\"aMapListEcho(1, " + jd + ", " + (5+sq) + ");\" title=\"建物評価で並び替える\">建物評価</a></th>");
	ta.push("<th><a href=\"javascript:void(0);\" onclick=\"aMapListEcho(1, " + jd + ", " + (7+sq) + ");\" title=\"土地+建物の評価で並び替える\">土地+建物</a></th>");
	ta.push("<th colspan=\"2\">賃料月額(<a href=\"javascript:void(0);\" onclick=\"aMapListEcho(1, " + jd + ", " + (9+sq) + ");\" title=\"賃料月額(坪単価)で並び替える\">坪単価</a>)</th>");
	ta.push("</tr>" + text + "</table>");
	ta.push("Thanks to <a href=\"http://code.google.com/intl/ja/apis/maps/\" class=\"out\" target=\"_blank\">Google Maps API</a> &amp; <a href=\"http://nlftp.mlit.go.jp/ksj/\" class=\"out\" target=\"_blank\">国土数値情報（地価公示データ・都道府県地価調査）</a>");
	$("content").innerHTML = title0 + ta.join("");
}
function aMapSet(zoom) {
	var gm = google.maps.MapTypeControlStyle;
	var gn = google.maps.NavigationControlStyle;
	var m1 = (mob!=1) ? gm.DEFAULT : gm.DROPDOWN_MENU;
	var m2 = (mob!=1) ? gn.DEFAULT : gn.ANDROID;
	map = new google.maps.Map($("map"), {
		zoom: zoom, 
		center: latlng, 
		mapTypeControlOptions: {style: m1},
		navigationControlOptions: {style: m2},
		disableDoubleClickZoom: true,
		scrollwheel: false,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	});
}
function aMapMovePoint(ido, keido, zid, xjd) {
	document.title = sitetile;
	var zooms = (zid==1) ? 14 : ((ido && keido) ? 17 : map.getZoom());
	if(ido && keido) {
		if(xjd!=1) {
			jdpoint = 1;
		}
		latlng = new google.maps.LatLng(ido, keido);
		aMapSet(zooms);
		if(jdzoom!=1) {
			google.maps.event.addListener(map, 'zoom_changed', aMapMovePoint);
			jdzoom = "";
		}
		if(jdclick!=1) {
			google.maps.event.addListener(map, 'dragend', aMapMovePoint);
			jdclick = "";
		}
	}else if(map.getZoom()<6) {
		alert("You can not zoom out more.")
		jdzoom = 1
		map.setZoom(6);
		zooms = 6
	}
	aMapClear();
	latlng = map.getCenter();
	var bounds = map.getBounds();
	if(bounds!=undefined) {
		bound = bounds.getNorthEast().lat() + "&lng1=" + bounds.getNorthEast().lng() + "&lat2=" + bounds.getSouthWest().lat() + "&lng2=" + bounds.getSouthWest().lng();
	}else {
		bound = "";
	}
	aMapFileLoad("lat=" + latlng.lat() + "&lng=" + latlng.lng() + "&km=" + zooms + "&lat1=" + bound);
	if(!jdstart) {
		jdstart = 1;
	}
}
function aMapSort(id) {
	var y = new Array();
	var s = new oX(tmpnear);
	aMapSortData(id);
	for(var i=0; i<s.x.length; i++) {
		y.push("<div id=\"tikalist" + s.x[i].no + "\"><a href=\"javascript:void(0);\" onclick=\"aMapLabelClick(" + s.x[i].no + ");\" title=\"中心からの直線距離" + s.x[i].km + "m (" + s.x[i].adr + ")\">" + chVal(s.x[i].val/0.3025) + "円/坪</a></div>");
	}
	aMapSortEcho(id, y.join(""));
}
function aMapSortData(id, jd) {
	var s = oXs(jd);
	var r, ids = Math.round(id/2);
	s.x.sort(function(a, b) {
		switch(ids) {
		case 1 :	//地価
			r = a['val']-b['val'];
			break;
		case 2 :	//土地
			r = a['val']*a['km2']-b['val']*b['km2'];
			break;
		case 3 :	//建物
			r = a['km2']*a['kper']*a['yper']-b['km2']*b['kper']*b['yper'];
			break;
		case 4 :	//土地+建物、賃料
			r = a['val']*a['km2']+a['km2']*a['kper']*a['yper']*0.3025*50-b['val']*b['km2']-b['km2']*b['kper']*b['yper']*0.3025*50;
			break;
		case 5 :	//賃料(坪単価)
			r = (a['val']*a['km2']+a['km2']*a['kper']*a['yper']*0.3025*50)/(a['km2']*a['kper']*a['yper'])-(b['val']*b['km2']+b['km2']*b['kper']*b['yper']*0.3025*50)/(b['km2']*b['kper']*b['yper']);
			break;
		default :
			return a['km']-b['km'];
		}
		return (id%2==0) ? r : -r;
	});
}
function aMapSortEcho(id, texts, ndata) {
	if(ndata && mob!=1) {
		$("mpoint").innerHTML = "<a href=\"javascript:void(0);\" onclick=\"aMapFileLoad('" + aMapAddQuerySort("prefid=" + ndata.pref) + "',1,1);\" title=\"この都道府県で絞り込む\">" + prefdata.all[ndata.pref-1].pref + "</a> <a href=\"javascript:void(0);\" onclick=\"aMapFileLoad('" + aMapAddQuerySort("areaid=" + ndata.area) + "',1,1);\" title=\"この市区町村で絞り込む\">" + ndata.areaname + "</a>";
	}
	$("sidebar").style.display = "block";
	$("sidebar").style.height = (resize.getHeight() - 120) + 'px';
	$("sidebar").innerHTML = "<div class=\"cc\">[<a href=\"javascript:void(0);\" onclick=\"aMapListEcho(1, 1);\" title=\"付近の地価を一覧表示する\">付近の地価</a>]</div><div id=\"sortid\"></div>" + texts;
	var text = new Array();
	var sids = ["地図の中心点から近", "地価が高", "地価が安"];
	for(var i=0; i<3; i++) {
		var sx = (id==i) ? " class=\"sx\"" : "";
		text.push("<a href=\"javascript:void(0);\" onclick=\"aMapSort(" + i + ");\" title=\"" + sids[i] + "い順に並び替える\"" + sx + "><img src=\"./img/sort" + i + ".gif\" /></a>");
	}
	$("sortid").innerHTML = "<span id=\"hiddens\"></span> " + text.join(" ");
	aMapHiddenEcho(1);
}
function chVal(v) {
	val = Math.round(v);
	if(val==Infinity) {
		return v + "";
	}else if(val>999999999999) {
		return (Math.round(val/100000000000) / 10) + "兆";
	}else if(val>99999999) {
		return (Math.round(val/10000000) / 10) + "億";
	}else if(val>9999) {
		return (Math.round(val/1000) / 10) + "万";
	}else {
		return val + "";
	}
}
function ContentView(id) {
	id = (id==1) ? 'none' : 'block';
	$("bodyin").style.display = id;
	$("content").scrollTop = $("bodyin").offsetTop; 
	$("content").style.display = id;
	$("content").style.height = (id=='none') ? '0px' : (resize.getHeight() - 80) + 'px';
	$("content").style.width = (id=='none') ? '0px' : (resize.getWidth() - 80) + 'px';
	var elems = document.getElementsByTagName('select');
	for(i=0; i<elems.length; i++) {
		if(!$("prefid")) {
			elems[i].style.visibility = (id=='none') ? 'visible' : 'hidden';
		}
	}
}
function aMapNoticeEcho() {
	var title = sitetile + " - 使い方等";
	document.title = title;
	var addc = (!jdstart) ? "" : "　<a href=\"javascript:void(0);\" onclick=\"ContentView(1);\" title=\"" + title + "を閉じる\"><img src=\"./img/close.png\" />閉じる</a>";
	var ta = new Array();
	ta.push("<h1>" + title + addc + "</h1>");
	ta.push("<p>" + sitedesc + "<a href=\"javascript:void(0);\" onclick=\"aMapFileLoad('', 1, 1);\">地価ランキングへ戻る</a></p>");
	ta.push("<div style=\"line-height:1.8em; font-size:1.1em;\">");
	ta.push("<h2>使い方</h2>");
	ta.push("<ol>");
	ta.push("<li><a href=\"javascript:void(0);\" onclick=\"aMapFileLoad('', 1, 1);\">地価ランキング</a>で物件を探します。都道府県別や市区町村別で絞り込んだり、各種項目でソートすることが可能です。<br /><img src=\"./img/x1.png\" alt=\"map1\" class=\"xx\" /></li>");
	ta.push("<li>物件を選択すると地図が表示されます。周辺の坪単価が一目で分かります。（<a href=\"javascript:void(0);\" onclick=\"aMapMovePoint(35.671824, 139.765223, 1); ContentView(1);\">サンプル</a>）<br /><img src=\"./img/x2.png\" alt=\"map1\" class=\"xx\" /></li>");
	ta.push("<li>地図上や右側に表示された坪単価をクリックすると、物件に関する各種情報を表示します。<br /><img src=\"./img/x3.png\" alt=\"map1\" class=\"xx\" /></li>");
	ta.push("<li>右側の「付近の地価」をクリックすると、地図の中心点に近い地価データが一覧表示されます。各種項目でソート可能です。<br /><img src=\"./img/x4.png\" alt=\"map1\" class=\"xx\" /></li>");
	ta.push("<li>右上の「=都道府県=」をクリックすると、各都道府県の地価ランキングが表示されます。<br /><img src=\"./img/x5.png\" alt=\"map1\" class=\"xx\" /></li>");
	ta.push("<li>地図をドラッグしたり、ズームを変更したりすると、自動的に新たな地価データを表示します。<object width=\"640\" height=\"505\"><param name=\"movie\" value=\"http://www.youtube.com/v/-YiqcyOtiuw&hl=ja_JP&fs=1&\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/-YiqcyOtiuw&hl=ja_JP&fs=1&\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"640\" height=\"505\"></embed></object></li>");
	ta.push("</ol>");
	ta.push("<h2>注意事項</h2>");
	ta.push("<dl>");
	ta.push("<dt>免責事項</dt>");
	ta.push("<dd>　<a href=\"http://ma-bank.com/\" class=\"out\">株式会社M&amp;Aバンク</a>（以下、弊社という）は、相応の注意を払い「" + sitetile + "ホームページ」（以下、当サイトという）を運営していますが、各コンテンツの正確性・完全性について、いかなる保証をするものでもありません。当サイトを利用しての情報収集・状況判断については、利用者ご自身の責任において行って下さい。</dd>");
	ta.push("<dd>　当サイトのコンテンツが不正確・不完全であることが原因で発生した損失や損害について、弊社は一切の責任を負いかねます。</dd>");
	ta.push("<dt>著作権について</dt>");
	ta.push("<dd>　記載・断りが無い場合、当サイトに係る一切の知的財産権は、弊社が所有します。文章や画像等の無断転載はご遠慮ください。</dd>");
	ta.push("<dd>　内容の一部を引用する場合は、必ず出典を明示すると共に、当サイトへのハイパーリンクをお願いします。</dd>");
	ta.push("<dt>個人情報保護ポリシー</dt>");
	ta.push("<dd>　弊社は、投稿などを通して、任意で提供されたユーザーの氏名、住所、電話番号、電子メールアドレスなどの個人情報を管理しています。弊社はこれら個人情報が細心の注意をはらって取り扱われるべきデータと考え、その収集・保存・利用については厳重な管理の下に運用しています。</dd>");
	ta.push("<dd>　提供していただいた個人情報は、明示された利用目的のために利用させていただきます。公的機関からの法律に基づく要請がない限り、ユーザーに無断で個人を特定できるデータを第三者に対して開示することはありません。</dd>");
	ta.push("<dt>動作環境について</dt>");
	ta.push("<dd>　CSSが有効な以下のブラウザにおいて動作確認をしています。（いずれもWindows）");
	ta.push("<ul>");
	ta.push("<li>FireFox 3</li>");
	ta.push("<li>Internet Explorer 7</li>");
	ta.push("</ul>");
	ta.push("</dd>");
	ta.push("<dt>JavaScriptについて</dt>");
	ta.push("<dd>　当サイトではJavaScriptを使用しています。お使いのブラウザでJavaScriptの設定が無効になっている場合、正しく動作しませんので、JavaScriptの設定を有効にすることをお勧めします。</dd>");
	ta.push("<dt>商標について</dt>");
	ta.push("<dd>　当サイトにおいて言及されている全ての商標・製品名等は各所有者に帰属します。</dd>");
	ta.push("<dt>その他</dt>");
	ta.push("<dd>　当サイトは予告なく改変または廃止されることがあります。各コンテンツは制作時に入手したデータに基づいて作成されています。</dd>");
	ta.push("<dd>　システムにおける障害の発生、システムのメンテナンス等のため、情報提供を一時的に停止する場合があります。あらかじめご了承ください。</dd>");
	ta.push("<dd>　当サイトに対するお問い合わせは、下記サイト運営者までご連絡をお願いします。</dd>");
	ta.push("</dl>");
	ta.push("<h2>利用ＡＰＩ等</h2>");
	ta.push("<dl>");
	ta.push("<dt><a href=\"http://code.google.com/intl/ja/apis/maps/\" class=\"out\" target=\"_blank\">Google Maps API</a></dt>");
	ta.push("<dd>　地図データはGoogle Maps API（version 3）を利用しています。</dd>");
	ta.push("<dt><a href=\"http://nlftp.mlit.go.jp/ksj/\" class=\"out\" target=\"_blank\">国土数値情報（地価公示データ・都道府県地価調査）</a></dt>");
	ta.push("<dd>　地価データは国土数値情報（地価公示データ・都道府県地価調査）を利用しています。</dd>");
	ta.push("</dl>");
	ta.push("<h2>サイト運営者</h2>");
	ta.push("<dl>");
	ta.push("<dd>　<a href=\"http://ma-bank.com/\" class=\"out\" target=\"_blank\">株式会社M&amp;Aバンク</a>　");
	ta.push("<a href=\"&#109;&#97;i&#108;t&#111;&#58;in&#102;o&#64;ma&#45;&#98;&#97;&#110;k&#46;c&#111;&#109;\">&#105;&#110;&#102;&#111;&#64;&#109;&#97;&#45;&#98;&#97;&#110;&#107;&#46;&#99;&#111;&#109;</a></dd>");
	ta.push("</dl>");
	ta.push("</div>");
	$("content").innerHTML = ta.join("");
}
// http://bluedb.org/ajax/archives/23
var resize = function() {
	return {
		start:function(event) {
			$("content").style.height = (resize.getHeight() - 80) + 'px';
			$("content").style.width = (resize.getWidth() - 80) + 'px';
			$("sidebar").style.height = (resize.getHeight() - 120) + 'px';
		},
		getWidth:function() {
			if(window.innerWidth) {
				return window.innerWidth;
			}else if(document.documentElement && document.documentElement.clientWidth) {
				return document.documentElement.clientWidth;
			}else if(document.body && document.body.clientWidth) {
				return document.body.clientWidth;
			}
		},
		getHeight:function() {
			if(window.innerHeight) {
				return window.innerHeight;
			}else if(document.documentElement && document.documentElement.clientHeight) {
				return document.documentElement.clientHeight;
			}else if(document.body && document.body.clientHeight) {
				return document.body.clientHeight;
			}
		},
		addEvent:function(obj, evType, fn) {
			if(obj.addEventListener) {
				obj.addEventListener(evType, fn, false);
			}else if(obj.attachEvent) {
				obj.attachEvent("on" + evType, fn);
			}
		}
	};
}();
resize.addEvent(window, "load", resize.start);
resize.addEvent(window, "resize", resize.start);
// http://allabout.co.jp/internet/javascript/closeup/CU20050515A/
function createXMLHttpRequest(){
	if(window.ActiveXObject){
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e2) {
				return null;
			}
		}
	}else if(window.XMLHttpRequest) {
		return new XMLHttpRequest();
	}else {
		return null;
	}
}
function oX(x, y) {
	this.x = x;
	this.y = y;
}
function oXs(jd) {
	return (!jd) ? new oX(tmpnear) : new oX(tmpsql);
}
function $(tagId) {
	return document.getElementById(tagId);
}
//http://blog.mura.com/blogs/index.php/charlie/2007/07/16/javascript_dump_object
var print_r = function(o) {
	var str = new Array(), no = 1;
	for(var i in o) {
		str.push(no + ".<b>" + i + "</b>:"+ o[i]);
		no++;
	}
	document.writeln("<pre>" + str.join("\n") + "</pre>");
	document.close();
}
