// JavaScript Document

function CheckPost() {

	formErrors = false;

	if (document.post.message.value.length < 2) {
		formErrors = "กรุณากรอกรายละเอียดด้วย";
		document.post.message.focus();
	}
	if (document.post.name.value.length < 2) {
		formErrors = "กรุณากรอกชื่อของคุณด้วย";
		document.post.name.focus();
	}
	if (document.post.code.value.length==0){
		formErrors = "กรุณากรอกรหัสด้วย";
		document.post.code.focus();		
	}
	
	var fn = document.post.picture.value.toLowerCase();
	if(fn.length>0){
		if(fn.indexOf('.jpg') == -1 && fn.indexOf('.jpeg') == -1 && fn.indexOf('.gif') == -1 && fn.indexOf('.png') == -1){
		alert('กรุณาเลือกเฉพาะภาพที่มีนามสกุล *.jpg, *.gif, *.png  เท่านนั้น!');
			document.post.picture.select();
			return(false);
		}
	}
	
	if (formErrors) {
		alert(formErrors);
		return false;
	} else {
		bbstyle(-1);
		return true;
	}
}

function CheckTopic() {

	formErrors = false;

	if (document.post.message.value.length < 2) {
		formErrors = "กรุณากรอกรายละเอียดด้วย";
		document.post.message.focus();
	}
	if (document.post.topic_subject.value.length < 2) {
		formErrors = "กรุณากรอกชื่อกระทู้ด้วย";
		document.post.topic_subject.focus();
	}
	if (document.post.name.value.length < 2) {
		formErrors = "กรุณากรอกชื่อของคุณด้วย";
		document.post.name.focus();
	}
	if (document.post.code.value.length==0){
		formErrors = "กรุณากรอกรหัสด้วย";
		document.post.code.focus();		
	}
	
	var fn = document.post.picture.value.toLowerCase();
	if(fn.length>0){
		if(fn.indexOf('.jpg') == -1 && fn.indexOf('.jpeg') == -1 && fn.indexOf('.gif') == -1 && fn.indexOf('.png') == -1){
		alert('กรุณาเลือกเฉพาะภาพที่มีนามสกุล *.jpg, *.gif, *.png  เท่านนั้น!');
			document.post.picture.select();
			return(false);
		}
	}

	if (formErrors) {
		alert(formErrors);
		return false;
	} else {
		bbstyle(-1);
		return true;
	}
}



