
function chknullLogin(){
	if(document.fLogin.username.value==""){
		alert("โปรดระบุชื่อเข้าใช้ระบบ ");
		document.fLogin.username.focus();
	}else if(document.fLogin.password.value==""){
		alert("โปรดระบุรหัสผ่าน");
		document.fLogin.password.focus();
	}else{
		document.fLogin.submit();
	}	
}//function chknullchapter(){

 function checknulregister()
{
 if(document.Fromfuntong.inputUsername.value.length < 5 || document.Fromfuntong.inputUsername.value.length > 20) 
	{
	alert("กรุณากรอกชื่อผู้ใช้ความยาว 5-25 ตัวอักษร");
	document.Fromfuntong.inputUsername.focus();
	}

else if(document.Fromfuntong.inputPassword.value.length < 4 || document.Fromfuntong.inputPassword.value.length > 20)
	{
	alert("กรุณากรอกรหัสผ่านใหม่ยาว4-25ตัวอักษร");
	document.Fromfuntong.inputPassword.focus();
	}
else if(document.Fromfuntong.inputPassword.value != document.Fromfuntong.inputPassword1.value)
	{
	alert("กรุณากรอกรหัสผ่านให้เหมือนกัน");
	document.Fromfuntong.inputPassword1.focus();
	}
else if(document.Fromfuntong.inputName.value.length < 3)
	{
	alert("กรุณากรอกชื่อ");
	document.Fromfuntong.inputName.focus();
	}		
else if(document.Fromfuntong.inputLName.value.length < 3)
	{
	alert("กรุณากรอกนามสกุล");
	document.Fromfuntong.inputLName.focus();
	}
else if(document.Fromfuntong.inputEmail.value.indexOf('@',0) == -1 || document.Fromfuntong.inputEmail.value.indexOf('.',0) == -1)
	{
		alert("กรุณากรอกอีเมลให้ถูกต้องเช่นabc@hotmail.com");
		document.Fromfuntong.inputEmail.focus();
	}


else if(document.Fromfuntong.gender.value.length < 1)
	{
	alert("กรุณาเลือกเพศ");
	document.Fromfuntong.gender.value.focus();
	}
else if(document.Fromfuntong.birthdayDate.value.length < 1)
	{
	alert("กรุณาเลือกวันเกิด");
	document.Fromfuntong.birthdayDate.value.focus();
	}
else if(document.Fromfuntong.birthdayDay.value.length < 1)
	{
	alert("กรุณาเลือกวันที่");
	document.Fromfuntong.birthdayDay.value.focus();
	}
else if(document.Fromfuntong.birthdayMonth.value.length < 1)
	{
	alert("กรุณาเลือกเดือนเกิด");
	document.Fromfuntong.birthdayMonth.value.focus();
	}
else if(document.Fromfuntong.year.value.length < 1)
	{
	alert("กรุณาเลือกปีเกิด");
	document.Fromfuntong.year.value.focus();
	}
else if(document.Fromfuntong.inputTimeH.value.length < 1)
	{
	alert("กรุณาเลือกเวลาเกิด(ชั่วโมง)");
	document.Fromfuntong.inputTimeH.value.focus();
	}
else if(document.Fromfuntong.inputTimeM.value.length < 1)
	{
	alert("กรุณาเลือกเวลาเกิด(นาที)");
	document.Fromfuntong.inputTimeM.value.focus();
	}
else if(document.Fromfuntong.inputPhoneAll.value.substring(0,1) != "0") 
	{
	alert("เบอร์โทรศัพท์ของคุณรูปแบบไม่ถูกต้อง กรุณาขึ้นต้นด้วย '0' เช่น 0812345674 ");
	document.Fromfuntong.inputPhoneAll.value.focus();
	}
	else if(document.Fromfuntong.inputPhoneAll.value.length < 9) 
	{
	alert("กรุณากรอกเบอร์โทรศัพท์ยาว 9-10 ตัวอักษร");
	document.Fromfuntong.inputPhoneAll.value.focus();
	}
else if((document.Fromfuntong.inputPhoneAll.value.substring(0,2) != "08")&&(document.Fromfuntong.inputPhoneAll.value.length != 9))
	{
	alert("กรุณากรอกเบอร์โทรศัพท์ยาว 9 ตัวอักษร");
	document.Fromfuntong.inputPhoneAll.value.focus();
	}
else if((document.Fromfuntong.inputPhoneAll.value.substring(0,2) == "08")&&(document.Fromfuntong.inputPhoneAll.value.length != 10)) 
	{
	alert("กรุณากรอกเบอร์โทรศัพท์ยาว 10 ตัวอักษร");
	document.Fromfuntong.inputPhoneAll.value.focus();
	}

else if(document.Fromfuntong.txt_random.value.length < 1)
	{
	alert("กรุณากรอกรหัสตามภาพ");
	document.Fromfuntong.txt_random.value.focus();
	}
else if(document.Fromfuntong.txt_random.value != document.Fromfuntong.txt_hidden.value)
	{
	alert("กรุณากรอกรหัสภาพให้ถูกต้อง");
	document.Fromfuntong.txt_random.focus();
	}
else
	{
		document.Fromfuntong.submit();				
	}
}

function hiddenfromregis()
{
document.getElementById('fromregis').style.display = 'none';//โม่โชว์ lightview
}
//function hiddenfromlogin()
//{
//document.getElementById('fromlogin').style.display = 'none';//โม่โชว์ lightview
//}
function hiddenforgetpass()
{
document.getElementById('forgetpass').style.display = 'none';//โม่โชว์ lightview
}
function hiddenchangpass()
{
document.getElementById('changpass').style.display = 'none';//โม่โชว์ lightview
}
function forgetpass(){
document.getElementById('forgetpass').style.display = '';//โชว์ lightview
document.getElementById('fromregis').style.display = 'none';//โชว์ lightview
//document.getElementById('fromlogin').style.display = 'none';//โชว์ lightview
}
function showchangpass(){
document.getElementById('changpass').style.display = '';//โชว์ lightview
document.getElementById('forgetpass').style.display = 'none';//โชว์ lightview
document.getElementById('fromregis').style.display = 'none';//โชว์ lightview
//document.getElementById('fromlogin').style.display = 'none';//โชว์ lightview
}
function showfromregis(){
document.getElementById('fromregis').style.display = '';//โชว์ lightview
//document.getElementById('fromlogin').style.display = 'none';//โชว์ lightview
document.getElementById('forgetpass').style.display = 'none';//โชว์ lightview
}


//function showfromlogin(){
//document.getElementById('fromlogin').style.display = '';//โชว์ lightview
//document.getElementById('fromregis').style.display = 'none';//โชว์ lightview
//document.getElementById('forgetpass').style.display = 'none';//โชว์ lightview
//} 
function resetsignupForm(){
document.signupForm.reset();

}

 function showprovince()
{
if(document.Fromfuntong.userCountry.value == "Thailand") 
	{
	document.getElementById('province').style.display ='';//โชว์ lightview
	}
else
	{
	document.getElementById('province').style.display ='none';//โชว์ lightview		
	}
}

function resetFromfuntong(){
document.Fromfuntong.reset();
document.getElementById("resultinputUsername").innerHTML="";
document.getElementById("resultemail").innerHTML="";
}

function OnlyName(e)//กรุณากรอกข้อมูลเป็นภาษาไทยหรือภาษาอังกฤษเท่านั้น
{			var keyPressed;
 	if(window.event){
	keyPressed = window.event.keyCode; // IE
					if((keyPressed<65||keyPressed>122)&&(keyPressed<3585||keyPressed>3660)) 
						{	alert("กรุณากรอกข้อมูลเป็นภาษาไทยหรือภาษาอังกฤษเท่านั้น");
						document.Fromfuntong.inputName.focus();
							window.event.returnValue = false;
						}else{
							window.event.returnValue = true;
							}
	}else{
	 keyPressed = e.which; // Firefox      
       if ((keyPressed < 8||keyPressed > 8)&&(keyPressed < 65) || (keyPressed > 122)&&(keyPressed<3585||keyPressed>3660)){
	   
	   
	   alert("กรุณากรอกข้อมูลเป็นภาษาไทยหรือภาษาอังกฤษเท่านั้น");document.Fromfuntong.inputName.focus(); keyPressed = e.preventDefault();
	   }else{
	   
	   		}
    }
}

function OnlyLast(e)//กรุณากรอกข้อมูลเป็นภาษาไทยหรือภาษาอังกฤษเท่านั้น
{			var keyPressed;
 	if(window.event){
	keyPressed = window.event.keyCode; // IE
					if((keyPressed<65||keyPressed>122)&&(keyPressed<3585||keyPressed>3660)) 
						{	alert("กรุณากรอกข้อมูลเป็นภาษาไทยหรือภาษาอังกฤษเท่านั้น");
						document.Fromfuntong.inputLName.focus();
							window.event.returnValue = false;
						}else{
							window.event.returnValue = true;
							}
	}else{
	 keyPressed = e.which; // Firefox      
       if ((keyPressed < 8||keyPressed > 8)&&(keyPressed < 65) || (keyPressed > 122)&&(keyPressed<3585||keyPressed>3660)){
	   
	   
	   alert("กรุณากรอกข้อมูลเป็นภาษาไทยหรือภาษาอังกฤษเท่านั้น");document.Fromfuntong.inputLName.focus(); keyPressed = e.preventDefault();
	   }else{
	   
	   		}
    }
}

function OnlyEnglish(e)//กรุณากรอกข้อมูลเป็นภาษาอังกฤษหรือตัวเลข(A-Z, a-z, หรือ 0-9)
{			var keyPressed;
 	if(window.event){
	keyPressed = window.event.keyCode; // IE
				if((keyPressed<65||keyPressed>122)&&(keyPressed<48||keyPressed>59)) {
										alert("กรุณากรอกข้อมูลเป็นภาษาอังกฤษหรือตัวเลข(A-Z, a-z, หรือ 0-9)");
										document.Fromfuntong.inputUsername.focus();
										window.event.returnValue = false;
				}else{
										window.event.returnValue = true;
					}
	}else{
	 keyPressed = e.which; // Firefox      
       if ((keyPressed < 8||keyPressed > 8)&&(keyPressed < 48 || keyPressed > 59)&&(keyPressed<65||keyPressed>122)){
	   
	   
	   alert("กรุณากรอกข้อมูลเป็นภาษาอังกฤษหรือตัวเลข(A-Z, a-z, หรือ 0-9)");
	   document.Fromfuntong.inputUsername.focus();keyPressed = e.preventDefault();
	   }else{
	   
	   			}
    }
}

function OnlyNumber(e)//กรุณากรอกข้อมูลเป็นตัวเลข(0-9)
{
	var keyPressed;
 	if(window.event){
	keyPressed = window.event.keyCode; // IE
		if((keyPressed<48)|| (keyPressed>59)){
					alert("กรุณากรอกข้อมูลเป็นตัวเลข(0-9)");
			<!--	document.Fromfuntong.inputPhoneAll.value.focus(); -->
					window.event.returnValue = false;
					

											}else{
					window.event.returnValue = true;
												}
	}else{
	 keyPressed = e.which; // Firefox      
       if ((keyPressed < 8||keyPressed > 8)&&(keyPressed < 48) || (keyPressed > 59)){
	   
	   
	   alert("กรุณากรอกข้อมูลเป็นตัวเลข(0-9)");document.Fromfuntong.inputPhoneAll.value.focus(); keyPressed = e.preventDefault();
	   }else{
	   
	   }
    }
}
function OnlyEmail(e) //กรุณากรอกข้อมูลเป็นภาษาอังกฤษหรือตัวเลข(A-Z, a-z, หรือ 0-9)
{			var keyPressed;
 	if(window.event){
	keyPressed = window.event.keyCode; // IE
				if((keyPressed < 3665||keyPressed > 3665)&&(keyPressed < 45||keyPressed > 46)&&(keyPressed < 48 || keyPressed > 59)&&(keyPressed < 95||keyPressed > 95)&&(keyPressed<64||keyPressed>122)) {
										alert("กรุณากรอกข้อมูลให้ถูกต้อง");
										document.Fromfuntong.inputEmail.focus();
										window.event.returnValue = false;
				}else{
										window.event.returnValue = true;
					}
	}else{
	 keyPressed = e.which; // Firefox      
       if ((keyPressed < 8||keyPressed > 8)&&(keyPressed < 50||keyPressed > 50)&&(keyPressed < 45||keyPressed > 46)&&(keyPressed < 48 || keyPressed > 59)&&(keyPressed < 95||keyPressed > 95)&&(keyPressed<64||keyPressed>122)){
	   
	   
	   alert("กรุณากรอกข้อมูลให้ถูกต้อง");document.Fromfuntong.inputEmail.focus(); keyPressed = e.preventDefault();
	   }else{
	   
	   			}
    }
}
