//配列の作成
function MakeArray(n) {
    this.length = n;
    for (i = 1; i <= n; i++) {
        this[i] = "";
    }
    return(this);
}
function logout(url){
     var ret = false;
     ret = confirm("ログアウトしますか？");
     if(ret){
             top.location.href=url;
            }
}

function errWin(errMsg,errFile,errNo)
{
    alert("別ウインドウでコンテンツを表示しようとしましたが失敗しました。\nブラウザの設定によってキャンセルされた可能性があります。");
    /* alert(errMsg+"\n"+errFile+"\n"+errNo);*/
}
/*window.onerror = errWin;を使用*/
function openWin2(url,name,stat){
    var Win1;
    Win1=window.open("",name,stat);
    Win1.location.href=url;
}


function openWnd(wid,url){
  var W1;
  //var wid=400;
  //var url="a01.html";
  winname="subwindow1";
  W1=window.open(url,winname,"width="+wid+",height=1,resizable=yes,scrollbars=yes");
  if(W1!=null){
  W1.focus();
  W1.moveTo((screen.availWidth-wid),0);
  W1.resizeTo(wid,screen.availHeight);
  //W1.resizeTo(wid,(screen.availHeight*2)/3)
  }
}

//文字数を数えるぞ
function countform(C1,C2) {
    var tmp=C1.value;
    regexp=new RegExp("\r","g");
    tmp=tmp.replace(regexp,"");
    regexp=new RegExp("\n","g");
    tmp=tmp.replace(regexp,"");
    C2.value=tmp.length;
}

var start=new Date();
var maxt = 0;
var display;
var id;

function subgo(){document.disq_f.submit();}

var countdown_msg="制限時間が終了しました。";
function countdown() {
  var itime;
  now = new Date();
  if(maxt!=0){
  itime=(now.getTime()-start.getTime())/1000;
  itime=Math.round(itime);
  cnt=maxt-itime;

  // カウンタが0なら結果のページへ
  if( cnt <= 0){
      clearTimeout(id);
      window.alert(countdown_msg);
      subgo();
    }else{         
   hour=Math.floor(cnt/3600);
   min=Math.floor((cnt%3600)/60);
   sec=cnt-3600*hour-min*60;
   display.value = "[ 残り時間 ] "+((hour<10)?"0":"")+hour+":"+((min<10)?"0":"")+min+":"+((sec<10)?"0":"")+sec + "";

   // 1秒イベント
   id = setTimeout("countdown()",1000);
   }
  }
}

function subok()
{ 
    var ch=0;
    ch= confirm('解答を提出してもよろしいですか？');
    if(ch==1)
         {
         if(maxt!=0){ clearTimeout(id);}
         subgo();
         }
}


