/************************************************
 * 
 * コメントクッキー保存処理
 * 
 * DEPENDENCIES
 *  - /p_skin/cmn/js/cookie.js
 * 
 * Author        : $Author: ohira $
 * Last Modified : $Date: 2006/05/02 12:28:43 $
 * Version       : $Revision: 1.1 $
 * 
 * (c) CYBER AGENT.LTD
 * 
 ************************************************/
var commentNameCookie = new Cookie();
var commentUrlCookie = new Cookie();
commentNameCookie.setData("amebloCommentName", 30);
commentUrlCookie.setData("amebloCommentUrl", 30);
/**
 * コメント欄クッキー保存処理
 * 
 * @see Cookie()
 */
function setCommentItems() {
    var getForm = document.publicCommentInputForm;
    if (getForm.comment_cookie) {
        if (getForm.comment_cookie.checked == true) {
            commentNameCookie.create(escape(getForm.comment_name.value));
            commentUrlCookie.create(getForm.comment_url.value);
        } else {
            commentNameCookie.remove();
            commentUrlCookie.remove();
        }
    }
}

/**
 * コメント欄クッキー取得処理
 * 
 * @see Cookie()
 */
function getCommentItems() {
    var getForm = document.publicCommentInputForm;
    var comment_name = "";
    var comment_url = "http://";

    if (commentNameCookie.read() != null && commentNameCookie.read() != "") {
        comment_name = unescape(commentNameCookie.read());
        getForm.comment_name.value = comment_name;
    }

    if (commentUrlCookie.read() != null && commentUrlCookie.read() != "") {
        comment_url = commentUrlCookie.read();
        getForm.comment_url.value = comment_url;
    }

    if ((commentNameCookie.read() != null && commentNameCookie.read() != "")
     || (commentUrlCookie.read() != null && commentUrlCookie.read() != ""))
    {
        getForm.comment_cookie.checked = true;
    }
}

function SetCommentOnSubmit(){
    if (document.publicCommentInputForm) {
        getCommentItems();
        document.publicCommentInputForm.onsubmit = setCommentItems;
    }
}

