// そう思う
function agreePoint(cmtID) {

    var URL = '/point.php?id=' + cmtID;
    new Ajax.Request(URL, { method: 'get',
    onSuccess: function(httpObj) {
        if (httpObj.responseText) { $('agr' + cmtID).innerHTML = httpObj.responseText; }
    },
    onFailure: function(httpObj) {
        alert('エラー：ポイントが加算されませんでした。');
    }});

}


// そう思わない
function disagreePoint(cmtID) {

    var URL = '/point.php?id=' + cmtID + '&tp=1';
    new Ajax.Request(URL, { method: 'get',
    onSuccess: function(httpObj) {
        if (httpObj.responseText) { $('disagr' + cmtID).innerHTML = httpObj.responseText; }
    },
    onFailure: function(httpObj) {
        alert('エラー：ポイントが加算されませんでした。');
    }});

}


// 文字数制御
function strLimit( objID, maxNum ) {
    var str = document.getElementById(objID).value;

    if (str.length > maxNum) {
        str = str.substring( 0, maxNum )
        document.getElementById(objID).value = str;
        alert(maxNum+'文字までです。');
    }

    var leftNum = maxNum - str.length;
    document.getElementById(objID+'Count').innerHTML = '残り ' + leftNum + '文字';
}


// フォームチェック
function formCheck() {

  if(document.topicCmt.comment.value == ""){
    alert("コメントが入力されていません。");
    document.topicCmt.comment.style.backgroundColor = "#FFCCCC";
    document.topicCmt.comment.focus();
    return false;
  }
  if(!document.topicCmt.agree.checked){
    alert("「利用規約に同意する」のチェックがされていません。");
    document.topicCmt.agree.style.backgroundColor = "#FFCCCC";
    document.topicCmt.agree.focus();
    return false;
  }

  return window.confirm('コメントを投稿しますがよろしいでしょうか？確認画面はございません。また一度投稿されたメッセージは編集できません。コメントが表示されるまで時間が掛かるケースもございます。固定ニックネームを利用されていない場合はコメントの削除はできません。');

}


// 違反報告ウィンドウ（トピック）
function reportWinTop(topicID) {
    var openURL = '/report_topic.php?topicID='+topicID;
    window.open(openURL, 'report','width=500, height=500,location=no,derectories=no,status=yes, menubar=no, toolbar=no, scrollbars=yes,resizable=yes');
}


// 違反報告ウィンドウ（コメント）
function reportWin(cmtID) {
    var openURL = '/report.php?cmtID='+cmtID;
    window.open(openURL, 'report','width=500, height=500,location=no,derectories=no,status=yes, menubar=no, toolbar=no, scrollbars=yes,resizable=yes');
}


// コメント削除ウィンドウ
function delCmt(cmtID) {
    var openURL = '/comment_del.php?id='+cmtID;
    if (confirm("コメントを削除しますがよろしいですか？確認画面はございません。")) {
        window.open(openURL, 'report','width=500, height=500,location=no,derectories=no,status=yes, menubar=no, toolbar=no, scrollbars=yes,resizable=yes');
    }
}


// 規約ウィンドウ
function kiyakuWin() {
    var openURL = '/rules_topic.html';
    window.open(openURL, 'report','width=500, height=500,location=no,derectories=no,status=yes, menubar=no, toolbar=no, scrollbars=yes,resizable=yes');
}

