//<!--
// V3.9 2006-02-02
window.onerror = ecmaerr;
function ecmaerr(msg, url, line){
	alert('firstEC ECMA (Java) Script Error Detected.\nウェブブラウザで予期しないエラーが発生しました。\nW3C勧告に準拠していないか未対応のブラウザです。\n\n(line:' + line + ') ' + msg + '\n' + url);
}

// すべての submit ボタンを無効にする
function submitDisabled(){
	var lf = le = 0;
	if(document.forms.length<=0) return;
	for(lf=0;lf<document.forms.length;lf++)
	if(document.forms[lf].elements.length>0)
	for(le=0;le<document.forms[lf].elements.length;le++){
		if(document.forms[lf].elements[le].type=='submit')
		document.forms[lf].elements[le].disabled = true;
	}
}


// クッキーコントロール
function CookieWrite(kword, kdata, kday){
  if(!navigator.cookieEnabled) return;
  sday = new Date();
  sday.setTime(sday.getTime() + (kday * 1000 * 60 * 60 * 24));
  s2day = sday.toGMTString();
  document.cookie = kword + "=" + escape(kdata) + ";expires=" + s2day;
}
function CookieRead(kword){
  if(typeof(kword) == "undefined") return "";
  kword = kword + "=";
  kdata = "";
  scookie = document.cookie + ";";
  start = scookie.indexOf(kword);
  if (start != -1){
    end = scookie.indexOf(";", start);
    kdata = unescape(scookie.substring(start + kword.length, end));
  }
  return kdata;
}


// オブジェクトの表示と非表示を切替える
function existenceSwitch(id){
	var obj = getObjEle(id); if(obj==null) return;

	if(document.getElementById || document.all){
		obj.style.display = (obj.style.visibility=='hidden')? 'block' : 'none';
		obj.style.visibility = (obj.style.visibility=='hidden')? 'visible' : 'hidden';
	}else if(document.layers){
		obj.display = (obj.visibility=='hide')? 'block' : 'none';
		obj.visibility = (obj.visibility=='hide')? 'show' : 'hide';
	}
}

// オブジェクトの位置を指定座標に移動する
function eleMove(id, lx, ly){
	if(isNaN(lx)||isNaN(ly)) return;
	var elm = getObjEle(id);
	if (!elm){
		// browser not supported or element not found
	}else if (elm.style){
		// browser implements part of W3C DOM Style
		// Gecko, Internet Explorer 4+, Opera 5+
		if (typeof(elm.style.left) == 'number'){
			elm.style.left = lx;
			elm.style.top = ly;
		}else{
			// Gecko/Internet Explorer 4+
			// W3C DOM Style states that elm.style.left is a string
			// containing the length followed by the unit. e.g. 10px
			// Gecko will allow you to omit the unit only in Quirks 
			// mode. 
			// Gecko REQUIRES the unit when operating in Standards
			// mode.
			elm.style.left = lx + 'px';
			elm.style.top = ly + 'px';
		}
	}else if (typeof(elm.left) == 'number'){
		// Navigator 4
		elm.left = lx;
		elm.top = ly;
	}
}
// オブジェクトのサイズを指定座標にする（x, y ともに数値によるピクセル指定）
function eleResize(id, ex, ey){
	if(isNaN(ex)||isNaN(ey)) return;
	if((ex<1)||(ey<1)) return;

	var elm = getObjEle(id);
	if (!elm){
		// browser not supported or element not found
	}else if (elm.style){
		// browser implements part of W3C DOM Style
		// Gecko, Internet Explorer 4+, Opera 5+
		if (typeof(elm.style.width) == 'number'){
			elm.style.width = ex;
			elm.style.height = ey;
		}else{
			// Gecko/Internet Explorer 4+
			// W3C DOM Style states that elm.style.left is a string
			// containing the length followed by the unit. e.g. 10px
			// Gecko will allow you to omit the unit only in Quirks 
			// mode. 
			// Gecko REQUIRES the unit when operating in Standards
			// mode.
			elm.style.width = ex + 'px';
			elm.style.height = ey + 'px';
		}
	}else if (typeof(elm.width) == 'number'){
		// Navigator 4
		elm.width = ex;
		elm.height = ey;
	}
}
// オブジェクトのサイズを指定座標にする（x, y ともに数値による相対 % 指定）
function eleResizePc(id, ex, ey){
	if(isNaN(ex)&&isNaN(ey)) return;
	if((ex<0)&&(ey<0)) return;

	var elm = getObjEle(id);
	if (!elm){
		// browser not supported or element not found
	}else if (elm.style){
		// browser implements part of W3C DOM Style
		// Gecko, Internet Explorer 4+, Opera 5+
		if (typeof(elm.style.width) == 'number'){
			if(typeof(ex) == 'number') elm.style.width = ex;
			if(typeof(ey) == 'number') elm.style.height = ey;
		}else{
			// Gecko/Internet Explorer 4+
			// W3C DOM Style states that elm.style.left is a string
			// containing the length followed by the unit. e.g. 10px
			// Gecko will allow you to omit the unit only in Quirks 
			// mode. 
			// Gecko REQUIRES the unit when operating in Standards
			// mode.
			if(typeof(ex) == 'number') elm.style.width = ex + '%';
			if(typeof(ey) == 'number') elm.style.height = ey + '%';
		}
	}
}

// オブジェクトの縦位置を指定のウィンドウ縦幅の相対座標にする
function rsizerAct(id, oy){
	if(isNaN(oy)) return;
	var iy=null;
	if (self.window.document.body && typeof(self.window.document.body.clientWidth) == 'number'){
		// Gecko 1.0 (Netscape 7) and Internet Explorer 5+
		iy = document.body.clientHeight;
	}else if (typeof(self.window.innerWidth) == 'number'){
		// Navigator 4.x, Netscape 6.x, CompuServe 7 and Opera
		iy = self.window.innerHeight;
	}
	if(iy==null) return;
	if((oy+iy)<1) return;

	var elm = getObjEle(id);
	if (!elm){
		alert('element offset change (rsizerAct) error. element [' + id + '] was not found.');
		// browser not supported or element not found
	}else if (elm.style){
		// browser implements part of W3C DOM Style
		// Gecko, Internet Explorer 4+, Opera 5+
		if (typeof(elm.style.left) == 'number'){
			elm.style.height = (oy+iy);
		}else{
			// Gecko/Internet Explorer 4+
			// W3C DOM Style states that elm.style.left is a string
			// containing the length followed by the unit. e.g. 10px
			// Gecko will allow you to omit the unit only in Quirks 
			// mode. 
			// Gecko REQUIRES the unit when operating in Standards
			// mode.
			elm.style.height = (oy+iy) + 'px';
		}
	}else if (typeof(elm.left) == 'number'){
		// Navigator 4
		elm.height = (oy+iy);
	}
}

// img 要素の src を変更する
function imgChg(id, src){
	var elm = getObjEle(id);
	if (!elm) return;
	if (typeof(elm.src)=='string') elm.src = src;
}


// 10進数を16進数にする
function hexa(nn) {
	var n10 = parseInt(nn);
	var n16=0;
	var ans ="";
	while (n10 > 0) {
		n16=n10%16;
		n10=(n10-n16)/16;
		ans=bunrui(n16) + ans;
	}
	if(ans.length<2) ans = 'A' + ans;
	return ans;
} 
function bunrui(n) {
	switch (n) {
		case 10: n16="A"; break;
		case 11: n16="B"; break;
		case 12: n16="C"; break;
		case 13: n16="D"; break;
		case 14: n16="E"; break;
		case 15: n16="F"; break;
		default:  n16=n;
	}
	return n16;
}



//-->
