
function focusFirstField() {
	document.logonForm.login.focus()
}

// JavaScript Form Validation   
function submit_page(form) {

	foundError = false;        

	// FIRST CHECK FOR BLANK FIELDS
	
	// Make sure the Owner and Password field is not blank
	if(isFieldBlank(document.logonForm.login)) {
		alert("กรุณาป้อนชื่อบัญชีผู้ใช้ (Username) ด้วยครับ."); 
		document.logonForm.login.focus()
		foundError = true;
	}        
	else  if(isFieldBlank(document.logonForm.passwd)) {
		alert("กรุณาป้อนรหัสผ่าน (Password) ด้วยครับ.");
		document.logonForm.passwd.focus()
		foundError = true;
	}

	// NOW LET'S CHECK THAT THE FIELDS ARE VALID

	if(foundError == false) {
		document.logonForm.action = "https://mail.nti.co.th/exchweb/bin/auth/owaauth.dll";
		document.logonForm.destination.value = "https://mail.nti.co.th/exchange";
		document.logonForm.username.value = "nti/" + document.logonForm.login.value;
		document.logonForm.password.value = document.logonForm.passwd.value;
		ClearPWField()
		return true;
	}
	return false;
}

// Check for a blank field
function isFieldBlank(theField) {
	if (theField.value == "")
        		return true;
    	else
        		return false;
}

function ClearPWField() {
	document.logonForm.passwd.value = "";
}
