﻿document.write("<script type='text/javascript' src='http://web.infolocal.jp/kawagoe/yahoo.js'></script>");
document.write("<script type='text/javascript' src='http://web.infolocal.jp/kawagoe/dom.js'></script>");
document.write("<script type='text/javascript' src='http://web.infolocal.jp/kawagoe/event.js'></script>");
document.write("<script type='text/javascript' src='http://o.aolcdn.com/dojo/1.0.0/dojo/dojo.js'></script>");
document.write("<script type='text/javascript' src='http://o.aolcdn.com/dojo/1.0.0/dojo/io/script.js'></script>");
document.write("<link rel='stylesheet' href='http://web.infolocal.jp/kawagoe/bubble/bubble.css' media='screen'>");
document.write("<div id='bubble_start'><div class='bubble_start_top'><span></span></div><div class='bubble_start_middle'><span id='bubble_start_content'></span></div><div class='bubble_start_bottom'></div></div><div id='bubble_end'><div class='bubble_end_top'><span></span></div><div class='bubble_end_middle'><span id='bubble_end_content'></span></div><div class='bubble_end_bottom'></div></div>");

var CommunityMap = function(area) {
	this.area = area;
	this.map = document.createElement('img');
	var objBody = document.getElementById(this.area);
	if ( objBody.width != undefined )  this.imgwidth = objBody.width;
	if ( objBody.height != undefined )  this.imgheight = objBody.height;
	this.map.id = this.area;
	objBody.appendChild(this.map);
//	this.map.onclick = this.mevent;
    YAHOO.util.Event.addListener(this.map, "click", this.mevent);
//	var xy = YAHOO.util.Dom.getXY(this.map);
//	this.map.style.position = "absolute";
//	var clipst ='rect('+ xy[1] +','+ parseInt(parseInt(xy[0]) + parseInt(this.imgwidth)) +','
//                       + parseInt(parseInt(xy[1]) + parseInt(this.imgheight)) +','+ xy[1]  +')';
//    alert("clipst:"+clipst);
//	this.map.style.clip = clipst;
//	this.map.onmousedown = this.dragOn;
//	this.map.onmouseup = this.dragOff;
//	this.map.onmousemove = this.dragImg;
//	this.mapimage.onload = this.drawmarker;
	this.map.self = this;
	this.chiname = new Array(20);
	this.chix = new Array(20);
	this.chiy = new Array(20);
	this.markerx = new Array(20);
	this.markery = new Array(20);
	this.markerimg = new Array(20);
	this.mkonof = new Array(20);
	this.mkx = new Array(20);
	this.mky = new Array(20);
	this.bubble_x = new Array(2);
	this.bubble_y = new Array(2);
	this.bubble_text = new Array(2);
	for (var i=0;i<20;i++) {
		var newmarker = document.createElement('img');
		this.markerimg[i] = objBody.appendChild(newmarker);
		this.markerimg[i].id = this.area + "marker" + i;
		this.markerimg[i].style.position = "absolute";
		this.markerimg[i].src = "http://web.infolocal.jp/kawagoe/marker/marker"+Math.floor(parseInt(i+1)/10)+parseInt(i+1)%10+".gif";
		this.markerimg[i].style.left = (i+1)*10;
		this.markerimg[i].style.top = (i+1)*100;
		this.markerimg[i].width = this.markerwidth;
		this.markerimg[i].height = this.markerheight;
		this.markerimg[i].style.zIndex = 2;
		this.markerimg[i].style.display = "none";
	}
	this.bubble_x[0] = 0;		// bubble text box start point x coordinate
	this.bubble_y[0] = 0;		// bubble text box start point y coordinate
	this.bubble_text[0] = "";
	this.bubble_x[1] = 0;		// bubble text box end   point x coordinate
	this.bubble_y[1] = 0;		// bubble text box end   point y coordinate
	this.bubble_text[1] = "";
	this.mapimage = new Image();
//	this.ele = document.createElement('script');
//	this.ele.type = "text/javascript";
//	document.getElementById(this.area).appendChild(this.ele);
//	this.ele.text = "json text";
};

CommunityMap.prototype = {

	area: "",				// div id in which the map image element will be placed
	map: 0,					// image element for map
	mouse: [],				// mouse event offset value buffer for Yahoo UI
	mapimage: 0,			// map image buffer
	centx: -33292.800,		// x coordinates of map center
	centy: -10894.900,		// y coordinates of map center
	mapwidth: 20000,		// actual map width in metor
	imgwidth: 300,			// image width of drawing map
	imgheight: 300,			// image height of drawing map
	chimeiresult: 0,		// searched chimei data in JSON
	chicnt:0,				// searched chimei count
	chiname:0,				// searched chimei table
	chix:0,					// searched chimei x
	chiy:0,					// searched chimei y
	markerx: 0,				// marker x coordinate in metor
	markery: 0,				// marker y coordinate in metor
	markerimg: 0,			// marker image element table
	mkno: 0,				// count of marker in display
	mkonof: 0,				// display on/off switch of marker
	mkx: 0,					// display x coordinate of marker
	mky: 0,					// display y coordinate of marker
	markerwidth: 50,		// the width of marker
	markerheight: 45,		// the height of marker
	lang: "japanese",		// client language mode default
	ele: "",
	flag: false,
	startx: 0,				// coordinate x of mouse event from image Left
	starty: 0,				// coordinate y of mouse event from image Top
	endx: 0,
	endy: 0,
	imgLeft: 0,
	imgTop: 0,
	start_disp: 0,
	end_disp: 0,
	bubble_x: 0,			// bubble text box x coordinates table
	bubble_y: 0,			// bubble text box y coordinates table
	bubble_text: 0,			// bubble text box text data


//---------- drawing map ------------------------
draw: function() {
	if ( chmplotcnt > 0 ) {
		var plotbuff = "&plotxy=";
		plotbuff += chmplotcnt;
		for (i=0;i<chmplotcnt;i++) {
			plotbuff += ","+chimeix[i]+","+chimeiy[i];
		}
		this.mapimage = "http://web.infolocal.jp/kawagoe/tourmap.php?centx="+this.centx+"&centy="+this.centy+"&mapwidth="+this.mapwidth+"&imgwidth="+this.imgwidth+"&imgheight="+this.imgheight+plotbuff+"&lang="+this.lang;
	} else {
		this.mapimage = "http://web.infolocal.jp/kawagoe/tourmap.php?centx="+this.centx+"&centy="+this.centy+"&mapwidth="+this.mapwidth+"&imgwidth="+this.imgwidth+"&imgheight="+this.imgheight+"&lang="+this.lang;
	}
	this.map.src = this.mapimage;
	this.drawmarker(20);
	this.bubble_draw();
},

//---------- zoom in -----------------------------
zoomin: function(zif) { // zif : zoom in factor
	this.mapwidth /= zif;
	this.draw();
},

//---------- zoom out ----------------------------
zoomout: function(zof) { // zof : zoom out factor
	this.mapwidth *= zof;
	this.draw();
},

//---------- move map window to given coordinates -----------
center: function(cx,cy) { // coordinates of new window center(x,y)
	this.centx = cx;
	this.centy = cy;
	this.draw();
},

//---------- fit map window width to given width -
fitwidth: function(width) { // new map window width in metor
	this.mapwidth = width;
	this.draw();
},

//---------- whole city map ----------------------
whole: function() {
	this.centx = -33292.800;
	this.centy = -10894.900;
	if ( this.imgwidth > this.imgheight )  this.mapwidth = 20000 * this.imgwidth / this.imgheight;
	else this.mapwidth = 20000;
	this.draw();
},

//---------- plot marker over the map ----------
marker: function(mx,my) {
	this.markerx[this.mkno] = mx;
	this.markery[this.mkno] = my;
	this.mkonof[this.mkno] = 1;
	this.mkno++;
	this.drawmarker();
},

//---------- draw marker -------------------------
drawmarker: function(drwcnt) {
	var xy = YAHOO.util.Dom.getXY(this.area);
//	alert("xy:"+xy[0]+","+xy[1]);
    mcount = Math.min(drwcnt,20);
	for (var i=0;i<mcount;i++) {
		if (i<this.mkno ) {
			mkx = parseInt(xy[0],10) + parseInt(this.imgwidth/2,10) - parseInt(parseInt(this.centx,10)-parseInt(this.markerx[i],10))*parseInt(this.imgwidth,10)/parseInt(this.mapwidth,10);
			mky = parseInt(xy[1],10) + parseInt(this.imgheight/2,10) + parseInt(parseInt(this.centy,10)-parseInt(this.markery[i],10))*parseInt(this.imgwidth,10)/parseInt(this.mapwidth,10) - parseInt(this.markerheight,10);
			this.markerimg[i].style.left = mkx+"px";
			this.markerimg[i].style.top = mky+"px";
		}
		if ( (parseInt(this.markerimg[i].style.left) >= parseInt(xy[0])) && (parseInt(this.markerimg[i].style.left) <= parseInt(xy[0])+parseInt(this.imgwidth)) &&
			( parseInt(this.markerimg[i].style.top)+parseInt(this.markerheight) >= parseInt(xy[1])) && (parseInt(this.markerimg[i].style.top)+parseInt(this.markerheight) <= parseInt(xy[1])+parseInt(this.imgheight)) &&
			( parseInt(this.mkonof[i]) == parseInt(1) )) {
			this.markerimg[i].style.display = "inline";
		} else {
			this.markerimg[i].style.display = "none";
		}
	}
},

//---------- delete marker from the map ----------
delmarker: function() {
	for (var i=0;i<20;i++) {
		this.mkonof[i] = 0;
	}
	this.drawmarker();
	this.mkno = 0;
},
	
//---------- process mouse event -----------------
mevent: function(evt) {
	var mouse = YAHOO.util.Dom.getXY(this.self.area);
	var mouseX = YAHOO.util.Event.getPageX(evt)-mouse[0];
	var mouseY = YAHOO.util.Event.getPageY(evt)-mouse[1];
	mvx = mouseX - this.self.imgwidth / 2;
	mvy = this.self.imgheight - mouseY - this.self.imgheight / 2;
	this.self.centx = this.self.centx + mvx / this.self.imgwidth * this.self.mapwidth;
	this.self.centy = this.self.centy + mvy / this.self.imgwidth * this.self.mapwidth;
//	alert ("new center: " + this.map.centx + "," + this.map.centy);
	this.self.draw();
},

//---------- start dynamic pan operation ---------
dragOn: function() {
//	alert("enter dragOn");
	var xy = YAHOO.util.Dom.getXY(this.self.map);
	this.self.imgLeft = xy[0];
	this.self.imgTop  = xy[1];
//	alert ("start x,y:"+xy[0]+","+xy[1]);
	this.self.startx = event.x;
	this.self.starty = event.y;
	this.self.flag = true;
},

//---------- finish dynamic pan operation -----------
dragOff: function(){
	this.self.flag = false;
	mvx = this.self.endx - this.self.startx;
	mvy = this.self.endy - this.self.starty;
	this.self.centx = this.self.centx + mvx / this.self.imgwidth * this.self.mapwidth;
	this.self.centy = this.self.centy + mvy / this.self.imgwidth * this.self.mapwidth;
	this.self.draw();
},

//---------- drag map image -------------------------
dragImg: function() {
	if (!this.self.flag) return;
//	alert("enter dragImg");
	this.self.endx = event.x;
	this.self.endy = event.y;
	mvx = event.x - this.self.startx;
	mvy = event.y - this.self.starty;
	this.style.pixelLeft = this.self.startx + mvx;
	this.style.pixelTop  = this.self.starty + mvy;
	for (var i=0;i<20;i++) {
		if ( this.self.markerimg[i].style.left + mvx >= 0 && this.self.markerimg[i].style.top + mvy >= 0 ) {
			this.self.markerimg[i].style.left += mvx;
			this.self.markerimg[i].style.top  += mvy;
		}
	}
	return false;
},

chmmark: function(drwcnt) {
	this.delmarker();
	var cnt = Math.min(chmeicount,20);
	cnt = Math.min(cnt,drwcnt);
//	alert("chmplog-chmeicount : "+chmeicount);
	var xmin = 9999999999;
	var ymin = 9999999999;
	var xmax = -9999999999;
	var ymax = -9999999999;
	if ( cnt > 0 ) {
		for (i=0;i<cnt;i++) {
//			alert("marker x,y : " + chimeix[i] + " : " + chimeiy[i]+"no.:"+i );
			this.marker(chimeix[i],chimeiy[i]);
			xmin = Math.min(xmin,chimeix[i]);
			ymin = Math.min(ymin,chimeiy[i]);
			xmax = Math.max(xmax,chimeix[i]);
			ymax = Math.max(ymax,chimeiy[i]);
		}
	}
	var width = xmax - xmin;
	var height0 = width / this.imgwidth * this.imgheight;
	var height1 = ymax - ymin;
	if ( height0 < height1 ) {
		width = width / height0 * height1 + 200;
	}
	if ( width < 200 ) width = 200;
	var cx = (xmax + xmin) / 2;
	var cy = (ymax + ymin) / 2;
	this.center(cx,cy);
	this.fitwidth(width);
	this.mkno=cnt;
},

chmplot: function(drwcnt) {
	var cnt = Math.min(chmeicount,20);
	cnt = Math.min(cnt,drwcnt);
//	alert("chmplog-chmeicount : "+chmeicount);
	var xmin = 9999999999;
	var ymin = 9999999999;
	var xmax = -9999999999;
	var ymax = -9999999999;
	var plotbuff = "&plotxy=";
	if ( cnt > 0 ) {
		plotbuff += cnt;
		for (i=0;i<cnt;i++) {
			plotbuff += ","+chimeix[i]+","+chimeiy[i];
			xmin = Math.min(xmin,chimeix[i]);
			ymin = Math.min(ymin,chimeiy[i]);
			xmax = Math.max(xmax,chimeix[i]);
			ymax = Math.max(ymax,chimeiy[i]);
		}
	}
//	var width = xmax - xmin;
//	var height0 = width / this.imgwidth * this.imgheight;
//	var height1 = ymax - ymin;
//	if ( height0 < height1 ) {
//		width = width / height0 * height1 + 200;
//	}
//	if ( width < 200 ) width = 200;
//	this.mapwidth = width;
	this.mapwidth = 2500;
	var cx = (xmax + xmin) / 2;
	var cy = (ymax + ymin) / 2;
	this.centx = cx;
	this.centy = cy;
//	this.centx = -31592.800;
//	this.centy = -9394.900;
	this.mapimage = "http://web.infolocal.jp/kawagoe/tourmap.php?centx="+this.centx+"&centy="+this.centy+"&mapwidth="+this.mapwidth+"&imgwidth="+this.imgwidth+"&imgheight="+this.imgheight+plotbuff;
	this.map.src = this.mapimage;
},

// ------ Bubble text area of current point and object point display ----------

bubble: function(text,x,y,sw){
//	if(document.all)e = event;
//	if ( sw == 0 ) { 
//		start_disp = 0;
//		end_disp = 0;
//		obj_start.style.display = 'none';
//		obj_end.style.display = 'none';
//	}
	if ( sw == 'start' ) {
//		var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
//		if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
		this.bubble_x[0] = x;
		this.bubble_y[0] = y;
		this.bubble_text[0] = text;
		this.start_disp = 1;
//		alert("text : "+this.bubble_text[0]+"  x : "+this.bubble_x[0]+"   y: "+this.bubble_y[0]);
	}
	if ( sw == 'end' ) {
//		var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
//		if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
		this.bubble_x[1] = x;
		this.bubble_y[1] = y;
		this.bubble_text[1] = text;
		this.end_disp = 1;
//		alert("text : "+this.bubble_text[1]+"  x : "+this.bubble_x[1]+"   y: "+this.bubble_y[1]);
	}
},

bubble_draw: function() {
	var tshxy = YAHOO.util.Dom.getXY(this.area);
	if ( this.start_disp == 1 ) {
		var obj_start = document.getElementById('bubble_start');
		var obj2_start = document.getElementById('bubble_start_content');
		obj2_start.innerHTML = this.bubble_text[0];
		tshx = parseInt(tshxy[0],10) + parseInt(this.imgwidth/2,10) - parseInt(parseInt(this.centx,10)-parseInt(this.bubble_x[0],10))*parseInt(this.imgwidth,10)/parseInt(this.mapwidth,10);
		tshy = parseInt(tshxy[1],10) + parseInt(this.imgheight/2,10) + parseInt(parseInt(this.centy,10)-parseInt(this.bubble_y[0],10))*parseInt(this.imgwidth,10)/parseInt(this.mapwidth,10);
		obj_start.style.left = tshx - 100 + 'px';
		obj_start.style.top  = tshy -  72 + 'px';
		if ( (parseInt(tshx) >= parseInt(tshxy[0])) && (parseInt(tshx) <= parseInt(tshxy[0])+parseInt(this.imgwidth)) &&
			( parseInt(tshy) >= parseInt(tshxy[1])) && (parseInt(tshy) <= parseInt(tshxy[1])+parseInt(this.imgheight)) ) {
			obj_start.style.display = 'block';
		} else {
			obj_start.style.display = 'none';
		}
	}
	if ( this.end_disp == 1 ) {
		var obj_end = document.getElementById('bubble_end');
		var obj2_end = document.getElementById('bubble_end_content');
		obj2_end.innerHTML = this.bubble_text[1];
		tshx = parseInt(tshxy[0],10) + parseInt(this.imgwidth/2,10) - parseInt(parseInt(this.centx,10)-parseInt(this.bubble_x[1],10))*parseInt(this.imgwidth,10)/parseInt(this.mapwidth,10);
		tshy = parseInt(tshxy[1],10) + parseInt(this.imgheight/2,10) + parseInt(parseInt(this.centy,10)-parseInt(this.bubble_y[1],10))*parseInt(this.imgwidth,10)/parseInt(this.mapwidth,10);
		obj_end.style.left = tshx - 100 + 'px';
		obj_end.style.top  = tshy -  72 + 'px';
		if ( (parseInt(tshx) >= parseInt(tshxy[0])) && (parseInt(tshx) <= parseInt(tshxy[0])+parseInt(this.imgwidth)) &&
			( parseInt(tshy) >= parseInt(tshxy[1])) && (parseInt(tshy) <= parseInt(tshxy[1])+parseInt(this.imgheight)) )  {
			obj_end.style.display = 'block';
		} else {
			obj_end.style.display = 'none';
		}
	}
},

bubble_onoff: function (onoff) {
	if ( onoff == 'on' ) {
		var obj_start = document.getElementById('bubble_start');
		obj_start.style.display = 'none';
		var obj_end = document.getElementById('bubble_end');
		obj_end.style.display   = 'none';
		this.bubble_draw();
	}
	if ( onoff == 'off' ) {
		var obj_start = document.getElementById('bubble_start');
		obj_start.style.display = 'none';
		var obj_end = document.getElementById('bubble_end');
		obj_end.style.display   = 'none';
	}
}
};


//---------- Chimei Search ---------------------------------
var chm;
var chmeicount = -1;
chimeitbl = [];
chimeishu = [];
chimeix = [];
chimeiy = [];
chmplotcnt = 0;
chmplotx = [];
chmploty = [];

function chimei(cshu,cname,chmcnt) {
	dojo.require("dojo.io.script");
	delete chm;
	shubetsu = cshu;
	name=encodeURIComponent(cname);
//	chrtn = 0;
	dojo.io.script.get({
		url : "http://web.infolocal.jp/kawagoe/chimei.php",
		content: { shubetsu:shubetsu, name:name, chmcnt:chmcnt },
		handleAs: "json",
		preventCache: true,
		callbackParamName: "callback",
		handle: function(responce,ioArgs){
			ioArgs;
			chget();
//			chrtn = 1;
		}
	});
}

function chget()  {
//	if ( chrtn==0 ) { setTimeout("chget()",100); }
//	else {
	if ( chm.count > 0 ) {
		for (i=0;i<chm.count;i++) {
			chimeitbl[i] = eval('chm.name'+i);
			chimeishu[i] = eval('chm.shu'+i);
			chimeix[i] = eval('chm.x'+i);
			chimeiy[i] = eval('chm.y'+i);
//			alert( "chimei:" + chimeitbl[i] + " x:" + chimeix[i] + " - y:" + chimeiy[i] );
		}
//	}
	chmeicount = chm.count;
	}
}

function chimeisk(ckshu,cname,chmcnt) {
	dojo.require("dojo.io.script");
	delete chm;
	shubetsu = encodeURIComponent(ckshu);
	name=encodeURIComponent(cname);
//	chrtn = 0;
	dojo.io.script.get({
		url : "http://web.infolocal.jp/kawagoe/chimeisk.php",
		content: { shubetsu:shubetsu, name:name, chmcnt:chmcnt },
		handleAs: "json",
		preventCache: true,
		callbackParamName: "callback",
		handle: function(responce,ioArgs){
			ioArgs;
			chget();
//			chrtn = 1;
		}
	});
}


chlist = 0;
map = 0;
iconmap = 0;
tkai = 0;

function corpus(sentence,map0,list) {

	chmplotcnt = 0;
	map = map0;
	chlist = list;
	dojo.require("dojo.io.script");
	chmeicount = 0;
	sent = sentence;
	sleng = sentence.length;
	skai = Math.ceil((sleng-20)/100);
	skai = Math.max(skai,1);
	tkai = skai;
//	alert("skai:"+skai);
	chmeijdg = skai;
	for (var ik=0;ik<skai;ik++)  {
		if ( chmeicount > 20 ) break;
		delete chm;
		sent=encodeURIComponent(sentence.substring(ik*100,ik*100+120));
		rtn = 0;
		dojo.io.script.get({
			url : "http://web.infolocal.jp/kawagoe/corpus.php",
			content: { sentence: sent, objno:ik},
			handleAs: "json",
			preventCache: true,
			callbackParamName: "callback",
			handle: function(responce,ioArgs){
				ioArgs;
				chmeijdg--;
			}
		});
	}
	chmwait();
}

function chmwait() {
//	alert("chmwait-chmeijdg:"+chmeijdg+ "skai:"+tkai);
	if ( chmeijdg>0 ) { setTimeout("chmwait()",100); }
	else {
		for (jk=0;jk<tkai;jk++) {
			ccount = eval('chm'+jk+'.count');
//			alert("ccount : "+ccount);
			for (i=0;i<ccount;i++) {
				chimdata = eval('chm'+jk+'.name'+i)
				ex = 0;
				if (chmeicount>0) {
					for (k=0;k<=chmeicount;k++) {
						if ( chimeitbl[k] == chimdata )  ex = 1;
					}
				}
				if ( ex == 0 ) {
					chimeitbl[chmeicount] = chimdata;
					chimeishu[chmeicount] = eval('chm'+jk+'.shu'+i);
					chimeix[chmeicount] = eval('chm'+jk+'.x'+i);
					chimeiy[chmeicount] = eval('chm'+jk+'.y'+i);
					chmeicount++;
//					alert("chmeicout up: "+chmeicount);
				}
			}
		}
		chmlist(chlist);
		map.chmmark(20);
	}
}

function corpus0(sentence,map0) {

	iconmap = map0;
	dojo.require("dojo.io.script");
	chmeicount = 0;
	sent = sentence;
	sleng = sentence.length;
	skai = Math.ceil((sleng-20)/100);
	skai = Math.max(skai,1);
	tkai = skai;
//	alert("skai:"+skai);
	chmeijdg = skai;
	for (var ik=0;ik<skai;ik++)  {
		if ( chmeicount > 20 ) break;
		delete chm;
		sent=encodeURIComponent(sentence.substring(ik*100,ik*100+120));
		dojo.io.script.get({
			url : "http://web.infolocal.jp/kawagoe/corpus.php",
			content: { sentence: sent, objno:ik},
			handleAs: "json",
			preventCache: true,
			callbackParamName: "callback",
			handle: function(responce,ioArgs){
				ioArgs;
				chmeijdg--;
			}
		});
	}
	chmwait0();
}

function chmwait0() {
//	alert("chmwait-chmeijdg:"+chmeijdg+ "skai:"+tkai);
	if ( chmeijdg>0 ) { setTimeout("chmwait0()",100); }
	else {
		chmplotcnt = 0;
		for (jk=0;jk<tkai;jk++) {
			ccount = eval('chm'+jk+'.count');
//			alert("ccount : "+ccount);
			for (i=0;i<ccount;i++) {
				chimdata = eval('chm'+jk+'.name'+i)
				ex = 0;
				if (chmeicount>0) {
					for (k=0;k<=chmeicount;k++) {
						if ( chimeitbl[k] == chimdata )  ex = 1;
					}
				}
				if ( ex == 0 ) {
					chimeitbl[chmeicount] = chimdata;
					chimeishu[chmeicount] = eval('chm'+jk+'.shu'+i);
					chimeix[chmeicount] = eval('chm'+jk+'.x'+i);
					chimeiy[chmeicount] = eval('chm'+jk+'.y'+i);
					chmeicount++;
//					alert("chmeicout up: "+chmeicount);
					chmplotx[chmeicount] = chimeix[chmeicount];
					chmploty[chmeicount] = chimeix[chmeicount];
				}
			}
		}
		chmplotcnt = chmeicount;
		iconmap.chmplot(20);
	}
}

function chmlist (chmdiv) {
	
	var listBody = document.getElementById(chmdiv);
//	if ( typeof(chm) == 'object' ) {
		while (listBody.firstChild) {
			listBody.removeChild(listBody.firstChild);
		}
//	}
	if ( chmeicount > 0 ) {
		for (i=0;i<chmeicount;i++) {
			img = document.createElement("img");
			img.setAttribute("src","http://web.infolocal.jp/kawagoe/marker/number"+Math.floor(parseInt(i+1)/10)+parseInt(i+1)%10+".gif");
			img.setAttribute("height","18");
			img.setAttribute("width","18");
			a=listBody.appendChild(img);
			a=listBody.appendChild(document.createTextNode(chimeitbl[i]+"　　"));
//			a=listBody.appendChild(document.createTextNode("("+(i+1)+") "+chimeitbl[i]+"　　"));
//			listBody.appendChild(document.createElement("br"));
		}
	}
//	alert("chmlist:"+chmeicount);
}

var icount;
var instname = [];
var lv1cls = [];
var lv2cls = [];
var lv3cls = [];
var instx = [];
var insty = [];
var onlist;

function ontology(classname,instcount,list, lang) {
//function ontology(classname,instcount,list) {

	onlist = list;
	dojo.require("dojo.io.script");
	irtn = 0;
	clsnam = classname;
	icnt = instcount;
	language = lang; // for language transration
	delete instance;
	clsnam=encodeURIComponent(clsnam);
	rtn = 0;
	dojo.io.script.get({
		url : "http://web.infolocal.jp/kawagoe/ontology.php",
		content: { classname: clsnam, instcnt:icnt, lang:language },
//		content: { classname: clsnam, instcnt:icnt },
		handleAs: "json",
		preventCache: true,
		callbackParamName: "callback",
		handle: function(responce,ioArgs){
			ioArgs;
			irtn = 1;
		}
	});
	ontwait();
}
function ontwait() {
//	alert("chmwait-chmeijdg:"+chmeijdg+ "skai:"+tkai);
	if ( irtn == 0 ) { setTimeout("ontwait()",100); }
	else {
		icount = eval('instance.count');
		for (ik=0;ik<icount;ik++) {
			instname[ik] = eval('instance.name'+ik);
			lv1cls[ik] = eval('instance.lv1nm'+ik);
			lv2cls[ik] = eval('instance.lv2nm'+ik);
			lv3cls[ik] = eval('instance.lv3nm'+ik);
			instx[ik] = eval('instance.x'+ik);
			insty[ik] = eval('instance.y'+ik);
		}
		ontlist(onlist);
	}
}


function ontlist (ontdiv) {
	
	var listBody = document.getElementById(ontdiv);
//	if ( typeof(chm) == 'object' ) {
		while (listBody.firstChild) {
			listBody.removeChild(listBody.firstChild);
		}
//	}
	if ( icount > 0 ) {
			sel = document.createElement("select");
			sel.setAttribute("size",6);
			attri = document.createAttribute("multiple");
			sel.attributes.setNamedItem(attri);
			sel.setAttribute("multiple",true);
			sel.setAttribute("id","selnam");
		for (i=0;i<icount;i++) {
			opt = document.createElement("option");
			opt.innerText = instname[i];
			opt.textContent = instname[i];
			a = sel.appendChild(opt);
//			a=listBody.appendChild(document.createTextNode(instname[i]+"　　"));
//			a=listBody.appendChild(document.createTextNode("("+(i+1)+") "+chimeitbl[i]+"　　"));
//			listBody.appendChild(document.createElement("br"));
		}
			a=listBody.appendChild(sel);
	}
//	alert("chmlist:"+chmeicount);
}

function freesearch(fretxt,frecnt,flist) {

	onlist = flist;
	dojo.require("dojo.io.script");
	irtn = 0;
	freetxt0 = fretxt;
	ifcnt = frecnt;
	delete instance;
	freetxt0=encodeURIComponent(freetxt0);
	rtn = 0;
	dojo.io.script.get({
		url : "http://web.infolocal.jp/kawagoe/freesearch.php",
		content: { freetext: freetxt0, freecnt:ifcnt},
		handleAs: "json",
		preventCache: true,
		callbackParamName: "callback",
		handle: function(responce,ioArgs){
			ioArgs;
			irtn = 1;
		}
	});
	ontwait();
}


//---------- Taisho-butsu Search ---------------------------------
var tsh;
var tshcount;
var tpattern = "222222222222222222222222222222";
t_title = [];
t_cat = [];
t_area = [];
t_x = [];
t_y = [];
t_pat = [];
t_card = [];
t_budget = [];
t_churge = [];
t_hours = [];
t_holiday = [];
t_copy = [];
t_comment = [];
t_image1 = [];
t_image2 = [];
t_no = [];

k_name = [];
k_no = [];
k_gou = [];
k_gyoshu = [];
k_yubin = [];
k_jusho = [];
k_renraku = [];

function taisho(t_start, t_count, t_lang) {
	dojo.require("dojo.io.script");
	delete tsh;
	tstart = t_start;
	tcount = t_count;
	tlang = t_lang;
	tshcount = -1;
	tshrtn = 0;

	dojo.io.script.get({
		url : "http://web.infolocal.jp/kawagoe/taisho.php",
		content: { pattern:tpattern, start:tstart, count:tcount, lang:tlang },
		handleAs: "json",
		preventCache: true,
		callbackParamName: "callback",
		handle: function(responce,ioArgs){
			ioArgs;
			tshrtn = 1;
		}
	});
	tshwait();
}

function tshwait()  {
	if ( tshrtn == 0 ) { setTimeout("tshwait()",100); }
	else {
		if ( tsh.count >= 0 ) {
			for (i=0;i<tsh.count;i++) {
				t_title[i] = eval('tsh.tsh1_'+i);
				t_cat[i] = eval('tsh.tsh2_'+i);
				t_area[i] = eval('tsh.tsh3_'+i);
				t_x[i] = eval('tsh.tsh4_'+i);
				t_y[i] = eval('tsh.tsh5_'+i);
				t_pat[i] = eval('tsh.tsh6_'+i);
				t_card[i] = eval('tsh.tsh7_'+i);
				t_budget[i] = eval('tsh.tsh8_'+i);
				t_churge[i] = eval('tsh.tsh9_'+i);
				t_hours[i] = eval('tsh.tsh10_'+i);
				t_holiday[i] = eval('tsh.tsh11_'+i);
				t_copy[i] = eval('tsh.tsh12_'+i);
				t_comment[i] = eval('tsh.tsh13_'+i);
				t_image1[i] = eval('tsh.tsh14_'+i);
				t_image2[i] = eval('tsh.tsh15_'+i);
				t_no[i] = eval('tsh.tsh16_'+i);
				k_name[i] = eval('tsh.kin1_'+i);
				k_no[i] = eval('tsh.kin2_'+i);
				k_gou[i] = eval('tsh.kin3_'+i);
				k_gyoshu[i] = eval('tsh.kin4_'+i);
				k_yubin[i] = eval('tsh.kin5_'+i);
				k_jusho[i] = eval('tsh.kin6_'+i);
				k_renraku[i] = eval('tsh.kin7_'+i);
			}
			tshcount = tsh.count;
		}
	}
}

function condset( item, sw ) {
	if ( item == "車椅子対応" ) { // 0
		if ( sw == 0 ) tpattern = "0" + tpattern.substring(1,30);
		if ( sw == 1 ) tpattern = "1" + tpattern.substring(1,30);
		if ( sw == 2 ) tpattern = "2" + tpattern.substring(1,30);
	}
	if ( item == "寺社・仏閣" ) { // 1
		if ( sw == 0 ) tpattern = tpattern.substring(0,1) + "0" + tpattern.substring(2,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,1) + "1" + tpattern.substring(2,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,1) + "2" + tpattern.substring(2,30);
	}
	if ( item == "施設・建物" ) { // 2
		if ( sw == 0 ) tpattern = tpattern.substring(0,2) + "0" + tpattern.substring(3,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,2) + "1" + tpattern.substring(3,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,2) + "2" + tpattern.substring(3,30);
	}
	if ( item == "博物館・美術館" ) {  //3
		if ( sw == 0 ) tpattern = tpattern.substring(0,3) + "0" + tpattern.substring(4,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,3) + "1" + tpattern.substring(4,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,3) + "2" + tpattern.substring(4,30);
	}
	if ( item == "文化財" ) {  //4
		if ( sw == 0 ) tpattern = tpattern.substring(0,4) + "0" + tpattern.substring(5,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,4) + "1" + tpattern.substring(5,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,4) + "2" + tpattern.substring(5,30);
	}
	if ( item == "体験" ) {  //5
		if ( sw == 0 ) tpattern = tpattern.substring(0,5) + "0" + tpattern.substring(6,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,5) + "1" + tpattern.substring(6,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,5) + "2" + tpattern.substring(6,30);
	}
	if ( item == "その他（観）" ) {  //6
		if ( sw == 0 ) tpattern = tpattern.substring(0,6) + "0" + tpattern.substring(7,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,6) + "1" + tpattern.substring(7,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,6) + "2" + tpattern.substring(7,30);
	}
	if ( item == "いも・うなぎ料理" ) {  //7
		if ( sw == 0 ) tpattern = tpattern.substring(0,7) + "0" + tpattern.substring(8,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,7) + "1" + tpattern.substring(8,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,7) + "2" + tpattern.substring(8,30);
	}
	if ( item == "和食" ) {  //8
		if ( sw == 0 ) tpattern = tpattern.substring(0,8) + "0" + tpattern.substring(9,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,8) + "1" + tpattern.substring(9,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,8) + "2" + tpattern.substring(9,30);
	}
	if ( item == "洋食" ) {  //9
		if ( sw == 0 ) tpattern = tpattern.substring(0,9) + "0" + tpattern.substring(10,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,9) + "1" + tpattern.substring(10,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,9) + "2" + tpattern.substring(10,30);
	}
	if ( item == "中華" ) {  //10
		if ( sw == 0 ) tpattern = tpattern.substring(0,10) + "0" + tpattern.substring(11,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,10) + "1" + tpattern.substring(11,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,10) + "2" + tpattern.substring(11,30);
	}
	if ( item == "食べ歩き" ) {  //11
		if ( sw == 0 ) tpattern = tpattern.substring(0,11) + "0" + tpattern.substring(12,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,11) + "1" + tpattern.substring(12,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,11) + "2" + tpattern.substring(12,30);
	}
	if ( item == "喫茶" ) {  //12
		if ( sw == 0 ) tpattern = tpattern.substring(0,12) + "0" + tpattern.substring(13,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,12) + "1" + tpattern.substring(13,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,12) + "2" + tpattern.substring(13,30);
	}
	if ( item == "その他（食）" ) {  //13
		if ( sw == 0 ) tpattern = tpattern.substring(0,13) + "0" + tpattern.substring(14,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,13) + "1" + tpattern.substring(14,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,13) + "2" + tpattern.substring(14,30);
	}
	if ( item == "ブランド産品" ) {  //14
		if ( sw == 0 ) tpattern = tpattern.substring(0,14) + "0" + tpattern.substring(15,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,14) + "1" + tpattern.substring(15,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,14) + "2" + tpattern.substring(15,30);
	}
	if ( item == "お菓子" ) {  //15
		if ( sw == 0 ) tpattern = tpattern.substring(0,15) + "0" + tpattern.substring(16,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,15) + "1" + tpattern.substring(16,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,15) + "2" + tpattern.substring(16,30);
	}
	if ( item == "民芸品" ) {  //16
		if ( sw == 0 ) tpattern = tpattern.substring(0,16) + "0" + tpattern.substring(17,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,16) + "1" + tpattern.substring(17,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,16) + "2" + tpattern.substring(17,30);
	}
	if ( item == "食料品" ) {  //17
		if ( sw == 0 ) tpattern = tpattern.substring(0,17) + "0" + tpattern.substring(18,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,17) + "1" + tpattern.substring(18,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,17) + "2" + tpattern.substring(18,30);
	}
	if ( item == "その他（買）" ) {  //18
		if ( sw == 0 ) tpattern = tpattern.substring(0,18) + "0" + tpattern.substring(19,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,18) + "1" + tpattern.substring(19,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,18) + "2" + tpattern.substring(19,30);
	}
	if ( item == "公共施設" ) {  //19
		if ( sw == 0 ) tpattern = tpattern.substring(0,19) + "0" + tpattern.substring(20,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,19) + "1" + tpattern.substring(20,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,19) + "2" + tpattern.substring(20,30);
	}
	if ( item == "休憩" ) {  //20
		if ( sw == 0 ) tpattern = tpattern.substring(0,20) + "0" + tpattern.substring(21,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,20) + "1" + tpattern.substring(21,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,20) + "2" + tpattern.substring(21,30);
	}
	if ( item == "宿泊" ) {  //21
		if ( sw == 0 ) tpattern = tpattern.substring(0,21) + "0" + tpattern.substring(22,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,21) + "1" + tpattern.substring(22,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,21) + "2" + tpattern.substring(22,30);
	}
	if ( item == "交通" ) {  //22
		if ( sw == 0 ) tpattern = tpattern.substring(0,22) + "0" + tpattern.substring(23,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,22) + "1" + tpattern.substring(23,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,22) + "2" + tpattern.substring(23,30);
	}
	if ( item == "クーポン" ) {  //23
		if ( sw == 0 ) tpattern = tpattern.substring(0,23) + "0" + tpattern.substring(24,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,23) + "1" + tpattern.substring(24,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,23) + "2" + tpattern.substring(24,30);
	}
	if ( item == "カード" ) {  //24
		if ( sw == 0 ) tpattern = tpattern.substring(0,24) + "0" + tpattern.substring(25,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,24) + "1" + tpattern.substring(25,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,24) + "2" + tpattern.substring(25,30);
	}
	if ( item == "喫煙" ) {  //25
		if ( sw == 0 ) tpattern = tpattern.substring(0,25) + "0" + tpattern.substring(26,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,25) + "1" + tpattern.substring(26,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,25) + "2" + tpattern.substring(26,30);
	}
	if ( item == "座敷" ) {  //26
		if ( sw == 0 ) tpattern = tpattern.substring(0,26) + "0" + tpattern.substring(27,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,26) + "1" + tpattern.substring(27,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,26) + "2" + tpattern.substring(27,30);
	}
	if ( item == "個室" ) {  //27
		if ( sw == 0 ) tpattern = tpattern.substring(0,27) + "0" + tpattern.substring(28,30);
		if ( sw == 1 ) tpattern = tpattern.substring(0,27) + "1" + tpattern.substring(28,30);
		if ( sw == 2 ) tpattern = tpattern.substring(0,27) + "2" + tpattern.substring(28,30);
	}
}
