var var_t = '';
var var_l = '';
var var_bbid = '';

function EnquteStatusCallBack()
{
	if( request1.readyState == 4 )
	{
		if( request1.status == 200 )
		{
			var response = request1.responseText;
			if( response == '1' )
			{
				SetLayerVisible("ENQ_1",false);
				SetLayerVisible("ENQ_2",false);
			}
			else
			{
				SetLayerVisible("ENQ_3",false);
			}
		}
		else if( request1.status == 404 )
		{
		}
		else
		{
		}
	}
}
function EnqueteSend(Number,Answer)
{
	SetLayerVisible("ENQ_1",false);
	SetLayerVisible("ENQ_2",false);
	SetLayerVisible("ENQ_3",true);
	var DateID = new Date();
	var url = "../../asp/enquete.asp?no=" + Number + "&an=" + Answer + "&id=" + DateID.getTime();
	request1.open("GET",url,true);
	request1.onreadystatechange = EnquteStatusCallBack;
	request1.send(null);
}
function EnqueteStatus(Number)
{
	var_bbid = Number;
	var EnqueteDate = new Date();
	var url = "../../asp/enquete_status.asp?no=" + Number + "&id=" + EnqueteDate.getTime();
	request1.open("GET",url,true);
	request1.onreadystatechange = EnquteStatusCallBack;
	request1.send(null);
}
function CheckCallBack()
{
	if( request2.readyState == 4 )
	{
		if( request2.status == 200 )
		{
			var response = request2.responseText;
			if( response == "0" )
			{
				ReplaceCM0();
			}
			else
			{
				ReplaceCM1(response);
			}
		}
		else if( request2.status == 404 )
		{
		}
		else
		{
		}
	}
}

function CheckCM()
{
	var DateID = new Date();
	var url = "../../asp/result_status.asp?id=" + DateID.getTime();
	request2.open("GET",url,true);
	request2.onreadystatechange = CheckCallBack;
	request2.send(null);
}
function ReplaceCM0()
{
	var html;
	html = '<map name="Map">';
	html = html + '<area shape="rect" coords="18,19,175,97" href="../../btop.html" alt="B-BOX トップへ">'
	html = html + '<area shape="rect" coords="18,97,175,118" href="#" alt="琵琶湖河川事務所HOMEへ" onClick="javascript:Home()">'
	html = html + '<area shape="rect" coords="184,6,330,49" href="#" onclick="javascript:Usage();return false" alt="このサイトのご利用にあたって必ずお読みください">';
	html = html + '<area shape="poly" coords="349,63,349,118,421,118,440,92,421,63" href="#" alt="琵琶湖河川事務所HOME" onClick="javascript:Home()">';
	html = html + '<area shape="poly" coords="442,63,442,118,514,118,533,92,514,63" href="../../btop.html" alt="B-BOX トップへ">';
	html = html + '<area shape="poly" coords="542,61,542,99,613,99,632,81,613,61" href="../../btop.html" alt="B-BOX トップ">';
	html = html + '<area shape="poly" coords="542,98,542,117,611,117,632,107,611,98" href="' + G_BSKY_URL;
	html = html + '?t=' + var_t;
	html = html + '&l=' + var_l;
	html = html + '&bbid=' + var_bbid + '"';
	html = html + ' target="BSKY" alt="地図から選択">';
	html = html + '</map>';
	var cm = SetObj('cm');
	cm.innerHTML = html;
}
function ReplaceCM1(URLString)
{
	var html;
	html = '<map name="Map">';
	html = html + '<area shape="rect" coords="18,19,175,97" href="../../btop.html" alt="B-BOX トップへ">'
	html = html + '<area shape="rect" coords="18,97,175,118" href="#" alt="琵琶湖河川事務所HOMEへ" onClick="javascript:Home()">'
	html = html + '<area shape="rect" coords="184,6,330,49" href="#" onclick="javascript:Usage();return false" alt="このサイトのご利用にあたって必ずお読みください">';
	html = html + '<area shape="poly" coords="349,63,349,118,421,118,440,92,421,63" href="#" alt="琵琶湖河川事務所HOME" onClick="javascript:Home()">';
	html = html + '<area shape="poly" coords="442,63,442,118,514,118,533,92,514,63" href="../../btop.html" alt="B-BOX トップへ">';
	html = html + '<area shape="poly" coords="542,61,542,99,613,99,632,81,613,61" href="../../asp/result.asp' + URLString + '"' + ' ' + 'alt="検索結果から選択">';
	html = html + '<area shape="poly" coords="542,98,542,117,611,117,632,107,611,98" href="' + G_BSKY_URL;
	html = html + '?t=' + var_t;
	html = html + '&l=' + var_l;
	html = html + '&bbid=' + var_bbid + '"';
	html = html + ' target="BSKY" alt="地図から選択">';
	html = html + '</map>';
	var cm = SetObj('cm');
	cm.innerHTML = html;
}
var bOP6=0; // opera6-
var bIE4=0; // IE4-
var bNS4=0; // NS4
var bNS6=0; // NS6-,mozilla
distiBrowser();
function distiBrowser(){
  if(document.layers){ bNS4=1;return true;}
  if(window.opera){
          if(document.getElementById){ bOP6=1;return true;}
  }
  else if(document.all){ bIE4=1;return true;}
  else if(document.addEventListener){ bNS6=1;return true;}
  return false;
}
var bOpera;
var bN6;
var bIE;
var bN4;
function innerResizeTo(iw, ih){
  var ww=0;
  var wh=0;
  if(bIE4||bOP6){
    window.resizeTo(iw, ih);
    ww = iw + (iw-document.body.clientWidth);
    wh = ih + (ih-document.body.clientHeight);
  } else if(bNS6||bOP6){
    ww = iw + (window.outerWidth-document.body.clientWidth);
    wh = ih + (window.outerHeight-document.body.clientHeight);
  }
  window.resizeTo(ww, wh);
}
function GetInnerW(iw,ih){
  var ww=0;
  var wh=0;
  if(bIE4||bOP6){
    window.resizeTo(iw, ih);
    ww = iw + (iw-document.body.clientWidth);
    wh = ih + (ih-document.body.clientHeight);
  } else if(bNS6||bOP6){
    ww = iw + (window.outerWidth-document.body.clientWidth);
    wh = ih + (window.outerHeight-document.body.clientHeight);
  }
	return ww;
}
function GetInnerH(iw,ih){
  var ww=0;
  var wh=0;
  if(bIE4||bOP6){
    window.resizeTo(iw, ih);
    ww = iw + (iw-document.body.clientWidth);
    wh = ih + (ih-document.body.clientHeight);
  } else if(bNS6||bOP6){
    ww = iw + (window.outerWidth-document.body.clientWidth);
    wh = ih + (window.outerHeight-document.body.clientHeight);
  }
	return wh;
}
function GetBrowser()
{
	// opera
   bOpera = window.opera;

	// n6 or ie
   bN6 = document.getElementById;

	// ie
   bIE = document.all;

	// n4
   bN4 = document.layers;
}
//--イベント開始関数 
  function startEvent(ojNameStr,eventTypeNameStr,funcNameStr){
    //n4,m1,n7,e4,e5,e6,o6,o7,s1,k3用
    eval(ojNameStr+".on"+eventTypeNameStr+"="+ funcNameStr)
    //n4用
    if(document.layers)
      eval(ojNameStr+".captureEvents(Event."
                 +eventTypeNameStr.toUpperCase()+")")
  }
  
  //--イベント停止関数 
  function stopEvent(ojNameStr,eventNameStr){
    //n4,m1,n7,e4,e5,e6,o6,07,s1,k3用
    eval(ojNameStr+".on"+eventNameStr+" = null")
    //n4用
    if(document.layers)
      eval(ojNameStr+".releaseEvents(Event."
                 +eventNameStr.toUpperCase()+")") 
  }

function getLayOjStr(idName){
    if(document.getElementById)         //e5,e6,n6,n7,m1,o6,o7,s1用
      return "document.getElementById('"+idName+"')"
    else if(document.all)               //e4用
      return "document.all('"+idName+"')"
    else if(document.layers)            //n4用
      return "document.layers['"+idName+"']"
  }
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function SetLayerVisible(LayerName,Visible)
{
	//ie5,ie6,nn6,nn7
	if(document.getElementById)
	{
		if( Visible == true )
		{
			document.getElementById(LayerName).style.visibility='visible'
		}
		else
		{
			document.getElementById(LayerName).style.visibility='hidden'
		}
	}
	else if(document.all)
	{
			//ie4
		if( Visible == true )
		{
			document.all(LayerName).style.visibility='visible'
		}
		else
		{
			document.all(LayerName).style.visibility='hidden'
		}
	}
	else if(document.layers)
	{
		//nn4
		if( Visible == true )
		{
			document.layers[LayerName].visibility='show'
		}
		else
		{
			document.layers[LayerName].visibility='hide'
		}
	}
}
function getWsLeft(){
  var wsl=0;
  if (bIE4||bOP6){
    wsl=window.screenLeft;
  }else if(bNS6){
    wsl=window.screenX;
  }
  if(wsl<0){wsl=0;}
  return wsl;
}
function getWsTop(){
  var wst=0;
  if (bIE4||bOP6){
    wst=window.screenTop-100;
  }else if(bNS6){
    wst=window.screenY;
  }
  if(wst<0){wst=0;}
  return wst;
}
function openShowurl(no)
{
	var url = "../../asp/showurl.asp?no=" + no;
	window.open(url,"showurl","resizable=yes,scrollbars=yes,menubar=no,toolbar=no,status=no,width=660,height=220,left="+getWsLeft()+",top="+getWsTop());
}
function openImage(n)
{
	var url = "../../image.html?" + n;
	window.open(url,"bboximage","resizable=yes,scrollbars=yes,menubar=no,toolbar=no,status=no,width=800,height=600,left="+getWsLeft()+",top="+getWsTop());
}
function OpenUsage(no)
{
	var url = '../../asp/information.asp?no=' + no;
	window.open(url,"BBOXUSAGE","resizable=yes,scrollbars=yes,menubar=no,toolbar=no,status=no,width=1024,height=700,left="+getWsLeft()+",top="+getWsTop());
}
function OpenBSKY(t,l,bbid,x,y)
{
	var url = G_BSKY_URL + '?t=' + t + '&l=' + l + '&bbid=' + bbid + "&x=" + x + "&y=" + y;
	window.open(url,"BSKY","resizable=yes,scrollbars=yes,menubar=yes,toolbar=yes,status=yes");
}
function SetObj(elmName)
{
	var elm;
	if(document.all)
	{
		elm=document.all.item(elmName);
	}
	else
	{
		elm=document.getElementById(elmName);
	}
	return elm;
}
function SetValue(elm,val){
	if (document.all){
		elm.innerText=val;
	}
	if (!document.all && document.getElementById) {
		elm.childNodes[0].nodeValue=val;
	}
}
function GetValue(elm)
{
	if(document.all)
	{
		return elm.getAttribute('value');
	}
	if(!document.all && document.getElementById)
	{
		return elm.childNodes[0].nodeValue;
	}
}
function HowMany()
{
	var url = "asp/howmany.asp";
	request1.open("GET",url,true);
	request1.onreadystatechange = HowManyCallBack;
	request1.send(null);
}
function HowManyCallBack()
{
	if( request1.readyState == 4 )
	{
		if( request1.status == 200 )
		{
			var response = request1.responseText;
			var elm = SetObj("cnts");
			SetValue(elm,response);
		}
		else if( request1.status == 404 )
		{
		}
		else
		{
		}
	}
}
function Message()
{
	var query = new Array;
	if( location.search.length > 1 )
	{
	　var NewArray = location.search.substr(1).split("&");
	　for( i in NewArray )
		{
	　　query.push(NewArray[i].split("="));
	　}
		if( query[0][1] == "1" )
		{
			var elm = SetObj("foundmsg");
			SetValue(elm,"条件に該当する情報は見つかりませんでした。");
//			var elm2 = SetObj("kw");
//			SetValue(elm2,"条件に該当する情報は見つかりませんでした。");
		}
	}
}
function mdown(event)
{
	var x;
	var y;

	if(bOpera)
	{
		 x= window.event.offsetX;
		 y= window.event.offsetY;
	}
	else if(bIE)
	{
		x = window.event.offsetX;
		y = window.event.offsetY;
	}
	else if(bN6)
	{
		// N6,N7 FireFox
		x = event.layerX;
		y = event.layerY;
	}
	else if(bN4)
	{
		// N4
		x = event.layerX;
		y = event.layerY;
	}

	//左下 -23500,-137450
	//右上  45500, -27500

	var wx;
	var wy;
	var dx;
	var dy;

	wx = 45500 - ( -23500 );
	wy = -27500 - ( -137450 );

	dx = x / 170;
	dy = y / 272;

	x = -23500 + wx * dx;
	y = -27500 - wy * dy;

	OpenBSKY( var_t,var_l,'',x,y);

	return false;
}
function Home()
{
	location.href = G_HOME_URL;
}
function Accessibility()
{
	location.href = G_ACCESSIBILITY_URL;
}
function SetThemeLayer(t,l)
{
	var_t = t;
	var_l = l;
}
