	function chkdata()
            {
						if(document.getElementById("to").value=='0')
                       {
                          alert('ยังไม่ได้เลือกผู้รับค่ะ');
						  document.getElementById("to").focus();
                                 return false;
					   } if(document.getElementById("name").value==''){
                          alert('ยังไม่ได้กรอกชื่อค่ะ');
						  document.getElementById("name").focus();
                                 return false;
                       } if (document.getElementById("email").value==''){
                          alert('ยังไม่ได้กรอก E-mail ค่ะ');
						  document.getElementById("email").focus();
                                 return false;
			} if(document.getElementById("email").value != ""){
			  if(document.getElementById("email").value == "" || document.getElementById("email").value.indexOf ('@',0) == -1 || document.getElementById("email").value.indexOf ('.',0) == -1)
{
alert("รูปแบบอีเมล์ไม่ถูกต้องค่ะ รูปแบบที่ถูกต้องคือ xxx@hotmail.com")
document.getElementById("email").focus();
return false; }
                       } if (document.getElementById("tel").value==''){
                          alert('ยังไม่ได้กรอกเบอร์โทรศัพท์ค่ะ');
						  document.getElementById("tel").focus();
                                 return false;	
					   } if (document.getElementById("subject").value==''){
                          alert('ยังไม่ได้กรอกหัวข้อค่ะ');
						  document.getElementById("subject").focus();
                                 return false;
					   } if (document.getElementById("message").value==''){
                          alert('ยังไม่ได้กรอกข้อความค่ะ');
						  document.getElementById("message").focus();
                                 return false;		
					   } if (document.getElementById("code").value==''){
                          alert('ยังไม่ได้กรอกรหัส Verify Code ค่ะ');
						  document.getElementById("code").focus();
                                 return false;	
					   } 
           }		   
		   
function check_num(e)
{
   var keyPressed;
   
   if(window.event){
      keyPressed = window.event.keyCode; // IE
       if ((keyPressed < 45) || (keyPressed > 57)) window.event.returnValue = false;
   }else{
      keyPressed = e.which; // Firefox      
       if ((keyPressed < 45) || (keyPressed > 57)) keyPressed = e.preventDefault();
    }
}

extArray = new Array(".doc", ".xls", ".pdf", ".zip", ".rar");
function LimitAttach(form, file) {
allowSubmit = false;
if (!file) return;
while (file.indexOf("\\") != -1)
file = file.slice(file.indexOf("\\") + 1);
ext = file.slice(file.indexOf(".")).toLowerCase();
for (var i = 0; i < extArray.length; i++) {
if (extArray[i] == ext) { allowSubmit = true; break; }
}
if (allowSubmit) return true;
else
alert("กรุณาอัพโหลดเฉพาะไฟล์นามสกุล "
+ (extArray.join("  ")) + "\nกลับไปเลือกไฟล์ที่เรากำหนดไว้ ");
return false;
}
