// JavaScript Document
function checkPostComment(){
	postby= document.getElementById('postby');
	msg = document.getElementById('msg');
	strCheck = document.getElementById('strCheck');
	howto_id = document.getElementById('howto_id');
    
	if(postby.value ==""){
	  alert("กรุณาระบุชื่อของคุณด้วยค่ะ");
	  postby.focus();
	}else if(msg.value ==""){
	  alert("กรุณาใส่ข้อความของคุณด้วยค่ะ");
	  msg.focus();
	}else if(strCheck.value ==""){
	  alert("พิมพ์ตัวอักษรที่คุณเห็นในรูปด้วยค่ะ");
	  strCheck.focus();
	}else{
		
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].setVar('howto_id',howto_id.value)
		ajax[index].setVar('postby',postby.value);
		ajax[index].setVar('msg',msg.value);
		ajax[index].setVar('strCheck',strCheck.value);	 
		ajax[index].method = "POST";
		ajax[index].requestFile = 'post_comment_script.php';
        ajax[index].onCompletion = function(){ 
           if(ajax[index].response == "fail"){
			   alert("พิมพ์ตัวอักษรที่คุณเห็นในรูปให้ถูกต้องค่ะ"); 
			   
		   }else{
			   createCommentList(index);
			   document.getElementById('postby').value = "";
			   document.getElementById('msg').value = "";
			   document.getElementById('strCheck').value = "";
		   }
		};	
				ajax[index].runAJAX();

	}
	

}