/************************************************
* Required field(s) validation v1.10- By NavSurf
* Visit Nav Surf at http://navsurf.com
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function validate(formobj,input,descrip){
	var object = input.split(",");
	
	var objectdescrip = descrip.split(",");
	
	var alertMsg = "กรุณาใส่ข้อมูลเหล่านี้\nPlease fill in these data\n";
	
	var l_Msg = alertMsg.length

	for (var i = 0; i < object.length; i++){
		var obj = formobj.elements[object[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				// Nui---if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == "" || obj.options[obj.selectedIndex].value == ""){
					alertMsg += " - " + objectdescrip[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + objectdescrip[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + objectdescrip[i] + "\n";
				}
				break;
			case "hidden":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + objectdescrip[i] + "\n";
				}
				break;				
			case "password":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + objectdescrip[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + objectdescrip[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg) {
		return true;
	}else{
		alert (alertMsg);
		return false;
	}
}

function delconfirm(){
	return confirm("ยืนยันการลบ\nDelete confirm");
}

function forwardconfirm(){
    var a;
	a = confirm ("คุณกำลังตัดยอดยกไปเพื่อตั้งต้นเป็นยอดยกมาใช่หรือไม่ ?\nYou are process carry/bring forward?");
	if (a == 1) 	return confirm("กรุณายืนยันการยกยอดอีกครั้ง\nPlease confirm forwarding");
	else return false;
}




function check_number() {
	e_k=event.keyCode
//if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
	if (e_k != 13 && (e_k < 48) || (e_k > 57)) {
		event.returnValue = false;
		alert("ต้องเป็นตัวเลขเท่านั้น...  กรุณาตรวจสอบข้อมูลของท่านอีกครั้ง...\nfill in figures only..please check figures again");
	}
}

function check_number2() {
	e_k=event.keyCode
//if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
	if (e_k != 13 && e_k != 45 && (e_k < 48) || (e_k > 57)) {
		event.returnValue = false;
		alert("ต้องเป็นตัวเลขเท่านั้น...  กรุณาตรวจสอบข้อมูลของท่านอีกครั้ง...\nfill in figures only..please check figures again");
	}
}

var submitcount=0;
function submitonce(){
	if (submitcount==0)
	{			
		submitcount++;
		return true;
	}else{
		alert("กำลังประมวลผล... ! \n Data processing")
		return false;
	}
}




