//* 共通分

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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 MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

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_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

var pop1;
function MM_openBrWindowEX(theURL) { //v2.0 拡大写真表示用
  pop1 = window.open(theURL,'expand','status=yes,scrollbars=yes,resizable=yes,width=880,height=660');
  pop1.focus();
}

var pop2;
function MM_openBrWindowKiyaku(theURL) { //v2.0
  pop2 = window.open(theURL,'kiyaku','status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=580,height=600');
  pop2.focus();
}


function MM_DisplayLayers() { //v6.0
  var i,p,v,obj,args=MM_DisplayLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='s')?'block':(v=='h')?'none':v; }
    obj.display=v; }
}



//* index利用分
function SendFormLogin(add) {
    document.form1.target = "_self";
    document.form1.method = "POST";
//  document.form1.action = "https:/e-kazoku.net/utils/com_auth.asp?target="+add;
    document.form1.action = "/utils/com_auth.asp?target="+add;
    document.form1.submit();
}

function LogOff() {
//  location.href = "https:/e-kazoku.net/utils/com_logout.asp";
    location.href = "/utils/com_logout.asp";
}


//* 写真・コメント編集Navi (2007/03/25)
var eflg;
// 'def':通常モード,'navi':ナビモード
var emode ='def';

function PhotoEditNavi(step,flg) {
   if (step=='') {
     window.alert("[Error]STEPフラグ未定");
     return(false);
   } else {
     emode ='navi';
     if (flg=='') {
       flg = eflg;
     }
     eflg = flg;
     if (step=='1') {
       MM_DisplayLayers('step1','','s','step1add','','s','step2add','','h','step2exchg','','h','step2mainchg','','h','step2del','','h','step2a','','h','step2b','','h','fami','','h','step3add','','h','step3exchg','','h','step3mainchg','','h','step3del','','h');
       return(true);
     } else if (step=='2') {
       // window.alert("FLG="+eflg);
       if (eflg=='EXCHG') {
         MM_DisplayLayers('step1','','h','step1add','','h','step2add','','s','step2exchg','','s','step2mainchg','','h','step2del','','h','step2a','','s','step2b','','s','fami','','s','step3add','','h','step3exchg','','h','step3mainchg','','h','step3del','','h');
       } else if (flg=='MAINCHG') {
         MM_DisplayLayers('step1','','h','step1add','','h','step2add','','s','step2exchg','','h','step2mainchg','','s','step2del','','h','step2a','','s','step2b','','s','fami','','h','step3add','','h','step3exchg','','h','step3mainchg','','h','step3del','','h');
         //document.all.IMG01.style.border = '1';
         //document.all.IMG01.style.borderstyle = 'dotted';
         //document.all.IMG01.style.bordercolor = 'red';
       } else if (flg=='DEL') {
         MM_DisplayLayers('step1','','h','step1add','','h','step2add','','s','step2exchg','','h','step2mainchg','','h','step2del','','s','step2a','','s','step2b','','s','fami','','s','step3add','','h','step3exchg','','h','step3mainchg','','h','step3del','','h');
       }
       return(true);
     } else if (step=='3') {
       if (eflg =='DEL') {
        if (document.form_photo.photo_no.value=='') {
          window.alert("削除する写真を選択ください。");
          return(false);
        }
       } else if (eflg =='MAINCHG') {
        if (document.form_photo.photo_no.value=='') {
          window.alert("メインに指定する写真を選択ください。");
          return(false);
        } else if (document.form_photo.photo_no.value=='1') {
          window.alert("選んだ写真は既にメイン写真です。");
          return(false);
        }
       } else if (eflg =='EXCHG') {
        if (document.form_photo.photo_no.value=='') {
          window.alert("編集したい写真を指定ください。");
          return(false);
        }
       }
       // window.alert("FLG="+eflg);
       if (eflg=='EXCHG') {
         MM_DisplayLayers('step1','','h','step1add','','h','step2add','','h','step2exchg','','h','step2mainchg','','h','step2del','','h','step2a','','h','step2b','','h','fami','','h','step3add','','s','step3exchg','','s','step3mainchg','','h','step3del','','h');
       } else if (flg=='MAINCHG') {
         MM_DisplayLayers('step1','','h','step1add','','h','step2add','','h','step2exchg','','h','step2mainchg','','h','step2del','','h','step2a','','h','step2b','','h','fami','','h','step3add','','s','step3exchg','','h','step3mainchg','','s','step3del','','h');
       } else if (flg=='DEL') {
         MM_DisplayLayers('step1','','h','step1add','','h','step2add','','h','step2exchg','','h','step2mainchg','','h','step2del','','h','step2a','','h','step2b','','h','fami','','h','step3add','','s','step3exchg','','h','step3mainchg','','h','step3del','','s');
       }
       return(true);
     } else {
       window.alert("[Error]STEPフラグ範囲外");
       return(false);
     }
   }
}


//* photo_edit利用分

function PhotoSelect(kcd,m,img,alt) {
  if (kcd!='01010101'&&m=='0') {
    window.alert("主利用者のみ、写真の登録・編集が可能です。");
    return;
  }

  document.form_photo.photo_no.value = m;
  document.form_photo.img_no.value   = img;
  if (emode=='def') {
    document.form_photo.button_main.disabled = false;
  }
  //document.form_photo.com_family.disabled = true;

  var i;
  for (i=0; i<6; i+=1){
   if (m==i) {
     MM_showHideLayers('LayerIMG0'+i,'','show');
     if (i=='0') {
       if (emode=='def') {
         document.form_photo.button_main.disabled = true;
         //document.form_photo.com_family.disabled = false;
       } else {
         //document.form_photo.com_family.disabled = false;
         // MM_showHideLayers('famiALT','','show');
         MM_showHideLayers('famiALT','','hide');
       }
     } else if (i=='1') {
       if (emode=='def') {
         document.form_photo.button_main.disabled = true;
       } else {
         MM_showHideLayers('famiALT','','hide');
       }
     }
     document.form_photo.com_alt.value = alt;
   } else {
     MM_showHideLayers('LayerIMG0'+i,'','hide');
   }
  }

}

function PhotoEditSend(flg) {
 if (flg =='DEL') {
  if (document.form_photo.photo_no.value=='') {
    window.alert("削除する写真を選択ください。");
  } else {
   if (window.confirm("選択した写真と説明を削除します。よろしいですか？")) {
    document.form_photo.mode.value = flg;
    if (emode=='navi') {
      document.form_photo.emode.value = emode;
    }
    document.form_photo.submit();
   }
  }
 } else if (flg =='MAINCHG') {
  if (document.form_photo.photo_no.value=='') {
    window.alert("メインに指定する写真を選択ください。");
  } else {
    document.form_photo.mode.value = flg;
    if (emode=='navi') {
      document.form_photo.emode.value = emode;
    }
    document.form_photo.submit();
  }
 } else if (flg =='EXCHG') {
  if (document.form_photo.photo_no.value=='') {
    window.alert("編集したい写真を指定ください。");
  } else if (document.form_photo.file.value=='' && document.form_photo.com_alt.value!='') {
    document.form_photo.mode.value = 'COMCHG';
    if (emode=='navi') {
      document.form_photo.emode.value = emode;
    }
    document.form_photo.submit();
  } else if (document.form_photo.file.value!='' && document.form_photo.com_alt.value=='') {
    document.form_photo.mode.value = flg;
    if (emode=='navi') {
      document.form_photo.emode.value = emode;
    }
    document.form_photo.submit();
  } else {
    window.alert("今表示されている写真とコメントが削除され、選択した写真とコメントに変更します。");
    document.form_photo.mode.value = flg;
    if (emode=='navi') {
      document.form_photo.emode.value = emode;
    }
    document.form_photo.submit();
  }
 } else if (flg =='COMCHG') {
  if (document.form_photo.photo_no.value=='') {
    window.alert("説明文を変更したい写真を選択ください。");
  } else if (document.form_photo.com_alt.value=='') {
    window.alert("説明文を入力ください。");
  } else {
    document.form_photo.mode.value = flg;
    if (emode=='navi') {
      document.form_photo.emode.value = emode;
    }
    document.form_photo.submit();
  }
 }
}


//* comment_edit利用分

function CommentEditSend(kcd,flg) {
 if (flg =='DEL') {

 } else if (flg =='UPDATE') {
  if (kcd=='01010101') {
   if (document.form_comme.wakeup.value=='') {
     window.alert("「起床時間」が未選択です。");
     return(false);
   } else if (document.form_comme.breakfast.value=='') {
     window.alert("「朝食時間」が未選択です。");
     return(false);
   } else if (document.form_comme.walking.value=='') {
     window.alert("「一日歩数」が未選択です。");
     return(false);
   } else if (document.form_comme.kaiwa.value=='') {
     window.alert("「会話相手人数」が未選択です。");
     return(false);
   } else if (document.form_comme.comment.value=='') {
     window.alert("「ひとこと」が未入力です。");
     return(false);
   } else if (document.form_comme.comment.value.length > 19 ) {
     window.alert("「ひとこと」の文字数は19字までです。");
     return(false);
   } else {
     return(true);
   }
  } else {
   if (document.form_comme.comment.value=='') {
     window.alert("「ひとこと」が未入力です。");
     return(false);
   } else if (document.form_comme.comment.value.length > 19 ) {
     window.alert("「ひとこと」の文字数は19字までです。");
     return(false);
   } else {
     return(true);
   }
  }
 }
}


function updateMess(msg){
  window.alert(msg);
}


//* Sumcomment_edit利用分

function SumCommentEditSend(flg) {
 if (flg =='DEL') {

 } else if (flg =='UPDATE') {
   if (document.form_sumcomme.SUMCOM.value=='') {
     window.alert("「まとめコメント」が未入力です。");
     return(false);
   } else if (document.form_sumcomme.SUMCOM.value.length>200) {
     window.alert("「まとめコメント」の文字数は200文字以内です。");
     return(false);
   } else {
     if (window.confirm("家族メンバーに通知メールを送信しますか？")) {
       document.form_sumcomme.SMAIL_FLG.value = 'true' ;
       return(true);
     } else {
       document.form_sumcomme.SMAIL_FLG.value = 'false' ;
       return(true);
     }
   }
 }
}


//* Rescomment_edit利用分

function ResCommentEditSend(flg) {
 if (flg =='DEL') {

 } else if (flg =='UPDATE') {
   if (document.form_rescomme.RESCOM.value=='') {
     window.alert("「返答コメント」が未入力です。");
     return(false);
   } else if (document.form_rescomme.RESCOM.value.length>19) {
     window.alert("「返答コメント」の文字数は19文字以内です。");
     return(false);
   } else {
     return(true);
   }
 }
}


function MovEditSend(flg) {
 if (flg =='DEL') {
   if (window.confirm("動画と説明を削除します。よろしいですか？")) {
    document.form_mov.mode.value = flg;
    if (emode=='navi') {
      document.form_mov.emode.value = emode;
    }
	$(document.body).startWaiting('bigWaiting');
    document.form_mov.submit();
   }
 } else if (flg =='EXCHG') {
  if (document.form_mov.file.value=='' && document.form_mov.alt.value!='') {
    document.form_mov.mode.value = 'COMCHG';
    if (emode=='navi') {
      document.form_mov.emode.value = emode;
    }
	$(document.body).startWaiting('bigWaiting');
    document.form_mov.submit();
  } else if (document.form_mov.file.value!='' && document.form_mov.alt.value=='') {
    document.form_mov.mode.value = flg;
    if (emode=='navi') {
      document.form_mov.emode.value = emode;
    }
	$(document.body).startWaiting('bigWaiting');
    document.form_mov.submit();
  } else if (document.form_mov.file.value=='' && document.form_mov.alt.value=='') {
    window.alert("「動画ファイル」と「説明文」が指定されていません。");
    return(false);
  } else {
    window.alert("今表示されている動画と説明が削除され、新たな動画と説明に変更します。");
    document.form_mov.mode.value = flg;
    if (emode=='navi') {
      document.form_mov.emode.value = emode;
    }
	$(document.body).startWaiting('bigWaiting');
    document.form_mov.submit();
  }
 } else if (flg =='COMCHG') {
  if (document.form_mov.alt.value=='') {
    window.alert("説明文を入力ください。");
  } else {
    document.form_mov.mode.value = flg;
    if (emode=='navi') {
      document.form_mov.emode.value = emode;
    }
	$(document.body).startWaiting('bigWaiting');
    document.form_mov.submit();
  }
 }
}

//* Sumcomment_edit_adm利用分

function SumCommentEditSendAdm(flg) {
 if (flg =='DEL') {

 } else if (flg =='UPDATE') {
   if (document.form_sumcomme.OUTCOM.value=='') {
     window.alert("「まとめコメント」が未入力です。");
     return(false);
   } else if (document.form_sumcomme.OUTCOM.value.length>400) {
     window.alert("「まとめコメント」の文字数は400文字以内です。");
     return(false);
   } else {
   //  if (window.confirm("家族メンバーに通知メールを送信しますか？")) {
   //    document.form_sumcomme.SMAIL_FLG.value = 'true' ;
   //    return(true);
   //  } else {
       document.form_sumcomme.SMAIL_FLG.value = 'false' ;
       return(true);
   //  }
   }
 }
}


//* comment_edit_adm利用分

function CommentEditSendAdm(kcd,flg) {
 if (flg =='DEL') {

 } else if (flg =='UPDATE') {
  if (kcd=='01010101') {
   if (document.form_comme.sche.value=='') {
     window.alert("「スケジュール」が未入力です。");
     return(false);
   } else if (document.form_comme.sche.value.length > 19 ) {
     window.alert("「スケジュール」の文字数は19字までです。");
     return(false);
   } else {
     return(true);
   }
  }
 }
}


function roading() {
	// optinal argument: can be name of a CSS class
	$(document.body).startWaiting('bigWaiting');
	window.setTimeout(document.body.stopWaiting.bind(document.body), 90000);
}


//****** 未使用 *****

   function del_master() {
     if (window.confirm("データを削除します。よろしいですか？")) {
       document.form.FLG.value = "DEL";
       document.form.method = "POST";
       document.form.target = "_self";
       document.form.action = "/adm/member_edit.asp";
       document.form.submit();
     }
   }

  function newOpen(file){
    window.open(file,"new","toolbar=0,location=0,directories=no,status=0,menubar=0,scrollbars=0,resizable=0,width=370,height=360");
  }
