//  common param var splitter="<>";var tout=1;var tout2=2500;var allColor="background-color:#ddd;";// each box config.var bord=1;var size=14;var hNColor="#ccc";var hLColor="#333";var hLight="border-color:"+hLColor+";";var bxstr="border:"+hNColor+" "+bord+"px solid;";bxstr+="margin:0px;padding:0px;width:"+size+"px;height:"+size+"px;";bxstr+="position:relative;overflow:hidden;float:left;background-repeat:no-repeat;";bxstr+="font-size:9px;text-align:center;";var stListDef="<table class='list'><tr><td> </td></tr></table>";// for internal usevar availColor,availName;var i;var i2;var mapda=new Array();var datai=new Array();var datainmap=new Array();var availI=new Array();var x=new Array();var y=new Array();var timer;var time2;var holdstate,iNumSelected;var activeS=new Array();var ave;var hnum=new Array();var dfName;var gyoumax=0;// cssvar defstyle="<style type='text/css'><!--";defstyle+="div.hmem{letter-spacing:-1px;text-align:center;"+bxstr+"}";defstyle+="table.list{border:black 1px solid;width:85%;height:100px;margin-bottom:4px;margin-right:30px}";defstyle+="--></style>";if(getCookie('data')=="testList"){	dfName="/v2/db/test/rec.js";	cdName="/v2/db/test/cfg.js";}else if(getCookie('data')=="shopList"){	dfName="/v2/db/shop/rec.js";	cdName="/v2/db/shop/cfg.js";}else if(getCookie('data')=="tokList"){	dfName="/v2/db/tok/rec.js";	cdName="/v2/db/tok/cfg.js";}else { // hospitalityList	dfName="/v2/db/hos/rec.js";	cdName="/v2/db/hos/cfg.js";}var linkstr="";//dfName="file:///D:"+dfName;defstyle+="<script type='text/JavaScript' src='"+dfName+"'><\/script>";defstyle+="<script type='text/JavaScript' src='"+cdName+"'><\/script>";document.open();document.write(defstyle);document.close();//******************var iC2=false;var ieop=false;var mac=false;var macosx=false;var netscape=false;var nc72=false;function getBrowserInfo(){	var ua=navigator.userAgent;//	alert(ua);	var matchStr=/Mac/;var matchStr2=/Mac OS X/;	if(ua.match(matchStr)!=null && ua.match(matchStr2)==null )mac=true;	if(ua.match(matchStr2)!=null )macosx=true;		matchStr=/MSIE ([0-9\.]+)/;	if(ua.match(matchStr)!=null){		ieop=true;		return("IE/"+RegExp.$1) ;	}	matchStr=/Opera(\/|\s)([0-9\.]+)/;	if(ua.match(matchStr)!=null){		ieop=true;		return("OP/"+RegExp.$2) ;	}	matchStr=/iCab ([0-9\.]+)/;	if(ua.match(matchStr)!=null){		if(RegExp.$1.charAt(0)<3)iC2=true;		return("iC/"+RegExp.$1) ;	}	matchStr=/Netscape(\/|\s)([0-9\.]+)/;	if(ua.match(matchStr)!=null){		netscape=true;		if(RegExp.$2.charAt(0)>6 && RegExp.$2.charAt(2)>1)nc72=true;		return("NC/"+RegExp.$2) ;	}	//matchStr=/iCab ([0-9\.]+)/;	//if(ua.match(matchStr)!=null)return("iC/"+RegExp.$1) ;}//==================== init ====================function init(str){	var bz=getBrowserInfo();	if(ieop)bord=0;//when IE5 	initStr=str;	var i;var i2,i3=0,i4;var ovflw=0;var divspan;var idHokui,idToukei;	var art=new Array();	var switchStr=strinitial;	holdstate=false;ave=0;	iNumSelected=-1;	if(!iC2){divspan="div";cl2="";cl="class='black'";}	else {divspan="span";cl="";cl2="class='black'";}	var mapdata=str;	mapda=mapdata.split(",");	for(i=0;i<mapda.length-2;i++){		mapda[i]=do2shousuu(mapda[i]);	}		if(mapda.length!=6){alert("Number of the GPS position of the map should be 2!");}	if(mapda[0]>=mapda[2]){alert("GPS data of the map is incorrect(Longituge)!");}	if(mapda[1]<=mapda[3]){alert("GPS data of the map is incorrect(Latituge)!");}	for(i=0;i<data.length;i++){		datai=data[i].split(splitter);		idToukei=do2shousuu(datai[iToukei]);		idHokui=do2shousuu(datai[iHokui]);		if(mapda[0]<idToukei && idToukei<mapda[2] && mapda[1]>idHokui && idHokui>mapda[3]){						x[i]=parseInt(mapda[4]*(idToukei-mapda[0])/(mapda[2]-mapda[0]),10);			y[i]=parseInt(mapda[5]*(mapda[1]-idHokui)/(mapda[1]-mapda[3]),10);			availI[i]="";			var chk=false;var style="";			for(i4=0;i4<availColor.length;i4++){				if(datai[iHost+i4]=="")availI[i]+="0" 				else availI[i]+=datai[iHost+i4];				if(datai[iHost+i4]==1 && !chk){					style=availColor[i4];					chk=true;				}			}			datainmap[i]=style;			i3++;			if(i3*(size+bord*2)>mapda[4]){				ovflw++;			}else ave++;			hnum[i]=i3;			}		else{			datainmap[i]="";x[i]=0;y[i]=0;			availI[i]="";			for(i4=0;i4<availColor.length;i4++)availI[i]+="0";			hnum[i]=-1;		}	}	gyoumax=parseInt((i3-1)/ave,10);	switchStr+="<div class='p' style='clear:both'><table border='0' cellspacing='10' width=540><tr>";	//for Mac OS IE5	var ck;	if(mac){		if(ieop){			switchStr+="<td style='width:90px;text-align:left;vertical-align:top'>";			switchStr+="<form name='formGroups'><span style='font-size:9pt;'>Groups : <wbr>";			for(i=0;i<gyoumax+2;i++){				if(i<gyoumax+1){					if(i==0)ck=" checked";else ck="";					switchStr+="<input type='radio'  style='text-vartical-align:middle;' name='radioB'"+ck+">"+(i+1)+" ";				}else {					switchStr+="<input type='hidden'  style='text-vartical-align:middle;' name='radioB'>";				}			}			switchStr+="</form></td><td>";			switchStr+="<span style='font-size:9pt'>Your browser(Mac:IE5) has a small bug of the implitation of CSS. Therefore, in case there are many records on this map, you have to chose one of the groups.</span><span style='color:white'>"+gyoumax+"/"+i3+"/"+ave+"</span></td></tr>";		}		else {			switchStr+="<td colspan='2'><span style='font-size:9pt'>We are regret to say that we already recongnized there are some problems when you open this page by your browser(<b>MacOS:"+bz+"</b>). So, we recommend you use <b>Internet explore 5</b> when you open this page. Thank you.";			switchStr+="</td></tr><tr>";		}	}	//for Mac OS X IE5	else if(macosx && ieop){		switchStr+="<td colspan='2'><span style='font-size:9pt'>We are regret to say that we already recongnized there are some problems when you open this page by your browser(<b>MacOS X:IE5</b>). So, we recommend you use <b>Safari</b>, <B>Mozila</b> or <b>Netscape(7.2 or later)</b> when you open this page. Thank you.";		switchStr+="</td></tr><tr>";	}	//for Netscape 7.1 or earlier	else if(netscape && !nc72){		switchStr+="<td colspan='2'><span style='font-size:9pt'>We are regret to say that we already recongnized there are some problems when you open this page by your browser(<b>Netscape "+bz+"</b>). So, we recommend you use newer Netscape(<b>7.2 or later</b>) or <B>Mozila</b>";		switchStr+=" when you open this page. Thank you.";		switchStr+="</td></tr><tr>";	}			//to show all		for(i=0;i<availColor.length;i++){art[i]=1;}		switchStr+="<td style='width:90px;text-align:left;vertical-align:top'><"+divspan+" class='hmem' style='"+allColor+"top:0px;left:0px;' onmouseover='showPlace(Array("+art+"),0)' onmouseout='cleartext2()' onClick='showPlace(Array("+art+"),1)'>&nbsp;&nbsp;&nbsp;</"+divspan+"><a href='javascript:void(0)' onClick='showPlace(Array("+art+"),1)' onmouseover='showPlace(Array("+art+"),0)' onmouseout='cleartext2()' "+cl2+">Show all</a> <a href='javascript:void(0)' onmouseover='showPlace(Array("+art+"),2)' onmouseout='cleartext2()' onClick='showPlace(Array("+art+"),3)'>&darr;</a></td><td>";		//to show each		for(i=0;i<availColor.length;i++){				for(i2=0;i2<availColor.length;i2++){art[i2]=0;}			art[i]=1;			switchStr+="<"+divspan+" style='float:left;'><"+divspan+" class='hmem' style='"+availColor[i]+"top:0px;left:0px;margin-left:3px' onmouseover='showPlace(Array("+art+"),0)' onmouseout='cleartext2()' onClick='showPlace(Array("+art+"),1)'>&nbsp;&nbsp;&nbsp;</"+divspan+">";		switchStr+="<a href='javascript:void(0)' onmouseover='showPlace(Array("+art+"),0)' onmouseout='cleartext2()' onClick='showPlace(Array("+art+"),1)' style='vertical-align:middle' "+cl2+">"+availName[i]+"</a> <a href='javascript:void(0)' onmouseover='showPlace(Array("+art+"),2)' onmouseout='cleartext2()' onClick='showPlace(Array("+art+"),3)'>&darr;</a></"+divspan+">";		}	switchStr+="</td></tr>";		// show index	switchStr+="<tr><td style='width:90px;vertical-align:top;'>Member index:</td><td><div id='INDEX'></div></td></tr></table></div>";	//show hold clear	switchStr+="<div class='p' style='clear:both;padding-top:2px;'>[Click square to <a href='javascript:hold()' id='black'>Hold</a> <span id='HCLR'></span>]<span style='color:#fff;'>Browser:";	if(mac)switchStr+="Classical Mac OS ";	switchStr+=bz+"<span></div>";	if(iC2)switchStr+=" <p>Your browser(maybe iCab 2) <b>doesn't support</b> CSS2 well. <br>Therfore it cannot show the records on this map.</p>";	switchStr+="<div id='LIST' style='clear:both;margin-top:9px;margin-left:50px;margin-right:30px;padding:5px;width:100%;vertical-align:top;overflow:visible'>";	switchStr+=stListDef;	switchStr+="</div>";	switchStr+="<p>Help:<i> Click category or Member index squares.Then it will be shown on the map.<br>You can also click squares on the map when those are shown.<br>Click \"&darr;\" to show all member of that category.</i></p>";	showtext(switchStr,"SWITCH");	showIndex();}function initParam(){}//==================== DHTML ====================function showtext(str,index) { 	if(document.getElementById){		var obj=document.getElementById(index);		obj.innerHTML = str;	}} /*=============printing function=============*/// show a square on the mapfunction showOnmap(){	var i,i2=0,i3=0,i4;var style;var str;var gyou;	var leftval=0;var topval=0;var zure=0;var zurepx=0;var boxover="";	for(i=0;i<data.length;i++){		if(datainmap[i]!=""){			for(i2=0;i2<availColor.length;i2++){				if(availI[i].charAt(i2)=="1" && activeS[i2]==1){					if(!mac || !ieop){						leftval=x[i]-size*(zure+1/2)-bord*(2*zure+1)+parseInt(i3/ave,10)*(size+bord*2)*ave;						topval=y[i]-size/2-bord-parseInt(i3/ave,10)*(size+bord*2);						style="left:"+leftval+"px;top:"+topval+"px;";						if(i==iNumSelected){style+=hLight;}						boxover+="<div class='hmem' style='"+style+availColor[i2]+"' onClick='over2("+i+",1)' onmouseover='over2("+i+",0)' onmouseout='cleartext2()' id='iNumM"+i+"'>"+hnum[i]+"</div>";						i3++;						zure+=1;						break;					}					else{						for(i4=0;i4<gyoumax+2;i4++){							if(document.formGroups.radioB[i4].checked)gyou=i4;						}						leftval=x[i]-size*(zure+1/2)-bord*(2*zure+1);						topval=y[i]-size/2-bord;						style="left:"+leftval+"px;top:"+topval+"px;";						if(i==iNumSelected){style+=hLight;}						if(parseInt(i3/ave,10)==gyou){							boxover+="<div class='hmem' style='"+style+availColor[i2]+"' onClick='over2("+i+",1)' onmouseover='over2("+i+",0)' onmouseout='cleartext2()' id='iNumM"+i+"'>"+hnum[i]+"</div>";							zure+=1;						}						i3++;												break;					}				}			}		}	}	if(!iC2)showtext(boxover,"ONMAP");	}// show index squares under the mapfunction showIndex(){	var i,i3=0;var divspan;	var style;var str="";	for(i=0;i<data.length;i++){		if(datainmap[i]!=""){			style=datainmap[i];			if(i==iNumSelected){style+=hLight;}			if(!iC2)divspan="div";else divspan="span";			str+="<"+divspan+" class='hmem' onmouseover='over("+i+",0)' onmouseout='cleartext()' onClick='over("+i+",1)' style='"+style+"margin-left:3px;margin-bottom:3px' id='iNum"+i+"'>"+hnum[i]+"</"+divspan+"> ";			i3++;		}	}	if(i3==0)str="There is <b>no record</b> in this area!";	showtext(str,"INDEX");}//show records datas in the square framefunction showPlace(active,h){	var i,i2,str;	if(h==1|h==3){		holdsw(1);	}	else if(holdstate){		return;	}		if(document.getElementById && iNumSelected!=-1){		var obj=document.getElementById("iNum"+iNumSelected);		obj.style.borderColor = hNColor;	}		iNumSelected=-1;	clearTimeout(timer);	clearTimeout(time2);	activeS=active;	if(h==2)str="<table class='list'><tr><td style='vertical-align:top;'><b>Click this arrow</b> to show all records in this area</td></tr></table>";	else if(h==3){		str="";		for(i=0;i<data.length;i++){			if(datainmap[i]=="")continue;			for(i2=0;i2<availColor.length;i2++){				if(availI[i].charAt(i2)=="1" && activeS[i2]==1){					str+=printTable(i);//###					break;				}			}		}	}	else str=stListDef;	showtext(str,"LIST");	if(!iC2)showOnmap();}//show each record datas in the square framefunction printTable(iNum){	var strover="<table class='list'>";	var strins="</td></tr><tr><td style='vertical-align:top'>";	var boxover="";	datai=data[iNum].split(splitter);		strover+="<tr><td style='vertical-align:top'>Name:</td><td><b>"+datai[iName]+"</b><span style='color:gray;'>(No."+iNum+" of all)</span>";	if(!iC2)divspan="div";else divspan="span";	strover+=strins;	strover+="Availability:</td><td>";	for(i=0;i<availColor.length;i++){		if(datai[i+iHost]==1){			strover+="<"+divspan+" style='float:left'><"+divspan+" class='hmem' style='"+availColor[i]+"'>"+hnum[iNum]+"</"+divspan+">"+availName[i]+"</"+divspan+">";		}	}	strover+="</td></tr>";		strover+=tableins(datai);/*	strover+="<tr><td style='vertical-align:top'>";	strover+="Comment:</td><td>"+datai[iComment];	strover+="</td></tr>";*/		strover+="<tr><td style='vertical-align:top'>";	strover+="Position:</td><td>"+dobunbyou(datai[iToukei])+" E Longtitude : "+dobunbyou(datai[iHokui])+" N Latitude <a href='javascript:void(0)' onClick=\"opengps('"+datai[iName]+"','"+datai[iToukei]+"','"+datai[iHokui]+"')\">More detailed<img src='/v2/img/maps.gif' alt='Open this position by other maps' class='i'></span>";	strover+=strins;	var matchStr=/SEARCHSTRING/;var linkstrtmp;	if(linkstr.match(matchStr)!=null)linkstrtmp=linkstr.replace(matchStr,datai[iName]);	strover+="Database:</td><td>"+linkstrtmp+"</td></tr></table>";		return(strover);}//------------- clear -------function cleartext(){	if(!holdstate){		timer=setTimeout("showtext(stListDef,'LIST');",tout);			time2=setTimeout("showtext('','ONMAP');",tout);		iNumSelected=-1;	showIndex();	}}function cleartext2(){	if(!holdstate){		timer=setTimeout("showtext(stListDef,'LIST');",tout);			time2=setTimeout("showtext('','ONMAP');",tout2);			iNumSelected=-1;		if(!iC2)showOnmap();		showIndex();		}}//----------------- hold(when clicked) functions---------------function holdClear(){	holdsw(0);	cleartext();}function hold(){	clearTimeout(timer);	clearTimeout(time2);	holdsw(1);}function holdsw(i){	if(i==1){		holdstate=true;				showtext("| <a href='javascript:void(0)' onClick='holdClear()'>Clear</a>","HCLR");	}else{		holdstate=false;		setTimeout("showtext('','HCLR')",200);			}}//==================called by onmouseover,onClick==================function over(iNum,h){	var i;var boxover="";var style;	var leftval=0;var topval=0;	if(h==1){		holdsw(1);	}else if(holdstate){		return;	}	if(document.getElementById && iNumSelected!=-1){		var obj=document.getElementById("iNum"+iNumSelected);		obj.style.borderColor = hNColor;	}	iNumSelected=iNum;	clearTimeout(timer);	clearTimeout(time2);	showtext(printTable(iNum),"LIST");	datai=data[iNum].split(splitter);	for(i=0;i<availColor.length;i++){		if(datai[i+iHost]==1){			leftval=x[iNum]-size/2-bord;			topval=y[iNum]-size/2-bord;			style="left:"+leftval+"px;top:"+topval+"px;";			style+=hLight;			boxover="<div class='hmem' style='"+style+availColor[i]+"'>"+hnum[iNum]+"</div>";			break;		}	}	if(!iC2)showtext(boxover,"ONMAP");		if(document.getElementById){		var obj=document.getElementById("iNum"+iNum);		obj.style.borderColor =hLColor;	}	}function over2(iNum,h){	if(h==1){		holdsw(1);	}else if(holdstate){		return;	}	if(document.getElementById && iNumSelected!=-1){		var obj=document.getElementById("iNumM"+iNumSelected);		obj.style.borderColor = hNColor;	}	iNumSelected=iNum;	clearTimeout(timer);	clearTimeout(time2);	if(document.getElementById){		var obj=document.getElementById("iNumM"+iNum);		obj.style.borderColor = hLColor;	}	showIndex();//	showOnmap();	showtext(printTable(iNum),"LIST");}//====================Keii tanikei converter====================function dobunbyou(str){	str=shousuu2do(str);	var matchStr=/\./;	if(str.match(matchStr)!=null)str=str.replace(matchStr,"&deg;");	if(str.match(matchStr)!=null)str=str.replace(matchStr,"&acute;");	if(str.match(matchStr)!=null)str=str.replace(matchStr,"byou");	matchStr=/byou.*$/;	if(str.match(matchStr)!=null)str=str.replace(matchStr,"");	return(str);}function do2shousuu(str){	var ido=new Array();	var idor;var imax;	var i=str.indexOf(".");var i2;	if(i!=-1){		i2=str.lastIndexOf(".");		if(i==i2){return(str);}//when it was already 10 shin suu		if(i2==str.length-1){		str=str.substring(0,i2);		}		ido=str.split(".");	}	else{		ido[0]=str;	}	if(ido.length==4){		ido[2]+="."+ido[3];		imax=2;	}else{imax=ido.length-1;}	for(i=imax;i>0;i--){		var f=parseFloat(ido[i-1]);		var g=parseFloat(ido[i]);			ido[i-1]=f+parseFloat(g/60);	}	idor=ido[0];return(idor);}function shousuu2do(str){	if(str.indexOf(".")!=str.lastIndexOf("."))return(str);// when str was already do-hun-byou		var tmp=parseInt(str,"10");	var str2=(str-tmp)*60;	var tmp2=parseInt(str2,"10");	var tmp3=Math.round((str2-tmp2)*6000)/100;	if(tmp3==60){		tmp2+=1;tmp3=0;	}	if(tmp2==60){		tmp+=1;tmp2=0;	}	tmp+="."+tmp2+"."+tmp3;	return(tmp);}function jntoFormat(str){	str=shousuu2do(str);	var ido=new Array();	var i=str.indexOf(".");	if(i!=-1){		i=str.lastIndexOf(".");		if(i==str.length-1){		str=str.substring(0,i);// remove last "."(ex. 135. becomes 135)		}		ido=str.split(".");	}	if(ido.length<=1){// if there is no "." 		ido[0]=str;	}		for(i=1;i<4;i++){		if(i>=ido.length){			ido[i]="0";		}		if(ido[i].length==1){			ido[i]="0"+ido[i];		}		ido[0]+=ido[i];	}	if(ido.length==4)len=3-ido[3].length;	else len=3;	ido[3]="";	for(i=0;i<len;i++){		ido[3]+="0";	}	ido[0]+=ido[3];	return(ido[0]);}function mapionFormat(str){	str=shousuu2do(str);	var matchStr=/\./;	if(str.match(matchStr)!=null)str=str.replace(matchStr,"%2F");	if(str.match(matchStr)!=null)str=str.replace(matchStr,"%2F");	return(str);}function googleFormat(str){	str=do2shousuu(str);	return(str);}function gsiFormat(str){	str=shousuu2do(str);	var ido=new Array();	var i=str.indexOf(".");	if(i!=-1){		i=str.lastIndexOf(".");		if(i==str.length-1){		str=str.substring(0,i);		}		ido=str.split(".");	}	else{		ido[0]=str;	}		for(i=1;i<3;i++){		if(i>=ido.length){			ido[i]="0";		}		if(ido[i].length==1){			ido[i]="0"+ido[i];		}		ido[0]+=ido[i]	}	if(ido.length==4)len=3-ido[3].length;	else len=3;	for(i=0;i<len;i++){		ido[3]+="0";	}	ido[0]+="."+ido[3];	return(ido[0]);}function dfile(str){	setCookie('data',str);	location.reload();}
