//---- バイト数チェック
function getByte(p_txobj,p_length)
{
	text = p_txobj.value;
	count = 0;
	text2 = "";
	for (i=0; i<text.length; i++)
	{
		text2 = text2 + text.charAt(i);
		n = escape(text.charAt(i));
		if (n.length < 4) count++; else count+=2;
		if (count >= p_length){
		   p_txobj.value = text2;	
		   break;
		}
	}
}
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_openWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
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_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];}
}

//--- windowをサイズ指定などして OPENする。
function win_open(winname,parameta){
    result = window.open("", winname,parameta);
}
function mm_win_open(url,winname,parameta){
    result = window.open(url, winname,parameta);
}

function mm_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

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_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_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 showhide(id){
  if(document.getElementById){
    if(document.getElementById(id).style.display == "block"){
      document.getElementById(id).style.display = "none";
    }else{
      document.getElementById(id).style.display = "block";
    }
  }
}

function CheckNum(p_txobj)
{
 txt = p_txobj.value;
 data = txt.match(/[^0-9]/g);

 if (data) {
   alert("数値以外が含まれています");
   p_txobj.value = "";
   p_txobj.focus();
   return;
 }
}

/*---------- 日付のチェック（年月日） ----------*/
function checkYMDay( y, m, d ){
     if(y >= 1867 && y <= 2099) { 
	if(( m==1 )||( m==3 )||( m==5 )||( m==7 )||( m==8 )||( m==10 )||( m==12 )){	
		if( d <= 31 )	return true;
	} else if(( m==4 )||( m==6 )||( m==9 )||( m==11 )){
		if( d <= 30 )	return true;
	} else if( m==2 ){		/* うるう年チェック */
		if( y%4==0 && y%100!=0 || y%400==0 ){ if( d <= 29 )	return true; } 
		else { if( d <= 28 ) return true; }
	}
     }
     return false;
}
function date_check(p_stritem,p_objyy,p_objmm,p_objdd) {

 if (p_objyy.value != "" || p_objmm.value != "" || p_objdd.value !=""){
    txt = p_objyy.value;
    data = txt.match(/[^0-9]/g);

   if (txt.length != 4) {
    if (txt.length == 0) { 	
      alert(p_stritem + "の年は省略できません。");
    } else {	
      alert(p_stritem + "の年は４桁で入力して下さい。");
    } 	
     p_objyy.focus();
     return false;
   }
 
   if (data) {
     alert(p_stritem + "の年に数値以外が含まれています");
     p_objyy.focus();
     return false;
   }

   txt = p_objmm.value;
   data = txt.match(/[^0-9]/g);

   if (txt.length == 0) { 	
      alert(p_stritem + "の月は省略できません。");
     p_objmm.focus();
     return false;
   }
   if (data) {
     alert(p_stritem + "の月に数値以外が含まれています");
     p_objmm.focus();
     return false;
   }
   txt = p_objdd.value;
   data = txt.match(/[^0-9]/g);

   if (txt.length == 0) { 	
      alert(p_stritem + "の日は省略できません。");
      p_objdd.focus();
      return false;
   }
   if (data) {
     alert(p_stritem + "の日に数値以外が含まれています");
     p_objdd.focus();
     return false;
   }
   if (checkYMDay(p_objyy.value,p_objmm.value,p_objdd.value) == false) {
      alert(p_stritem + "の日付入力に誤りがあります。");
      p_objyy.focus();
  　  return false;
   } 	
 } 
}
function open_proc()
{
  window.focus();
}
function subWin(url,name,x,y,w,h) {
  var _l  = (screen.width-w)/2;
  var t   = (screen.height-h)/2;
  var win = window.open("",name,"scrollbars=yes,resizable=yes,left="+x+",top="+y+",screenX="+x+",screenY="+y+",width="+w+",height="+h);
  win.focus();
  win.location.href = url;
  return win;
}
