function printWeblogCommentResData(text_data) {
	document.getElementById('commentmsg').innerHTML = text_data;

	if (text_data.indexOf('完了しました') < 0) {
	    document.getElementById('commenttransmit').disabled = false;
	} else {
		var funcRef = function(text_data) {
			document.getElementById('weblogcommentlist').innerHTML = text_data;
		}
	    var thecontent  = document.getElementById('theContent').value;
	    //var theclassify  = document.getElementById('theClassify').value;
		httpRequest('getblogcomment.jspx?theContent='+thecontent+'&theClassify=0', funcRef);
		document.getElementById('theName').value = '';
		document.getElementById('theEmailaddress').value = '';
		if(document.getElementById('theURL') != null){
			document.getElementById('theURL').value = '';
		}
		document.getElementById('theComment').value = '';
	}
}

function postWeblogCommentData(e) {
    document.getElementById('commenttransmit').disabled = true;
	document.getElementById('commentmsg').innerHTML = '';

    var thename = document.getElementById('theName').value;
    var theemailaddress = document.getElementById('theEmailaddress').value;
    var theurl = '';
    if(document.getElementById('theURL') != null){
	    theurl = document.getElementById('theURL').value;
	}
    var thecomment  = document.getElementById('theComment').value;
    var thecontent = document.getElementById('theContent').value;

    var post_data;

    post_data = 'theName=' + encodeURI(thename) +
                '&theEmailaddress=' + encodeURI(theemailaddress) +
                '&theURL=' + encodeURI(theurl) +
                '&theComment=' + encodeURI(thecomment) +
                '&theContent=' + encodeURI(thecontent);
         
    var target_url = 'setblogcomment.jspx';
    httpPostRequest(target_url, post_data, printWeblogCommentResData);
}

function setListenersWeblogComment(e) {
    var evaluation = document.getElementById('commenttransmit');
    addListener(evaluation, 'click', postWeblogCommentData, false);
}

addListener(window, 'load', setListenersWeblogComment, false);