function indexMapLoad(){
  document.indexMap.submit();
}
function MM_openBrWindow(theURL,winName,features) {
  var win = window.open(theURL,winName,features);
  win.focus();
  return false;
}
function scroll(dir) {
  document.mapform.MV.value = dir;
  document.mapform.mode.value = 1;	// 必ず地図表示に！
  return true;
}
function scroll2(dir) {
  document.mapform.MV.value = dir;
  document.mapform.submit();
  return false;
}
function setSize(size) {
  document.mapform.s.value = size;
  document.mapform.mode.value = 1;	// 必ず地図表示に！
  return true;
}
function setScale(scale) {
  document.mapform.r.value = scale;
  document.mapform.mode.value = 1;	// 必ず地図表示に！
  return true;
}
function setInit() {
  document.mapform.INIT.value = 1;
  document.mapform.submit();
  return false;
}
function show_license() {
  return MM_openBrWindow('/map/license.html','license','width=400,height=65,resizable=yes');
}

function mapClick(e){
	if(top.frame_menu.myhome=='on'){
		if(e.x >= 0 && e.y >= 0){
			putHome(e.x,e.y,'r');
			return false;
		} else if(e.clientX >= 0 && e.clientY >= 0){
			putHome(e.clientX,e.clientY,'a');
			return false;
		} else {
			alert("このブラウザでは、この機能はご利用になれません。");
			return false;
		}
	} else {
		with(document.mapform){
			if(clkmode && mode){
				mode.value = clkmode[1].checked ? 2 : 1;
			}
		}
		return true;
	}
}
function putHome(x,y,cd) {
	this.x = x;
	this.y = y;

	var objtype;
	if(document.layers){
		objtype = document.layers.homeIcon;
		parentobj = document.layers.mainMap;
	} else if(document.all){
		objtype = document.all.homeIcon;
		parentobj = document.all.mainMap;
	} else if(document.getElementById){
		objtype = document.getElementById("homeIcon");
		parentobj = document.getElementById("mainMap");
	}

	// cd:座標が相対(r) or 絶対(a)? 
	if(cd == 'a'){
		x = x - parentobj.offsetLeft;
		y = y - parentobj.offsetTop;
		this.x = x;
		this.y = y;
	}
	with(objtype.style){
		left = (x - 10) + "px";
		top = (y - 10) + "px";
		display = "inline";
	}
	//座標格納
	with(top.frame_menu.document.form1){
		x.value = this.x;
		y.value = this.y;
	}
}
// 呼び出しウィンドウ変更のため。
function backHome() {
	// Cookieから座標を読み込み、設定。
	var cookies;
	cookies = new CookieJar("kobemed");
	if(cookies.result){
		if(top.frame_map.document.mapform){
			with(top.frame_map.document.mapform){
				a.value = cookies.orglat;
				o.value = cookies.orglon;
				submit();
			}
		} else {
			with(cookies){
				top.frame_map.location = "/cgi-bin/kobemed/map.cgi?a="+orglat+"&o="+orglon;
			}
		}
	}
}
function backHome_old() {
	// Cookieから座標を読み込み、設定。
	var cookies;
	cookies = new CookieJar("kobemed");
	with(document.mapform){
		a.value = cookies.orglat;
		o.value = cookies.orglon;
		submit();
	}
}
function CookieJar(ckname) {

	// Cookie情報の読込み
	var theCookie, s, e, ckstr, ckary;
	ckname += "=";
	theCookie = document.cookie + ";";
	s = theCookie.indexOf(ckname);
	if(s != -1){
		e = theCookie.indexOf(";", s);
		ckstr = unescape(theCookie.substring(s + ckname.length, e));

		// 実際に利用する変数の設定
		ckary = ckstr.split("&");
		for(i=0;i<ckary.length;i++){
			if(ckary[i] == "orglon"){
				i++;
				this.orglon = ckary[i];
			} else if(ckary[i] == "orglat"){
				i++;
				this.orglat = ckary[i];
			}
		}
		this.result = true;
	} else {
		this.result = false;
	}
}

