function checkUsername(){
	if(!olcheck("#mem_username",{chk:"username"})){
		$("#checkresult").html("ป้อน Username ไม่ถูกต้อง").removeClass("txtpass").addClass("txterror").show();;
		return(false);
	}
	$("#checkresult").html("กำลังตรวจสอบ..").removeClass("txtpass").addClass("txterror").show();;
	jQuery.post("/frontmodule/register/checkusername.php", {username:$("#mem_username").val()}, function(data){				
		if(data.indexOf("Yes")!=-1){
			jQuery("#checkresult").html("ท่านสามารถใช้ Username นี้ได้").removeClass("txterror").addClass("txtpass").show();
						
		}else if(data.indexOf("No")!=-1){
			jQuery("#checkresult").html("ขออภัย! Username นี้มีผู้ใช้งานแล้ว").removeClass("txtpass").addClass("txterror").show();
		}else{
			alert(data)
		}			
	});
}
function checkDispName(){
	if(!olcheck("#mem_dispname",{chk:"all"})){
		jQuery("#checkresult2").html("ป้อนชื่อที่ต้องการ").removeClass("txtpass").addClass("txterror").show();;
		return(false);
	}
	$("#checkresult2").html("กำลังตรวจสอบ..").removeClass("txtpass").addClass("txterror").show();;
	this.disabled = true;
	jQuery.post("/frontmodule/register/checkdispname.php", {name:$("#mem_dispname").val()}, function(data){				
		if(data.indexOf("Yes")!=-1){
			jQuery("#checkresult2").html("ชื่อนี้ยังว่างอยู่ ท่านสามารถใช้งานได้ครับ").removeClass("txterror").addClass("txtpass").show();
						
		}else if(data.indexOf("No")!=-1){
			jQuery("#checkresult2").html("ขออภัย! ชื่อนี้มีผู้ใช้งานแล้ว").removeClass("txtpass").addClass("txterror").show();
		}else{
			alert(data)
		}			
	});
}
var fieldsconf= [
		["#mem_username", {chk:"username",label:"ชื่อเข้าระบบ (Username)"}],
		["#password", {chk:"password",label:"รหัสผ่าน (Password)"}],
		["#password2", {chk:"compare", target:"#password",label:"ยืนยันรหัสผ่าน (Retype password)"}],
		["#mem_email", {chk:"email",label:"อีเมล์"}],			
		["#mem_firstname", {chk:"all",label:"ชื่อ"}],
		["#mem_lastname", {chk:"all",label:"นามสกุล"}],
		["#sex1", {chk:"all",label:"เพศ"}],			
		["#province_id", {chk:"all",label:"จังหวัด"}],
		["#mem_postcode", {chk:"postcode",label:"รหัสไปรษณีย์"}]
];
var olconf = {disp:"alert", fields: fieldsconf};

function checkForm(){
	if( !checkall(olconf) ){
		return(false);
	}
	$("#form1").attr("action","");
	return(true);
}