// 指定されたkeyにvalをセット
function setKeyValue(key, val) {
    document.getElementById(key).value = val;
}

//Next画面のセット
function setNextPage(fr_name, url) {
    var fr = document.getElementById(fr_name);
    fr.action = url;
}

function callNextPage(fr_name) {
    var fr = document.getElementById(fr_name);
    fr.submit();
}

function setReply(from, to, no) {
    if(to == 'ななし'){
      document.getElementById(from).value = '＞＞No.' + no + 'さんへ';
    }else{
      document.getElementById(from).value = '＞＞' + to + 'さんへ';
    }
    location.hash = 'bbs_write'
}

function confirmBbs(id) {
    var val = document.getElementById(id).value;
    if ( val.length == 0 || val.length > 400){
        alert('コメントは必須項目です。\n400文字までで入力してください。')
        return false;
    }
//    var str = '投稿してもよろしいですか？\n\n投稿データと共に以下のホスト情報がサーバに記録されます。\n' + location.host;
    var str = '投稿してもよろしいですか？';
    if ( !confirm(str) ) {
        return false;
    }
    return true;
}

  function doAjaxAlert(id, id1, id2) {
//      var str = 'この投稿を通報しますか？\n\n通報と共に以下のホスト情報がサーバに記録されます。\n' + location.host;
      var str = 'この投稿を通報しますか？';
      if ( !confirm(str) ) {
          return false;
      }
      httpObj = createXMLHttpRequest(doResponse);
      if (httpObj) {
          if(id == 'program' ){
              httpObj.open("GET", "/ajax/alert/index/shm_id/" + id1 + "/bbs_id/" + id2 + "/time/" + (new Date()).getTime() + "/", true);
          }else if(id == 'cm' ){
              httpObj.open("GET", "/ajax/alert/index/cm_id/" + id1 + "/cbs_id/" + id2 + "/time/" + (new Date()).getTime() + "/", true);
          }
          httpObj.send(null);
      }
  } // doAjaxAlert()

  function doResponse() {
      if ((httpObj.readyState == 4) && (httpObj.status == 200)) {
          alert('通報しました。');
      }
  } // doResponse()
  function createXMLHttpRequest(callBackFunction) {
      var XMLhttpObject = null ;
      try {
          XMLhttpObject = new XMLHttpRequest() ;
      }
      catch(e) {
          try {
              XMLhttpObject = new ActiveXObject("Msxm12.XMLHTTP") ;
          }
          catch(e) {
              try {
                  XMLhttpObject = new ActiveXObject("Microsoft.XMLHTTP") ;
              }
              catch(e) {
                  XMLhttpObject = null ;
              }
          }
      }

      if (XMLhttpObject) {
          XMLhttpObject.onreadystatechange = callBackFunction ;
      }
      return XMLhttpObject ;
  } // createXMLHttpRequest()

function showpage(key) {
    var val = document.getElementById(key).value;
    if( val.length > 0){
        location.href = '#' + val;
    }
}

