var pref = {1:"北海道",2:"青森県",3:"岩手県",4:"宮城県",5:"秋田県",6:"山形県",7:"福島県",8:"茨城県",9:"栃木県",10:"群馬県",11:"埼玉県",12:"千葉県",13:"東京都",14:"神奈川県",15:"新潟県",16:"富山県",17:"石川県",18:"福井県",19:"山梨県",20:"長野県",21:"岐阜県",22:"静岡県",23:"愛知県",24:"三重県",25:"滋賀県",26:"京都府",27:"大阪府",28:"兵庫県",29:"奈良県",30:"和歌山県",31:"鳥取県",32:"島根県",33:"岡山県",34:"広島県",35:"山口県",36:"徳島県",37:"香川県",38:"愛媛県",39:"高知県",40:"福岡県",41:"佐賀県",42:"長崎県",43:"熊本県",44:"大分県",45:"宮崎県",46:"鹿児島県",47:"沖縄県"};
var sqlurl = '/get/';
var nowse = selck = mct = mst = ss = sm = se = fc = fck = fnu = apib = distn = 0;
var nowpref, nowss, nowm, selse, map, mmap, cview, whn, gls, distl, polyl, dire;
var selmsg = map3 = sa = sc = mp = mp_c = resit = flas = mdl = '';
var myTimer = [,,,,,,,,];
var scw = [318,788,0,47];
var scl = [579,100,0,47];
var flaa = [425,120,370,267,300,220,249,284,186,253,121,292];
var maps = []; var mapi = []; var lmapi = []; var lmapt = []; var lmapn = 0; var srs = []; var glsn = []; var wns = []; var ocwhn = []; var dist = []; var polys = []; var ico = []; var lico = []; var httpRequest = [];

window.onload = function() {
	$("search").style.display = "block"; selse = 1; 
	if (mp) { mapdraw(mp); }
	if ($("newcoming")) { myTimer[3] = setTimeout("getmysql(sqlurl + \"newcoming&dat=/\" ,2 ,1)",500); }
	if ($("yourhisto")) { myTimer[4] = setTimeout("getmysql(sqlurl + \"yourhistory&dat=1\" ,3 ,1)",1000); }
	if ($("weathernews")) { myTimer[6] = setTimeout("wnsbp()",3000); }
	if ($("shotsrs")) { myTimer[5] = setTimeout("getmysql(sqlurl + \"shotrs&rs=" + srs[0] + "_" + srs[1] + "\" ,5 ,1)",1); }
	}

function $(tagId) {
	return document.getElementById(tagId);
}

function stripPx(value) { 
	if (value == "") { return false; } 
	return parseFloat(value.substring(0, value.length - 2)); 
} 

function number_format(a){ 
	if (a) { 
		var b = String(Math.floor(a)); 
		var c = ""; 
		while (b != (c = b.replace(/^([+-]?\d+)(\d\d\d)/,"$1,$2"))) { b = c; } 
		return b; 
	} 
	return ''; 
} 

for (i = 1; i <= 5; i++) {
	httpRequest[i] = false; 
	if (window.XMLHttpRequest) { httpRequest[i] = new XMLHttpRequest(); } 
	else if (window.ActiveXObject) { try { httpRequest[i] = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { httpRequest[i] = new ActiveXObject("Microsoft.XMLHTTP"); } }
}

function getmysql(url,num,chk) {
	httpRequest[num].abort(); httpRequest[num].open("GET", url , true); httpRequest[num].onreadystatechange = function() { if ((httpRequest[num].readyState == 4) && (httpRequest[num].status == 200) && httpRequest[num].responseText) { var a = httpRequest[num].responseText; switch (num) {
		case 1 : 
		switch (chk) {
			case  1 : showarea(a,''); break;
			case  2 : searchpref(a,''); break;
			case  3 : ssearch(a,'',''); break;
			case  4 : buildrc(a,''); break;
			case  5 : topone(a); break;
			case  6 : getresit(a); break;
		}
		break;
		case 2 : 
		switch (chk) {
			case  1 :$("newcoming").innerHTML = ((a === "0") ? '' : a); clearTimeout(myTimer[3]); break;
		}
		break;
		case 3 : 
		switch (chk) {
			case  1 : $("yourhisto").innerHTML = ((a === "0") ? '' : a); clearTimeout(myTimer[4]); break;
		}
		break;
		case 4 : 
		switch (chk) {
			case  1 : flas = eval("(" + a + ")"); fc = 0; myTimer[2] = setTimeout("changeflash()",2000); break;
		}
		break;
		case 5 : 
		switch (chk) {
			case  1 : shotrs(a); break;
		}
		break;
	} } }; httpRequest[num].send(null);
}

function shotrs(a) {
	clearTimeout(myTimer[5]);
	var b = eval("(" + a + ")");
	if (b.none === "none") {
		$("shotsrs").style.display = "none";
		$("shotsrs").innerHTML = '';
		return;
	}
	var c = b.length;
	var d = '';
	var e = 0;
	var f = '';
	srs[2] = 0;
	for (i = 0; i < c; i++) {
		f = 	(	(srs[1] && (srs[1] == b[i].a)) 
			? 	' class="att2"' : '') + ' title="' + b[i].c + '駅（' + pref[b[i].b] + '）にはブレインマンションが' + (b[i].d ? b[i].d + '件登録されています' 
			: 	'まだ登録されていません'
			) + '"';
		d += 	'<span class="rstxt">' + 
			(	b[i].d 
			? 	'<a href="/s/station/' + b[i].a + '"' + f + '>' + b[i].c + '</a>' 
			: 	'<span' + f + '>' + b[i].c + '</span>'
			) + 
			'</span>';
		srs[2] -= b[i].c.length * 15;
		if (i != (c - 1)) { d += '<img src="/img/rs.png" class="rsimg" />'; }
	}
	$("shotsrs").innerHTML = d;
	srs[2] -= (c - 1) * (23 + 3 * 2);
	if (srs[2] < -820) {
		srs[3] = 900;
		srs[4] = 1;
		$("shotsrs").style.textIndent = srs[3] + "px";
		myTimer[5] = setInterval("shotsrs()",1);
	} else {
		srs[2] = '';
	}
}

function shotsrs() {
	if (srs[4] == 1) {
		srs[3] -= 1;
		if (srs[3] < srs[2]) { srs[3] = srs[2]; srs[4] = 2; }
	} else {
		srs[3] += 1;
		if (srs[3] > 900) { srs[3] = 900; srs[4] = 1; }
	}
	$("shotsrs").style.textIndent = srs[3] + "px";
}

function ctrlsrs(a) {
	if (srs[2]) {
		if (a && myTimer[5]) {
			clearInterval(myTimer[5]);
		} else {
			myTimer[5] = setInterval("shotsrs()",1);
		}
	}
}

function changeflash() {
	clearTimeout(myTimer[2]);
	if (!$("sefla")) { return; }
	if (fc >= flas.length) { fc = 0; }
	var a = $("sefla");
	var b = a.style;
	if (b.display === "block") { b.display = "none"; }
	a.innerHTML = '<a href="javascript:void(0)" onclick="searchpref(\'\',' + flas[fc].b + ')" title="' + flas[fc].c + 'に' + number_format(flas[fc].d) + '件の情報があります">' + flas[fc].c + ' ' + flas[fc].d + '件</a>';
	b.left = flaa[(flas[fc].a - 1) * 2] + "px"; b.top = flaa[(flas[fc].a - 1) * 2 + 1] + "px";
	fnu = 10; b.filter = "alpha(opacity=" + fnu + ")"; b.opacity = (fnu / 100);
	b.display = "block";
	myTimer[2] = setInterval("cngingflash()",100);
}

function cngingflash() {
	if (fnu >= 100) { clearInterval(myTimer[2]); fc++; myTimer[2] = setTimeout("changeflash()",5000) }
	fnu += 10; $("sefla").style.filter = "alpha(opacity=" + fnu + ")"; $("sefla").style.opacity = (fnu / 100);
}

function omarea(a) {
	if (selck || (a && nowse && (a == nowse))) { return; }
	if (a) { 
		nowse = a; 
		$("seimg").innerHTML = '<img src="/img/se' + a + '.png" usemap="#seimgbase" />';
	} else { 
		nowse = 0; 
	}
}

function showarea(a,b) {
	if (a) { 
		$("selink").innerHTML = a; 
		$("sefla").style.visibility = "hidden";
		$("semsg").style.backgroundPosition = "-218px 0"; 
	} else if (b) { 
		selck = 1; getmysql(sqlurl + "showarea&area=" + b ,1 ,1); 
	}
}

function clsb(a) { $("clsb").style.backgroundPosition = (0 - a * 15) + "px 0px"; }
function ocrma(a) { $("rma").style.backgroundPosition = (0 - a * 32) + "px 0px"; }

function delarea() {
	$("rma").style.display = "none";
	$("selink").innerHTML = $("seimg").innerHTML = '';
	$("searchc").style.width = scw[0] + "px"; $("searchc").style.left = scl[0] + "px"; $("searchc").style.borderLeft = "none";
	selck = nowse = 0;
	$("semsg").style.backgroundPosition = selmsg;
	$("sefla").style.visibility = "visible";
	showssearch();
}

function searchpref(a,b) {
	if (a) {
		if ($("rmc3")) { $("rmc3").innerHTML = a; cngspref(selse,''); }
		else { $("searchc").innerHTML = '<div id="rm1" onclick="cngrmtab(2)" title="住所での検索結果を表示します"></div><div id="rm2" onclick="cngrmtab(3)" title="沿線・駅での検索結果を表示します"></div><div id="rmc"><div id="rmc2"><div id="rmc3">' + a + '</div></div></div>'; cngspref(selse,1); }
	} else if (b) {
		nowpref = b; getmysql(sqlurl + "searchpref&pref=" + nowpref + "&md=" + selse ,1 ,2);
	}
}

function cngrmtab(a) { if (nowpref) { selse = (a - 1); searchpref('',nowpref); } }

function cngspref(a,b) {
	var b1 = $("rm1").style; var b2 = $("rm2").style;
	if (a == 1) { b1.backgroundPosition = "0px 0px"; b2.backgroundPosition = "-394px -26px"; }
	else { b1.backgroundPosition = "0px -26px"; b2.backgroundPosition = "-394px 0px"; }
	if (b) { scw[2] = scw[0]; scl[2] = scl[0]; myTimer[1] = setInterval("scrsc()",15); }
}

function scrsc() {
	var a = $("rma").style;
	var b = $("searchc").style;
	b.width = scw[2] + "px"; b.left = scl[2] + "px";
	if (scw[2] >= scw[1]) { clearInterval(myTimer[1]); b.borderLeft = "1px solid #8a8a8a"; a.display = "block"; a.left = (scl[2] - 31) + "px"; }
	scw[2] += scw[3]; scl[2] -= scl[3];
}

function searchtab(a) {
	nowm = a;
	selse = (a - 1);
	selmsg = ((selse == 2) ? "-218px -77px" : "0 -77px");
	delarea();
	for (i = 1; i <= 3; i++) { $("menu" + i).style.backgroundPosition = (0 - (i - 1) * 225) + "px 0px"; }
	sa = "menu";
	ss = (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0);
	se = $(sa).offsetTop;
	sm = Math.abs(Math.ceil((se - ss) / 5));
	sc = ((se < ss) ? '' : 1);
	myTimer[0] = setInterval("sscrollb(sc)",50);
}

function showssearch() {
	var a = '';
	if ($("ssnew")) { a = $("ssnew").innerHTML; }
	$("searchc").innerHTML = '<div id="ss1"></div><form action="" method="post" id="ss2" name="ss2"><div id="sss1">地名を入力 <input type="text" class="ssinp" id="s1" name="s1" value="(中央区 日本橋)" onclick="clearss(1)" onkeyup="ssearch(\'\',this.value,1)" /></div><div id="ssss1"></div><div id="sss2">駅名を入力 <input type="text" class="ssinp" id="s2" name="s2" value="(神田)" onclick="clearss(2)" onkeyup="ssearch(\'\',this.value,2)" /></div><div id="ssss2"></div><div id="ssnew"></div>' + 
						'</form>';
	if (a) { $("ssnew").innerHTML = a; } else { getmysql(sqlurl + "topone&sc=1" ,1 ,5); }
}

function topone(a) { $("ssnew").innerHTML = '<div class="misctitle4">おすすめブレインマンション</div>' + a; }

function clearss(a) { if ((a == 1) && ($("s1").value === "(中央区 日本橋)")) { $("s1").value = ""; } else if ((a == 2) && ($("s2").value === "(神田)")) { $("s2").value = ""; } }

function ssearch(a,b,c) {
	if (a) { $("ssss1").style.display = $("ssss2").style.display = "none"; $("ssss" + nowss).style.display = "block"; $("ssss" + nowss).innerHTML = a; }
	else if (b) { var z = b.replace(/[\x20-\x7F]/,""); if (z.length > 1) { nowss = c; getmysql(sqlurl + "ssearch&kind=" + c + "&dat=" + b ,1 ,3); } }
	else { $("ssss" + c).style.display = "none"; }
}

function cnglistbg(a,b) { $("tr" + a).style.background = "#" + b; }

function changelist1(a,b) { document.cookie = "lsele=" + a + "; path=/; expires= Sun, 05-Dec-2010 02:09:48GMT"; location.href = b; }
function changelist2(a,b) { document.cookie = "lstep=" + a + "; path=/; expires= Sun, 05-Dec-2010 02:09:48GMT"; location.href = b; }
function changelist3(a,b) { document.cookie = "lpage=" + a + "; path=/; expires= Sun, 05-Dec-2010 02:09:48GMT"; location.href = b; }

function obcontact() {
	$("bcontact").style.display = "block";
	sa = "toform1";
	ss = (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0);
	se = $(sa).offsetTop;
	sm = Math.ceil((se - ss) / 10);
	myTimer[0] = setInterval("sscrollb(1)",50);
}

function sscrollb(a) {
	if (sa) { if (a) { if (ss >= se) { sscrollc(); } else { ss += sm; window.scrollTo(0,ss); } } else { if (ss <= se) { sscrollc(); } else { ss -= sm; window.scrollTo(0,ss); } } }
	else { sscrollc(); }
}

function sscrollc() {
	clearInterval(myTimer[0]); 
	if (sa === "menu") { $("search").style.display = "block"; $("menu" + nowm).style.backgroundPosition = (0 - (nowm - 1) * 225) + "px -70px"; }
	location.hash = sa; ss = sm = se = 0; sa = '';
	return false;
}

function mapdraw(mp) {
	map = new GMap2($("map"));
	ico[1] = new GIcon(); ico[1].image = '/img/icon3.png';
	ico[2] = new GIcon(); ico[2].image = '/img/icon4.png';
	ico[1].iconSize = ico[2].iconSize = new GSize(21,21);
	ico[1].iconAnchor = ico[2].iconAnchor = new GPoint(12,12);
	ico[1].infoWindowAnchor = ico[2].infoWindowAnchor = new GPoint(18,3);
	ico[1].shadow = ico[2].shadow = '/img/shadow2.png';
	ico[1].shadowsSize = ico[2].shadowsSize = new GSize(32,22);
	ico[3] = new GIcon(); ico[3].image = '/img/icon1.png';
	ico[4] = new GIcon(); ico[4].image = '/img/icon2.png';
	ico[3].iconSize = ico[4].iconSize = new GSize(21,21);
	ico[3].iconAnchor = ico[4].iconAnchor = new GPoint(12,12);
	ico[3].infoWindowAnchor = ico[4].infoWindowAnchor = new GPoint(18,3);
	ico[3].shadow = ico[4].shadow = '/img/shadow1.png';
	ico[3].shadowsSize = ico[4].shadowsSize = new GSize(28,22);
	map.setCenter(new GLatLng(maps[1], maps[0]), maps[2]);
	if ((mp == 2) && maps[3]) { map.addControl(new GSmallMapControl()); map.disableDragging(); getMap(maps[3],1); myTimer[0] = setTimeout("window.print()",3000); return; }
	switch (mp) {
		case 1: map.addControl(new GMenuMapTypeControl(true));
			if (mp_c) { 
				map.addControl(new GLargeMapControl3D());
			} else { 
				map.addControl(new GSmallMapControl()); 
			}
			$("strv").innerHTML = '';
			var sVob = new GStreetviewPanorama($("strv")); 
			var sVll = new GLatLng(maps[1], maps[0]); 
			sVob.setLocationAndPOV(sVll); 
			GEvent.addListener(sVob, "error", function(err){ if (!err) { $("mapctrl3").style.display = "block"; } });
			if (maps[3]) { 
				map3 = maps[3]; 
				getMap(map3,0); 
				GEvent.addListener(map, "moveend", function(){ getMap(map3,0); }); 
				if ($("polydiv")) { myTimer[8] = setTimeout("drawpolytxt()",500); }
				$("mapctrl2").style.display = "block";
				$("mapctrl1").style.display = "block";
			}
			break;
		case 2: break;
		case 3: map.addControl(new GLargeMapControl3D());
			map.addControl(new GNavLabelControl());
			map.addControl(new GMenuMapTypeControl(true), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 34)));
			map3 = maps[3]; 
			getbMap(maps[3]); 
			GEvent.addListener(map, "moveend", function(){ getbMap(map3); }); 
			break;
	}
	if ($("moregmap")) { $("moregmap").style.display =  "block"; }
}

function drawpolytxt() {
	clearTimeout(myTimer[8]);
	$("polydiv").innerHTML = 
		'<div id="polyico1" onmouseout="cngpoly(0)" onmouseover="cngpoly(1)" onmousedown="cngpoly(2)" onclick="cngpoly(3)"></div>' + 
		'<div id="polyico2"></div>' + 
		'<div id="polytxt1" onclick="cngpoly(3)">'+ bname + ' からの距離を調べます。</div>' + 
		'<div id="polytxt2">' + bname + ' からの距離は<span id="polytxt4">...</span>。<br />（<a href="javascript:void(0);" title="この下に操作方法を表示します" onclick="ocpolytxt3()">操作方法</a>）</div>' + 
		'<div id="polytxt3">' + 
			'<p>地図が大きくなりましたので、' + bname + ' からの距離を調べることができます。</p>' + 
			'<p>※方法</p>' + 
			'<ol>' + 
			'<li>地図上でダブルクリックすると、ポイントが追加されます。</li>' + 
			'<li>追加されたポイントは、ドラッグして移動できます。</li>' + 
			'<li>地図上で右クリックすると、新しいポイントから削除されます。</li>' + 
			'<li>地図を小さくすると、順路が消去されます。</li>' + 
			'</ol>' + 
		'</div>';
}

function ocpolytxt3() {
	var a = $("polytxt3").style;
	a.display = ((a.display === "block") ? "none" : "block");
}

function getdirect(a,b) {
	if (b && (mdl == a)) { return; }
	if (b && (stripPx($("map").style.width) == 305)) { zoommap(); }
	if (mdl) { dire.clear(); }
	dire = new GDirections(map,$("route"));
	dire.load("from: " + maps[1] + "," + maps[0] + " to: " + a, { locale:"ja_JP", travelMode: "G_TRAVEL_MODE_WALKING", preserveViewport: true});
	mdl = a;
}

function getbMap(z) { 
	var a = map.getBounds(); 
	var b = a.toString().replace(/(\(|\)| )/g,""); 
	GDownloadUrl(sqlurl + "bpeek&area=" + b + "&shop=" + maps[3] , createMap); 
}

function getMap(z,y) { 
	var a = map.getBounds(); 
	var b = a.toString().replace(/(\(|\)| )/g,""); 
	GDownloadUrl(sqlurl + "peek&area=" + b + "&except=" + z + ((y == 1) ? "&only=1" : "") + ((cview == 1) ? "&cview=1" : ""), createMap); 
}

function createMap(jsondata, statusCode) {
	if (!jsondata) { return; }
	var json = eval("(" + jsondata + ")");
	var j = json.brain.length
	for (var i = 0; i < j; i++) {
		if (!mapi[json.brain[i].d]) {
			mapi[json.brain[i].d] = 1;
			var latlng = new GLatLng(json.brain[i].b, json.brain[i].c);
			if (json.brain[i].a == 3) {
				var a = ((mp == 3) ? 1 : "");
				var html = 	'<p class="gmhead"><span style="font-size: 12px; font-weight: normal;">取引業者：</span><br /><strong>' + json.brain[i].g + '</strong></p>' +
						'<p class="gminfo">〒' + json.brain[i].m + '<br />' + json.brain[i].h + '<br />TEL : ' + json.brain[i].n + '</p>';
			} else {
				var a = '';
				var b = '<a href="/brainmansion/' + json.brain[i].e + '" title="' + json.brain[i].g + '">';
				var html = 	'<p class="gmhead">' + b + json.brain[i].g + '</a></p>' +
						(json.brain[i].k ? b + '<img src=\"' + json.brain[i].k + '\" class="gmimg" />' + '</a>' : '') + 
						'<p class="gminfo">' + json.brain[i].f + '<br />' + json.brain[i].h + (json.brain[i].m ? json.brain[i].m : '') + '<br />' + json.brain[i].j + '　賃料 ' + number_format(json.brain[i].i) + '円' + (json.brain[i].l ? '<br />他' + json.brain[i].l + '件が登録されています' : '') + '</p>';
			}
			map.addOverlay(createMarker(latlng, html, json.brain[i].a, a, json.brain[i].o));
		}
	}
}

function createMarker(point, html, icontype, infoopen, zindex) {
	var marker = new GMarker(point, { zIndexProcess: function(){ return zindex; }, icon: ico[icontype] } );
	GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); });
	if (infoopen) { map.openInfoWindowHtml(point,html); }
	return marker;
}

function cngmgp(a,b) {
	if (isNaN(a) || isNaN(b)) { return; }
	$("mgp" + b).style.backgroundPosition = (0 - (b - 1) * 32) + "px " + (0 - a * 24) + "px";
}

function jmpmgp2(a,b) {
	if (stripPx($("map").style.width) == 305) { 
		var z = map.getZoom();
		map.setZoom( ((z - 4) > 13) ? (z - 4) : 13 );
		zoommap(); 
	}
	if (lmapn) {
		for (i = 0; i < lmapn; i++) {
			map.removeOverlay(lmapi[i]);
		}
	}
	lmapn = 0;
	lmapi = [];
	$("moregmaptxt").innerHTML = '';
	c = document.dummyf.dummyt.value;
	d = document.dummyf.dummyu.value;
	glsn = [a , (c + "周辺の" + b)];
	if ((b === "幼稚園・保育園") || (b === "小学校") || (b === "中学校")) {
		var ysearch = 
			'http://map.yahooapis.jp/LocalSearchService/V1/LocalSearch' + 
			'?appid=1Z95GVuxg65Je45z7zHyrsZQY8bLa38JXz16IH3KeJHsNyo74GS.BfIExEWwmlYwh65Odg--' + 
			'&category=landmark' + 
			'&o=json' + 
			'&detum=wgs' + 
			'&n=100' + 
			'&callback=glscompy' + 
			'&p=' + encodeURI(d + ' ' + b);
		// alert(d + ' | ' + b);
		var target = document.createElement('script');  
		target.charset = 'utf-8';  
		target.src = ysearch;  
		document.body.appendChild(target);  
	} else {
		gls.setSearchCompleteCallback(null, glscompg);
		gls.execute(c + '+' + b);
	}
}

function emptygls(a) {
	$("moregmaptxt").innerHTML = '<dl><dt class="att">' + a + 'は見つかりませんでした。</dt></dl>';
}

function glsb1(a,b) {
	var z = '<p class="lgmhead">' + glsn[1] + '</p><p class="lgminfo"><a target="_blank" href="' + 
	((a == 1)
	? 'http://search.yahoo.co.jp/search?ei=UTF-8&p=' + encodeURI(b.Address + " " + b.Title) + '" title="' + b.Title + '">' + b.Title + '</a><br />' + b.Address
	: b.url + '" title="' + b.titleNoFormatting + '">' + b.titleNoFormatting + '</a><br />' + b.streetAddress
	) + '</p>';
	return z;
}

function glsb2(a,u,lmapn,lmapt) {
	var z = '';
	u.sort(function(a,b) { return a.ll - b.ll });
	for (i = 0; i < lmapn; i++) {
		if (!i) { x = new GLatLng(u[i].l1, u[i].l2); map.panTo(x); lmapi[u[i].no].openInfoWindowHtml(lmapt[u[i].no]); }
		z += '<dd><a href="javascript:void(0)" title="' + u[i].tx + 'を表示します" onclick="glsopen(' + u[i].l1 + ',' + u[i].l2 + ',' + u[i].no + ')">' + u[i].tx + '</a>（' + u[i].ta + '）</dd>';
	}
	$("moregmaptxt").innerHTML = '<dl><dt>' + glsn[1] + '</dt>' + z + '<dd><a href="' + 
		( (a == 1)
		? 'http://developer.yahoo.co.jp/about"><img src="http://i.yimg.jp/images/yjdn/yjdn_attbtn2_105_17.gif" title="Webサービス by Yahoo! JAPAN" alt="Webサービス by Yahoo! JAPAN'
		: 'http://code.google.com/intl/ja/"><img src="/img/googlecode.png" title="Google Code'
		) + '" width="105" height="17" border="0" style="margin: 4px 0 7px 0"></a></dd></dl>';
}

function glscompy(result) {
	if (result.Count > 0) {
		var z = result.Item.length; var y,x,w; var v = []; var u = [];
		for (i = 0; i < z; i++) {
			y = result.Item[i];
			x = new GLatLng(y.DatumWgs84.Lat, y.DatumWgs84.Lon);
			w = Math.sqrt(Math.pow(Math.abs(maps[1] - y.DatumWgs84.Lat),2) + Math.pow(Math.abs(maps[0] - y.DatumWgs84.Lon),2));
			u[lmapn] = {no:lmapn, l1:y.DatumWgs84.Lat, l2:y.DatumWgs84.Lon, ll:w, tx:y.Title, ta:y.Address};
			lmapt[lmapn] = glsb1(1,y);
			map.addOverlay(lcreateMarker(x, lmapt[lmapn], glsn[0], "", lmapn, 2));
			lmapn++;
		}
		if (lmapn) { var lmapnt = ((lmapn > 8) ? 8 : lmapn); glsb2(1,u,lmapnt,lmapt); }
	} else {
		emptygls(glsn[1]);
	}
}

function glscompg() {
	if (gls.results[0] == undefined) {
		emptygls(glsn[1]);
	} else {
		var z = gls.results.length; var y,x,w; var v = []; var u = [];
		for (i = 0; i < z; i++) {
			y = gls.results[i];
			x = new GLatLng(y.lat, y.lng);
			w = Math.sqrt(Math.pow(Math.abs(maps[1] - y.lat),2) + Math.pow(Math.abs(maps[0] - y.lng),2));
			u[lmapn] = {no:lmapn, l1:y.lat, l2:y.lng, ll:w, tx:y.titleNoFormatting, ta:y.streetAddress};
			lmapt[lmapn] = 	glsb1(2,y);
			map.addOverlay(lcreateMarker(x, lmapt[lmapn], glsn[0], "", lmapn, 2));
			lmapn++;
		}
		if (lmapn) { glsb2(2,u,lmapn,lmapt); }
	}
}

function glsopen(a,b,c) {
	var z = new GLatLng(a, b);
	map.panTo(z);
	lmapi[c].openInfoWindowHtml(lmapt[c]);
}

function lcreateMarker(point, html, icontype, infoopen, iconumber, zindex) {
	lmapi[iconumber] = new GMarker(point, { zIndexProcess: function(){ return zindex; }, icon: lico[icontype] } );
	GEvent.addListener(lmapi[iconumber], "click", function() { lmapi[iconumber].openInfoWindowHtml(html); });
	if (infoopen) { map.openInfoWindowHtml(point,html); }
	return lmapi[iconumber];
}

function panto() { map.setCenter(new GLatLng(maps[1], maps[0]), maps[2]); }

function cngpoly(a) {
	switch (a) {
		case 3: zoommap(); break;
		default: $("polyico1").style.backgroundPosition = "0 " + (0 - a * 24) + "px";
	}
}

function zoommap() {
	var a = $("map").style;
	var a2 = $("strv").style;
	var b = $("mapctrl1").style;
	var c = $("mapctrl2").style;
	var d = $("mapctrl3").style;
	var z = ((map.getCenter()).toString()).replace(/(\(| |\))/g,"");
	var y = z.split(",");
	var x = map.getBoundsZoomLevel(map.getBounds());
	if (a2.display === "block") { a2.display = "none"; }
	map.clearOverlays();
	mapi = [];
	mst = 0; 
	ocmapctrl(3,0);
	if (stripPx(a.width) == 305) {
		mct = 1; ocmapctrl(1,0);
		a.width = a2.width = "650px"; a.left = a2.left = "-333px"; a.height = a2.height = "400px"; a.top = a2.top = "-5px";
		b.top = c.top = d.top = "395px";
		map = new GMap2($("map")); 
		map.addControl(new GLargeMapControl3D());
		map.addControl(new GScaleControl());
		map.addControl(new GMenuMapTypeControl(true));
		

	} else {
		mct = 0; ocmapctrl(1,0);
		a.width = a2.width = "305px"; a.left = a2.left = "0px"; a.height = a2.height = "225px"; a.top = a2.top = "0px";
		b.top = c.top = d.top = "225px";
		map = new GMap2($("map")); 
		map.addControl(new GSmallMapControl());
		map.addControl(new GMenuMapTypeControl(true));


		

	}
	map.setCenter(new GLatLng(y[0], y[1]) , x);
	getMap(map3,0);
	GEvent.addListener(map, "moveend", function(){ getMap(map3,0) });
	if (mdl) { getdirect(mdl,''); }
}

function drawpolies() {
	distl = 0;
	if (polyl) { map.removeOverlay(polyl); }
	if (distn) {
		polys = [];
		polys[0] = new GLatLng(maps[1], maps[0]);
		var lpo, ldi;
		for (i = 1; i <= distn; i++) {
			if (dist[i] == undefined) { return deadpoly(); }
			polys[i] = dist[i].getPoint();
			distl += polys[i-1].distanceFrom(polys[i]);
			lpo = polys[i];
			ldi = dist[i];
		}
		polyl = new GPolyline(polys, "#6E45E3","3","0.7")
		map.addOverlay(polyl); 
	}
	if (distl) {
		distl = Math.floor(distl);
	}
	$("polytxt4").innerHTML = 
		(	distl 
		? 	'約' + ((distl >= 1000) ? (Math.floor(distl / 100) / 10) + "k" : distl ) + "m（徒歩で約" + Math.ceil(distl / 80) + "分）です" 
		: 	'...'
		);
}

function deadpoly() {
	alert("エラーによりデータがクリアされました\n最初からやり直してください");
	for (i = 1; i <= distn; i++) {
		if (dist[i]) {
			map.removeOverlay(dist[i]); 
		}
	}
	distn = 0;
}

function strview() {
	var a = $("strv").style;
	if (mst == 1) { 
		mst = 0; 
		a.display = "none"; 
	} else { 
		a.innerHTML = '';
		var sVob = new GStreetviewPanorama($("strv")); 
		var sVll = new GLatLng(maps[1], maps[0]); 
		sVob.setLocationAndPOV(sVll); 
		mst = 1; 
		a.display = "block"; 
	}
	ocmapctrl(3,0);
}

function ocmapctrl(a,b) { 
	switch(a) {
		case 2 : var c = "0 -" + (b * 20) + "px"; break;
		case 3 : var c = (0 - mst * 22 - 66) + "px -" + (b * 20) + "px"; break;
		default: var c = (0 - (mct + 1) * 22) + "px -" + (b * 20) + "px";
	}
	$("mapctrl" + a).style.backgroundPosition = c;
}


function cngqr(a) { 
	var b = $("qr1").style; 
	var c = $("qr2").style; 
	if (a == 2) { 
		c.display = "block"; 
		b.display = "none"; 
	} else { 
		b.display = "block"; 
		c.display = "none"; 
	} 
}

function drawmenu() {
	var a = '<ul id="menu">' + 
		'<li><a id="menu1" name="menu1" href="/" title="トップページ">トップページ</a></li>' + 
		'<li><a id="menu2" name="menu2" href="javascript:void(0)" onclick="searchtab(2)" onkeypress="searchtab(2)" title="地域・住所から探す">地域・住所から探す</a></li>' + 
		'<li><a id="menu3" name="menu3" href="javascript:void(0)" onclick="searchtab(3)" onkeypress="searchtab(3)" title="沿線・駅から探す">沿線・駅から探す</a></li>' + 
		'</ul>';
	document.write(a);
}

function searchtbl() {
	var a = '<area shape="rect" href="javascript:void(0)" onmouseout="omarea(\'\')" title="';
	var b =	'<div class="startsep"></div>' + 
		'<div id="search">' + 
			'<div id="searchmap">' + 
				'<img src="/img/se_base.png" id="sebase" name="sebase" usemap="#seimgbase" alt="地域をクリックしてください" />' + 
				'<div id="seimg"></div><div id="semsg"></div><div id="selink"></div><div id="sefla"></div>' + 
				'<map id="seimgbase" name="seimgbase">' + 
				a + '北海道・東北" alt="北海道・東北" onmouseover="omarea(1)" onclick="showarea(\'\',1)" onkeypress="showarea(\'\',1)" coords="474,52,504,82" />' + 
				a + '北海道・東北" alt="北海道・東北" onmouseover="omarea(1)" onclick="showarea(\'\',2)" onkeypress="showarea(\'\',2)" coords="394,158,424,188" />' + 
				a + '関東" alt="関東" onmouseover="omarea(2)" onclick="showarea(\'\',3)" onkeypress="showarea(\'\',3)" coords="340,235,370,265" />' + 
				a + '甲信越・北陸・東海" alt="甲信越・北陸・東海" onmouseover="omarea(3)" onclick="showarea(\'\',4)" onkeypress="showarea(\'\',4)" coords="285,229,315,259" />' + 
				a + '近畿" alt="近畿" onmouseover="omarea(4)" onclick="showarea(\'\',5)" onkeypress="showarea(\'\',5)" coords="234,244,264,274" />' + 
				a + '中国・四国" alt="中国・四国" onmouseover="omarea(5)" onclick="showarea(\'\',6)" onkeypress="showarea(\'\',6)" coords="171,216,201,246" />' + 
				a + '中国・四国" alt="中国・四国" onmouseover="omarea(5)" onclick="showarea(\'\',7)" onkeypress="showarea(\'\',7)" coords="161,253,191,283" />' + 
				a + '九州・沖縄" alt="九州・沖縄" onmouseover="omarea(6)" onclick="showarea(\'\',8)" onkeypress="showarea(\'\',8)" coords="106,254,136,284" />' + 
				'</map>' + 
			'</div>' + 
			'<div id="searchc"><script type="text/javascript">showssearch();</script></div>' + 
			'<div id="rma" onmouseover="ocrma(1)" onmouseout="ocrma(0)" onmousedown="ocrma(2)" onkeydown="ocrma(2)" onclick="delarea()" onkeypress="delarea()" title="閉じる"></div>' + 
		'</div>';
	document.write(b);
}

function apiblock(a) {
	var b = 0;
	if (apib) { $("apim" + apib).style.background = "#FFFFFF"; $("api" + apib).style.display = "none"; } else { b = 1; }
	$("apim" + a).style.background = "#EEEEEE"; $("api" + a).style.display = "block";
	apib = a;
	if (!b) { location.hash = "apimenu"; }
}

function ccwh(a) {
	var c = $("wh" + a).style;
	c.width = "42px";
	c.height = "37px";
	c.backgroundPosition = "-308px " + ((0 - (a - 1)) * 242) + "px";
	c.zIndex = 9;
	$("wht" + a).style.display = "none";
	$("whl" + a).style.display = "none";
}

function ocwh(a,b) {
	for (i = 1; i <= 3; i++) {
		if (!b && (a == i)) {
			$("wht" + i).style.display = "none";
			$("whl" + i).style.display = "none";
			myTimer[7] = setInterval("socwh()",1);
			return;
		} else {
			ccwh(i);
		}
	}
	if (a && b) {
		var c = $("wh" + a).style;
		c.width = "304px";
		c.height = "242px";
		c.backgroundPosition = "-1px " + ((0 - (a - 1)) * 242) + "px";
		c.zIndex = 10;
		$("wht" + a).style.display = "block";
		$("whl" + a).style.display = "block";
		if (((a == 2) || (a == 3)) && !$("whl" + a).innerHTML) {
			$("wha" + a).style.display = "block";
			whn = a;
			getmysql(sqlurl + "getresit&dat=" + a ,1 ,6);
		}
		ocwhn[0] = a;
		ocwhn[1] = 290;
		ocwhn[2] = 1;
	}
}

function socwh() {
	ocwhn[1] -= ocwhn[2];
	ocwhn[2] += 10;
	if (ocwhn[2] == 22) { ocwhn[2] = 20; }
	if (ocwhn[1] < 0) {
		clearInterval(myTimer[7]);
		ccwh(ocwhn[0]);
		ocwhn = [];
	} else {
		$("wh" + ocwhn[0]).style.width = ocwhn[1] + "px";
	}
}

function getresit(a) {
	$("wha" + whn).style.display = "none";
	$("whl" + whn).innerHTML = ((a === "none") ? '情報が取得できませんでした' : a);
}

function wnsbp() {
	$("weathernews").innerHTML =
		'<div class="misctitle3">' + wns[0] + 'のお天気</div>' + 
		'<div id="weathernews_blog_parts" style="text-align: center;"></div>';
	wni_blog('blog/forecast',150,wns[1],false);
}

function moreinfo(a,b) {
	var z = ["幼稚園・保育園","小学校","中学校","病院","銀行","郵便局","コンビニエンスストア","ファミリーレストラン","ガソリンスタンド","スーパーマーケット"];
	var y = z.length; var x = '';
	for (i = 1; i <= y; i++) {
		x += '<li id="mgp' + i + '" onmouseout="cngmgp(0,' + i + ')" onmouseover="cngmgp(1,' + i + ')" onmousedown="cngmgp(2,' + i + ')" title="近隣の' + z[i-1] + 'を検索します" onclick="jmpmgp2(' + i + ',\'' + z[i-1] + '\')">' + z[i-1] + '</li>';
	}
	x = '<form id="dummyf" name="dummyf"><input type="hidden" id="dummyt" name="dummyt" value="' + a + '" /><input type="hidden" id="dummyu" name="dummyu" value="' + b + '" /><ul id="moregmap">' + x + '</ul></form><div id="moregmaptxt"></div><div id="moregmaptxt2">アイコンをクリックすると、地図が大きくなって周辺情報アイコンが表示されます。<br />場合によっては正しい結果が得られないかも知れませんのでご了承下さい。</div>';
	document.write(x);
}