function btn(msg){
	var msg;
	if(msg==undefined){
		msg="Submit";
	}
	document.write('<input type="button" name="go" value="'+msg+'" class="button">');
}

function ckRegis(a,b){
var a,b;
	if(a.name.value.length<3 || a.sname.value.length<3 || a.idcard.value.length<13){
		alert("กรุณาตรวจสอบข้อมูลส่วนตัวของท่านให้ถูกต้อง !");
		return false;
	}else if(a.add1.value.length<15){
		alert("กรุณาตรวจสอบข้อมูล ที่อยู่ ของท่านให้ถูกต้อง !");
		return false;
	}else if(a.tel.value.length<10 || a.email.value.length<5 || a.email.value.indexOf('@')<3 || a.email.value.indexOf('.')<3){
		alert("กรุณาตรวจสอบข้อมูล หมายเลขโทรศัพท์ หรือ E-Mail ของท่านให้ถูกต้อง !");
		return false;
	}else if(a.b2.value.length<3 || a.b3.value.length<6 || a.b4.value.length<10){
		alert("กรุณาตรวจสอบข้อมูล ทางธนาคาร ของท่านให้ถูกต้อง !");
		return false;
	}else if(a.uname.value.length<3){
		alert("กรุณาตรวจสอบข้อมูล Username ของท่านให้ถูกต้อง !\nUsername ควรมากกว่า 3 อักษรขึ้นไป");
		return false;
	}else if(a.pw1.value.length<3 || (a.pw1.value != a.pw2.value)){
		alert("กรุณาตรวจสอบข้อมูล Password ของท่านให้ถูกต้อง !");
		return false;		
	}else if(a.quest.value.length<5 || a.answer.value.length<2){
		alert("กรุณาตรวจสอบข้อมูล คำถาม/คำตอบ เพื่อขอรับ Password ของท่านให้ถูกต้อง !");
		return false;	
	}else if(a.img.value.length<8 || (a.img.value.indexOf('jpg')<2 && a.img.value.indexOf('gif')<2 && a.img.value.indexOf('JPG')<2)){
		alert("กรุณาตรวจสอบข้อมูล File สำเนาบัตรประชาชน ของท่านให้ถูกต้อง !");
		return false;	
	}else if(ckUserName('aj_checkuser.php?user='+a.uname.value)==0){
		alert("Username ที่ท่านต้องการไม่สามารถสมัครได้ \nกรุณาเปลี่ยนใหม่ !");
		a.uname.value='';
		a.uname.focus();
		return false;
	}
	/*else if(a.check.value!='Username นี้ใช้ได้'){
		alert("ก่อนการสมัครกรุณา Click ที่ปุ่ม ตรวจสอบ Username ก่อนครับ !");
		return false;	
	}*/
	b.value='..ระบบกำลังลงทะเบียน..';
	b.disabled=true;
	a.submit();
}

function ckPost(a,b){
var a,b;
var doc = document.getElementById("msg"); 
doc.value = document.getElementById("wysiwygmsg").contentWindow.document.body.innerHTML; 
	if(a.topic.value.length<3 || doc.value =='<SPAN style="FONT-SIZE: 14px; FONT-FAMILY: Tahoma"></SPAN>' || doc.value == ""){
		alert("กรุณากรอกข้อมูลให้ครบก่อนครับ !");
		return false;
	}else if(a.postType.value!=1){
		var x=parseInt(a.mm.value);
		var yy=parseInt(a.yy.value)+543;
		if(!confirm('คุณต้องการปิดรายการกระทู้วันที่ : '+a.dd.value+' '+arrMon[x]+' '+yy+' เวลา '+a.hh.value+':'+a.min.value+" น.\n... ต้องการโพสกด OK, ต้องการตั้งเวลาใหม่กด Cancel ...")){
			return false;
		}
	}
	updateTextArea('msg');
	b.value="กำลังบันทึกข้อมูล !";
	b.disabled="true";
	a.submit();
}
function noSpace(){
	if(event.keyCode==32){
		return false;
	}
	return true;
}

function ckLogin(a){
var a;
	if(a.uname.value.length<3 || a.pword.value.length<3 || a.uname.value=='username' || a.pword.value=='password'){
		alert("กรุณากรอก Username หรือ Password ก่อนนะ !");
		return false;
	}
		return true;
}
function forgotPop(){
	window.open("pwForgot.php",'popforg','width=450,height=350,top=120,left=150');
}

function popAction(a,b){
	var a,b;
	window.open('Action.php?tid='+a+'&action='+b,'popaction','width=450,height=250,top=100,left=150');
}

function numOnly(){
	if(event.keyCode<48 || event.keyCode>57){
		return false;
	}
	return true;
}

function ckPostPrivate(a,b,c){
var a,b;
var doc = document.getElementById(c); 
	updateTextArea(c);
	
}

function ckPMPost(a,b){
	var a,b;
	if (a.topic.value.length<5){
		alert('กรุณากรอกข้อมูลให้ครบถ้วน !');
	}else{
		updateTextArea('msg');
		b.disabled=true;
		a.submit();
	}
}
function showBox(a){
	var a;
	var b=document.getElementById(a);
		b.style.display='block';

	var to2Name=document.getElementById('fromName').innerText;
	//alert(document.getElementById('fromName').value);
	var topic=document.getElementById('msgTopic').innerText;
	var msg2=document.getElementById('showMsg').innerHTML;
	var referDate=document.getElementById('referDate').innerText;
		topic=topic.replace('หัวข้อ :','');
	//b.toName.value=to2Name;
	document.frmpm.toName.value=to2Name;
	b.topic.value='Re: '+topic;
	msg2='<div id="referMsg" style="font-size: 11px;width: 96%;background-color: #F2F2F2;padding: 3px; border: 1px solid #CCCCCC;"><strong>อ้างถึงข้อความ</strong>'+referDate+', จาก '+to2Name+''+msg2+'</div>';
	document.getElementById('wysiwygmsg').contentWindow.document.body.innerHTML=msg2;
	document.getElementById('wysiwygmsg').contentWindow.document.body.focus();
}
function moveTopic(a,b){
    var a,b;
    a.submit();
}
