//------------------------------- MyCode -------------------------------------
// wut 31/10/03
var EngCode = new Array();
var ThaiCode = new Array();
var MyCode = new Array();
var lang = "";
var swlang = "";
var FormatDate = "DD/MM/YYYY";
var systemName = "MyHR ";

function closePage() {
	window.close();
}
/*
 * Original From	: http://km0ti0n.blunted.co.uk/mozxpath/
 * Modified by : James
 */
if (document.implementation.hasFeature("XPath", "3.0") && typeof XMLDocument != "undefined") {
	XMLDocument.prototype.selectSingleNode = function (cXPathString, xNode) {
		if (!xNode) {
			xNode = this;
		}
		var oNSResolver = this.createNSResolver(this.documentElement)
		var results = this.evaluate(cXPathString, xNode, oNSResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null)
		return results.singleNodeValue;
	}

	Element.prototype.selectSingleNode = function (cXPathString) {
		if (this.ownerDocument.selectSingleNode) {
			return this.ownerDocument.selectSingleNode(cXPathString, this);
		} else {
			throw "For XML Elements Only";
		}
	}

	if (!Document.prototype.selectSingleNode) {
		Document.prototype.selectSingleNode = function (cXPathString, xNode) {
			if (!xNode) {
				xNode = this;
			}
			var oNSResolver = this.createNSResolver(this.documentElement)
			var results = this.evaluate(cXPathString, xNode, oNSResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null)
			return results.singleNodeValue;
		}
	}
}

objDOM = null;
// edit by james 18/12/2551
if (window.ActiveXObject) {
	var xmlDoc = new ActiveXObject("Msxml.DOMDocument");
	xmlDoc.async = false;
	var canload = xmlDoc.load("XML/SWAPLANG.xml");
	if (!canload) {
		xmlDoc.load("../XML/SWAPLANG.xml");
	}
	objDOM = xmlDoc;

} else if (window.XMLHttpRequest) {
	var xmlDoc = new XMLHttpRequest();
	xmlDoc.open("GET", "XML/SWAPLANG.xml", false);

	//edit for IE11
	try {
		xmlDoc.responseType = 'msxml-document';
	} catch (e) {}

	xmlDoc.send(null);
	if (xmlDoc.readyState == 4 && (xmlDoc.status != 200 && xmlDoc.status != 304)) {
		xmlDoc.open("GET", "../XML/SWAPLANG.xml", false);
		xmlDoc.send(null);
	}
	if (xmlDoc && xmlDoc.responseXML) {
		objDOM = xmlDoc.responseXML;
	}
}
/*===========================================*/
ThaiCode[0] = "คุณกรอกข้อมูลไม่ครบ";
EngCode[0] = "Incomplete Data or null Value !";

ThaiCode[1] = "ต้องการบันทึกข้อมูลหรือไม่ ?";
EngCode[1] = "Do you want to save data ?";

ThaiCode[2] = "มีข้อมูล Record นี้อยู่แล้ว ถ้าต้องการบันทึกข้อมูลกรุณากด EDIT ?";
EngCode[2] = "Duplicate data ! Click EDIT for update data";

ThaiCode[3] = "ต้องการแก้ไขข้อมูลหรือไม่ ?";
EngCode[3] = "Do you want to update data or not?";

ThaiCode[4] = "ต้องการลบข้อมูลหรือไม่ ?";
EngCode[4] = "Do you want to delete data or not?";
///------------------ result for database action
ThaiCode[5] = "แก้ไขข้อมูลไม่สำเร็จ";
EngCode[5] = "Updating is incomplete. Try again.";

ThaiCode[6] = "ไม่พบข้อมูล";
EngCode[6] = "Data have not been found.";

ThaiCode[7] = "ลบข้อมูลไม่ได้";
EngCode[7] = "Unable to delete data.";

ThaiCode[8] = "ยังไม่ได้กำหนด";
EngCode[8] = "Undifinded";

ThaiCode[9] = "ไม่พบข้อมูล ถ้าต้องการบันทึกกรุณากด ADD";
EngCode[9] = " Data not found. Please click ADD to save data";

ThaiCode[10] = "พิมพ์รายงาน";
EngCode[10] = "Print Report";

ThaiCode[11] = "ได้เลือกไว้แล้ว";
EngCode[11] = "Already chosen";

ThaiCode[12] = "ตรวจสอบโดย";
EngCode[12] = "Verified By:";

ThaiCode[13] = "วันเวลาที่แก้ไข";
EngCode[13] = "Edit Date";

ThaiCode[14] = "แก้ไขโดย";
EngCode[14] = " Edited By:";

ThaiCode[15] = "กรุณากรอกรหัสพนักงาน";
EngCode[15] = "Please enter Employee Code ";

ThaiCode[16] = "กรุณากดปุ่ม EDIT";
EngCode[16] = " Please click 'EDIT' button";

ThaiCode[17] = "บันทึกข้อมูลไม่ได้";
EngCode[17] = "Unable to save data";

ThaiCode[18] = "บันทึกข้อมูลเรียบร้อย";
EngCode[18] = "Save data completely";

ThaiCode[19] = "ลบข้อมูลเรียบร้อย";
EngCode[19] = "Delete data sucessfully";

ThaiCode[20] = "มีการเลือก Payment method แบบอื่นๆ แต่ไม่ใส่รายละเอียด";
EngCode[20] = "Selecting other payment methods without detail";

ThaiCode[21] = "ยังไม่มีการบันทึกเงื่อนไขการพิมพ์รายงาน";
EngCode[21] = "Undone condition for printing report";

ThaiCode[22] = "บันทึกเงื่อนไขที่ ";
EngCode[22] = "Save condition no.";

ThaiCode[23] = "ลบเงื่อนไขที่ ";
EngCode[23] = "Delete condition no.";

ThaiCode[24] = "กรอกหมายเลขเงื่อนไข ที่ต้องการลบ";
EngCode[24] = "Input condition no for deleting";

ThaiCode[25] = "กรอกหมายเลขเงื่อนไข บันทึกหรือแก้ไข";
EngCode[25] = "Input condition no for saving or updating";

ThaiCode[26] = "จำนวนพนักงานรวมไม่ถูกต้อง คำนวณใหม่ ?";
EngCode[26] = "Incorrect number of employee. Recalculate.";

ThaiCode[27] = "ยังไม่มีการเลือก field";
EngCode[27] = "Field has not been selected. ";

ThaiCode[28] = "เงื่อนไขไม่ตรงลำดับ";
EngCode[28] = "Order of condition incorect";


//employee
ThaiCode[29] = "หน้า refer ไม่สามารถแก้ใขข้อมูลได้";
EngCode[29] = "Referred page is unable to update data.";

ThaiCode[30] = "กลับไปยังหน้าหลัก ?";
EngCode[30] = " Return to Main Page ?";
// return from Verify
ThaiCode[31] = "ไม่สามารถเพิ่มข้อมูลได้ เพราะข้อมูลนี้กำลังรอการยืนยัน";
EngCode[31] = "Unable for adding. Data status is waiting for comfirmation.";

ThaiCode[32] = "ไม่สามารถแก้ใข้อมูลได้ เพราะข้อมูลนี้กำลังรอการยืนยันการลบ";
EngCode[32] = "Unable for updating. Data status is waiting for deleting comfirmation.";

ThaiCode[33] = "ไม่สามารถลบข้อมูลได้ เพราะข้อมูลกำลังรอการยืนยันการลบ";
EngCode[33] = "Unable for delete. Data status is waiting for deleting comfirmation.";

ThaiCode[34] = "ไม่สามารถลบข้อมูลได้ เพราะข้อมูลกำลังรอการยืนยันการแก้ใข";
EngCode[34] = "Unable for delete. Data status is waiting for updating comfirmation."

ThaiCode[35] = " :: ไม่สามารถแก้ไขได้ , ข้อมูลกำลังรอการยืนยันการแก้ไขงจาก user คนอื่น ";
EngCode[35] = " :: Unable for updating. Data status is waiting for the comfirmation by other user. ";

ThaiCode[36] = " ไม่สามารถแก้ไขได้ ข้อมูลชุดนี้อยู่ในระหว่างการรอ Verify ";
EngCode[36] = " Unable for updating. Data status is waiting to verify. ";

ThaiCode[37] = "ยอดรวมพนักงานไม่ถูกต้อง ต้องการคำนวณหรือไม่ ?";
EngCode[37] = "Incorrect total number of employee. Recalculate.";

//--------------------- PAS ----------------------------------------------------
/*ThaiCode[26] = "ผลรวมทั้งหมด ต้องเท่ากับ 100";
	EngCode[26] = " Over all score = 100";

	ThaiCode[27] = "กรอกคะแนนไม่ถูกต้อง !!!!!!";
	EngCode[27] = " This score is wrong  !!!!!!";

	ThaiCode[28] = "คำสั่งนี้จะใช้ได้ก็ต่อเมื่อ ประเมินครบทุกฟอร์มแล้ว เท่านั้น !!!!!!";
	EngCode[28] = " คำสั่งนี้จะใช้ได้ก็ต่อเมื่อ ประเมินครบทุกฟอร์มแล้ว เท่านั้น !!!!!!";

	ThaiCode[29] = "กรุณาเลือกเรื่องที่ประเมินก่อน !!!!!!";
	EngCode[29] = " Please choose Title topic !!!!!!";

	ThaiCode[30] = "เมื่อยืนยันการประเมินแล้วไม่สามารถแก้ไขได้ !!!!!!!!";
	EngCode[30] = "เมื่อยืนยันการประเมินแล้วไม่สามารถแก้ไขได้ !!!!!!!!";
*/

ThaiCode[38] = "รหัสนี้ถูกใช้แล้ว ไม่สามารถลบได้";
EngCode[38] = "This code is activated, Unable to delete.";

ThaiCode[39] = "ลบข้อมูลไม่ได้ เนื่องจากไม่มีข้อมูล";
EngCode[39] = "Data not found , Unable to delete.";

ThaiCode[40] = "ผลรวมทั้งหมด ต้องเท่ากับ 100";
EngCode[40] = " Total score must be equal to 100.";

ThaiCode[41] = "กรอกคะแนนไม่ถูกต้อง !!!!!!";
EngCode[41] = " Incorrect score data.";

ThaiCode[42] = "คำสั่งนี้จะใช้ได้ก็ต่อเมื่อ ประเมินครบทุกฟอร์มแล้ว เท่านั้น !!!!!!";
EngCode[42] = "This command is valid after completion of all evaluataion forms.";

ThaiCode[43] = "กรุณาเลือกเรื่องที่ประเมินก่อน !!!!!!";
EngCode[43] = "Firstly select Title Topic.";

ThaiCode[44] = "เมื่อยืนยันการประเมินแล้วไม่สามารถแก้ไขได้ !!!!!!!!";
EngCode[44] = "Unable to edit after comfirming the evaluation.";

ThaiCode[45] = "กรณีที่เป็น คำถามประเภทถูกผิด ให้ใส่ T หรือ F";
EngCode[45] = "Using T or F in case the question is required.";

///wut 070904

// เอามาจาก training


ThaiCode[46] = "ออกจากระบบ";
EngCode[46] = " Log out.";


ThaiCode[47] = "กรุณากรอกข้อมูลให้ครบ";
EngCode[47] = "Please input data completely.";

ThaiCode[48] = "เพิ่มข้อมูลเรียบร้อยแล้ว";
EngCode[48] = "Save data successfully.";
//personal
ThaiCode[49] = "ข้อมูลไม่ถูกต้อง";
EngCode[49] = "Incomplete Data Data or Null Value.";

ThaiCode[50] = "กรุณายืนรหัสผ่านใหม่อีกรอบ";
EngCode[50] = "Please reconfirm your new password.";

ThaiCode[51] = "Username นี้มีผู้ใช้งานแล้ว กรุณาเปลี่ยน";
EngCode[51] = "Username has been activated. Please change.";

ThaiCode[52] = "สามารถใช้ Username นี้ได้";
EngCode[52] = "Username is valid and able to use.";

ThaiCode[53] = "กรุณาตรวจสอบ Username ก่อน";
EngCode[53] = "Firstly check username before the next step.";

ThaiCode[54] = "กรุณายื่นเอกสารด้วยครับ....";
EngCode[54] = "Please sumit the documents.";

ThaiCode[55] = "ตัวอย่างก่อนพิมพ์";
EngCode[55] = "Print preview";

ThaiCode[56] = "กรุณาเลือกไฟล์ (.zip) หรือ ไฟล์ (.txt) เท่านั้น";
EngCode[56] = "Please choose only zip file(.zip) or text file(.txt)";

ThaiCode[57] = "กรุณาเลือกไฟล์ก่อน";
EngCode[57] = "Firstly choose file.";

ThaiCode[58] = "กรุณากรอกรหัสงานก่อน";
EngCode[58] = "Please insert jobcodeid.";

// pas 31/08/2005
ThaiCode[59] = "มีข้อมูล Record นี้อยู่แล้ว \n ต้องการแก้ไขข้อมูลหรือไม่ ?";
EngCode[59] = "Duplicate data. \n require for updating or not?";
//  end

// นก 06082005
ThaiCode[60] = "กรุณากรอกวันที่เปลี่ยนเงินเดือนด้วย";
EngCode[60] = "Please input Effective Date of Salary.";

EngCode[61] = "This ID card is active. Re-entry data.";
ThaiCode[61] = "หมายเลขบัตรที่ใช้ลงเวลานี้มีการใช้งานอยู่ กรุณากรอกข้อมูลใหม่อีกครั้ง";

ThaiCode[62] = "ไม่สามารถแก้ไขได้ !!! หากต้องการแก้ไข กรุณาลบ แล้วคีย์ใหม่";
EngCode[62] = "Unable to edit. Please delete and input new data, if required.";

ThaiCode[63] = "เงื่อนไขนี่มีอยู่แล้ว  !!! ต้องการแก้ไขข้อมูลหรือไม่ ?";
EngCode[63] = "Valid condition !!! Update data ?";

EngCode[64] = "Deleting is not permitted.";
ThaiCode[64] = "ไม่อนุญาตให้ลบข้อมูลนี้";

EngCode[65] = "Swipe Card ID has already been activated. Employee id.";
ThaiCode[65] = "หมายเลขบัตรที่ใช้ลงเวลามีคนใช้แล้ว ,รหัสพนักงาน";

EngCode[66] = "!! Unable for adding data \n Please press update button.";
ThaiCode[66] = "!! ไม่สามารถเพิ่มได้ \n กรุณากดปุ่มแก้ไข";

EngCode[67] = "!! Unable for adding data \n Please press update button.";
ThaiCode[67] = "!! ไม่สามารถเพิ่มได้ \n กรุณากดปุ่มแก้ไข";

EngCode[68] = "Unable to search data.";
ThaiCode[68] = "ค้นหาข้อมูลไม่ได้";

ThaiCode[69] = "ไม่สามารถเพิ่มได้ !!! หากต้องการแก้ไข กรุณาลบ แล้วคีย์ใหม่";
EngCode[69] = "Unable to edit. Please delete and input new data, if required.";

ThaiCode[70] = "กรุณากำหนดสิทธิใหม่!!!";
EngCode[70] = "Please reconfig the permission.";

ThaiCode[71] = "กรุณาตรวจสอบระยะเวลาการจ่ายเงิน";
EngCode[71] = "Please check Salary Payment period.";

ThaiCode[72] = "ผู้สมัครยังไม่ระบุอีเมล์แอดเดรส";
EngCode[72] = "Candidate does not identify an e-mail address.";

ThaiCode[73] = "อีเมล์แอดเดรสไม่ถูกต้อง";
EngCode[73] = "Incorrect e-mail address.";

ThaiCode[73] = "กรุณาเลือกไฟล์ (.jpg) หรือไฟล์ (.jpeg) หรือไฟล์ (.gif) เท่านั้น";
EngCode[73] = "Please choose file (.jpg) or (.jpeg) or (.gif)";

ThaiCode[74] = "ไม่สามารถเพิ่มข้อมูลได้";
EngCode[74] = "Unable to insert data";

ThaiCode[75] = "เลขบัตรประชาชนไม่ครบ 13 หลัก";
EngCode[75] = "Id Card number digit is less than 13";

ThaiCode[76] = "คุณเคยกรอกใบสมัครไว้แล้ว ต้องการดำเนินการต่อหรือไม่?";
EngCode[76] = "Your application form has been done. Do you need for further step or not?";

ThaiCode[77] = "กรุณาเลือกค่าตั้งต้นเพียงค่าเดียว";
EngCode[77] = "Please select only one default value";

ThaiCode[78] = "กรุณาเลือกค่าตั้งต้นด้วย";
EngCode[78] = "Please select a default value";

ThaiCode[79] = "ข้อมูลไม่ถูกต้อง, กรุณากรอกใหม่";
EngCode[79] = "Incorrect data. Please re-entry.";

//pae 2006/01/27
EngCode[80] = "Firstly select File.";
ThaiCode[80] = "กรุณาเลือกไฟล์ก่อน !!!";
EngCode[81] = "Please Select (.txt) File only.";
ThaiCode[81] = "กรุณาเลือกไฟล์ (.txt) เท่านั้น";
EngCode[82] = "Please Select (.txt)  or (.zip) File only.";
ThaiCode[82] = "กรุณาเลือกไฟล์ (.txt) หรือ (.zip) เท่านั้น";
EngCode[83] = "Duplicate Data.";
ThaiCode[83] = "มีข้อมูลแล้ว";
EngCode[84] = "Deleting is required.";
ThaiCode[84] = "ต้องการลบ";
EngCode[85] = "Unable to delete. the document is valid in workflow system.";
ThaiCode[85] = "ไม่สามารถลบ เนื่องจากเอกสารนี้อยู่ในระบบ Workflow";
EngCode[86] = "The document is valid in workflow system.";
ThaiCode[86] = "เอกสารนี้อยู่ในระบบ Workflow";
EngCode[87] = "Warning !! Please Check Send To box";
ThaiCode[87] = "คำเตือน !! กรุณาตรวจสอบช่องส่งถึงด้วย";
EngCode[88] = "Warning !! Please Input Comment To";
ThaiCode[88] = "คำเตือน !! กรุณากรอกข้อมูลช่องคำแนะนำด้วย";
EngCode[89] = "ERROR !! Please clear DocumentID before sending New Request.";
ThaiCode[89] = "ข้อผิดพลาด !!! กรุณากดปุ่มล้างหมายเลขเอกสารก่อนขอเอกสารใหม่ด้วย";
EngCode[90] = "Requested date must not be duplicated.";
ThaiCode[90] = "วันที่ขอห้ามซ้ำกัน !!!";

EngCode[91] = "Firstly enter Document Number";
ThaiCode[91] = "กรุณากรอกหมายเลยเอกสารก่อน !!!";

// โกนจ้าบ 19072006
EngCode[92] = "Fund returnable shortest period is ";
ThaiCode[92] = "ระยะเวลาการคืนทุนน้อยสุดคือ ";
EngCode[93] = " days \n Do you need to update or not?";
ThaiCode[93] = "วัน\n คุณต้องการแก้ไขหรือไม่? ";

// TUM 19-7-49
ThaiCode[94] = "มีข้อมูลการใช้งานอยู่แล้ว กรุณาตรวจสอบข้อมูลอีกครั้ง"; // TUM
EngCode[94] = "Duplicate data ! Please recheck."; // TUM
ThaiCode[95] = "ไม่สามารถ เพิ่ม หรือ เข้าดูรายการที่ได้ทำการสมัครไปแล้ว"; // TUM
EngCode[95] = "Unable to add data or view Done Application Form"; // TUM

//lambkin 070130
EngCode[96] = "Firstly select Regulation Order Notice Group.";
ThaiCode[96] = "กรุณาเลือกกลุ่มข้อบังคับ/ระเบียบ/ประกาศก่อน";

EngCode[97] = "Please select Master file";
ThaiCode[97] = "กรุณาเลือกทะเบียนก่อน";

EngCode[98] = "Please select Formet Code";
ThaiCode[98] = "กรุณาเลือกรหัสที่ต้องการเปลี่ยนก่อน";

EngCode[99] = "Please insert New Code";
ThaiCode[99] = "กรุณากรอกรหัสใหม่ก่อน";

EngCode[100] = "Incorrect period. Please select new date.";
ThaiCode[100] = "ช่วงวันที่ไม่ถูกต้อง กรุณาเลือกช่วงวันที่ใหม่";
//end lambkin 070130

EngCode[101] = "Please entry data of Employee 1 less than Employee 2";
ThaiCode[101] = "กรุณากรอกข้อมูลพนักงาน 1 น้อยกว่าพนักงาน 2";
//lambkin 070319
EngCode[102] = " Please select Attached File.";
ThaiCode[102] = "กรุณาเลือกไฟล์แนบ";

EngCode[103] = " Firstly input Project id.";
ThaiCode[103] = "กรุณาใส่รหัสโครงการก่อน";

EngCode[104] = "Please insert Maximum value greater than Minimum value.";
ThaiCode[104] = "กรุณากรอกค่า มากสุด มากกว่า ค่าน้อยสุด";

EngCode[105] = "Please insert salary value less than Maximum salary.";
ThaiCode[105] = "กรุณากรอกค่า เงินเดือน น้อยกว่า เงินเดือนมากสุด";

EngCode[106] = "Please insert salary value more than Minimum salary.";
ThaiCode[106] = "กรุณากรอกค่า เงินเดือน มากกว่า เงินเดือนน้อยสุด";
//end lambkin 070319

//sin add
EngCode[107] = "Incorrect date. (System default is present date)";
ThaiCode[107] = "กรอกวันที่ผิด (ระบบจะใส่ค่าวันที่ให้เป็นวันปัจจุบัน)";

EngCode[108] = "Entry data of year in more than or equal to";
ThaiCode[108] = "กรุณาใส่ค่าปีให้มากกว่าหรือเท่ากับ: ";

EngCode[109] = "Re-entry date. Because ";
ThaiCode[109] = "กรุณากรอกวันที่ใหม่ เพราะว่า  ";

EngCode[110] = " More Then ";
ThaiCode[110] = " มากกว่า ";

EngCode[111] = "Date entry more or less then 80 year is prohibited. For example: 31012006 (31-01-2006) ";
ThaiCode[111] = "ห้ามกรอกวันที่มากกว่า 80 ปี หรือ น้อยกว่า 80 ปีนับจากวันปัจจุบัน [ ตัวอย่าง ] 31012006 (31-01-2006) ";

EngCode[112] = "Please input 8 digits for date. For example: 31012006 (31-01-2006)";
ThaiCode[112] = "กรุณากรอกวันที่ 8 ตัวเลข  [ ตัวอย่าง ] 31122006 (31-12-2006)";

EngCode[113] = " Year ";
ThaiCode[113] = " ปี ";

EngCode[114] = " Month ";
ThaiCode[114] = " เดือน ";

EngCode[115] = " Date not over than 366";
ThaiCode[115] = " วัน ";

EngCode[116] = "Input date for not more than 80 year based on the current date. For example: 2007 , 2550(2007)";
ThaiCode[116] = "กรอกวันที่ห้ามมากกว่า 80 นับจากวันปัจจุบัน [ ตัวอย่าง ] 2007 , 2550(2007)";

EngCode[117] = "Please input Thai year OR Eng Year. For example :: 2007 , 2550(2007)";
ThaiCode[117] = "กรุณากรอกปีไทยหรือปีอังกฤษ [ ตัวอย่าง ] 2007 , 2550(2007)";

EngCode[118] = "Re-entry Date. Because ";
ThaiCode[118] = "กรุณากรอกวันที่ใหม่ เพราะว่า ";

EngCode[119] = "Starting Date must not more than Ending Date. Please recheck.";
ThaiCode[119] = "วันที่เริ่มต้นห้ามมากกว่าวันที่สุดท้าย, กรุณาตรวจสอบวันที่เริ่มต้นหรือสุดท้ายใหม่";

EngCode[120] = "Do not entry date not more than or less than 80 years based on the current date. (Default date is present date)";
ThaiCode[120] = "ห้ามกรอกวันที่มากกว่า 80 ปี หรือ น้อยกว่า 80 ปีนับจากวันปัจจุบัน (ระบบใส่เป็นวันปัจจุบัน)";

EngCode[121] = "Input 8 digits for Start Date. Ex. 31012006 (output is 31-01-2006)";
ThaiCode[121] = "กรุณากรอกวันเริ่มต้น 8 ตัวเลข [ ตัวอย่าง ] 31012006(31-01-2006)";

EngCode[122] = "Input 8 digits for End Date. Ex. 31012006 (output is 31-01-2006)";
ThaiCode[122] = "กรุณากรอกวันสุดท้าย 8 ตัวเลข [ ตัวอย่าง ] 31012006(31-01-2006)";

EngCode[123] = "Input 8 digits for End Date. Ex.  31012006 (output is 31-01-2006) \n Starting date default is present date";
ThaiCode[123] = "กรุณากรอกวันสุดท้าย 8 ตัวเลข [ ตัวอย่าง ] 31012006(31-01-2006) \n ระบบจะใส่ค่าวันเริ่มต้นเป็นวันปัจจุบัน";

EngCode[124] = "Input Ending Date :: EX. 01012000(01-01-2000)";
ThaiCode[124] = "กรุณากรอกวันที่สุดท้าย [ ตัวอย่าง ] 01012000(01-01-2000)";

EngCode[125] = "Input Starting Date :: EX. 01012000(01-01-2000)";
ThaiCode[125] = "กรุณากรอกวันที่เริ่มต้น [ ตัวอย่าง ] 01012000(01-01-2000)";

EngCode[126] = "Re-entyr Ending Date:: EX. 01012000(01-01-2000)";
ThaiCode[126] = "กรุณากรอกวันที่สุดท้ายอีกครั้ง [ ตัวอย่าง ] 01012000(01-01-2000)";

EngCode[127] = "Input mobile phone number";
ThaiCode[127] = "กรอกเบอร์โทรศัพท์มือถือ ";

EngCode[128] = " More then EX:: 12345678 or 0812345678 ";
ThaiCode[128] = " มากกว่า [ ตัวอย่าง ] 12345678 หรือ 0812345678 ";

EngCode[129] = " Less then EX:: 12345678 or 0812345678 ";
ThaiCode[129] = " น้อยกว่า [ ตัวอย่าง ] 12345678 หรือ 0812345678 ";

EngCode[130] = " False EX:: 0812345678";
ThaiCode[130] = " ผิด [ ตัวอย่าง ] 12345678 หรือ 0812345678 ";

EngCode[131] = "Input number 0 - 100 only because the percentage is being used.";
ThaiCode[131] = "กรุณากรอกเลข 0-100 เท่านั้น เพราะว่ากำลังเลือกเป็นเปอร์เซ็นต์";

EngCode[132] = "Undefined Host Name. [ Ex. ] username@hostname.com";
ThaiCode[132] = "ไม่ได้ชื่อเว็บไซต์ [ ตัวอย่าง ] username@hostname.com";

EngCode[133] = "Do not input dot after '@'. [ Ex. ] username@hostname.com";
ThaiCode[133] = "หลัง @ ไม่ได้ใส่ . หลังชื่อเว็บไซต์ [ ตัวอย่าง ] username@hostname.com ";

EngCode[134] = "Input more than one '@'. [ Ex. ] username@hostname.com";
ThaiCode[134] = "ใส่ @ เกิน [ ตัวอย่าง ] username@hostname.com ";

EngCode[135] = "Unidentified '@'. [ Ex. ] username@hostname.com";
ThaiCode[135] = "ไม่ได้ใส่ @ [ ตัวอย่าง ] username@hostname.com ";

EngCode[136] = "Unidentified E-Mail address.";
ThaiCode[136] = "ไม่ได้ใส่ชื่ออีเมล์ [ ตัวอย่าง ] username@hostname.com ";

EngCode[137] = "Please input Max Value";
ThaiCode[137] = "กรุณาใส่ค่าสูงสุด";

EngCode[138] = "Please input Min Value";
ThaiCode[138] = "กรุณาใส่ค่าต่ำสุด";

EngCode[139] = "Please re-entry Year of marriage. Because ";
ThaiCode[139] = "กรุณาใส่ปีแต่งงานใหม่ เพราะว่า ";

EngCode[140] = " Less Than ";
ThaiCode[140] = " น้อยกว่า ";

EngCode[141] = "Please input  Year of marriage less then year Present Year. ";
ThaiCode[141] = "กรุณากรอกปีแต่งงานให้น้อยกว่าวันปัจจุบัน";

EngCode[142] = "Please input  Year of marriage more then year Birthdate Year.";
ThaiCode[142] = "กรุณากรอกปีแต่งงานให้มากกว่าวันเกิด";

EngCode[143] = "Please recheck age, Because ";
ThaiCode[143] = "กรุณาตรวจสอบอายุอีกครั้ง เพราะว่า ";

EngCode[144] = "Please input Value ";
ThaiCode[144] = "กรุณากรอกค่า ";

EngCode[145] = " to ";
ThaiCode[145] = " ถึง ";

EngCode[146] = " only ";
ThaiCode[146] = " เท่านั้น ";
//end siner 100507

// PipoXP 20070504
EngCode[147] = "Please insert full hour.";
ThaiCode[147] = "กรุณากรอกเวลาให้เต็มชั่วโมง";

EngCode[148] = "Early leaving.";
ThaiCode[148] = "กรุณาลาก่อนเวลาที่กำหนด";

// end PipoXP -20070504
EngCode[149] = "Sex Type does not relate to title.";
ThaiCode[149] = "ข้อมูลเพศไม่สัมพันธ์กับคำนำหน้าชื่อ";
//siner add 11-05-2007


//end siner 11-05-2007
//lambkin 20070512
EngCode[150] = "Unable to use this page.";
ThaiCode[150] = "ไม่สามารถใช้ได้ในหน้านี้";
EngCode[151] = "Duplicate.";
ThaiCode[151] = "มีอยู่แล้ว";
EngCode[152] = "Please insert Identification ID.";
ThaiCode[152] = "กรุณาใส่เลขที่บัตรประชาชน";
//End lambkin 20070512
//TAE 16052007
EngCode[153] = "Please input hour and minute:: Ex 1234 == 12.34 or 830 == 8.30";
ThaiCode[153] = "กรุณาใส่ค่าของ ชั่วโมง และ นาที เช่น 1234 == 12.34 หรือ 830 == 8.30";
EngCode[154] = "Please input minute";
ThaiCode[154] = "กรุณาใส่นาที";
EngCode[155] = "Please input hour ";
ThaiCode[155] = "กรุณาใส่ชั่วโมง";
//TAE 16052007
//lambkin 20070518
EngCode[156] = "ID number is activated. Please change it.";
ThaiCode[156] = "หมายเลขบัตรที่ใช้ลงเวลานี้มีคนใช้แล้ว กรุณาเปลี่ยนแปลงค่า";
//End lambkin 20070518
//sin create 18-05-2007
EngCode[157] = "input date data is more then Present date.";
ThaiCode[157] = "วันที่กรอกเข้ามามากกว่าวันที่ปัจจุบัน ";
EngCode[158] = "Do not input Birthdate less then ";
ThaiCode[158] = " ห้ามใส่วันเกิดน้อยกว่า";
EngCode[159] = "Do not input Birthdate more then ";
ThaiCode[159] = " ห้ามใส่วันเกิดมากกว่า";
//tae 22052007
EngCode[160] = "Working hour must not more than";
ThaiCode[160] = " จำนวนชั่วโมงต้องไม่เกิน ";
EngCode[161] = " Minute must not more than";
ThaiCode[161] = " จำนวนนาทีต้องไม่เกิน  ";

//	Ball ใช้สำหรับฟังชันที่เขียนเอง
EngCode[162] = " One year data must not over 366 day";
ThaiCode[162] = " ใน 1 ปีมีวันได้ไม่เกิน 366 วัน  ";
EngCode[163] = "Incorrect Zipcode ";
ThaiCode[163] = " คุณกรอกรหัสไปรษณีย์ไม่ครบ  ";
EngCode[164] = " Please input number. EX 1234 ==> 12.34 or 830 ==> 8.30 ";
ThaiCode[164] = " เมื่อใส่ตัวเลข 1234 จะเปลี่ยนเป้น 12.34 หรือใส่ 830 จะเปลี่ยนเป็น 8.30";
EngCode[165] = " Mid-time value must not more than End time ";
ThaiCode[165] = " เวลากลางต้องน้อยกว่าเวลาเลิก  ";
EngCode[166] = " Starting time have must not more than Mid-time ";
ThaiCode[166] = " เวลาเริ่มต้อน้อยกว่าเวลากลาง  ";
EngCode[167] = " Confirm Process Move To Payroll ";
ThaiCode[167] = "  ยืนยันการดึงข้อมูล   ";
EngCode[168] = " Confirm Process";
ThaiCode[168] = "  ยืนยันการประมวลผล   ";
EngCode[169] = "Please entry Year ";
ThaiCode[169] = "  กรุณากรอกปี   ";
EngCode[170] = "All yearly payroll period has not been closed.";
ThaiCode[170] = "  งวดเงินเดือนทั้งปียังไม่ถูกปิด   ";
EngCode[171] = " Can not process cause: Order of Month  is 0  ";
ThaiCode[171] = "  ยังไม่ได้ผ่านรายการ   ";
EngCode[172] = " All Payroll Period has not been closed.";
ThaiCode[172] = "  งวดเงินเดือนยังไม่ถูกปิด   ";
EngCode[173] = " All Payroll Period has been closed.";
ThaiCode[173] = "  งวดเงินเดือนได้ถูกปิดทั้งหมดแล้ว   ";

EngCode[174] = "Firstly select Rules/Regulation/Announcement. ";
ThaiCode[174] = "  กรุณาเลือกประเภทข้อบังคับ/ระเบียบ/ประกาศก่อน   ";
EngCode[175] = "  Please wait. The system is in process. ";
ThaiCode[175] = "  ระบบกำลังทำงานอยู่   ";
//	MyCode[165]

//lambkin 20070629 for KKB
EngCode[176] = "  Firstly enter employee ID.";
ThaiCode[176] = "  กรุณากรอกรหัสพนักงานก่อน  ";
EngCode[177] = " Duplicate New employee ID.";
ThaiCode[177] = "  รหัสพนักงานใหม่ซ้ำ ";
EngCode[178] = "  Copying Employee Information is in process.  ";
ThaiCode[178] = "  ประมวลผลคัดลอกข้อมูลพนักงาน ";
EngCode[179] = " Please select copy list.";
ThaiCode[179] = " กรุณาเลือกรายการที่จะคัดลอก ";
//End lambkin 20070629 for KKB

//siner add 20070709 for KKB
EngCode[180] = "input date data is  less then  present date.";
ThaiCode[180] = "วันที่กรอกเข้ามาน้อยกว่าวันที่ปัจจุบัน ";

EngCode[181] = "Invalid Web Format. For example: www.csc.co.th";
ThaiCode[181] = "กรอกรูปแบบเว็บไซต์ผิด ตัวอย่าง. www.csc.co.th";
//end siner 20070709 for KKB

//20070725
EngCode[182] = " Data entry is longer than Text Box.";
ThaiCode[182] = " กรอกข้อมูลยาวเกินกำหนด ";

//20070727 sin
EngCode[183] = " Export file ";
ThaiCode[183] = " ส่งออกไฟล์ ";

EngCode[184] = "Confirm Process  ";
ThaiCode[184] = "ยืนยันการประมวลผล  ";

EngCode[185] = "Export file ";
ThaiCode[185] = "ส่งออกไฟล์ ";

EngCode[186] = "Number of day must less than 366.";
ThaiCode[186] = "กรุณากรอกจำนวนวันน้อยกว่า 366 วัน ";

EngCode[187] = "Tax payer Code must not less than 10 or more than 13 digit.";
ThaiCode[187] = "เลขที่ผู้เสียภาษีต้องไม่ต่ำกว่า 10 หรือมากกว่า 13 หลัก ";

// Ball 30/8/2007 for TIME TAU152
EngCode[188] = "Start Date or Start Time less then Last Date or Last time!!! ";
ThaiCode[188] = "วันหรือเวลาเริ่มต้น ต้องน้อยกว่า วันหรือเวลาที่สิ้นสุด";

EngCode[189] = "Identification ID have must 13 character";
ThaiCode[189] = "หมายเลขประจำตัวประชาชนต้องมี 13 หลัก";

EngCode[190] = "Calulation ";
ThaiCode[190] = "คำนวณ ";

EngCode[191] = "Please input Date. ";
ThaiCode[191] = "กรุณากรอกวันที่ด้วย";
EngCode[192] = "Please input Time. ";
ThaiCode[192] = "กรุณากรอกเวลาด้วย";
EngCode[193] = "Incorrect Date and Time.";
ThaiCode[193] = "คุณกรอกวัน เวลาผิด";
EngCode[194] = "Please input EmployeeID for viewing unrecorded time.";
ThaiCode[194] = "กรุณากรอกพนักงานที่ต้องการดูการไม่ได้บันทึกเวลา";
EngCode[195] = "Please input Cost Center.";
ThaiCode[195] = "กรุณากรอกคอสเซ็นเตอร์ด้วย";

//2011-10-12 for PI:PWF004_SV (Honda_Access)
EngCode[196] = "Unable to issue Letter of Recommendation because the permission has been completely used.";
ThaiCode[196] = "คุณไม่สามารถขอหนังสือรับรองการทำงานได้ เนื่องจากใช้สิทธิ์ครบแล้ว";
EngCode[197] = "Unable to issue Certificate of Salary because the permission has been completely used.";
ThaiCode[197] = "คุณไม่สามารถขอหนังสือรับรองเงินเดือนได้ เนื่องจากใช้สิทธิ์ครบแล้ว";
EngCode[198] = "Please identify type of cerficite document.";
ThaiCode[198] = "กรุณาระบุประเภทหนังสือรับรอง";
EngCode[199] = "Please select language.";
ThaiCode[199] = "กรุณาเลือกภาษา";

EngCode[200] = "Starting year must be less than Ending year.";
ThaiCode[200] = "ปีที่เริ่มต้น ต้องน้อยกว่า ปีที่สิ้นสุด";
EngCode[201] = "Starting month must be less than Ending month.";
ThaiCode[201] = "เดือนที่เริ่มต้น ต้องน้อยกว่า เดือนที่สิ้นสุด";

EngCode[202] = "Invalid data , please review .";
ThaiCode[202] = "คุณกรอกข้อมูลไม่ครบ กรุณาตรวจสอบ";

//2015-09-02 for PI:PRU339
EngCode[218] = "Invalid ID Card Number !!";
ThaiCode[218] = "รหัสประชาชนไม่ถูกต้อง !!";

EngCode[219] = "Please choose period group before";
ThaiCode[219] = "กรุณาเลือกกลุ่มช่วงเวลาก่อน !!";

EngCode[220] = "Please choose leave type";
ThaiCode[220] = "กรุณาประเภทการลา";

EngCode[204] = "User not permission save data";
ThaiCode[204] = "คุณไม่มีสิทธิ์ในการบันทึกข้อมูล";
EngCode[205] = "User not permission edit data";
ThaiCode[205] = "คุณไม่มีสิทธิ์ในการแก้ไขข้อมูล";
EngCode[206] = "User not permission delete data";
ThaiCode[206] = "คุณไม่มีสิทธิ์ในการลบข้อมูล";
ThaiCode[207] = "ช่วงเวลานี้มีการประมวลผลอยู่แล้ว ต้องการประมวลผลซ้ำหรือไม่ ?";
EngCode[207] = "Duplicate data ! are u want to process";
//MyCode=EngCode;

ThaiCode[221] = "ต้องการยกเลิกเอกสารหรือไม่ ?";
EngCode[221] = "Do you want to cancel or not ?";

ThaiCode[222] = "กรุณาเลือก Record ที่ต้องการ";
EngCode[222] = "Please select the record";

ThaiCode[223] = "จำนวนงวดที่คำนวณภาษีไม่ถูกต้อง กรุณาตรวจสอบ";
EngCode[223] = "Invalid number of count period, please check";

ThaiCode[224] = "กุณาเลือก option ก่อน";
EngCode[224] = "Please Choose Option";

ThaiCode[225] = "กรุณากรอกรหัสผ่าน";
EngCode[225] = "Please Input Password";

ThaiCode[226] = "รหัสผ่านไม่ถูกต้อง";
EngCode[226] = "password is incorrect";

ThaiCode[227] = "ไม่สามารถดำเนินการได้ กรุณาตรวจสอบสิทธิ์ของท่าน";
EngCode[227] = "Please check you permission";

ThaiCode[228] = "ไม่สามารถทำการสร้างเส้นทางการสมัครงานได้ \nเนื่องจากกำลังประกาศรับสมัครงานตำแหน่งนี้อยู่";
EngCode[228] = "Cannot generate router because this job already recruiting now";

ThaiCode[229] = "สร้างเส้นทางการสมัครงานสำเร็จ";
EngCode[229] = "Generate router complete";

ThaiCode[230] = "ไม่สามารถลบเส้นทางการสมัครงานได้";
EngCode[230] = "Cannot delete router";

ThaiCode[231] = "ตำแหน่งนี้ยังไม่มีข้อมูลเส้นทางการสมัครงาน \nระบบจะทำการสร้างให้อัตโนมัติ";
EngCode[231] = "This job don't have router. \nSystem will auto generate router";

ThaiCode[232] = "ไม่สามารถทำการบันทึกข้อมูลได้ \nเนื่องจากมีใบขออัตรากำลังที่ร้องขอตำแหน่งเดียวกันกำลังดำเนินการอยู่";
EngCode[232] = "Cannot save data because this job already recruit";

ThaiCode[233] = "ส่งข้อมูลสำเร็จ";
EngCode[233] = "Send data to jobboard complete";

ThaiCode[234] = "ข้อสอบได้รับการเปลี่ยนแปลงเป็นปัจจุบันแล้ว";
EngCode[234] = "Examination is up to date now"

ThaiCode[235] = "ไม่สามารถลบรูปภาพพื้นฐานได้"
EngCode[235] = "Cannot delete default picture"

ThaiCode[236] = "ค้นหารูปภาพนี้ไม่พบ"
EngCode[236] = "Cannot find picture"

ThaiCode[237] = "ไม่สามารถลบรูปภาพนี้ได้ \nกรุณาตรวจสอบความถูกต้องอีกครั้ง"
EngCode[237] = "Cannot delete picture \nPlease check again"

ThaiCode[238] = "มีการแก้ไขหน้าจอ \n ต้องการจะดำเนินการต่อหรือไม่";
EngCode[238] = "This page has modified \n Do you want to continue?";

ThaiCode[239] = "กรุณาลบไฟล์ที่ Upload ก่อน";
EngCode[239] = "Please delete uploaded file.";

ThaiCode[240] = "ใช่";
EngCode[240] = "Yes";

ThaiCode[241] = "ไม่ใช่";
EngCode[241] = "No";

ThaiCode[242] = "ปิด";
EngCode[242] = "Close";

ThaiCode[243] = "กรุณาเลือกค้นหา หรือ ระบบุอื่นๆ เพียงอย่างเดียว";
EngCode[243] = "Please select search or specify only one";

ThaiCode[244] = "ไม่สามารถเชื่อมต่อ Jobboard service ได้ \n กรุณาดำเนินการใหม่ในภายหลัง";
EngCode[244] = "Can not connect Jobboard service \n Please, Update data later";

ThaiCode[245] = "ไม่สามารถเเปลี่ยนสถานะการขออัตรากำลังเป็น ปกติ";
EngCode[245] = "Can not change status to Normal";

ThaiCode[246] = "ไม่สามารถเเปลี่ยนสถานะการขออัตรากำลังเป็น อยู่ระหว่างดำเนินการ";
EngCode[246] = "Can not change status to In Process";

ThaiCode[247] = "ไม่สามารถเเปลี่ยนสถานะการขออัตรากำลังเป็น ครบถ้วนแล้ว";
EngCode[247] = "Can not change status to Complete";

ThaiCode[248] = "ไม่สามารถเเปลี่ยนสถานะการขออัตรากำลังเป็น ยกเลิก";
EngCode[248] = "Can not change status to Cancled";

ThaiCode[249] = "ผ่านการคัดเลือกหรือไม่ ?";
EngCode[249] = "The Candidate is qualified for this position, confirm ?";

ThaiCode[250] = "กลับสู่กระบวนการสรรหาอีกครั้งหรือไม่ ?";
EngCode[250] = "Re-recruiting this person, confirm ?";

ThaiCode[251] = "ขออภัยไม่สามารถสมัครได้มากกว่า 1 ตำแหน่ง";
EngCode[251] = "Sorry you can't apply more than one job";

ThaiCode[252] = "ขออภัยไม่สามารถสมัครตำแหน่งซ้ำได้";
EngCode[252] = "Sorry you can't apply for this job \\nBecause you applied this job early";

ThaiCode[253] = "ขออภัยคุณได้ทำการสมัครงานไปแล้วเมื่อไม่นานมานี้";
EngCode[253] = "Sorry you can't apply for this job \\nBecause you recently applied for a job";


// ``, tha: ''}
//----------------------------------------------------------------------

function setLang(lan) {
	lang = lan.toLowerCase();
	// alert(lang);
	setCode();
}

function getLang() {
	return lang;
}

function setSwapLang(swlan) {
	swlang = swlan.toUpperCase();
}

function getSwapLang() {
	return swlang;
}

function setCode() {
	if (getLang() == "tha") {
		MyCode = ThaiCode;
		MyAlert = ThaiAlert;
	} else {
		MyCode = EngCode;
		MyAlert = EngAlert;
	}
}

/*================================================================*/
function swapLang(nodes) {
	var value = swap2String(nodes);
	if (value != null) {
		document.write(value);
	} else {
		document.write(nodes);
	}
}

// end of wut edit 31/10/03
//--------------------------------------------------------------------
function swap2String(nodes) {

	if (objDOM && nodes && getLang() == "tha") {
		var mynodes = nodes;
		var exp = /[\W]/g;
		mynodes = mynodes.replace(exp, "_");
		objMainNode = objDOM.selectSingleNode("/changelanguage/" + mynodes);
		if (objMainNode != null) {
			return objMainNode.firstChild.nodeValue;
		} else {
			//return null;
			//return MyCode[8]
			return nodes;
		}
	} else {
		return nodes;
	}
}
/*===============================================*/

function linkChild(page) {
	with(document.cscform) {
		window.open(page + ".jsp?__gorec=" + __gorec.value + "&__ack=add&__headMulti=" + __headMulti.value + "&__RecNo=" + maxrec.value);
	}
}

function saveChild() {
	if (nullCheck()) {
		with(document.cscform) {
			bCon = confirm(MyCode[1]);
			if (bCon == true) {
				__cmdchild.value = "save";
				submit();
			}
			//submit(); DONOT SUBMIT IF CANCEL
		}
	}
}

function bdOnload() {
	document.cscform.action = __pageCall.value + ".jsp";
	document.cscform.submit();
}

function linkGenXML(page) {
	with(document.cscform) {
		__xmlname.value = xmlname.value;
		action = "/genxml/" + page + ".jsp";
		submit();
	}
}

function backHelp() {
	with(document.cscform) {
		//		alert("__fieldSearch.value = "+__fieldSearch.value+" fieldV = "+fieldV);
		action = __pageCall.value + ".jsp";
		submit();
	}
}


function setcmd(acktion) {
	with(document.cscform) {
		if (acktion == "ack") {
			__gorec.value = __maxrec.value;
			__ack.value = "ack";
		} else if (acktion == "del") {
			__cmdchild.value = "del";

		} else if (acktion == "next") {
			if (__gorec.value < __maxrec.value) {
				__gorec.value++;
			}
		} else if (acktion == "prev") {
			if (__gorec.value > 1) {
				__gorec.value--;
			}
		} else if (acktion == "top") {
			__gorec.value = 1;
		} else if (acktion == "end") {
			__gorec.value = __maxrec.value;
		} else if (acktion == "save") {
			__cmdchild.value = "save";
			__ack.value = "add";
		}
		//alert(acktion+"  "+__gorec.value);
		//action="http://192.100.1.129:8080/aromatic/jsp/"+__screen.value+".jsp";
		submit();
	}
}

function showcscupload(record) {
	with(document.cscform) {
		__gorec.value = record;
		__cmd.value = "Child";
		action = "pwcscupload_show.jsp?__headMulti=" + __screen.value + "&__pwcscupload0=" + record;
		submit();
	}
}

function editcscupload(record) {
	with(document.cscform) {
		__gorec.value = record;
		//__cmd.value="Child";
		action = "pwcscupload_edit.jsp?__headMulti=" + __screen.value + "&__pwcscupload0=" + record;
		submit();
	}
}

function childMulti(record) {
	with(document.cscform) {
		window.open(__childMulti.value + ".jsp?__gorec=" + record + "&__ack=add&__headMulti=" + __headMulti.value + "&__RecNo=" + __maxrec.value,
			"Child", "left=150,top=20,width=700,height=800,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
	}
}

function backhead() {
	var check = true;
	if (((typeof document.cscform.__sysisedit) != "undefined") && (document.cscform.__sysisedit.value == 'true')) {
		aCon = confirm(MyCode[238]); // จะบันทึกหรือไม
		if (aCon == true) {
			check = false;
		}
		if (check) {
			window.close();
		}
		document.cscform.__sysisedit.value = "";
	} else {
		//with(window.opener.document.cscform){
		//bCon=confirm(MyCode[30]);
		//if (bCon==true)	{
		//action=__headMulti.value+".jsp";
		//	__cmd.value="ack";
		//	submit();
		window.close();
		//	}
		//}
	}
}

function addMulti() {
	with(document.cscform) {
		__cmd.value = "";
		__gorec.value = "";
		__ack.value = "add";
		//action=__childMulti.value+".jsp?__headMulti="+__screen.value;
		window.open("CS002.jsp?__gorec= &__ack.value=add",
			"Child", "left=150,top=20,width=700,height=800,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
		//submit();
	}
}

/*
function deleteMulti(){
	with(document.cscform){
	//	alert("aa::"+__cmd.value);
		__cmd.value="DelChild";
	//    action=__screen.value+".jsp";
		submit();
		//alert(__cmd.value);17/2/2547
	}
}
*/
function deleteMulti() {
	with(document.cscform) {
		bCon = confirm(MyCode[4]);
		if (bCon == true) {
			__cmd.value = "DelChild";
			submit();
		}
	}
}

function link(jsppage) {
	with(document.cscform) {
		action = jsppage + ".jsp";
		submit();
	}
}

function savepass() {
	with(document.cscform) {
		if (__pwpassword1.value == __pwpassword2.value) {
			bCon = confirm("ต้องการบันทึกข้อมูลหรือไม่ ?");
			if ((bCon == true) && (__pwpassword.value == __checkpass.value)) {
				__cmd.value = "save";
				__pwpassword.value = __pwpassword1.value;
				action = __screen.value + ".jsp";
				submit();
				alert("โปรด Login เข้าสู่ระบบใหม่");
			} else {
				alert("รหัสผ่านงานเก่าไม่ถูกต้อง");
			}
		} else {
			alert("ยืนยันรหัสผ่านไม่ถูกต้อง");
		}
	}
}


function linkReport(jsppage) {
	with(document.cscform) {
		action = jsppage + ".jsp";
		window.open(jsppage + ".jsp?__id=" + __id.value);
	}
}

function edelete() {
	if (nullCheck()) {
		with(document.cscform) {
			bCon = confirm(MyCode[4]);
			if (bCon == true) {
				//	setAction(__jspname.value,"delete");
				__cmd.value = "delete";
				setSysIsEdit("");
				submit();
			} else {
				if ((typeof __actioned) != "undefined") {
					__actioned.value = "";
				}
			}
		}
	}
}

function refreshEmp() {
	with(document.cscform) {
		if (__afterUpdate.value == "search") {
			__afterUpdate.value = "";
		}
		search();
	}
}

function search() {
	with(document.cscform) {
		if (chAction()) {
			__cmd.value = "search";
			submit();
		}
	}
}

function save() {
	//	saveRecord()
	with(document.cscform) {
		__confirm.value = "0";
		__cmd.value = "save";
		//alert("cmd:"+__cmd.value);
		setSysIsEdit("");
		submit();
	}
}

function saveRecord() {
	if (nullCheck()) {
		with(document.cscform) {
			bCon = confirm(MyCode[1]);
			if (bCon == true) {
				__confirm.value = "s";
				__cmd.value = "save";
				submit();
			}
		}
	}
}

function updateRecord() {
	//	if(nullCheck()){
	with(document.cscform) {
		bCon = confirm(MyCode[3]);
		if (bCon == true) {
			__confirm.value = "s";
			__cmd.value = "save";
			submit();
		}
	}
	//	}
}


function update() {
	saveRecord();
	/*if(nullCheck()){
		with(document.cscform){
			bCon=confirm(MyCode[3]);
			if (bCon==true)	{
				__confirm.value="2";
				__cmd.value = "save";
				submit();
			}
		  }
	   }*/
}

function updateAfterSave() {
	//if(nullCheck()){
	with(document.cscform) {
		bCon = confirm(MyCode[59]);
		if (bCon == true) {
			__confirm.value = "2";
			__cmd.value = "save";
			submit();
		}
	}
	// }
}

/*
function confirmSave(){
	//saveRecord();
	if(nullCheck()){
	with(document.cscform){
				//alert(__confirm.value);
		if((__confirm.value=="0")||(__confirm.value=="3")){
		    	aCon=confirm(MyCode[1]);// จะบันทึกหรือไม่
				if (aCon==true)	{
					save();
				}
		}else {
			alert(MyCode[2]);// ข้อมูลมีอยู่แล้ว
			__confirm.value = "0";
		}
	}
}
}
*/

function confirmSave() {
	//saveRecord();
	if (nullCheck()) {
		with(document.cscform) {
			//aCon=confirm(MyCode[1]);// จะบันทึกหรือไม่
			//if (aCon==true)	{
			save();
			//}
		}
	}
}

function getConfirmIndex(strCon, idx) {
	var tmp = strCon.split("#");
	if (tmp.length == 1) {
		return strCon;
	} else {
		if (idx == "0") {
			return tmp[0];
		} else {
			return tmp[1];
		}
	}
}

function checkConfirm() {
	var conCode = "";
	var conDesc = "";
	with(document.cscform) {
		//alert(__confirm.value);
		conCode = getConfirmIndex(__confirm.value, "0");
		conDesc = getConfirmIndex(__confirm.value, "1");
		if (__confirm.value == "4") alert(MyCode[19]);
		if (__confirm.value == "1" || __confirm.value == "2") alert(MyCode[18]);
		if (__confirm.value == "-1" || __confirm.value == "-2") alert(MyCode[17]);
		if (__confirm.value == "-21") alert("Old password invalid");
		if (conCode == "-99") {
			updateRecord();
		}
		if (__confirm.value == "-98") {
			alert(MyCode[204]);
		}
		if (__confirm.value == "-97") {
			alert(MyCode[205]);
		}
		if (__confirm.value == "-96") {
			alert(MyCode[206]);
		}
		if (__confirm.value == "-11") {
			alert(MyCode[227]);
		}
		if (__confirm.value == "-22") {
			alert(MyCode[227]);
		}
		if (__confirm.value == "-41") {
			alert(MyCode[227]);
		}
	}
}

function save_pwcscupload01() {
	with(document.cscform) {
		bCon = confirm(MyCode[1]);
		if (bCon == true) {
			__cmd.value = "save";
			action = "pwcscupload01" + ".jsp";
			submit();
		}
	}
}

function linkHelp_pwtran(help, input) {
	with(document.cscform) {
		__cmd.value = "help";
		__fixCon.value = "";
		action = "TestHelp.jsp?__helpName=" + help + "&__fieldSearch=" + input + "&__pageCall=" + __screen.value;
		submit();
	}
}

function linkHelp_fc(help, input) {
	with(document.cscform) {
		__cmd.value = "help";
		__cmdchild.value = "save";
		action = "testhelp.jsp?__helpName=" + help + "&__fieldSearch=" + input + "&__pageCall=bgfactorclass1";
		submit();
	}
}

function linkHelp_fc_active(help, input) {
	with(document.cscform) {
		__active.value = "active";
		__cmd.value = "help";
		__cmdchild.value = "save";
		action = "testhelp.jsp?__helpName=" + help + "&__fieldSearch=" + input + "&__pageCall=bgfactorclass1";
		submit();
	}
}

function linkHelp_bgtemp_active(help, input) {
	with(document.cscform) {
		__active.value = "active";
		__cmd.value = "help";
		__cmdchild.value = "save";
		action = "testhelp.jsp?__helpName=" + help + "&__fieldSearch=" + input + "&__pageCall=bgcscuploadtemplate1";
		submit();
	}
}

function linkHelp_bg(help, fieldName, show) {
	with(document.cscform) {
		__cmd.value = "help";
		__cmdchild.value = "save";
		action = "testhelp.jsp?__helpName=" + help + "&__fieldSearch=" + input + "&__pageCall=bgcscuploadgroup1";
		submit();
	}
}

function helpPage(helpName) {
	with(document.cscform) {
		window.open(helpName + ".jsp", "Help", "left=150,top=150,width=800,height=400,toolbar=no,status=yes,scrollbars=yes");
	}
}
//23/09/03 edit by SUK
function linkHelp(help, input) {
	with(document.cscform) {
		obj = eval("document.cscform." + input);
		if (obj.value == "" || obj.value == "0") {
			var param = "PRU084.jsp?__helpName=" + help + "&__fieldSearch=" + input + "&__pageCall=" + __screen.value + "&__fixCon=" + __fixCon.value;
		} else {
			var param = "PRU084.jsp?__helpName=" + help + "&__fieldSearch=" + input + "&__pageCall=" + __screen.value + "&__fixCon=" + __fixCon.value + "&__valueSearch=" + obj.value;
		}
		//var param="PRU084.jsp?__helpName="+help+"&__fieldSearch="+input+"&__pageCall="+__screen.value+"&__fixCon="+__fixCon.value;
		win = window.open(param, "Help", "left=150,top=150,width=800,height=400,resizable=yes,scrollbars=yes,toolbar=no,status=yes");
		if (window.focus) {
			win.focus();
		}
	}
}

function helpPageCon(help, input, fcon) {
	with(document.cscform) {
		var param = "PRU084.jsp?__fixCon=" + fcon + "&__helpName=" + help + "&__helpReturn=" + input + "&__pageCall=" + __screen.value;
		win = window.open(param, "Help", "left=150,top=150,width=800,height=400,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
		if (window.focus) {
			win.focus();
		}
	}
}

function linkHelp_Return(help, input, fixCon) {
	with(document.cscform) {
		var nInput = input;
		var filter = fixCon || __fixCon.value;
		if (input.indexOf(":") > 0) {
			nInput = input.substring(0, input.indexOf(":"));
		}
		obj = eval("document.cscform." + nInput);
		if ((obj == "") || (obj.value == "")) {
			var param = "PRU084.jsp?__helpName=" + help + "&__helpReturn=" + input + "&__pageCall=" + __screen.value + "&__fixCon=" + filter + "&__checkVerify=off";
		} else {
			var param = "PRU084.jsp?__helpName=" + help + "&__helpReturn=" + input + "&__pageCall=" + __screen.value + "&__fixCon=" + filter + "&__checkVerify=off" + "&__valueSearch=" + obj.value;
		}
		//var param="PRU084.jsp?__helpName="+help+"&__helpReturn="+input+"&__pageCall="+__screen.value+"&__fixCon="+filter+"&__checkVerify=off";
		win = window.open(param, "Help", "left=150,top=150,width=800,height=400,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
		if (window.focus) {
			win.focus();
		}
	}
}

//empView
function linkHelp_Return_Empview(help, input, fixCon) {
	with(document.cscform) {
		var nInput = input;
		var filter = fixCon || __fixCon.value;
		if (input.indexOf(":") > 0) {
			nInput = input.substring(0, input.indexOf(":"));
		}
		obj = eval("document.cscform." + nInput);
		if ((obj == "") || (obj.value == "")) {
			var param = "PRU084.jsp?__helpName=" + help + "&__helpReturn=" + input + "&__pageCall=" + __screen.value + "&__fixCon=" + filter + "&__checkVerify=off";
		} else {
			var param = "PRU084.jsp?__helpName=" + help + "&__helpReturn=" + input + "&__pageCall=" + __screen.value + "&__fixCon=" + filter + "&__checkVerify=off" + "&__valueSearch=" + obj.value;
		}
		//var param="PRU084.jsp?__helpName="+help+"&__helpReturn="+input+"&__pageCall="+__screen.value+"&__fixCon="+filter+"&__checkVerify=off";
		win = window.open(param, "Help", "left=150,top=150,width=1100,height=550,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
		if (window.focus) {
			win.focus();
		}
	}
}


// EDIT 26/4/2550 --> Ball
function linkHelpReport_Return(help, input) {
	with(document.cscform) {
		var nInput = input;
		if (input.indexOf(":") > 0) {
			nInput = input.substring(0, input.indexOf(":"));
		}
		obj = eval("document.cscform." + nInput);
		if (obj.value == "") {
			var param = "PRR084.jsp?__helpName=" + help + "&__helpReturn=" + input + "&__pageCall=" + __screen.value + "&__langOn=false" + "&__checkVerify=off";
		} else {
			var param = "PRR084.jsp?__helpName=" + help + "&__helpReturn=" + input + "&__pageCall=" + __screen.value + "&__langOn=false" + "&__checkVerify=off" + "&__valueSearch=" + obj.value;
		}
		window.open(param, "Help", "left=150,top=150,width=800,height=400,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
	}
}

function backMainPage(page) {
	with(document.cscform) {
		__screen.value = "bgcscuploadgroup";
		action = page + ".jsp";
		submit();
	}
}

function backPage(valueList) {
	if ((typeof window.opener.parent.leftFrame) != "undefined") {
		with(window.opener.parent.leftFrame.document.cscform) {
			__sysisedit.value = "true";
		}
	}
	with(window.opener.document.cscform) {
		__help.value = valueList;
		//	alert(__help.value);
		//__cmd.value="multiSearch";

		submit();
		//window.opener.location.refresh();
	}
	window.close();
}

/**
 * Function name :backPage_Return
 * Edit by : James
 * Edit date : 28/10/2551
 */
function backPage_Return(valueList) {
	var tmp = new Array();
	var tmp1 = new Array();
	var inputName = "";
	var inputValue = "";
	if ((typeof window.opener.document.cscform != "undefined") && (typeof window.opener.document.cscform.__sysisedit != "undefined")) {
		with(window.opener.document.cscform) {
			__sysisedit.value = "true";
		}
	} else {
		if ((typeof window.opener.parent.leftFrame) != "undefined") {
			with(window.opener.parent.leftFrame.document.cscform) {
				__sysisedit.value = "true";
			}
		}
	}
	with(window.opener) {
		tmp = valueList.split(";");
		for (var i = 0; i < tmp.length; i++) {
			tmp1 = tmp[i].split("#");
			inputName = tmp1[0];
			inputValue = tmp1[1];
			var inputObj = document.getElementsByName(inputName)[0];
			if (inputObj) {
				inputObj.value = inputValue;
				var event = document.createEvent("HTMLEvents");
				event.initEvent("change", true, true);
				inputObj.dispatchEvent(event)
			}
		}
		//   7/6/2556  bom
		if (typeof postReturn != "undefined") { // เอาให้ทำให้หน้าที่เรียกทำ การsubmit ค่าเพื่อแสดงข้แมูลออกมา
			postReturn();
		}
	}

	window.close();
}

function postReturn() { // how to use it,, An Override in your Page.

}

function goPage(page) {
	with(document.cscform) {
		__goPage.value = page;
		submit();
	}
}

function setOrderby() {
	with(document.cscform) {
		__orderBy.value = __listOrder.options[__listOrder.selectedIndex].value;
		submit();
	}
}

function setSearchby() {
	with(document.cscform) {
		__goPage.value = "1";
		alert(__searchBy.options[__searchBy.selectedIndex].value);
		alert("value" + __valueSearch.value);
		if (__valueSearch.value == "") {
			alert("กรุณาใส่ค่าในการค้นหา");
		} else {
			alert("__valueSearch.value = " + __valueSearch.value);
			submit();
		}
	}
}

function ckreport() {
	with(document.cscform) {
		action = "filereport.jsp";
		submit();
	}
}

function cmdrp() {
	with(document.cscform) {
		__cmd.value = "pdf";
		action = "filereport.jsp";
		submit();
	}
}

function linkStartup(page) {
	with(document.cscform) {
		action = page + ".jsp";
		submit();
	}
}

function goBookPage(page) {
	with(document.cscform) {
		__goPage.value = page;
		action = "show_help.jsp";
		submit();
	}
}

function linkPage(page) {
	with(document.cscform) {
		action = page + ".jsp";
		submit();
	}
}

function viewPayment(pymt) {
	with(document.cscform) {
		__cmd.value = "search";
		__pwsalatype.value = pymt;
		action = __screen.value + ".jsp";
		submit();
	}
}

function showtime() {
	with(document.cscform) {
		__timework.value = "go";
		__cmd.value = "ack";
		submit();
	}
}

function setstatus(status) {
	with(document.cscform) {
		__cmd.value = "save";
		__pwstatus.value = status;
		alert("pwstatus.value = " + __pwstatus.value);
		action = __backpage.value + ".jsp";
		submit();
	}
}

function cancel() {
	with(document.cscform) {
		reset();
	}
}

function editotsingle(record) {
	with(document.cscform) {
		action = "pwotsingle_edit.jsp?__pwot0=" + record;
		submit();
	}
}

function gopwotgroup2() {
	with(document.cscform) {
		action = "pwotgroup2" + ".jsp?__headMulti=" + __screen.value;
		submit();
	}
}

function gopwotgroup1() {
	with(document.cscform) {
		action = __headMulti.value + ".jsp";
		submit();
	}
}

function backpage() {
	with(document.cscform) {
		action = __backpage.value + ".jsp";
		submit();
	}
}

function backPageEmp(fname) {
	with(document.cscform) {
		action = fname;
		window.parent.document.forms[0].gopage.value = fname;
		submit();
	}
}

function gopwdoctran(pwdoctran, pwdoctype, pwstep) {
	with(document.cscform) {
		action = __childMulti.value + ".jsp?__pwdoctran=" + pwdoctran + "&__pwdoctype=" + pwdoctype + "&__pwstep=" + pwstep;
		submit();
	}
}

function send() {
	with(document.cscform) {
		__pwsend.value = "1";
		__cmd.value = "save";
		submit();
	}
}

function changeactor(pwemployee) {
	with(document.cscform) {
		action = __screen.value + ".jsp?__actor=" + pwemployee;
		submit();
	}
}

function genTime() {
	timecode = "";
	with(document.cscform) {
		__cmd.value = "ack";
		if (__timeGroup.value > 0) {
			for (i = 1; i <= __timeGroup.value; i++) {
				temp = document.cscform['__time' + i];
				if (temp.checked) {
					timecode = timecode + temp.value + ",";
				}
			}
			action = __screen.value + ".jsp?__genTime=genTime&__timecode=" + timecode;
			submit();
		}
	}
}

function next(screen) {
	with(document.cscform) {
		__cmd.value = "ack";
		action = screen + ".jsp";
		submit();
	}
}

function backpage1(screen) {
	with(document.cscform) {
		action = screen + ".jsp";
		submit();
	}
}

function logout() {
	with(document.cscform) {
		target = "_top";
		action = "../MAIN.jsp";
		submit();
	}
}

function admin_logout() {
	with(document.cscform) {
		target = "_top";
		action = "admin_logout" + ".jsp?__logout=ok";
		submit();
	}
}

function hilightOn(row) {
	row.setAttribute('bgcolor', '#99FF99', 0);
}

function hilightOff(row) {
	row.setAttribute('bgcolor', '#FFFFFF', 0);
}

function setAction(page, cmd) {
	with(document.cscform) {
		action = page + ".jsp?__cmd=" + cmd;
	}
}

//------------------------------------------------------------------------
// wut edit 15/09/03
//------------------ tooltip -------------------------------------------
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;
offsetX = 5;
offsetY = 5;
var toolTipSTYLE = "";

function initToolTips() {
	if (ns4 || ns6 || ie4) {
		if (ns4)
			toolTipSTYLE = document.toolTipLayer;
		else if (ns6)
			toolTipSTYLE = document.getElementById("toolTipLayer").style;
		else if (ie4)
			toolTipSTYLE = document.all.toolTipLayer.style;

		if (ns4) {
			document.captureEvents(Event.MOUSEMOVE);
		} else {
			toolTipSTYLE.visibility = "visible";
			toolTipSTYLE.display = "none";
		}
		document.onmousemove = moveToMouseLoc;
	}
}

function toolTip(msg) {

	if (toolTip.arguments.length < 1) { // hide
		if (ns4)
			toolTipSTYLE.visibility = "hidden";
		else
			toolTipSTYLE.display = "none";

	} else { // show

		var tableWidth = msg.length + 10;
		var content = "<table border='0' class=\"toolTip\"><tr><td>&nbsp;&nbsp;" + msg + "&nbsp;&nbsp;</td></tr></table>";
		if (ns4) {
			toolTipSTYLE.document.write(content);
			toolTipSTYLE.document.close();
			toolTipSTYLE.visibility = "visible";
			setTimeout("toolTip()", 5000);
		}

		if (ns6) {
			document.getElementById("toolTipLayer").innerHTML = content;
			toolTipSTYLE.display = 'block'
			setTimeout("toolTip()", 5000);
		}

		if (ie4) {
			document.all("toolTipLayer").innerHTML = content;
			toolTipSTYLE.display = 'block'
			setTimeout("toolTip()", 5000);
		}
	}
}

function moveToMouseLoc(e) {
	if (ns4 || ns6) {
		x = e.pageX;
		y = e.pageY;
	} else {
		x = event.x + document.body.scrollLeft;
		y = event.y + document.body.scrollTop;
	}
	toolTipSTYLE.left = (x + offsetX) + 'px';
	toolTipSTYLE.top = (y + offsetY) + 'px';
	return true;
}

function checkAll() {
	with(document.cscform) {
		for (i = 0; i < elements.length; i++) {
			if (elements[i].type == "checkbox") {
				elements[i].checked = true;
			}
		}
	}
}

function decheckAll() {
	with(document.cscform) {
		for (i = 0; i < elements.length; i++) {
			if (elements[i].type == "checkbox") {
				elements[i].checked = false;
			}
		}
	}
}

//------------------------------ cscform null check ----------------------------------------------

// comment by james 6/3/2552
function nullField(idx) {
	with(document.cscform) {
		var fieldName = new Array();
		var returnV = false;
		if ((__notNull.value != "") && (__notNull.value != null)) {
			fieldName = __notNull.value.split(",");
		}
	}
	for (i = 0; i < fieldName.length; i++) {
		tempValue = "__" + fieldName[i];
		if (tempValue == document.cscform.elements[idx].name) {
			returnV = true;
		}
	}
	return returnV;
}
/*
function nullCheck(){
	if(chAction()){
		for (var i=0;i<document.cscform.length;i++){
			if(nullField(i)){
				if(((document.cscform.elements[i].value==null)||(document.cscform.elements[i].value==""))&&(document.cscform.elements[i].type != "hidden")){
					 alert(MyCode[0]);
					 document.cscform.elements[i].focus();
					 with(document.cscform){
							if((typeof __actioned)!="undefined"){
								__actioned.value="";
							}
					}
					return false;
				}
			}
		}
		return true;
	}else{
		return false;
	}
}
*/
function nullCheck() {
	if (chAction()) {
		with(document.cscform) {
			var fieldName = new Array();
			// split __notNull to array
			if ((__notNull.value != "") && (__notNull.value != null)) {
				fieldName = __notNull.value.split(",");
			}
			for (i = 0; i < fieldName.length; i++) {
				var tmpelement = document.getElementsByName("__" + fieldName[i]);
				for (index = 0; index < tmpelement.length; index++) {
					var tmp = tmpelement[index];
					if (tmp.type != "hidden" && (tmp.value == null || tmp.value == "")) {
						alert(MyCode[0]);
						tmp.focus();
						if ((typeof __actioned) != "undefined") {
							__actioned.value = "";
						}
						return false;
					}
				}
			}
		}
		return true;
	} else {
		return false;
	}
}

//------------------------------ cscform NULL check ----------------------------------------------->

//-------------------------------- My Date ------------------------------------------------------------>
function MyDate(lang) {
	NDate = new Date();
	var thday = new Array("อาทิตย์", "จันทร์", "อังคาร", "พุธ", "พฤหัสบดี", "ศุกร์", "เสาร์");
	var engDay = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
	var thmonth = new Array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
	var engMonth = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
	var thDate = thday[NDate.getDay()] + ", " + NDate.getDate() + " " + thmonth[NDate.getMonth()] + " " + (NDate.getFullYear() + 543);
	var engDate = engDay[NDate.getDay()] + ", " + NDate.getDate() + " " + engMonth[NDate.getMonth()] + " " + NDate.getFullYear();
	var result = ""
	if (lang == "tha") {
		result = thDate;
	} else {
		result = engDate;
	}
	document.write(result);
}

function Logout(logPage) {
	with(document.cscform) {
		bCon = confirm("ต้องการออกจากระบบ ?");
		if (bCon == true) {
			action = logPage;
			submit();
		}
	}
}

function printEditCheck(editBy, editDate, editTime, verifyBy) {
	returnValue = "";
	if (Trim(editBy) != "") {
		returnValue = editBy + "_" + " : " + editDate + " : " + editTime;
		if (Trim(verifyBy) != "") {
			returnValue = returnValue + " :: " + verifyBy;
		}
	}
	document.write(returnValue + " ");
}
//pae crate 10/11/2003
//Code >>>>>>> 46=. 48=0 49=1 50=2 51=3 52=4 53=5 54=6 55=7 56=8 57=9
function chkInteger(e) {
	var keyCode = getKeyCode(e);
	if ((keyCode < 48) || (keyCode > 57)) {
		cancelEvents(e);
	}
}

function chkBigDecimal(e) {
	var keyCode = getKeyCode(e);
	if (((keyCode != 46) && (keyCode < 48)) || (keyCode > 57)) {
		cancelEvents(e);
	}
}

//---------  IFRAME Employee ----------------------------------------
function nullCheckIframe() {
	for (var i = 0; i < parent.mframe.document.forms[0].length; i++) {
		if (nullFieldframe(i)) {
			if (((parent.mframe.document.forms[0].elements[i].value == null) || (parent.mframe.document.forms[0].elements[i].value == "")) && (parent.mframe.document.forms[0].elements[i].type != "hidden")) {
				alert(parent.mframe.document.forms[0].elements[i].type + "   " + parent.mframe.document.forms[0].elements[i].name);
				alert(MyCode[0]);
				parent.mframe.document.forms[0].elements[i].focus();
				return false;
			}
		}
	}
	return true;
}

function nullFieldframe(idx) {
	with(parent.mframe.document.forms[0]) {
		var fieldName = new Array();
		var returnV = false;
		if (__notNull.value != "") {
			fieldName = __notNull.value.split(",");
		}
	}
	for (i = 0; i < fieldName.length; i++) {
		tempValue = "__" + fieldName[i];
		if (tempValue == parent.mframe.document.forms[0].elements[idx].name) {
			returnV = true;
		}
	}
	return returnV;
}

function saveIframe() {
	with(parent.mframe.document.forms[0]) {
		__cmd.value = "save";
		submit();
	}
}


function confirmSaveIframe() {
	if (nullCheckIframe()) {
		with(parent.mframe.document.forms[0]) {
			if (__confirm.value == "0") {
				aCon = confirm(MyCode[1]); // จะบันทึกหรือไม่
				if (aCon == true) {
					//					saveIframe();
					__cmd.value = "save";
					submit();
				}
			} else {
				alert(MyCode[2]); // ข้อมูลมีอยู่แล้ว
				__confirm.value = "0";
			}
		}
	}
}

function updateIframe() {
	if (nullCheckIframe()) {
		with(parent.mframe.document.forms[0]) {
			bCon = confirm(MyCode[3]);
			if (bCon == true) {
				__confirm.value = "2";
				__afterUpdate.value = "search";
				__cmd.value = "save";
				submit();
			}
		}
	}
}

function edeleteIframe() {
	with(parent.mframe.document.cscform) {
		bCon = confirm(MyCode[4]);
		if (bCon == true) {
			__cmd.value = "delete";
			submit();
		}
	}
}
//---------------  end of IFRAME Employee
//wut edit
function getInputFormatDate() {
	document.write("<input type=\"hidden\" name=\"__dateformat\" value=\"DD-MM-YYYY\">");
}

function getInputFormatTimestamp() {
	document.write("<input type=\"hidden\" name=\"__dateformat\" value=\"DD/MM/YYYY  00:00:00.000000\">");
}

function getTitleName() {
	document.write("<title>" + systemName + "</title>");
}

function chkDateTimeSave(valueSearch) {
	var tmpval = "";
	with(document.cscform) {
		var valueSearch1 = valueSearch.split("-");
		if (valueSearch1.length == 3) {
			if (valueSearch1[1].length == 1) {
				valueSearch1[1] = "0" + valueSearch1[1];
			}
			if (valueSearch1[0].length == 1) {
				valueSearch1[0] = "0" + valueSearch1[0];
			}
			valueSearch1[2] = parseInt(valueSearch1[2]);
			return valueSearch = valueSearch1[0] + "/" + valueSearch1[1] + "/" + valueSearch1[2];
		}
	}
}

function chkDateTime2(valueSearch) {
	var tmpval = "";
	with(document.cscform) {
		var valueSearch1 = valueSearch.split("/");
		if (valueSearch1.length == 3) {
			if (valueSearch1[1].length == 1) {
				valueSearch1[1] = "0" + valueSearch1[1];
			}
			if (valueSearch1[0].length == 1) {
				valueSearch1[0] = "0" + valueSearch1[0];
			}
			valueSearch1[2] = parseInt(valueSearch1[2]);
			return valueSearch = valueSearch1[2] + "-" + valueSearch1[1] + "-" + valueSearch1[0];
		}
	}
}

function chkHour(e) {
	var keyCode = getKeyCode(e);
	if (((keyCode != 46) && (keyCode < 48)) || (keyCode > 57))
		cancelEvents(e);
}

function checkOverHour(obj) {
	if (obj.value > 24) {
		return false;
	}
	return true;
}

function checkOverMinut(obj) {
	var tmpstr = "";
	if (obj.value.indexOf(".")) {
		tmpstr = obj.value.substring(obj.value.indexOf(".") + 1, obj.value.length);
		if (parseInt(tmpstr) > 60) {
			return false;
		}
	}
	return true;
}

function checkOver(obj) {
	if (checkOverHour(obj) && checkOverMinut(obj)) {
		return true;
	}
	return false;
}


function autoCheckIframe() {
	check = false;
	for (var i = 0; i < document.forms[0].length; i++) {
		if (document.forms[0].elements[i].name == "__autonum") {
			check = true;
			break;
		}
	}
	if (check) {
		for (var i = 0; i < document.forms[0].length; i++) {
			if (autoFieldframe(i)) {
				document.forms[0].elements[i].value = "0";
			}
		}
	}
}

function autoFieldframe(idx) {
	with(document.forms[0]) {
		var fieldName = new Array();
		var returnV = false;
		if (__autonum.value != "") {
			fieldName = __autonum.value.split(",");
		}
	}
	for (i = 0; i < fieldName.length; i++) {
		tempValue = "__" + fieldName[i];
		if (tempValue == document.forms[0].elements[idx].name) {
			returnV = true;
		}
	}
	return returnV;
}
/*****************************************************/
function IsNumber(szStr) {
	for (var i = 0; i < szStr.length; i++) {
		if ("0123456789.".indexOf(szStr.charAt(i)) == -1)
			return false;
	}
	return true;
}

function chkDate(obj) {
	var count = 0;
	if ((window.event.keyCode < 47) || (window.event.keyCode > 57))
		window.event.returnValue = false;
	for (k = 0; k < obj.value.length; k++) {
		if (obj.value.charAt(k) == "/") {
			count++;
		}
	}
	if (window.event.keyCode == 47) {
		count++;
	}
	if (count > 2) {
		if (window.event.keyCode == 47) {
			window.event.returnValue = false;
		}
	}
}

function unCheckBox(objname, objvalue) {
	with(document.cscform) {
		eval(objname + "box.checked!=" + objname + "box.checked");
	}
}

//  Begin Setcookies For Javascript create by pas 31/05/2005
var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays * 24 * 60 * 60 * 1000));

function setBgColor(currentClick) {
	var prevClick = GetCookie('currentClick');
	var prevClickObj;
	SetCookie('currentClick', currentClick.id, exp);
	SetCookie('fontClickColor', currentClick.style.color, exp);
	if (prevClick == null) {
		prevClickObj = currentClick;
	} else {
		prevClickObj = eval(prevClick);
	}
	prevClickObj.style.color = currentClick.style.color;
	prevClickObj.style.backgroundColor = currentClick.style.backgroundColor;
	currentClick.style.color = "#FFFFFF";
	currentClick.style.backgroundColor = "#0080C0";
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf(";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function SetCookie(name, value) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	var namesave = name + "=" + escape(value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
	document.cookie = namesave;
}

function expCookie() {
	var prevClick = GetCookie('currentClick');
	var fontClick = (GetCookie('fontClickColor') != null) ? GetCookie('fontClickColor') : "";
	var prevClickObj;
	if (prevClick != null) {
		prevClickObj = eval(prevClick);
		prevClickObj.style.backgroundColor = "";
		prevClickObj.style.color = fontClick;
		DeleteCookie('currentClick');
		DeleteCookie('fontClickColor');
	}
}

function DeleteCookie(name) {
	var exp = new Date();
	exp.setTime(exp.getTime() - 1);
	var cval = GetCookie(name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

//  End  Setcookies For Javascript create by pas 31/05/2005
function MM_swapImgRestore() { //v3.0
	var i, x, a = document.MM_sr;
	for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d = document;
	if (d.images) {
		if (!d.MM_p) d.MM_p = new Array();
		var i, j = d.MM_p.length,
			a = MM_preloadImages.arguments;
		for (i = 0; i < a.length; i++)
			if (a[i].indexOf("#") != 0) {
				d.MM_p[j] = new Image;
				d.MM_p[j++].src = a[i];
			}
	}
}

function MM_findObj(n, d) { //v4.01
	var p, i, x;
	if (!d) d = document;
	if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
		d = parent.frames[n.substring(p + 1)].document;
		n = n.substring(0, p);
	}
	if (!(x = d[n]) && d.all) x = d.all[n];
	for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
	for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
	if (!x && d.getElementById) x = d.getElementById(n);
	return x;
}

function MM_swapImage() { //v3.0
	var i, j = 0,
		x, a = MM_swapImage.arguments;
	document.MM_sr = new Array;
	for (i = 0; i < (a.length - 2); i += 3)
		if ((x = MM_findObj(a[i])) != null) {
			document.MM_sr[j++] = x;
			if (!x.oSrc) x.oSrc = x.src;
			x.src = a[i + 2];
		}
}
//--------------- end Pas edit 13/07/2005

// set group for menu pas 30/08/2005
function setGroupHeader(myid, flag) {
	with(document.cscform) {
		for (i = 0; i < elements.length; i++) {
			if (elements[i].type == "checkbox" && elements[i].id.indexOf(myid) > -1) {
				elements[i].checked = flag;
			}
		}
	}
}

function setGroup(myid, flag) {
	with(document.cscform) {
		for (i = 0; i < elements.length; i++) {
			if (elements[i].type == "checkbox" && elements[i].id == myid) {
				elements[i].checked = flag;
			}
		}
	}
}

function actionScript(menu, group, flag) {
	setGroupHeader(group, flag);
}

/**
:::::::::::::::::::::::::::::::::: FOR REPORT CONDITION:::::::::::::::::::::::::::::::::::::::::::::
*/
function goSaveCon() {
	conNo = prompt(MyCode[25], document.cscform.__conditionid.value);
	if (conNo != null && conNo != "") {
		var isSave = checkbfSaveCondition(conNo);
		document.cscform.__conditionid.value = conNo;
		if (isSave) {
			bCon = confirm(MyCode[22] + document.cscform.__conditionid.value);
			if (bCon == true) {
				saveCondition();
			}
		} else {
			bCon = confirm(MyCode[63]);
			if (bCon == true) {
				saveCondition();
			}
		}
	}
}


function saveCondition() {
	document.cscform.__cmd.value = "savecon";
	document.cscform.submit();
}

function checkbfSaveCondition(conIndex) {
	var conNo = eval("document.cscform.con" + conIndex);
	if (conNo.value.length > 0)
		return false;
	else
		return true;
}
/**
:::::::::::::::::::::::::::::::::: END FOR REPORT CONDITION:::::::::::::::::::::::::::::::::::::::::::::
*/

//------ end  set group for menu
function lockTextareaChar(obj, maxLength) {
	with(document.cscform) {
		if (obj.value.length > (maxLength - 1)) {
			window.event.returnValue = false;
		}
	}
}

function setValueDate(inputDate) {
	with(document.cscform) {
		document.write(chkDateTime1(inputDate));
	}
}

function chkDateTime1(valueSearch) {
	var tmpval = "";
	with(document.cscform) {
		var valueSearch1 = valueSearch.split("-");
		if (valueSearch1.length == 3) {
			if (valueSearch1[1].length == 1) {
				valueSearch1[1] = "0" + valueSearch1[1];
			}
			if (valueSearch1[0].length == 1) {
				valueSearch1[0] = "0" + valueSearch1[0];
			}
			if (valueSearch1[2].length == 1) {
				valueSearch1[2] = "0" + parseInt(valueSearch1[2]);
			}
			return valueSearch = valueSearch1[2] + "-" + valueSearch1[1] + "-" + valueSearch1[0];
		}
	}
}

function clsPage() {
	with(document.cscform) {
		for (i = 0; i < elements.length; i++) {
			if (elements[i].type == "text") {
				elements[i].value = "";
			}
		}
	}
}

function uploadFile(uploadField, fieldReturn) {
	with(document.cscform) {
		page = "/hr/UPLOADFILE.jsp?uploadfield=" + uploadField + "&fieldreturn=" + fieldReturn;
		var win = window.open(page, "", "height=320,width=650,resizable=0,toolbar=0,scrollbars=1,status=1");
		win.focus();
	}
}

function deleteFile(uploadField, fieldReturn, fileName) {
	if (uploadField != '' && fileName != "") {
		if (confirm(swap2String(swap2String("Confirm delete file")))) {
			page = "/hr/DELETEFILE.jsp?uploadfield=" + uploadField + "&fieldreturn=" + fieldReturn + "&filename=" + fileName;
			var win = window.open(page, "Help", "left=100,top=150,width=800,height=250,toolbar=0,status=1,scrollbars=1");
			win.focus();
		}
	}
}

function showFile() {
	with(document.cscform) {
		var linkfile = __pathfile.value;
		var win = window.open(linkfile, 'Picture', 'width=800,height=800 status=yes,scrollbars=yes,resizable=yes');
		win.focus();
	}
}


//   for getValue from radio button \\
function getRadioValue(buttonGroup) {
	var i = getSelectedRadio(buttonGroup);
	if (i == -1) {
		return "";
	} else {
		if (buttonGroup[i]) {
			return buttonGroup[i].value;
		} else {
			return buttonGroup.value;
		}
	}
}

function getSelectedRadio(buttonGroup) {
	if (buttonGroup[0]) {
		for (var i = 0; i < buttonGroup.length; i++) {
			if (buttonGroup[i].checked) {
				return i
			}
		}
	} else {
		if (buttonGroup.checked) {
			return 0;
		}
	}
	return -1;
}

function Trim(TRIM_VALUE) {
	if (TRIM_VALUE.length < 1) {
		return "";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if (TRIM_VALUE == "") {
		return "";
	} else {
		return TRIM_VALUE;
	}
}

function RTrim(VALUE) {
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if (v_length < 0) {
		return "";
	}
	var iTemp = v_length - 1;

	while (iTemp > -1) {
		if (VALUE.charAt(iTemp) == w_space) {} else {
			strTemp = VALUE.substring(0, iTemp + 1);
			break;
		}
		iTemp = iTemp - 1;

	} //End While
	return strTemp;

} //End Function

function LTrim(VALUE) {
	var w_space = String.fromCharCode(32);
	if (v_length < 1) {
		return "";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while (iTemp < v_length) {
		if (VALUE.charAt(iTemp) == w_space) {} else {
			strTemp = VALUE.substring(iTemp, v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function


function isValidTime(timeStr) {
	// Time validation function courtesty of
	// Sandeep V. Tamhankar (stamhankar@hotmail.com)

	// Checks if time is in HH.MM format.
	// The seconds and AM/PM are optional.

	var timePat = /^(\d{1,2}).(\d{1,2})$/;

	var matchArray = timeStr.match(timePat);
	if (matchArray == null) {
		alert("Time is not in a valid format.");
		return false;
	}
	var hour = matchArray[1];
	var minute = matchArray[2];


	if (hour < 0 || hour > 23) {
		alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
		return false;
	}

	if (minute < 0 || minute > 59) {
		alert("Minute must be between 0 and 59.");
		return false;
	}
	return true;
}

function chkLimitTextArea(obj, limit) {
	if (obj.value.length > limit) {
		alert(MyCode[182]);
		obj.value = obj.value.substr(0, limit);
	}
}

function chkIntColon(e) {
	var keyCode = getKeyCode(e);
	if ((keyCode < 48) || (keyCode > 58))
		cancelEvents(e);
}
/*-----------------------------------------------------------*/
//People Id : chkPeoId<onblur>
function chkPeoId(data) {
	if (data.value.length != "") {
		if (data.value.length != 13) {
			data.value = "";
			alert(MyCode[189]);
			data.focus();
		}
	}
}
/*
 * Tax Payer Id : chkTaxPayerId<onblur>
 * write by james
 */
function chkTaxPayerId(data) {
	if (!((data.value.length == 10) || (data.value.length == 13) || (data.value.length == 0))) {
		alert(MyCode[187]);
		data.focus();
	}
}
/*-----------------------------------------------------------*/
//general card : genCardIn<onkeypress>
function genCardIn(e) {
	var keyCode = getKeyCode(e);
	if (((keyCode < 44) || (keyCode > 45)) && ((keyCode < 97) || (keyCode > 122)) && ((keyCode < 48) || (keyCode > 57)) && ((keyCode < 65) || (keyCode > 90))) {
		cancelEvents(e);
	}
}
///web
function checkWeb(data) {
	if (data.value != "") {
		if (data.value.indexOf(".") < 0) {
			alert(MyCode[181]);
			data.focus();
		}
	}
}
/*-----------------------------------------------------------*/
//rest : restIn<onkeypress>, checRest<onkeyblur>
function restIn(data) {
	var st = data.value.split(":");
	if (st.length < 3)
		chkIntColon();
	else
		chkInteger();
}

function checkRest(data) {
	var st = data.value.split(":");
	if (st.length != 3) {
		alert("please format data same xx:xx:xx");
		data.value = "00:00:00";
		data.focus();
	} else {
		if (st[0] == "") {
			st[0] = "00";
		}
		if (st[1] == "") {
			st[1] = "00";
		}
		if (st[2] == "") {
			st[2] = "00";
		}
		data.value = st[0] + ":" + st[1] + ":" + st[2];
	}
}
/*-----------------------------------------------------------*/
//phone_h : phoneIn<onkeypress>
function phoneIn(e) {
	var keyCode = getKeyCode(e);
	if ((keyCode != 35) && (keyCode != 44) && (keyCode != 45) && (keyCode < 48) || (keyCode > 57)) {
		cancelEvents(e);
	}
}
//phone_m : defPhone<onfocus>
function defPhone(data) {
	if (data.value == "") {
		data.value += "08";
		data.focus();
	}
}

function chkCode(e) {
	var keyCode = getKeyCode(e);
	alert(keyCode);
}

function chkTall(data) {
	if (data.value != "") {
		if (data.value.length < 2) {
			alert("data format invalid");
			data.focus();
		}
	}
}
//=============================================================================================================
//	Work 2.	ปี 1 มีไม่เกิน 366 วัน
//	des		:	Check Day of year	|			event		:	Onblur
//	send	:	Object				|			auther	:	Ball
function chkDY(obj) {
	if (obj.value > 366) {
		alert(MyCode[186]);
		obj.focus();
	}
}
//=============================================================================================================
//	Work 3.	ตรวจสอบรหัสไปรษณีย์
//	des		:	Check Zipcode			|			event		:	Onblur
//	send	:	Object					|			auther	:	Ball
function chkZipCode(obj) {
	if (obj.value != '' && obj.value.length != 5) {
		alert(MyCode[163]);
		obj.focus();
	}
}
//=============================================================================================================
//	Work 4. ตรวจสอบเวลา
//	des		:	Check Time				|			event	:	ONBLUR
//	send	:	Object					|			auther	:	Ball
//	input size	:	4					|			format	:	####
function chkTime(obj) {
	if (obj.value != '') {
		deldotTime(obj);
		if (obj.value.length > 4) {
			obj.value = obj.value.substring(0, 4);
		}
		if (obj.value.length <= 2) {
			obj.value = obj.value + '00';
		}
		if (obj.value == 0) {
			obj.value = '0.00';
		} else if (obj.value.length == 4) {
			chkOverTime(obj);
		} else if (obj.value.length == 3) {
			chkOverTime2(obj);
		} else {
			alert(MyCode[164]);
		}
	} else {
		obj.value = '0.00';
	}
}
//	Work 4.1. ตรวจสอบช่วงของเวลา
//	des		:	Check DifferenceTime	|			event	:	ONBLUR
//	send	:	Object , Object2		|			auther	:	Ball
//	input size	:	4					|			format	:	####
function chkDifTime(obj1, obj2) {
	chkTime(obj1);
	chkTime(obj2);
	if ((obj1.value * 1) > (obj2.value * 1)) {
		obj2.value = obj1.value;
		obj2.value.focus();
	}
}

function chkDifTime1(obj1, obj2, obj3) {
	chkTime(obj1);
	chkTime(obj2);
	chkTime(obj3);
	if ((obj2.value * 1) > (obj3.value * 1)) {
		alert(MyCode[165]);
		obj1.value = obj2.value;
		obj2.focus();
	}
	if ((obj1.value * 1) > (obj2.value * 1)) {
		alert(MyCode[166]);
		obj1.value = '0.00';
		obj1.focus();
	}
}
//	Work 4.2. ลบจุดเวลาใช้ร่วมกับ chkTime และ chkDifTime
//	des		:	Delete dot Time		|			event		:	-
//	send	:	Object				|			auther	:	Ball
function deldotTime(obj) {
	if (obj.value.indexOf('.') != -1) {
		var temp = obj.value.split('.');
		obj.value = temp[0] + '' + temp[1];
	}
}
//	Work 4.3. เช็คเวลาใช้ร่วมกับ chkTime , deldotTime และ chkDifTime
//	des		:	Check Time and input . (dot)		|			event		:	-
//	send	:	Object								|			auther	:	Ball
function chkOverTime(obj) {
	var str1 = obj.value.substring(0, 2);
	var str2 = obj.value.substring(2);
	if ((str1 * 1) > 23) {
		alert(MyCode[160] + "23");
		obj.value = '0.00';
		obj.focus();
	} else if ((str2 * 1) > 59) {
		alert(MyCode[161] + "59");
		obj.value = '0.00';
		obj.focus();
	} else {
		obj.value = str1 + '.' + str2;
	}
}
//	Work 4.4. เช็คเวลาใช้ร่วมกับ chkTime , deldotTime และ chkDifTime
//	des		:	Check Time and input . (dot)		|			event		:	-
//	send	:	Object								|			auther	:	Ball
function chkOverTime2(obj) {
	var str1 = obj.value.substring(0, 1);
	var str2 = obj.value.substring(1);
	if ((str2 * 1) > 59) {
		alert(MyCode[161] + "59");
		obj.value = '0.00';
		obj.focus();
	} else {
		obj.value = str1 + '.' + str2;
	}
}
//=============================================================================================================
// Input only Number
function chkInteger(e) {
	var keyCode = getKeyCode(e);
	if ((keyCode < 48) || (keyCode > 57))
		cancelEvents(e);
}
//=============================================================================================================
/// ABOUT FUNCTION IS :: Input Eng Only <onKeypress>
/// RETURN TO CAUSE
function chkEng(e) {
	var keyCode = getKeyCode(e);
	if ((keyCode > 3584) && (keyCode < 3674))
		cancelEvents(e);
}
//=============================================================================================================
/// ABOUT FUNCTION IS :: Input Thai Only <onKeypress>
/// RETURN TO CAUSE
function chkThai(e) {
	var keyCode = getKeyCode(e);
	if ((keyCode < 3584) || (keyCode > 3670))
		cancelEvents(e);
}
//=============================================================================================================
function chkNotThaiChaOnly(e) {
	var keyCode = getKeyCode(e);
	if (keyCode >= 3585 && keyCode <= 3673) {
		cancelEvents(e);
	}
}

function chkMidOnMax(max, min, mid) {
	if (parseFloat(max.value) > 0 && parseFloat(min.value) > 0) {
		var num1 = parseFloat(delComma(max.value));
		var num2 = parseFloat(delComma(min.value));
		if (num1 > num2) {
			mid.value = (num1 + num2) / 2;
			checkNumFloat(mid, 0.00, 9000000);
		} else {
			alert("please input number morethan " + min.value);
			mid.value = "0.00"
		}
	} else {
		mid.value = "0.00";
		if (parseFloat(max.value) > 0 && parseFloat(min.value) <= 0) {
			min.focus();
		}
	}
	if (max.value != "" && parseFloat(max.value) >= 0) {
		checkNumFloat(max, 0.00, 9000000);
	} else {
		max.value = "0.00";
	}
}

function chkMidOnMin(min, max, mid) {
	/*
	if(parseFloat(max.value)>0&&parseFloat(min.value)>0)
	{
		var num1 = parseFloat(delComma(max.value));
		var num2 = parseFloat(delComma(min.value));
		if(num1>num2)
		{mid.value = (num1+num2)/2;
		checkNumFloat(mid,0.00,9000000);}
		else
		{alert("please input number lessthen "+max.value); mid.value = "0.00"}
	}else{ mid.value = "0.00";
		if(parseFloat(max.value)<=0&&parseFloat(min.value)>0)
		{max.focus();}
	}
	if(min.value!=""&&parseFloat(max.value)>=0)
	{checkNumFloat(min,0.00,9000000);}else{ min.value = "0.00";} */
	//==================== sin edit =========================
	checkNumFloat(min, 0, 9999999);
	chkMoreThen(min, max); //ตรวจสอบดูว่า max มากกว่า min หรือไม่
	if ((min.value.length > 0) && (max.value.length > 0)) {
		var tempmax = delComma(max.value);
		var tempmin = delComma(min.value);
		//alert("max = "+eval(tempmax)+"min = "+eval(tempmin));
		mid.value = (eval(tempmax) + eval(tempmin)) / 2;
		checkNumFloat(mid);
	} else if ((max.value.length > 0) && (min.value.length == 0)) {
		min.focus();
	} else if ((min.value.length > 0) && (max.value.length == 0)) {
		max.focus();
	}
}

function chkMidOnMax(max, min, mid) {
	/*
	if(parseInt(max.value)>0&&parseInt(min.value)>0)
	{
		var num1 = parseInt(delComma(max.value));
		var num2 = parseInt(delComma(min.value));
		if(num1>num2)
		{checkNumInt(mid,0,900000000);}
		else
		{alert("please input number morethan "+min.value);}
	}else{
		if(parseInt(max.value)>0&&parseInt(min.value)<=0)
		{min.focus();}
	}
	if(max.value!=""&&parseInt(max.value)>=0)
	{checkNumInt(max,0.00,900000000);}else{ max.value = "0.00";} */
	//=========================== sin edit ============================
	checkNumFloat(max, 0, 9999999);
	chkMoreThen(min, max); //ตรวจสอบดูว่า max มากกว่า min หรือไม่
	if ((min.value.length > 0) && (max.value.length > 0)) {
		var tempmax = delComma(max.value);
		var tempmin = delComma(min.value);
		//alert("max = "+tempmax+"min = "+tempmin);
		mid.value = (eval(tempmax) + eval(tempmin)) / 2;
		checkNumFloat(mid);
	} else if ((max.value.length > 0) && (min.value.length == 0)) {
		min.focus();
	} else if ((min.value.length > 0) && (max.value.length == 0)) {
		max.focus();
	}
}

function chkOnMid(obj, objmin, objmax) {
	/*
	if(parseInt(max.value)>0&&parseInt(min.value)>0)
	{
		var num1 = parseInt(delComma(max.value));
		var num2 = parseInt(delComma(min.value));
		if(num1>num2)
		{checkNumInt(mid,0.00,900000000);}
		else
		{alert("please input number lessthen "+max.value);}
	}else{
		if(parseInt(max.value)<=0&&parseInt(min.value)>0)
		{max.focus();}
	}
	if(min.value!=""&&parseInt(max.value)>=0)
	{checkNumInt(min,0.00,900000000);}else{ min.value = "0.00";} */
	var tempmin = delComma(objmin.value);
	var tempmax = delComma(objmax.value);
	if (obj.value != "") {
		obj.value = parseFloat(obj.value) + ""; // แปลงจาก 01234.xx เป็น 1234.xx
		checkInputComma(obj); // ถ้าพิม xxx ก็ให้เป็น xxx.00
		callMaxMin(obj, eval(tempmin), eval(tempmax)); // ตรวจดูว่าค่าที่กรอกเกินค่าสูงสุด หรือต่ำกว่าค่าต่ำสุดหรือไม่
		insertComma(obj); //123456 ==> 123,456
	}
}

function chkCheckBoxAllSel(str) {
	with(document.cscform) {
		for (i = 0; i < elements.length; i++) {
			if ((elements[i].type == "checkbox") && (elements[i].name.indexOf(str) >= 0))
				elements[i].checked = true;
		} //end for
	} //end with
} //end function
function chkCheckBoxAllDel(str) {
	with(document.cscform) {
		for (i = 0; i < elements.length; i++) {
			if ((elements[i].type == "checkbox") && (elements[i].name.indexOf(str) >= 0))
				elements[i].checked = false;
		} //end for
	} //end with
} //end function


//____________________________________________________________________
//check year1 < year2 onblur
function chkOnYear1(data1, data2) {
	chkTrueYear(data1);
	if (chkLimitYear(data2)) {
		if (parseInt(data1.value) > parseInt(data2.value) && parseInt(data2.value) != 0) {
			alert(MyCode[108] + data2.value);
			data1.value = data2.value;
			data1.focus();
		}
	}
}

function chkOnYear2(data1, data2) {
	chkTrueYear(data2);
	if (chkLimitYear(data1)) {
		if (parseInt(data1.value) > parseInt(data2.value) && parseInt(data1.value) != 0) {
			alert(MyCode[108] + data1.value);
			data2.value = data1.value;
			data2.focus();
		}
	}
}
//____________________________________________________________________


/*
 * function name : chkMinMax
 * write by : james
 */
function chkMinMax(min, max, active) {
	with(document.cscform) {
		if (min.value > max.value) {
			max.value = min.value;
			if (active == "max")
				alert(MyCode[104]);
			max.focus();
		}
	}
}

function showMess() {
	with(document.cscform) {
		if ((typeof __shortmessage) != "undefined") {
			if (__shortmessage.value.length > 1)
				alert(__shortmessage.value);
		}
	}
}

//function FOR TIME (02042007) onblur = chkTimeOver(time), onkeypress = chkInteger(time), onfocus = delDot(time)
function chkTimeOver(time, maxhour, minhour) {
	var hour;
	if (time.value != "" && time.value != 0) {
		if (time.value.length < 3) {
			alert(MyCode[153]);
			time.value = "0.00";
			time.focus();
		} else {
			if (parseInt(time.value.substring((time.value.length - 2), time.value.length)) >= 60) {
				alert(MyCode[154] + " <= 59");
				time.value = "0.00";
				time.focus();
			} else {
				hour = parseFloat(time.value.substring(0, (time.value.length - 2)));
				time.value = "" + parseFloat(time.value.substring(0, (time.value.length - 2))) + "." + time.value.substring((time.value.length - 2), time.value.length);
				if (hour > maxhour) {
					alert(MyCode[155] + " <= " + maxhour);
					time.value = "0.00";
					time.focus();
				} else {
					if (hour < minhour) {
						alert(MyCode[155] + " >= " + minhour);
						time.value = "0.00";
						time.focus();
					}
				}
			}
		}
	} else {
		time.value = "0.00";
	}
}

function delDot(data) {
	var n_data = data.value.split(".");
	data.value = "";
	for (var i = 0; i < n_data.length; i++) {
		data.value += n_data[i];
	}
	data.focus();
}

function chkTwoTime(time1, time2, position) {
	if (time1.value != "" && time2.value != "" && time1.value.length > 2 && time2.value.length > 2) {
		if (parseFloat(time1.value) > parseFloat(time2.value)) {
			if (position == 1) {
				time2.focus();
			} else {
				if (position == 2) {
					if (getLang() == "tha") {
						alert("กรุณาใส่เวลาสิ้นสุดมากกว่าเวลาเริ่มต้น");
					} else {
						alert("please input end time morethan start time");
					}
					time2.value = time1.value;
					time2.focus();
				}
			}
		}
	}
}

function calTwoTime(time1, time2, ttime) {
	if (time1.value != "" && time2.value != "") {
		if (parseFloat(time1.value) <= parseFloat(time2.value)) {
			var tmp = time1.value.split(".");
			var tm1 = (tmp[0] * 60) + parseInt(tmp[1]);
			tmp = time2.value.split(".");
			var tm2 = (tmp[0] * 60) + parseInt(tmp[1]);
			var tmpMin = ((tm2 - tm1) % 60) + "";
			if (tmpMin.length < 2) {
				tmpMin = "0" + tmpMin;
			}
			var tmpMax = parseInt(((tm2 - tm1) / 60)) + "";
			ttime.value = tmpMax + "." + tmpMin;
		} else {
			ttime.value = "0.00";
		}
	} else {
		ttime.value = "0.00";
	}
}
//function FOR TIME ______________________________________________________________________

function passValue() {
	with(document.cscform) {
		if (__fieldSearch.value.length > 0) {
			var conNo = eval("window.opener.document.cscform." + __fieldSearch.value);
			if (__valueSearch.value.length == 0) {
				__valueSearch.value = conNo.value;
			}
		} else {
			if (__helpReturn.value.length > 0) {
				var inputName;
				if (__helpReturn.value.indexOf(":") > 0) inputName = __helpReturn.value.substring(0, __helpReturn.value.indexOf(":"));
				var conNo = eval("window.opener.document.cscform." + inputName);
				if (__valueSearch.value.length == 0) {
					__valueSearch.value = conNo.value;
				}
			}
		}
	}
}


//REST---------------------------------------------
function chkRest(data) {
	if ((data.value != "") && (parseFloat(data.value) != 0)) {
		for (; data.value.length < 6;) {
			data.value = "0" + data.value;
		}
		var d = data.value.substring(0, 2);
		var h = data.value.substring(2, 4);
		var m = data.value.substring(4, 6);
		if (parseFloat(m) >= 60) {
			m = "" + (parseFloat(m) - 60);
			h = "" + (parseFloat(h) + 1);
			if (h.length < 2) {
				h = "0" + h;
			}
			if (m.length < 2) {
				m = "0" + m;
			}
		}
		if (parseFloat(h) >= 24) {
			var tmp = ("" + (parseFloat(h) / 24)).split(".");
			d = "" + (parseFloat(d) + parseFloat(tmp[0]));
			h = "" + (parseFloat(h) % 24);
			if (d.length < 2) {
				d = "0" + d;
			}
			if (h.length < 2) {
				h = "0" + h;
			}
		}
		if (parseFloat(d) > 50) {
			alert("date format not over 50");
			data.value = "00:00:00";
		} else {
			data.value = d + ":" + h + ":" + m;
		}
	} else {
		data.value = "00:00:00";
	}
}

function delRest(data) {
	if (data.value != "") {
		var tmp = "",
			r = data.value.split(":");
		for (var i = 0; i < r.length; i++) {
			tmp += r[i];
		}
		data.value = tmp;
	}
}
//REST---------------------------------------------

function sysIsEdit() {
	if ((typeof document.cscform.__sysisedit) != "undefined") {
		with(document.cscform) {
			if (typeof __sysisedit != "undefined") {
				__sysisedit.value = "true";
			}
		}
	} else if ((typeof parent.document.cscform.__sysisedit) != "undefined") {
		with(parent.document.cscform) {
			if (typeof __sysisedit != "undefined") {
				__sysisedit.value = "true";
			}
		}
	} else if ((typeof parent.parent.document.cscform.__sysisedit) != "undefined") {
		with(parent.parent.document.cscform) {
			if (typeof __sysisedit != "undefined") {
				__sysisedit.value = "true";
			}
		}
	} else if ((typeof parent.parent.parent.document.cscform.__sysisedit) != "undefined") {
		with(parent.parent.parent.document.cscform) {
			if (typeof __sysisedit != "undefined") {
				__sysisedit.value = "true";
			}
		}
	}
}

function setSysIsEdit(data) {
	if ((typeof document.cscform.__sysisedit) != "undefined") {
		with(document.cscform) {
			if (typeof __sysisedit != "undefined") {
				__sysisedit.value = data;
			}
		}
	} else if ((typeof parent.document.cscform.__sysisedit) != "undefined") {
		with(parent.document.cscform) {
			if (typeof __sysisedit != "undefined") {
				__sysisedit.value = data;
			}
		}
	} else if ((typeof parent.parent.document.cscform.__sysisedit) != "undefined") {
		with(parent.parent.document.cscform) {
			if (typeof __sysisedit != "undefined") {
				__sysisedit.value = data;
			}
		}
	} else if ((typeof parent.parent.parent.document.cscform.__sysisedit) != "undefined") {
		with(parent.parent.parent.document.cscform) {
			if (typeof __sysisedit != "undefined") {
				__sysisedit.value = data;
			}
		}
	}
}

function getSysIsEdit() {
	var sysisedit = "";
	if ((typeof document.cscform.__sysisedit) != "undefined") {
		with(document.cscform) {
			if (typeof __sysisedit != "undefined") {
				sysisedit = __sysisedit.value;
			}
		}
	} else if ((typeof parent.document.cscform.__sysisedit) != "undefined") {
		with(parent.document.cscform) {
			if (typeof __sysisedit != "undefined") {
				sysisedit = __sysisedit.value;
			}
		}
	} else if ((typeof parent.parent.document.cscform.__sysisedit) != "undefined") {
		with(parent.parent.document.cscform) {
			if (typeof __sysisedit != "undefined") {
				sysisedit = __sysisedit.value;
			}
		}
	} else if ((typeof parent.parent.parent.document.cscform.__sysisedit) != "undefined") {
		with(parent.parent.parent.document.cscform) {
			if (typeof __sysisedit != "undefined") {
				sysisedit = __sysisedit.value;
			}
		}
	}
	return sysisedit;
}

/*function removeSysEdit(data){
	if ((typeof window.parent.document.cscform)!="undefined"){
		with(document.cscform){
			__sysisedit.value="false";
		}
	}
}*/
//============== FOR COPY VALUE TO FIELD ========================
function passValue(obj1, obj2) {
	with(document.cscform) {
		var temp = obj1.value;
		var temp1 = eval(obj1.value);
		var temp2 = eval(obj2.value);
		//alert(temp1+" == "+temp2)
		if (temp1 < temp2) {
			obj2.value = temp;
		}
	}
}

/************************ nuball  *******************************/
function chAction() {
	with(document.cscform) {
		if ((typeof __actioned) != "undefined") {
			if (__actioned.value == "1") {
				alert(MyCode[175]);
				__actioned.value = "";
				return false;
			} else {
				__actioned.value = "1";
				return true;
			}
		}
	}
	return true;
}

/*******************************************************/

// ============================================= My Alert Of Sin ====================================================== //
// ============================================= อย่าลบหรือเพิ่มต่อนะคับ =================================================== \\
var EngAlert = new Array();
var ThaiAlert = new Array();
var MyAlert = new Array();

EngAlert[1] = "Please Input value ";
ThaiAlert[1] = "กรุณากรอกค่า ";

EngAlert[2] = " to ";
ThaiAlert[2] = " ถึง ";

EngAlert[3] = " only ";
ThaiAlert[3] = " เท่านั้น ";

EngAlert[4] = "Please input year marry more then year birthday !";
ThaiAlert[4] = "กรุณากรอกปีแต่งงานให้มากกว่าวันเกิด";

EngAlert[5] = "Please input year marry less then year present! ";
ThaiAlert[5] = "กรุณากรอกปีแต่งงานให้น้อยกว่าวันปัจจุบัน";

EngAlert[6] = "Please input year marry again, Becouse ";
ThaiAlert[6] = "กรุณาใส่ปีแต่งงานใหม่ เพราะว่า ";

EngAlert[7] = " More Then ";
ThaiAlert[7] = " มากกว่า ";

EngAlert[8] = " Less Than ";
ThaiAlert[8] = " น้อยกว่า ";

EngAlert[9] = "Please Input Min Value";
ThaiAlert[9] = "กรุณาใส่ค่าต่ำสุด";

EngAlert[10] = "Please Input Max Value";
ThaiAlert[10] = "กรุณาใส่ค่าสูงสุด";

EngAlert[11] = "Input E-Mail name,Please";
ThaiAlert[11] = "ไม่ได้ใส่ชื่ออีเมล์ [ ตัวอย่าง ] username@hostname.com ";

EngAlert[12] = "May be you forgot @ [ Ex. ] username@hostname.com";
ThaiAlert[12] = "ไม่ได้ใส่ @ [ ตัวอย่าง ] username@hostname.com ";

EngAlert[13] = "One E-Mail one @ [ Ex. ] username@hostname.com";
ThaiAlert[13] = "ใส่ @ เกิน [ ตัวอย่าง ] username@hostname.com ";

EngAlert[14] = "Why after @ have not dot [ Ex. ] username@hostname.com";
ThaiAlert[14] = "หลัง @ ไม่ได้ใส่ . หลังชื่อเว็บไซต์ [ ตัวอย่าง ] username@hostname.com ";

EngAlert[15] = "Where host name ? [ Ex. ] username@hostname.com";
ThaiAlert[15] = "ไม่ได้ชื่อเว็บไซต์ [ ตัวอย่าง ] username@hostname.com";

EngAlert[16] = "Please input number 0 - 100 becouse you use percent";
ThaiAlert[16] = "กรุณากรอกเลข 0-100 เท่านั้น เพราะว่ากำลังเลือกเป็นเปอร์เซ็นต์";

EngAlert[17] = "Input number mobile phone ";
ThaiAlert[17] = "กรอกเบอร์โทรศัพท์มือถือ ";

EngAlert[18] = " false EX:: 0812345678";
ThaiAlert[18] = " ผิด [ ตัวอย่าง ] 12345678 หรือ 0812345678 ";

EngAlert[19] = " less then EX:: 12345678 or 0812345678 ";
ThaiAlert[19] = " น้อยกว่า [ ตัวอย่าง ] 12345678 หรือ 0812345678 ";

EngAlert[20] = " more then EX:: 12345678 or 0812345678 ";
ThaiAlert[20] = " มากกว่า [ ตัวอย่าง ] 12345678 หรือ 0812345678 ";

EngAlert[21] = "Please Input End Date Agian :: EX. 01012000(01-01-2000)";
ThaiAlert[21] = "กรุณากรอกวันที่สุดท้ายอีกครั้ง [ ตัวอย่าง ] 01012000(01-01-2000)";

EngAlert[22] = "Please Input Start Date :: EX. 01012000(01-01-2000)";
ThaiAlert[22] = "กรุณากรอกวันที่เริ่มต้น [ ตัวอย่าง ] 01012000(01-01-2000)";

EngAlert[23] = "Please Input End Date :: EX. 01012000(01-01-2000)";
ThaiAlert[23] = "กรุณากรอกวันที่สุดท้าย [ ตัวอย่าง ] 01012000(01-01-2000)";

EngAlert[24] = "Please input Thai year OR Eng Year! EX :: 2007 , 2550(2007)";
ThaiAlert[24] = "กรุณากรอกปีไทยหรือปีอังกฤษ [ ตัวอย่าง ] 2007 , 2550(2007)";

EngAlert[25] = "Please Input date not over 100 year! EX :: 2007 , 2550(2007)";
ThaiAlert[25] = "กรอกวันที่ห้ามมากกว่า 100 นับจากวันปัจจุบัน [ ตัวอย่าง ] 2007 , 2550(2007)";

EngAlert[26] = " Year ";
ThaiAlert[26] = " ปี ";

EngAlert[27] = " Month ";
ThaiAlert[27] = " เดือน ";

EngAlert[28] = " Day ";
ThaiAlert[28] = " วัน ";

EngAlert[29] = "Input date false! (System default is date present)";
ThaiAlert[29] = "กรอกวันที่ผิด (ระบบจะใส่ค่าวันที่ให้เป็นวันปัจจุบัน)";

EngAlert[30] = " Don't input character , Please input number 0-9 only ";
ThaiAlert[30] = " ห้ามกรอกตัวอักษรในช่องรูปแบบของวันที่ ";

EngAlert[31] = "Please Input Date! Ex. 31012006 (31-01-2006)";
ThaiAlert[31] = "กรุณากรอกวันที่ 8 ตัวเลข  [ ตัวอย่าง ] 31122006 (31-12-2006)";

EngAlert[32] = "Date more then 80 year or less then 80 year! Ex. 31012006 (31-01-2006) ";
ThaiAlert[32] = "ห้ามกรอกวันที่มากกว่า 80 ปี หรือ น้อยกว่า 80 ปีนับจากวันปัจจุบัน [ ตัวอย่าง ] 31012006 (31-01-2006) "; //32

EngAlert[33] = "Please input date again, Because ";
ThaiAlert[33] = "กรุณากรอกวันที่ใหม่ เพราะว่า  ";

EngAlert[34] = "input date more then date present ";
ThaiAlert[34] = "วันที่กรอกมากกว่าวันที่ปัจจุบัน ";

EngAlert[35] = " Can't input birthday less then ";
ThaiAlert[35] = " ห้ามใส่วันเกิดน้อยกว่า";

EngAlert[36] = "Start date more then end date is false, Please check end date or start date again!";
ThaiAlert[36] = "วันที่เริ่มต้นห้ามมากกว่าวันที่สุดท้าย, กรุณาตรวจสอบวันที่เริ่มต้นหรือสุดท้ายใหม่";

EngAlert[37] = "input date less then date present ";
ThaiAlert[37] = "วันที่กรอกน้อยกว่าวันที่ปัจจุบัน ";

EngAlert[38] = "Please Input Date! Ex. 20060131 (2006-01-31)";
ThaiAlert[38] = "กรุณากรอกวันที่ 8 ตัวเลข  [ ตัวอย่าง ] 20060131 (2006-01-31)";

EngAlert[39] = "Date more then 80 year or less then 80 year! Ex. 20060131 (2006-01-31) ";
ThaiAlert[39] = "ห้ามกรอกวันที่มากกว่า 80 ปี หรือ น้อยกว่า 80 ปีนับจากวันปัจจุบัน [ ตัวอย่าง ] 20060131 (2006-01-31) ";

MyAlert = ThaiAlert;

// ============================================= My Script Of Sin ===================================================== //
// ============================================= อย่าลบหรือเพิ่มต่อนะคับ =================================================== \\

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบตัวเลข nummin ต้องน้อยกว่า numcheck และ nummax ต้องมากกว่า numcheck ถ้าไม่ถูกจะ retrun ค่า false
/// WANING :: NUMCHECK NUMMIN AND NUMMAX ==> INTEGER
/// ACTION :: RETURN BOOLEAN <PROCESS>
function checkMaxMin(numcheck, nummin, nummax) {
	if ((parseFloat(numcheck) > parseFloat(nummax)) || (parseFloat(numcheck) < parseFloat(nummin)))
		return false;
	else
		return true;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบตัวเลข max และ min
/// ACTION :: RETURN ALERT <PROCESS>
/* CALL ::
					checkMaxMin(obj,nummin,nummax)
*/
function callMaxMin(obj, min, max) {
	if (!checkMaxMin(obj.value, min, max)) {
		alert(MyAlert[1] + min + MyAlert[2] + max + MyAlert[3]);
		obj.value = min;
		obj.focus();
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ใส่ลูกน้ำให้ตัวเลข เช่น 123456.00 จะเป็น 123,456.00
/// ACTION :: RETURN VALUE GIVE OBJECT <PROCESS>
function insertComma(obj) {
	var formatnum = '',
		checkcomma = 0,
		text, tempindexcomma = obj.value.indexOf(".");

	if (tempindexcomma >= 0)
		text = obj.value.substring(0, tempindexcomma); // ตรวจสอบค่า obj มีจุดทศนิยม
	else
		text = obj.value; // ตรวจสอบค่า obj ไม่มีจุดทศนิยม
	for (var i = text.length; i > 0; i--) {
		if (checkcomma == 3) {
			formatnum = text.substring(i - 1, i) + ',' + formatnum;
			checkcomma = 1;
		} else {
			formatnum = text.substring(i - 1, i) + formatnum;
			checkcomma++;
		}
	}

	if (tempindexcomma >= 0) // ถ้ามีจุดทศนิยมจะทำการการส่งค่าเป็นแบบทศนิยม
		formatnum = formatnum + obj.value.substring(tempindexcomma, obj.value.length);
	obj.value = formatnum;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ใส่จุดทศนิยมให้ เช่น 123 เป็น 123.00
/// WANING :: ก่อนเรียกสคริปนี้ค่าที่ส่งมาต้องมีจุด ( . ) แค่จุดเดียว
/// ACTION :: RETURN VALUE GIVE OBJECT <PROCESS>
function checkInputComma(obj) {
	var temp = obj.value.split(".");
	if (temp.length == 2) {
		if (temp[1].length == 0) {
			obj.value = obj.value + "00";
		} else if (temp[1].length == 1) {
			obj.value = obj.value + "0";
		}
	} else {
		obj.value = obj.value + ".00";
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ใส่จุดทศนิยมให้ เช่น 123. เป็น 123.00
/// WANING :: ก่อนเรียกสคริปนี้ค่าที่ส่งมาต้องมีจุด ( . ) แค่จุดเดียว
/// ACTION :: RETURN VALUE GIVE OBJECT <PROCESS>
function checkInputComma2(obj) {
	var temp = obj.value.split(".");
	if (temp.length == 2) {
		if (temp[1].length == 0)
			obj.value = obj.value + "00";
		else if (temp[1].length == 1) {
			obj.value = obj.value + "0";
		}
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ลบลูกน้ำออกจากตัวเลข เช่น 123,456.00 เป็น 123456.00>
/// ACTION :: RETURN STRING <PROCESS>
function delComma(str) {
	var formatdelcomm = '',
		checkcomma = 0;
	for (var i = str.length; i > 0; i--) {
		if (str.substring(i - 1, i) != ",") formatdelcomm = str.substring(i - 1, i) + formatdelcomm;
	}
	return formatdelcomm;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจดูว่าค่า max มากกว่า min
/// ACTION :: RETURN BOOLEAN <PROCESS>
function chkNumDiff(num1, num2) {
	if (eval(num2) >= eval(num1))
		return true;
	else
		return false;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบวันที่เริ่มต้น ( strstart [ 01-01-2000 ] ) ต้องน้อยกว่า วันที่สิ้นสุด ( strend [ 01-01-2001 ] )
/// WANING :: ค่าวันที่เริ่มต้นและสิ้นสุดต้องเป็นรูปแบบวันที่ถูกต้องแล้ว
/// ACTION :: RETURN BOOLEAN  <PROCESS>
function checkFdateEdate(strstart, strend) {
	var dayF, dayE, monthF, monthE, yearF, yearE, checkdaytrue = true;
	dayF = parseFloat(strstart.substring(0, 2)); // วันเริ่มต้น
	dayE = parseFloat(strend.substring(0, 2)); // วันสิ้นสุด
	monthF = parseFloat(strstart.substring(3, 5)); // เดือนเริ่มต้น
	monthE = parseFloat(strend.substring(3, 5)); // เดือนสิ้นสุด
	yearF = parseFloat(strstart.substring(6, 10)); // ปีเริ่มต้น
	yearE = parseFloat(strend.substring(6, 10)); // ปีสิ้นสุด
	if (yearE < yearF) checkdaytrue = false; //ถ้าปีท้ายน้อยกว่าปีก่อน
	else if ((yearE == yearF) && (monthF > monthE)) checkdaytrue = false; //ปีเท่ากันแต่เดือนปีก่อนมากกว่า
	else if ((yearE == yearF) && (monthF == monthE) && (dayF > dayE)) checkdaytrue = false; //ปีและเดือนเท่ากันแต่วันก่อนมากกว่าวันท้าย
	return checkdaytrue; // ถ้าวันก่อนมากกว่าวันท้ายส่ง false
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: คำนวณจำนวนวันจากวันเริ่มต้นถึงวันสิ้นสุด [ ไม่นับวันแรก ]
/// WANING :: ค่าวันที่เริ่มต้นและสิ้นสุดต้องเป็นรูปแบบวันที่ถูกต้องแล้ว และ strtwo ต้องมากกว่า strone
/// ACTION :: RETURN VALUE STRING  <DD-MM-YYYY>
function calDayMonthYear(strone, strtwo) {
	var dayF, dayE, monthF, monthE, yearF, yearE, monthcount = 0,
		yearcount = 0,
		daycount = 0,
		temp;
	dayF = eval(strone.substring(0, 2)); // วันเริ่มต้น
	dayE = eval(strtwo.substring(0, 2)); // วันสิ้นสุด
	monthF = eval(strone.substring(3, 5)); // เดือนเริ่มต้น
	monthE = eval(strtwo.substring(3, 5)); // เดือนสิ้นสุด
	yearF = eval(strone.substring(6, 10)); // ปีเริ่มต้น
	yearE = eval(strtwo.substring(6, 10)); // ปีสิ้นสุด
	temp = eval(chkAmountDay(monthF, yearF)); //เก็บจำนวนวันของเดือนแรก
	monthF++; // เริ่มนับเดือนถัดไป
	if (monthF > 12) {
		monthF = 1;
		yearF = yearF + 1;
	}
	while (((yearE == yearF) && (monthF < monthE)) || (yearF < yearE)) {
		monthcount++;
		if (monthcount == 12) {
			yearcount++;
			monthcount = 0;
		}
		if (monthF == 12) {
			monthF = 1;
			yearF = yearF + 1;
		} else monthF = monthF + 1;
	} // นับจำนวนเดือน
	if (dayF <= dayE) {
		daycount = (dayE - dayF);
		if (monthE == monthF) monthcount++;
	} // นับจำนวนวันของวันเริ่มต้นเท่านั้น
	else {
		monthE--;
		if (monthE < 1) {
			monthE == 12;
			yearE--;
		}
		daycount = (temp + 1 - dayF) + dayE;
	} // นับจำนวนวันของวันที่สิ้นสุดเท่านั้น <MORE THEN 1 MONTH>
	if (monthcount == 12) {
		yearcount++;
		monthcount = 0;
	} // ถ้าจำนวนเดือนเท่ากับ 12 ให้เพิ่มไปอีก 1 ปี
	return yearcount + "-" + monthcount + "-" + daycount;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: คำนวณจำนวนวันจากวันเริ่มต้นถึงวันสิ้นสุด [ นับตั้งแต่วันแรก ]
/// WANING :: ค่าวันที่เริ่มต้นและสิ้นสุดต้องเป็นรูปแบบวันที่ถูกต้องแล้ว และ strtwo ต้องมากกว่า strone
/// ACTION :: RETURN VALUE STRING  <DD-MM-YYYY>
function calDayMonthYear2(strone, strtwo) {
	var dayF, dayE, monthF, monthE, yearF, yearE, monthcount = 0,
		yearcount = 0,
		daycount = 0,
		temp;
	dayF = eval(strone.substring(0, 2)); // วันเริ่มต้น
	dayE = eval(strtwo.substring(0, 2)); // วันสิ้นสุด
	monthF = eval(strone.substring(3, 5)); // เดือนเริ่มต้น
	monthE = eval(strtwo.substring(3, 5)); // เดือนสิ้นสุด
	yearF = eval(strone.substring(6, 10)); // ปีเริ่มต้น
	yearE = eval(strtwo.substring(6, 10)); // ปีสิ้นสุด
	temp = eval(chkAmountDay(monthF, yearF)); //เก็บจำนวนวันของเดือนแรก
	monthF++; // เริ่มนับเดือนถัดไป
	if (monthF > 12) {
		monthF = 1;
		yearF = yearF + 1;
	}
	while (((yearE == yearF) && (monthF < monthE)) || (yearF < yearE)) {
		monthcount++;
		if (monthcount == 12) {
			yearcount++;
			monthcount = 0;
		}
		if (monthF == 12) {
			monthF = 1;
			yearF = yearF + 1;
		} else monthF = monthF + 1;
	} // นับจำนวนเดือน
	if (dayF <= dayE + 1) {
		daycount = (dayE - dayF) + 1; // จุดนี้เพิ่ม 1 ต่างจาก calDayMonthYear \\
		if (monthE == monthF) monthcount++;
	} // นับจำนวนวันของวันเริ่มต้นเท่านั้น
	else {
		monthE--;
		if (monthE < 1) {
			monthE == 12;
			yearE--;
		}
		daycount = (temp + 1 - dayF) + dayE;
	} // นับจำนวนวันของวันที่สิ้นสุดเท่านั้น <MORE THEN 1 MONTH>
	if (monthcount == 12) {
		yearcount++;
		monthcount = 0;
	} // CHECK IF MONTH MORE THEN 12
	return yearcount + "-" + monthcount + "-" + daycount;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: คำนวณจำนวนวันของแต่ละเดือน ค่าที่เป็นปีต้องส่งมาเป็นแบบปี ค.ศ. <28 , 29 , 30 or 31 day>
/// ACTION :: RETURN INT <PROCESS>
function chkAmountDay(strmonth, stryear) {
	if ((strmonth == 1) || (strmonth == 3) || (strmonth == 5) || (strmonth == 7) || (strmonth == 8) || (strmonth == 10) || (strmonth == 12)) return 31;
	else if ((strmonth == 4) || (strmonth == 6) || (strmonth == 9) || (strmonth == 11)) return 30;
	else if (strmonth == 2) {
		if ((stryear % 4) != 0) return 28;
		else return 29;
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: CHECK NEXT NAME OBJECT  [ คือใช้ตัดคำตรงกลางออกแล้วใส่ชื่อตัวแปรไปใหม่ตามค่า str ]
/// RETURN TO CAUSE <PROCESS>
/// REMARK :: ค่าที่ส่งไปคือชื่อ object
function chkNextObj(obj, str) {
	var tempsplit = obj.name.split("$");
	tempsplit[1] = str;
	return tempsplit[0] + "$" + tempsplit[1] + "$" + tempsplit[2];
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: เป็นรูปแบบจากปี พ.ศ. ไปเป็นปี ค.ศ. เช่น 11-01-2550 เป็น 11-01-2007>
/// REMARK :: str ต้องเป็นรูปแบบ dd-mm-yyyy เท่านั้น
/// ACTION :: RETURN STRING <PROCESS>
function formatEngYear(str) {
	var date = str.substring(0, 6);
	var year = eval(str.substring(6, 10));
	if (year >= 2400) date = date + (year - 543); // ถ้ากรอกปีตั้งแต่ 2501 เป็นต้นไปถือว่าเป็นปี พ.ศ.
	else date = str;
	return date;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS ::  เป็นรูปแบบจากปี พ.ศ. ไปเป็นปี ค.ศ. เช่น 2550 เป็น 2007>
/// REMARK ::  str ต้องเป็นรูปแบบ yyyy เท่านั้น
/// ACTION :: RETURN STRING <PROCESS>
function chkEngYear(str) {
	if (str >= 2400) str = eval(str) - 543; // ถ้ากรอกปีตั้งแต่ 2501 เป็นต้นไปถือว่าเป็นปี พ.ศ.
	return str;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบจำนวนปีต้องไม่เกินที่กำหนด
/// REMARK :: OBJ มีค่าเป็น YYYY หรือ DD-MM-YYYY หรือ MM-DD-YYYY เท่านั้น  LIMITYEAR คือ จำนวนปีที่กำหนดห้ามเกิน
/// ACTION :: RETURN BOOLEAN <PROCESS>
function chkLimitYear(obj, limityear) {
	var yearpresent = datePresent().substring(6, 10),
		check = true,
		yearbd = obj.value.substring(6, 10);
	if (obj.value != '01-01-1900' && obj.value != '31-12-2100') {
		if (obj.value.length == 4) {
			if ((eval(obj.value) > eval(yearpresent) + limityear) || (eval(obj.value) < eval(yearpresent) - limityear)) check = false;
		} else if (obj.value.length == 10) {
			if ((eval(obj.value.substring(6, 10)) > eval(yearpresent) + limityear) || (eval(obj.value.substring(6, 10)) < eval(yearpresent) - limityear)) {
				check = false;
			}
		}
	}
	return check;
}


//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ลบ - ของรูปแบบวันที่ออก เช่น 31-12-2000 จะเป็น 31122000
/// ACTION :: RETURN STRING [ PRECESS ]
function delWordDate(str) {
	var text = "";
	for (var i = 0; i < str.length; i++) {
		if (str.charAt(i) != "-") text = text + str.charAt(i);
	}
	return text;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: คำนวณจำนวนปีจากปีปัจจุบันลบด้วยปีที่ส่งมา ( str )
/// ACTION :: RETURN VALUE STRING  <PROCESS>
function calAgeYear(str) {
	return parseFloat(datePresent().substring(6, 10)) - parseFloat(str.substring(6, 10));
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: คำนวณจำนวนวันโดยเพิ่มจากจำนวน วัน เดือน และปี ที่ส่งมา ( วันแรกนับ )
/// ACTION ::  RETRUN STRING <PROCESS>
function calLastDate(strone, strday, strmonth, stryear) {
	var dayF = eval(strone.substring(0, 2)); // วันเริ่มต้น
	var dayE = 1;
	var monthF = eval(strone.substring(3, 5)); // เดือนเริ่มต้น
	var monthE = "";
	var yearF = eval(strone.substring(6, 10)); // ปีเริ่มต้น
	var yearE = "";
	var tempmonth;
	var tempyear;
	yearE = yearF + eval(stryear);
	monthE = monthF + eval(strmonth);
	dayE = (dayF - 1) + eval(strday);
	//=================================================================//
	if (monthE > 12) {
		yearE++;
		monthE = monthE - 11;
	}
	if (eval(dayE) > chkAmountDay(monthE, yearE)) {
		dayE = eval(dayE) - chkAmountDay(monthE, yearE);
		monthE++;
	}
	//=================================================================//
	if (dayE == 0) {
		if (monthE == 1) {
			tempmonth = 12;
			tempyear = yearE - 1;
			monthE = 12;
			yearE--;
		} else {
			tempmonth = monthE - 1;
			tempyear = yearE;
			monthE--;
		}
		dayE = chkAmountDay(tempmonth, tempyear);
	}
	//===================== ใส่ 0 ให้กับวัน เดือนที่เป็นแค่หลักหน่วย ===================//
	dayE = dayE + "";
	monthE = monthE + "";
	if (dayE.length == 1) dayE = "0" + dayE;
	if (monthE.length == 1) monthE = "0" + monthE;
	//=================================================================//
	return dayE + "-" + monthE + "-" + yearE;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: คำนวณจำนวนวันโดยเพิ่มจากจำนวน วัน เดือน และปี ที่ส่งมา ( วันแรกไม่นับ )
/// ACTION ::  RETRUN STRING <PROCESS>
function calLastDate2(strone, strday, strmonth, stryear) {
	var dayF = eval(strone.substring(0, 2)); // วันเริ่มต้น
	var dayE = 1;
	var monthF = eval(strone.substring(3, 5)); // เดือนเริ่มต้น
	var monthE = "";
	var yearF = eval(strone.substring(6, 10)); // ปีเริ่มต้น
	var yearE = "";
	var tempmonth;
	var tempyear;
	yearE = yearF + eval(stryear);
	monthE = monthF + eval(strmonth);
	dayE = (dayF) + eval(strday); // จุดแตกต่าง calLastDate
	//=================================================================//
	if (monthE > 12) {
		yearE++;
		monthE = monthE - 11;
	}
	if (eval(dayE) > chkAmountDay(monthE, yearE)) {
		dayE = eval(dayE) - chkAmountDay(monthE, yearE);
		monthE++;
	}
	//=================================================================//
	if (dayE == 0) {
		if (monthE == 1) {
			tempmonth = 12;
			tempyear = yearE - 1;
			monthE = 12;
			yearE--;
		} else {
			tempmonth = monthE - 1;
			tempyear = yearE;
			monthE--;
		}
		dayE = chkAmountDay(tempmonth, tempyear);
	}
	//===================== ใส่ 0 ให้กับวัน เดือนที่เป็นแค่หลักหน่วย ===================//
	dayE = dayE + "";
	monthE = monthE + "";
	if (dayE.length == 1) dayE = "0" + dayE;
	if (monthE.length == 1) monthE = "0" + monthE;
	//=================================================================//
	return dayE + "-" + monthE + "-" + yearE;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS ::  ใช้สำหรับถ้าเพิ่มจำนวน วัน เดือน หรือปี วันที่สุดท้ายจะเพิ่มตามจำนวนที่เพิ่มโดยนับจากวันที่เริ่มต้น ( วันแรกนับ )
/// RETURN VALUE TO OBJECT	objlastdate  <ON BLUR>
/* CALL ::
					checkNumInt(month,0,11)
					calLastDate(obj.value,day.value,month.value,year.value)
*/
/// SET FUNCTION 1 คือทุก function ใช้หมด
function calLastDateMonth(obj, objlastdate, day, month, year) { // textbox ที่เป็นจำนวนเดือน
	if (month == "") month.value = 0;
	checkNumInt(month, 0, 11); //ตรวจดูว่ากรอกจำนวนเดือนไม่เกิน 11 เดือน
	if ((day.value.length > 0) && (month.value.length > 0) && (year.value.length > 0))
		objlastdate.value = calLastDate(obj.value, day.value, month.value, year.value);
}

function calLastDateDay(obj, objlastdate, day, month, year) { // textbox ที่เป็นจำนวนวัน
	if (((month.value.length == 0) || (eval(month.value) > 0)) || ((year.value.length == 0) || (eval(year.value) > 0))) {
		if (day == "") day.value = 0;
		checkNumInt(day, 0, 30); //ตรวจดูว่ากรอกจำนวนวันไม่เกิน 30 วัน
	} else {
		if (day == "") day.value = 1;
		checkNumInt(day, 1, 30); //ตรวจดูว่ากรอกจำนวนวันไม่เกิน 30 วัน
	}
	if ((day.value.length > 0) && (month.value.length > 0) && (year.value.length > 0))
		objlastdate.value = calLastDate(obj.value, day.value, month.value, year.value);
}

function calLastDateYear(obj, objlastdate, day, month, year) { // textbox ที่เป็นจำนวนปี
	if (year == "") year.value = 0;
	if ((day.value.length > 0) && (month.value.length > 0) && (year.value.length > 0))
		objlastdate.value = calLastDate(obj.value, day.value, month.value, year.value);
}
/// END SET FUNTION 1===============================================================================================//

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS ::
/// ACTION :: CHECK <ON BLUR>
/* CALL ::
					checkNumInt(num1,nummin,nummax)
					chkMoreThen(num1,num2);
*/
/// SET FUNCTION 2 คือทุก function ใช้หมด
function chkLengthAge1(num1, num2, nummin, nummax) {
	checkNumInt(num1, nummin, nummax);
	chkMoreThen(num1, num2);
}

function chkLengthAge2(num1, num2, nummin, nummax) {
	checkNumInt(num1, nummin, nummax);
	chkMoreThen(num2, num1);
}
/// END SET FUNTION 2============================================================================================//

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS ::  ใช้สำหรับถ้าเพิ่มจำนวน วัน เดือน หรือปี วันที่สุดท้ายจะเพิ่มตามจำนวนที่เพิ่มโดยนับจากวันที่เริ่มต้น ( วันแรกไม่นับ )
/// RETURN VALUE TO OBJECT	objlastdate  <ON BLUR>
/* CALL ::
					checkNumInt(month,0,11)
					calLastDate2(obj.value,day.value,month.value,year.value)
*/
/// SET FUNCTION 3 คือทุก function ใช้หมด
function calLastDateMonth2(obj, objlastdate, day, month, year) { // textbox ที่เป็นจำนวนเดือน
	if (month == "") month.value = 0;
	checkNumInt(month, 0, 11); //ตรวจดูว่ากรอกจำนวนเดือนไม่เกิน 11 เดือน
	if ((day.value.length > 0) && (month.value.length > 0) && (year.value.length > 0))
		objlastdate.value = calLastDate2(obj.value, day.value, month.value, year.value);
}

function calLastDateDay2(obj, objlastdate, day, month, year) { // textbox ที่เป็นจำนวนวัน
	if (((month.value.length == 0) || (eval(month.value) > 0)) || ((year.value.length == 0) || (eval(year.value) > 0))) {
		if (day == "") day.value = 0;
		checkNumInt(day, 0, 30); //ตรวจดูว่ากรอกจำนวนวันไม่เกิน 30 วัน
	} else {
		if (day == "") day.value = 1;
		checkNumInt(day, 0, 30); //ตรวจดูว่ากรอกจำนวนวันไม่เกิน 30 วัน
	}
	if ((day.value.length > 0) && (month.value.length > 0) && (year.value.length > 0))
		objlastdate.value = calLastDate2(obj.value, day.value, month.value, year.value);
}

function calLastDateYear2(obj, objlastdate, day, month, year) { // textbox ที่เป็นจำนวนปี
	if (year == "") year.value = 0;
	if ((day.value.length > 0) && (month.value.length > 0) && (year.value.length > 0))
		objlastdate.value = calLastDate2(obj.value, day.value, month.value, year.value);
}
/// END SET FUNTION 3===============================================================================================//

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบตัวเลข num2 ต้องมากกว่า num1 [NUMBER];
/// ACTION :: RETURN STRING GIVE OUTPUT <PROCESS>
/* CALL ::
					checkNumInt(num1,0,100)
					delComma(num2.value)
					insertComma(num1)
*/
function chkMoreThen(num1, num2) {
	if ((num1.value.length > 0) && (num2.value.length == 0)) {
		num2.focus();
	} else if ((num1.value.length == 0) && (num2.value.length > 0)) {
		num1.focus();
	} else if ((num1.value != "") && (num2.value != "")) {
		var temp = delComma(num2.value);
		var temp2 = delComma(num1.value);
		if (!chkNumDiff(temp2, temp)) { // IF END NUMBER LESS THEN START NUMBER GIVE INPUT AGAIN!
			num2.value = num1.value;
			num2.focus();
		}
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบวันแต่งงานต้องมากกว่าวันเกิด
/// ACTION :: CHECK <ON BLUR>
/* CALL ::
					datePresent()
					chkEngYear(objyearmarry.value)
*/
function chkYearMarry(strbd, objyearmarry) {
	var yearpresent = datePresent().split("-"); //ปีปัจจุบัน
	var yearbd = strbd.split("-"); //ปีวันเกิด
	var yearmarry = chkEngYear(objyearmarry.value); //ปีแต่งงาน
	//ตรวจสอบวันแต่งงานต้องมากกว่าวันเกิด
	if (eval(yearmarry) < eval(yearbd[2])) {
		alert(MyAlert[4]);
		objyearmarry.focus();
	}
	//ตรวจสอบวันแต่งงานต้องน้อยกว่าวันปัจจุบัน
	else if (eval(yearmarry) > eval(yearpresent[2])) {
		alert(MyAlert[5]);
		objyearmarry.focus();
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS ::
/// ACTION :: CHECK <ON BLUR>
/* CALL ::
					chkTrueYear(objyearmarry)
					chkYearMarry(objbd.value,objyearmarry)
*/
function yearMarry(objbd, objyearmarry) {
	chkTrueYear(objyearmarry);
	if (objyearmarry.value.length == 4) {
		chkYearMarry(objbd.value, objyearmarry);
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS ::
/// ACTION :: CHECK <ON BLUR>
/* CALL ::
					chkTrueYear(objyearmarry)
					datePresent()
*/
function chkMarryPer(objbd, objmarry) {
	chkTrueYear(objmarry);
	var tempbd = objbd.value.split("-"); //ปีวันเกิด
	var temppresent = datePresent().split("-"); //ปีปัจจุบัน
	if (eval(objmarry.value) > eval(temppresent[2])) {
		alert(MyAlert[6] + objmarry.value + MyAlert[7] + temppresent[2]);
		objmarry.focus();
	} else if (eval(objmarry.value) < eval(tempbd[2])) {
		alert(MyAlert[6] + objmarry.value + MyAlert[8] + tempbd[2]);
		objmarry.focus();
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบตัวเลขแบบมีทศนิยม
/// ACTION :: RETURN STRING GIVE OBJ <ON BLUR>
/* CALL ::
					insertComma(object)
					checkMaxMin(<number>,min<number>,max<number>)
					checkInputComma(object)
*/
function checkNumFloat(obj, min, max) {
	if (obj.value != "") {
		obj.value = parseFloat(obj.value) + ""; // แปลงจาก 01234.xx เป็น 1234.xx
		checkInputComma(obj); // ถ้าพิม xxx ก็ให้เป็น xxx.00
		if (min >= 0 && max > 0) {
			callMaxMin(obj, min, max); // ตรวจดูว่าค่าที่กรอกเกินค่าสูงสุด หรือต่ำกว่าค่าต่ำสุดหรือไม่
		}
		insertComma(obj); //123456 ==> 123,456
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบตัวเลขแบบจำนวนเต็ม
/// ACTION :: RETURN STRING GIVE OBJ <ON BLUR>
/* CALL ::
					insertComma(object)
					callMaxMin(obj,min,max);
*/
function checkNumInt(obj, min, max) {
	if (obj.value != "") {
		obj.value = parseFloat(obj.value) + ""; // แปลงจาก 01234 เป็น 1234
		if (min >= 0 && max > 0) {
			callMaxMin(obj, min, max); // ตรวจดูว่าค่าที่กรอกเกินค่าสูงสุด หรือต่ำกว่าค่าต่ำสุดหรือไม่
		}
		insertComma(obj); //123456 ==> 123,456
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบตัวเลขแบบจำนวนเต็ม หรือ แบบทศนิยม
/// ACTION :: RETURN STRING GIVE OBJ <ON BLUR>
/* CALL ::
					insertComma(object)
					checkMaxMin(obj<number>,min<number>,max<number>)
					callMaxMin(obj,min,max)
*/
function checkNumFloatInt(obj, min, max) {
	if (obj.value != "") {
		if (obj.value.indexOf('.') >= 0)
			obj.value = eval(obj.value) + "."; // แปลงจาก 01234. เป็น 1234.xx
		else
			obj.value = eval(obj.value) + ""; // แปลงจาก 01234 เป็น 1234
		checkInputComma2(obj); // ถ้าพิม xxx. ก็ให้เป็น xxx.00
		if (min >= 0 && max > 0) {
			callMaxMin(obj, min, max); // ตรวจดูว่าค่าที่กรอกเกินค่าสูงสุด หรือต่ำกว่าค่าต่ำสุดหรือไม่
		}
		insertComma(obj); //ใส่ comma
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: CALL DELECT COMMA
/// ACTION :: RETURN STRING GIVE OBJECT <ON FOCUS>
/* CALL ::
						delComma(string)
*/
function callDelComma(obj) {
	obj.value = delComma(obj.value);
	obj.focus();
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบตัวเลข
/// ACTION :: RETURN STRING GIVE OBJECT <ON KEYUP>
function checkComma(obj, limitcomma) {
	var tempspl = obj.value.split("."),
		tempstr;
	if (tempspl.length == 2) { // ตรวจสอบดูว่าถ้ามีจุด  ( . )
		if (tempspl[1].length > limitcomma) { // ตรวจสอบจำนวนทศนิยมเกินที่กำหนดหรือไม่ ( limitcomma )
			tempstr = tempspl[1].substring(0, limitcomma);
			obj.value = tempspl[0] + "." + tempstr;
		}
		if (tempspl[0] == "") { // ตรวจสอบดูว่าค่าจำนวนเต็มกรอกแล้วหรือยัง
			obj.value = "0" + obj.value;
		}
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: คำนวณตัวเลข
/// ACTION :: RETURN STRING GIVE OUTPUT <ON CLICK> <NOT USE>
/* CALL ::
						delComma(string)
*/
function calNum(obj1, obj2, objoutput) {
	var tempobj1, tempobj2;
	if (obj1.value == "") {
		alert(MyAlert[9]);
		obj1.focus();
	} else if (obj2.value == "") {
		alert(MyAlert[10]);
		obj2.focus();
	} else {
		tempobj1 = eval(delComma(obj1.value)); //  xxx,xxx.00 ===> xxxxxx.00
		tempobj2 = eval(delComma(obj2.value)); //  xxx,xxx.00 ===> xxxxxx.00
		objoutput.value = parseFloat(tempobj1 - tempobj2);
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบเลขแรกต้องน้อยกว่าเลขหลัง [ generate name object ] [ ตัวเลขแรกเรียกใช้ ] [ number is integer ]
/// ACTION ::  <ONBLUR>
/* CALL ::
						chkNextObj(objstart,str)
						chkLengthInt1(objstart,objLast,nummax)
*/
function chkLengthInt$Start(objstart, str, nummax) {
	var objLast = document.getElementsByName(chkNextObj(objstart, str)); // CHECK NEXT INPUT BOX HAVE NAME OBJECT
	chkLengthInt1(objstart, objLast[0], nummax)
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS ::  ตรวจสอบเลขแรกต้องน้อยกว่าเลขหลัง [ generate name object ] [ ตัวเลขหลังเรียกใช้ ] [ number is integer ]
/// ACTION ::  <ONBLUR>
/* CALL ::
						chkNextObj(objstart,str)
						chkLengthInt1(objstart,objLast,nummax)
*/
function chkLengthInt$End(objend, str, nummax) {
	var objStart = document.getElementsByName(chkNextObj(objend, str)); // CHECK NEXT INPUT BOX HAVE NAME OBJECT
	chkLengthInt2(objend, objStart[0], nummax)
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบเลขแรกต้องน้อยกว่าเลขหลัง [ ตัวเลขแรกเรียกใช้ ] [ number is integer ]
/// ACTION :: RETURN STRING GIVE OUTPUT <ON BLUR>
/* CALL ::
					checkNumInt(num1,0,100)
					chkMoreThen(num2,num1)
*/
function chkLengthInt1(num1, num2, nummax) {
	checkNumInt(num1, 0, nummax); // ตรวจสอบตัวเลข
	chkMoreThen(num1, num2);
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบเลขแรกต้องน้อยกว่าเลขหลัง [ ตัวเลขหลังเรียกใช้ ] [ number is integer ]
/// ACTION :: RETURN STRING GIVE OUTPUT <ON BLUR>
/* CALL ::
					checkNumInt(num1,0,100)
					chkMoreThen(num2,num1)
*/
function chkLengthInt2(num1, num2, nummax) {
	checkNumInt(num1, 0, nummax); // ตรวจสอบตัวเลข
	chkMoreThen(num2, num1);
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS ::  ตรวจสอบเลขแรกต้องน้อยกว่าเลขหลัง [ generate name object ] [ ตัวเลขแรกเรียกใช้ ] [ number is float ]
/// ACTION ::  <ONBLUR>
/* CALL ::
					chkNextObj(objstart,str)
					chkLengthFloat1(objstart,objLast,nummax)
*/
function chkLengthFloat$Start(objstart, str, nummax) {
	var objLast = document.getElementsByName(chkNextObj(objstart, str)); // CHECK NEXT INPUT BOX HAVE NAME OBJECT
	chkLengthFloat1(objstart, objLast[0], nummax)
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS ::  ตรวจสอบเลขแรกต้องน้อยกว่าเลขหลัง [ generate name object ] [ ตัวเลขหลังเรียกใช้ ] [ number is float ]
/// ACTION ::  <ONBLUR>
/* CALL ::
					chkNextObj(objstart,str)
					chkLengthFloat2(objstart,objLast,nummax)
*/
function chkLengthFloat$End(objend, str, nummax) {
	var objStart = document.getElementsByName(chkNextObj(objend, str)); // CHECK NEXT INPUT BOX HAVE NAME OBJECT
	chkLengthFloat2(objend, objStart[0], nummax)
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบเลขแรกต้องน้อยกว่าเลขหลัง [ ตัวเลขแรกเรียกใช้ ] [ number is float ]
/// ACTION :: RETURN STRING GIVE OUTPUT <ON BLUR>
/* CALL ::
					checkNumFloat(num1,0,100)
					chkMoreThen(num1,num2)
*/
function chkLengthFloat1(num1, num2, nummax) {
	checkNumFloat(num1, 0, nummax); // ตรวจสอบตัวเลขทศนิยม
	chkMoreThen(num1, num2);
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบเลขแรกต้องน้อยกว่าเลขหลัง [ ตัวเลขหลังเรียกใช้ ] [ number is float ]
/// ACTION :: RETURN STRING GIVE OUTPUT <ON BLUR>
/* CALL ::
					checkNumFloat(num1,0,100)
					chkMoreThen(num1,num2)
*/
function chkLengthFloat2(num1, num2, nummax) {
	checkNumFloat(num1, 0, nummax); // ตรวจสอบตัวเลขทศนิยม
	chkMoreThen(num2, num1);
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: หาค่า midpoint ระหว่างตัวเลขสองตัว  ;
/// ACTION :: RETURN STRING GIVE OBJAVE <ON BLUR>
/* CALL ::
					checkNumInt(obj1,0,10000);
*/
function calAverage(obj1, obj2, objAve) {
	chkMoreThen(obj1, obj2); //ตรวจสอบดูว่า max มากกว่า min หรือไม่
	if ((obj1.value.length > 0) && (obj2.value.length > 0)) {
		objAve.value = ((eval(obj2.value)) + (eval(obj1.value))) / 2;
	} else if ((obj2.value.length > 0) && (obj1.value.length == 0)) {
		obj1.focus();
	} else if ((obj1.value.length > 0) && (obj2.value.length == 0)) {
		obj2.focus();
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบอีเมล์
/// ACTION :: RETURN ALERT <ON BLUR>
function chkEmail(obj) {
	if (obj.value != '') {
		with(obj.value) {
			if (indexOf('@') == 0) {
				alert(MyAlert[11]);
				obj.value = "";
				obj.focus();
			} else if (indexOf('@') < 0) {
				alert(MyAlert[12]);
				obj.value = "";
				obj.focus();
			} else if (indexOf('@') != lastIndexOf('@')) {
				alert(MyAlert[13]);
				obj.value = "";
				obj.focus();
			} else if (lastIndexOf('.') < lastIndexOf('@')) {
				alert(MyAlert[14]);
				obj.value = "";
				obj.focus();
			} else if (lastIndexOf('.') > lastIndexOf('@') && (lastIndexOf('.') - lastIndexOf('@')) == 1) {
				alert(MyAlert[15]);
				obj.value = "";
				obj.focus();
			}
		}
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบจำนวนตัวเลขต้องไม่เกิน 100 ถ้าเลือก radio เป็น เปอร์เซ็นต์
/// ACTION :: RETURN ALERT <ON BLUR>
///SET FUNCTION 4
function chkPerOrMoneyRadio(obj, radiocheck) { // textbox use
	if (radiocheck[0].checked) {
		if (eval(obj.value) > 100) {
			alert(MyAlert[16]);
			obj.value = 0;
			obj.focus();
		}
	}
	checkNumFloat(obj, 0, 900000000) // Limit value
}

function chkPerOrMoneyRadio2(obj, radiocheck) { // radio use
	if (radiocheck.checked) {
		if (eval(obj.value) > 100) {
			alert(MyAlert[16]);
			obj.value = 0;
			obj.focus();
		}
	}
	checkNumFloat(obj, 0, 900000000) // Limit value
}
///SET FUNCTION 4 ===============================================================================================//


//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบจำนวนตัวเลขต้องไม่เกิน 100 ถ้าเลือก listbox เป็น เปอร์เซ็นต์
/// ACTION :: RETURN ALERT <ON BLUR>
function chkPerOrMoneyListBox(obj, listbox) {
	if (listbox.value == "1") {
		if (eval(obj.value) > 100) {
			alert(MyAlert[16]);
			obj.value = 0
			obj.focus();
		}
	}
	checkNumFloat(obj, 0, 900000000) // Limit value
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบเบอร์มือถือ [INPUT NUMBER AND COMMA ONLY]
/// ACTION :: RETURN VALUE GIVE OBJECT objoutput [hidden]
function chkMobilePhone(objphone, objoutput) {
	var temp = objphone.value.split(',');
	objoutput.value = "";
	for (var i = 0; i < temp.length; i++) {
		if (temp[i].length == 8) {
			temp[i] = "08" + temp[i];
		} else if (temp[i].length == 10) {
			if (temp[i].substring(0, 2) != "08") {
				objphone.focus();
				alert(MyAlert[17] + temp[i] + MyAlert[18]);
				break;
			}
		} else if ((temp[i].length < 8) && (temp[i].length > 0) || (temp[i].length == 9)) {
			objphone.focus();
			alert(MyAlert[17] + temp[i] + MyAlert[19]);
			break;
		} else if (temp[i].length > 10) {
			objphone.focus();
			alert(MyAlert[17] + temp[i] + MyAlert[20]);
			break;
		}
		if (temp[i] != "") {
			if (objoutput.value != "")
				objoutput.value = objoutput.value + "," + temp[i];
			else if (objoutput.value == "")
				objoutput.value = temp[i];
		}
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบเบอร์โทรศัพท์มือถือ [INPUT NUMBER AND COMMA ONLY]
/// ACTION :: RETURN VALUE GIVE OBJECT
function chkMobile(objphone) {
	var temp = objphone.value.split(',');
	var objoutput = "";
	for (var i = 0; i < temp.length; i++) {
		if (temp[i].length == 8) {
			temp[i] = "08" + temp[i];
		} else if (temp[i].length == 10) {
			if (temp[i].substring(0, 2) != "08") {
				objphone.focus();
				alert("Input number mobile phone " + temp[i] + " false EX:: 0812345678");
				break;
			}
		} else if ((temp[i].length < 8) && (temp[i].length > 0) || (temp[i].length == 9)) {
			objphone.focus();
			alert("Input number mobile phone " + temp[i] + " less then EX:: 12345678 or 0812345678");
			break;
		} else if (temp[i].length > 10) {
			objphone.focus();
			alert("Input number mobile phone " + temp[i] + " more then EX:: 12345678 or 0812345678");
			break;
		}
		if (temp[i] != "") {
			if (objoutput != "")
				objoutput = objoutput + "," + temp[i];
			else if (objoutput == "")
				objoutput = temp[i];
		}
	}
	objphone.value = objoutput;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบเบอร์บ้าน [INPUT NUMBER AND COMMA ONLY]
/// ACTION :: RETURN VALUE GIVE OBJECT objoutput [hidden]
function chkHomePhone(objlistbox, objphone, objoutput) {
	objoutput.value = objlistbox.value + objphone.value;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: CHECK NUMBER INTEGER  LIMIT WITH LISTBOX [ PERSENT,AMOUNTMONEY ]
/// ACTION ::  <ONBLUR>
/* CALL ::
					chkNextObj(objstart,str)
					chkPerOrMoneyListBox(objamount,temp[0])
*/
///SET FUNCTION 5
function chkPerOrMoneyListBox$(objamount, str) {
	var temp = document.getElementsByName(chkNextObj(objamount, str)); // CHECK NEXT INPUT BOX HAVE NAME OBJECT
	chkPerOrMoneyListBox(objamount, temp[0]);
}

function chkPerOrMoneyListBox$2(objtype, str) {
	var temp = document.getElementsByName(chkNextObj(objtype, str)); // CHECK NEXT INPUT BOX HAVE NAME OBJECT
	chkPerOrMoneyListBox(temp[0], objtype);
}
///SET FUNCTION 5 ===============================================================================================//

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: คำนวณจำนวนวันตั้งแต่วันเริ่มต้นถึงวันที่สิ้นสุด
/// ACTION :: RETURN VALUE STRING
function calAmountDay(strstart, strend) {
	var dayF, dayE, monthF, monthE, yearF, yearE, checkDay = true,
		dayamount = 0;
	dayF = parseInt(strstart.substring(0, 2)); // วันเริ่มต้น
	dayE = parseInt(strend.substring(0, 2)); // วันสิ้นสุด
	monthF = parseInt(strstart.substring(3, 5)); // เดือนเริ่มต้น
	monthE = parseInt(strend.substring(3, 5)); // เดือนสิ้นสุด
	yearF = parseInt(strstart.substring(6, 10)); // ปีเริ่มต้น
	yearE = parseInt(strend.substring(6, 10)); // ปีสิ้นสุด
	dayamount = dayamount + dayE; // BEGIN :: CALCULATE END MONTH
	if (monthE != 1)
		monthE = monthE - 1;
	else {
		monthE = 12;
		yearE = yearE - 1;
	}
	if (((monthE < monthF) && (yearF == yearE)) || ((monthE > monthF) && (yearF > yearE))) {
		dayamount = dayamount - (dayF - 1);
		checkDay = false;
	} else
		checkDay = true;
	while (checkDay) {
		if ((monthF == 1) || (monthF == 3) || (monthF == 5) || (monthF == 7) ||
			(monthF == 8) || (monthF == 10) || (monthF == 12))
			dayamount = dayamount + 31 - (dayF - 1);
		else if ((monthF == 4) || (monthF == 6) || (monthF == 9) || (monthF == 11))
			dayamount = dayamount + 30 - (dayF - 1);
		else if (monthF == 2) {
			if ((yearF % 4) != 0) {
				dayamount = dayamount + 28 - (dayF - 1);
			} else
				dayamount = dayamount + 29 - (dayF - 1);
		}
		if ((monthF == monthE) && (yearF == yearE)) checkDay = false;
		else {
			if (monthF == 12) {
				monthF = 1;
				yearF = yearF + 1;
			} else monthF = monthF + 1;
			if (dayF != 1) dayF = 1;
		}
	}
	return dayamount; // จำนวนวัน
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบการคำนวณจำนวนวันตั้งแต่วันเริ่มต้นถึงวันที่สิ้นสุด
/// ACTION :: RETURN VALUE GIVE OBJECT
/* CALL ::
					checkFdateEdate(obj , obj)
					calAmountDay(objstart.value,objend.value)
*/
function caldate(objstart, objend, objoutput) {

	if (chkInputDate2(objstart, objend) && (isNaN(objstart.value)) && (isNaN(objend.value))) {
		objoutput.value = calAmountDay(objstart.value, objend.value);
	} else {
		if (!checkFdateEdate(objstart.value, objend.value)) { // วันที่เริ่มต้นมากกว่าวันที่สิ้นสุด
			alert(MyAlert[21]);
			objend.focus();
		} else if (!isNaN(objstart.value)) { // วันที่เริ่มต้นมีค่าเป็น null
			alert(MyAlert[22]);
			objstart.focus();
		} else if (!isNaN(objend.value)) { // วันที่สิ้นสุดมีค่าเป็น null
			alert(MyAlert[23]);
			objend.focus();
		}
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบวันเริ่มต้นต้องน้อยกว่าวันที่สิ้นสุด [ object generate ] [ วันเริ่มต้นใช้ ]
/// RETURN TO CAUSE <ONBLUR>
/* CALL ::
					chkNextObj(obj,str) [PROCESS]
					chkInputDate2(objstart,objend) [ONBLUR]
*/
function chkInputDate$Start(objstart, str) {
	var objLast = document.getElementsByName(chkNextObj(objstart, str)); // CHECK NEXT INPUT BOX HAVE NAME OBJECT
	chkInputDate2(objstart, objLast[0]);
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบวันเริ่มต้นต้องน้อยกว่าวันที่สิ้นสุด [ object generate ] [ วันสิ้นสุดใช้ ]
/// RETURN TO CAUSE <ONBLUR>
/* CALL ::
					chkNextObj(obj,str) [PROCESS]
					chkInputDate2(objstart,objend) [PROCESS]
*/
function chkInputDate$End(objlast, str) {
	var objStart = document.getElementsByName(chkNextObj(objlast, str)); // CHECK NEXT INPUT BOX HAVE NAME OBJECT
	chkInputDate2(objStart[0], objlast);
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบปี พ.ศ. ไปเป็น ค.ศ.
/// ACTION :: RETURN VALUE OBJECT <ON KEYUP>
/* CALL ::
					chkEngYear(object) [PROCESS]
*/
function formatYear(obj) {
	if (obj.value.length == 4) {
		obj.value = chkEngYear(obj.value);
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบปีถูกต้องและเกิน limit ที่กำหนดหรือไม่ <YEAR>
/// ACTION :: RETURN ALERT	<ON BLUR>
/* CALL ::
					chkLimitYear(obj,limityear) [PROCESS]
*/
function chkTrueYear(obj) {
	if ((obj.value.length < 4) && (obj.value.length > 0)) {
		// obj.focus();
		alert(MyAlert[24]);
	} else if (!chkLimitYear(obj, 100)) {
		// obj.focus();  
		alert(MyAlert[25]);
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: คำนวณอายุ ( วันแรกไม่นับ )
/// ACTION :: RETURN VALUE OBJECT objcalage <ON ONBLUR>
/* CALL ::
					calDayMonthYear(obj,datePresent,obj) [PROCESS]
					datePresent() [PROCESS]
*/
function calAge(objbd, objcalage) {
	var temp = document.getElementsByName("temp"); //สร้าง object
	temp.value = datePresent(); // วันที่ปัจจุบัน
	if (chkInputDate(objbd) && checkFdateEdate(objbd.value, temp.value)) // ตรวจสอบวันเกิดต้องน้อยกว่าวันปัจจุบัน
		calDateFullDetail(objbd.value, datePresent(), objcalage); // BIRTHDAY , PRESENT DAY , OUTPUT  \\ ถ้าจะนับวันแรกเลยต้องใช้ calDateFullDetail3
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: คำนวณวัน < 3 OUTPUT > [ไม่นับวันแรก]
/// ACTION :: RETURN VALUE GIVE OBJECT daycount,monthcount,yearcount
/* CALL ::
					calDayMonthYear(str1,str2)
*/
function calDateDetail(objdate1, objdate2, daycount, monthcount, yearcount) {
	var temp = calDayMonthYear(objdate1.value, objdate2.value).split("-");
	yearcount.value = temp[0];
	monthcount.value = temp[1];
	daycount.value = temp[2];
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบการคำนวณวัน < 3 OUTPUT >[ไม่นับวันแรก]
/// ACTION :: RETURN VALUE TO OBJECT dayc,monthc,yearc <ON BLUR>
/* CALL ::
					chkInputDate2(obj1,obj2)
					calDateDetail(obj1,obj2,dayc,monthc,yearc);
*/
function calDateDetail1(obj1, obj2, dayc, monthc, yearc) {
	// ตรวจสอบวันเริ่มต้นต้องน้อยกว่าวันที่สิ้นสุด
	if (chkInputDate2(obj1, obj2)) {
		calDateDetail(obj1, obj2, dayc, monthc, yearc); //CALCULATE PROCESS
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS ::  คำนวณวัน < 3 OUTPUT > [นับตั้งแต่วันแรกถึงวันสุดท้าย]
/// ACTION :: RETURN VALUE GIVE OBJECT daycount,monthcount,yearcount
/* CALL ::
					calDayMonthYear2(str1,str2)
*/
function calDateDetail3(strdate1, strdate2, daycount, monthcount, yearcount) {
	var temp = calDayMonthYear2(strdate1.value, strdate2.value).split("-");
	yearcount.value = temp[0];
	monthcount.value = temp[1];
	daycount.value = temp[2];
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS ::  ตรวจสอบการคำนวณวัน < 3 OUTPUT > [นับตั้งแต่วันแรกถึงวันสุดท้าย]
/// ACTION :: RETURN VALUE TO OBJECT dayc,monthc,yearc <ON BLUR>
/// CALL :: chkInputDate2(obj1,obj2) , calDateDetail(obj1,obj2,dayc,monthc,yearc);
function calDateDetail4(obj1, obj2, dayc, monthc, yearc) {
	// ตรวจสอบวันเริ่มต้นต้องน้อยกว่าวันที่สิ้นสุด
	if (chkInputDate2(obj1, obj2)) {
		calDateDetail3(obj1, obj2, dayc, monthc, yearc); //CALCULATE PROCESS
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: คำนวณวัน < 1 OUTPUT > [ วันแรกไม่นับ ]
/// ACTION :: RETURN VALUE GIVE OBJECT [objfulldate]
/* CALL ::
					calDayMonthYear(str1,str2)
*/
function calDateFullDetail(strdate1, strdate2, objfulldate) {
	var temp = calDayMonthYear(strdate1, strdate2).split("-");
	objfulldate.value = temp[0] + MyAlert[26] + temp[1] + MyAlert[27] + temp[2] + MyAlert[28];
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: คำนวณวัน < 1 OUTPUT > [ นับตั้งแต่วันแรกถึงวันสุดท้าย ]
/// ACTION :: RETURN VALUE GIVE OBJECT [objfulldate]
/* CALL ::
					calDayMonthYear2(str1,str2)
*/
function calDateFullDetail2(strdate1, strdate2, objfulldate) {
	var temp = calDayMonthYear2(strdate1, strdate2).split("-");
	objfulldate.value = temp[0] + MyAlert[26] + temp[1] + MyAlert[27] + temp[2] + MyAlert[28];
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบการคำนวณวัน < 1 OUTPUT > [ วันแรกไม่นับ ]
/// ACTION ::
/* CALL ::
					chkInputDate2(obj1,obj2)
					calDateFullDetail(obj1.value,obj2.value,objoutput)
*/
function chkCalDateFullDetail(obj1, obj2, objoutput) {
	if (chkInputDate2(obj1, obj2)) // ตรวจก่อนว่าวันแรกน้อยกว่าวันหลังหรือไม่
		calDateFullDetail(obj1.value, obj2.value, objoutput); // คำนวณจำนวนวัน [ ปี เดือน วัน ]
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบการคำนวณวัน < 1 OUTPUT > [ นับตั้งแต่วันแรกถึงวันสุดท้าย ]
/// ACTION ::
/* CALL ::
					chkInputDate2(obj1,obj2)
					calDateFullDetail(obj1.value,obj2.value,objoutput)
*/
function chkCalDateFullDetail2(obj1, obj2, objoutput) {
	if (chkInputDate2(obj1, obj2)) // ตรวจก่อนว่าวันแรกน้อยกว่าวันหลังหรือไม่
		calDateFullDetail2(obj1.value, obj2.value, objoutput); // คำนวณจำนวนวัน [ ปี เดือน วัน ]
}

//================================================================================================================//
/// ABOUT FUNCTION IS :: ตรวจสอบการคำนวณวันโดยวันที่เริ่มต้นเป็นวันที่ส่งมาคำนวณและวันที่สิ้นสุดเป็นวันปัจจุบัน < 1 OUTPUT > [ นับตั้งแต่วันแรกถึงวันสุดท้าย ]
/// ACTION ::
/* CALL ::
					chkBirthDay(obj1)
					datePresent()
					calDateFullDetail2(obj1.value,datePresent(),objoutput)
*/
function chkCalDateFullDetail3(obj1, objoutput) {
	if (chkBirthDay(obj1)) // ตรวจก่อนว่าวันแรกน้อยกว่าวันปัจจุบัน
		calDateFullDetail2(obj1.value, datePresent(), objoutput); // คำนวณจำนวนวัน [ ปี เดือน วัน ]
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: เปลี่ยนแปลงให้เพิ่มหรือลดจากวันปัจจุบันเท่าไร  strchange is "-" or "+" และ stramount จำนวนปีที่จะเพิ่มหรือลด
/// ACTION :: RETURN VALUE STR
/* CALL ::
					datePresent()
*/
function changeDate(strchange, stramount) {
	var temDate = datePresent().split("-");
	if (strchange == "-")
		var temYear = eval(temDate[2] - stramount);
	else
		var temYear = eval(temDate[2] + stramount);
	return temDate[0] + "-" + temDate[1] + "-" + temYear;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: หาตัวไม่เจอ
/// ACTION ::
/// CALL ::
function calEffectiveDate(objEff, objCalEff) {
	if (objEff.value.length > 0) {
		calAge(objEff, objCalEff);
	}
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: หาตัวไม่เจอ (แก้ถูกไหมไม่รู้)
/// ACTION ::
/// CALL ::
function dateAddDay(startDate, amount) {
	var date = startDate.split("-");
	date[0] = date[0] - 1;
	while (amount > 0) {
		if (chkAmountDay(date[1], date[2]) == date[0]) {
			date[1]++;
			if (date[1] > 12) {
				date[2]++;
				date[1] = "0" + 1;
			}
			date[0] = "0" + 1;
			amount--;
		} else {
			date[0]++;
			amount--;
		}
	}

	return date[0] + "-" + date[1] + "-" + date[2];
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: หาตัวไม่เจอ
/// ACTION ::
/// CALL ::
function dateAddMonth(strstartdate, amountdate) {
	var datespl = strstartdate.split("-");
	datespl[0] = eval(datespl[0]);
	datespl[1] = eval(datespl[1]);
	datespl[2] = eval(datespl[2]) + Math.floor(amountdate / 12);
	var temmonth = amountdate % 12;
	if (temmonth > 0) {
		if ((12 - datespl[1] - 1) > temmonth) {
			datespl[1] = eval(datespl[1]) + eval(temmonth);
		} else {
			datespl[2]++;
			datespl[1] = eval(temmonth) - (12 - eval(datespl[1]) - 1);
		}
	}
	if (chkAmountDay(datespl[1], datespl[2]) < datespl[0])
		datespl[0] = chkAmountDay(datespl[1], datespl[2]);
	if (datespl[0] < 10) datespl[0] = "0" + datespl[0];
	if (datespl[1] < 10) datespl[1] = "0" + datespl[1];
	return datespl[0] + "-" + datespl[1] + "-" + datespl[2];
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: หาตัวไม่เจอ
/// ACTION ::
/// CALL ::
function calAmoutDate(strstrartdate, amountdate, typecal, objoutput) {
	if (typecal.value == "M") {
		objoutput.value = dateAddMonth(strstrartdate, amountdate);
	} else {
		objoutput.value = dateAddDay(strstrartdate, amountdate);
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: CREAT DATE PRESENT FORMAT DD-MM-YYYY [แสดงวันปัจจุบัน]
/// ACTION :: RETURN STRING <PROCESS>

/*Edited by Liverman :: 19-04-2012*/
function datePresent() {
	var date, formatdate, day, month;
	date = new Date();
	day = date.getDate() + "";
	month = date.getMonth() + 1 + ""; // +1 Because getMonth is Array
	if (day.length == 1) day = "0" + date.getDate();
	if (month.length == 1) month = "0" + (date.getMonth() + 1);
	formatdate = day + "-" + month + "-" + date.getFullYear();
	return formatdate;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบว่าค่าที่จะตรวจสอบมีอักษรอื่นหรือไม่นอกจาก 0 ถึง 9 และ - หรือไม่
/// ACTION :: RETURN BOOLEAN [ PROCESS ]
function chkIntNotChar(str) {
	var chk = true;
	for (i = 0; i < str.length; i++) {
		chkchr = str.charAt(i);
		if (chkchr != "-" && chkchr != "0" && chkchr != "1" && chkchr != "2" && chkchr != "3" && chkchr != "4" && chkchr != "5" && chkchr != "6" && chkchr != "7" && chkchr != "8" && chkchr != "9") {
			chk = false;
			break;
		}
	}
	return chk;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: จะทำการแปลงจาก ddmmyyyy เป็น dd-mm-yyyy เมื่อพิมเลขครบ 8 หลัก  ( ทุกช่องของวันที่จะใช้สคริปนี้ )
/// ACTION :: RETURN VALUE OBJECT <ON KEYUP>
/* CALL ::
					delWordDate( object ) [PROCESS]
					formatEngYear( string ) [PROCESS]
					datePresent() [PROCESS]
					checkTrueDay( string ) [PROCESS]
*/
function formatDate(obj) {
	var textValue;
	var chkValue
	chkValue = obj.value.split("-");
	textValue = obj.value;
	if (chkIntNotChar(textValue) && (textValue.length == 8) && (textValue == delWordDate(obj.value)) && (chkValue.length < 2)) { // CHECK LENGTH OF VAR X
		if (checkTrueDay(textValue)) { // CHECK DAY NOT FALSE < EX :: 32012004 ==> is false >
			textValue = textValue.substring(0, 2) + "-" + textValue.substring(2, 4) + "-" + textValue.substring(4, 8);
			textValue = formatEngYear(textValue);
			obj.value = textValue;
		} else {
			//alert(MyAlert[29]);
			obj.value = datePresent();
			obj.focus();
		}
	} else if ((chkValue.length == 2) && (chkValue[0].length == 4 && chkValue[1].length == 4)) {
		textValue = chkValue[0].substring(0, 2) + "-" + chkValue[0].substring(2, 4) + "-" + chkValue[1];
		obj.value = textValue;
	} else if ((chkValue.length == 2) && (chkValue[0].length == 2 && chkValue[1].length == 6)) {
		textValue = chkValue[0] + "-" + chkValue[1].substring(0, 2) + "-" + chkValue[1].substring(2, 6);
		obj.value = textValue;
	} else if (!chkIntNotChar(obj.value)) {
		obj.value = datePresent();
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบวันที่ว่าถูกต้องหรือไม่
/// RETURN TO CAUSE :: ON BLUR
/// DATA INPUT IS :: DD-MM-YYYY
/* CALL ::
					chkLimitYear( object , numberlimit ) [PROCESS]
				    delWordDate( str ) [PROCESS]
					checkTrueDay( str ) [PROCESS]
					datePresent();  [PROCESS]
					chkIntNotChar ( str )
*/
function chkInputDate(obj) {
	var temp = obj.value;
	var tempdate = obj.value.split("-");
	var chk = true;
	//ตรวจสอบดูว่าพิมเป็นตัวอักษรหรือไม่
	if (!chkIntNotChar(temp)) {
		alert(MyAlert[30]);
		obj.value = datePresent();
		//obj.focus();
		chk = false;
	}
	//ตรวจสอบดูว่ากรอกตัวเลขครบแปดหลักแล้วหรือไม่
	else if ((obj.value.length < 8) && (obj.value.length > 0)) {
		alert(MyAlert[31]);
		obj.value = datePresent();
		//obj.focus();
		chk = false;
	}
	//ตรวจสอบดูว่าถ้ากรอกวันที่ครบแปดตัวเลขแล้ว กรอก วัน เดือน ปี ถูกต้องหรือไม่ ( โดยเรียก script checkTrueDay(str) )
	else if ((tempdate[0].length == 2) && (tempdate[1].length == 2) && (tempdate[2].length == 4) && (temp.length > 0) && (!checkTrueDay(delWordDate(temp)))) {
		obj.value = datePresent();
		alert(MyAlert[31]);
		//obj.focus();
		chk = false;
	}
	//ตรวจสอบดูว่ากรอก วันเป็นเลขสองหลัก เดือนเป็นเลขสองหลัก และปีเป็นเลขสี่หลักหรือป่าว
	else if ((tempdate[0].length != 2 || tempdate[1].length != 2 || tempdate[2].length != 4) && temp.length > 0) {
		obj.value = datePresent();
		alert(MyAlert[31]);
		//obj.focus();
		chk = false;
	}
	//ตรวจสอบดูว่ากรอกวันเกินสิบตัวเลขหรือไม่ ( กรณีที่เกิดคือ copy คำมาแปะอาจเป็นภาษาไทย หรือ อักษร )
	else if ((temp != delWordDate(obj.value)) && (temp.length > 10)) {
		obj.value = datePresent();
		alert(MyAlert[31]);
		//obj.focus();
		chk = false;
	}
	//ตรวจสอบดูว่ารูปแบบวันที่อยู่ในรูปของ ddmmyyyy หรือ dd-mm-yyyy แล้วหรือยัง
	else if (tempdate.length != 3) {
		obj.value = datePresent();
		alert(MyAlert[31]);
		//obj.focus();
		chk = false;
	}
	//ตรวจสอบดูว่า วันที่กรอกเป็นเลขสองหลัก เดือนเป็นเลขสองหลัก และปีเป็นเลขสี่หลักหรือไม่
	else if ((tempdate[0].length != 2) && (tempdate[1].length != 2) && (tempdate[2].length != 4)) {
		obj.value = datePresent();
		alert(MyAlert[31]);
		//obj.focus();
		chk = false;
	}
	//ตรวจสอบดูว่ากรอกจำนวนปีเกินที่กำหนดหรือไม่
	else if (!chkLimitYear(obj, 80)) {
		obj.value = datePresent();
		alert(MyAlert[32]);
		//obj.focus();
		chk = false;
	}
	return chk; //ถ้ากรอกวันที่ถูกต้องตามเงื่อนไขแล้วจะ retrun เป็น true
}


//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบวันเกิด ( หรือเอาตรวจสอบว่าวันที่กรอกน้อยกว่าวันปัจจุบันหรือไม่ )
/// ACTION :: RETURN BOOLEAN
/* CALL ::
					chkInputDate(obj)
					checkFdateEdate(str1,str2)
*/
function chkBirthDay(obj) {
	var chk = true;
	if (chkInputDate(obj) && !checkFdateEdate(obj.value, datePresent())) {
		chk = false;
		alert(MyAlert[33] + MyAlert[34] + " ( " + obj.value + MyAlert[7] + datePresent() + " )");
		obj.value = datePresent();
		obj.focus();
	}
	return chk
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบวันเกิดว่าต้องน้อยกว่าปีปัจจุบันกี่ปี   ( ถ้าหน้าไหนใช้นอกเหนือ 15 ปีให้ overwrite function เอานะคับ เปลี่ยนเลขตรง changeDate("-",15)  )
/// ACTION :: RETURN ALERT
/* CALL ::
					chkInputDate(obj)  [ BOOLEAN ]
					checkFdateEdate(str1,str2) [ BOOLEAN ]
					changeDate("-", amount year) [ STRING ]
*/
function chkBirthDay2(obj) {
	if (chkInputDate(obj) && !checkFdateEdate(obj.value, changeDate("-", 15))) {
		alert(MyAlert[33] + obj.value + MyAlert[7] + changeDate("-", 15) + MyAlert[35] + " 15 " + MyAlert[26]);
		obj.value = changeDate("-", 15);
		//obj.value = changeDate("-",15);
		obj.focus();
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบวันที่เริ่มต้นต้องน้อยกว่าวันสุดท้าย
/// RETURN TO CAUSE <ON BLUR>
/* CALL ::
					datePresent() [PROCESS]
					chkLimitYear(object,numberlimit) [PROCESS]
					checkFdateEdate(obj1,obj2) [PROCESS]
*/

/*Edit By Liverman Case :: Can't Submit form*/
function chkInputDate2(obj1, obj2) {
	var temp1 = obj1.value;
	var temp2 = obj2.value;
	var tempdate1 = obj1.value.split("-");
	var tempdate2 = obj2.value.split("-");
	var chk = true;
	if (obj1.value == "") {
		if (obj2.value == "") {
			obj1.value = datePresent();
		} else {
			obj1.value = obj2.value;
		}
	}
	if (obj2.value == "") {
		if (obj1.value == "") {
			obj2.value = datePresent();
		} else {
			obj2.value = obj1.value;
		}
	}
	if (!chkInputDate(obj1)) {
		chk = false;
		obj1.focus();
	} else if (!chkInputDate(obj2)) {
		chk = false;
		obj2.focus();
	} else if (!checkFdateEdate(obj1.value, obj2.value)) {
		obj2.value = obj1.value;
		chk = false;
		obj2.focus();
		//alert(MyCode[119]);
	}
	return chk;
}


/*
	function chkInputDate2(obj1,obj2) {
		var temp1 = obj1.value;
		var temp2 = obj2.value;
		var tempdate1 = obj1.value.split("-");
		var tempdate2 = obj2.value.split("-");
		var chk = true;
		if (obj1.value == "") {
			obj1.value = datePresent();
		}
		if (obj2.value == "") {
			obj2.value = datePresent();
		}
		if (!chkInputDate(obj1)) {
			chk = false;
		} else if (!chkInputDate(obj2)) {
			chk = false;
		} else if (!checkFdateEdate(obj1.value,obj2.value)) {
			chk = false;
			obj2.focus();
			obj2.value = obj1.value;
			alert(MyCode[119]);
		}
		return chk;
	}*/

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบวันที่เริ่มต้นต้องน้อยกว่าวันสุดท้าย ( ส่งเลข MyCode มาด้วย )
/// RETURN TO CAUSE <ON BLUR>
/* CALL ::
					datePresent() [PROCESS]
					chkLimitYear(object,numberlimit) [PROCESS]
					checkFdateEdate(obj1,obj2) [PROCESS]
*/
function chkInputDate3(obj1, obj2, numalert) {
	var temp1 = obj1.value;
	var temp2 = obj2.value;
	var tempdate1 = obj1.value.split("-");
	var tempdate2 = obj2.value.split("-");
	var chk = true;
	if (!chkInputDate(obj1)) {
		chk = false;
		if (obj2.value == "") {
			obj2.value = obj1.value;
		}
	} else if (!chkInputDate(obj2)) {
		chk = false;
		if (obj1.value == "") {
			obj1.value = obj2.value;
		}
	} else if (!checkFdateEdate(obj1.value, obj2.value)) {
		chk = false;
		obj2.focus();
		obj2.value = obj1.value;
		alert(MyAlert[numalert]);
	}
	return chk;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบคำนวณอายุ [CALCULATE AGE]
/// ACTION :: RETURN VALUE STRING  <ONBLUR>
/* CALL ::
					calAgeYear(obj.value) [PROCESS]
					chkInputDate(obj) [ONBLUR]
*/
function chkInputDate4(obj, objoutput) {
	if (chkInputDate(obj))
		objoutput.value = calAgeYear(obj.value);
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบวันที่แบบสามวัน [THREE DATE CHECK]
/// ACTION :: RETURN VALUE STRING  <ONBLUR>
/* CALL ::
					chkInputDate(obj) [ONBLUR]
*/
function chkInputDate5(obj1, obj2, obj3) {
	if (chkInputDate2(obj1, obj2))
		chkInputDate2(obj2, obj3);
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบวันที่กรอกต้องไม่น้อยกว่าวันที่ปัจจุบัน
/// ACTION :: RETURN ALERT
/// CALL :: chkInputDate(obj) , checkFdateEdate(str1,str2)
function chkNotLessThanPresent(obj) {
	var temp = obj.value;
	var tempdate = obj.value.split("-");
	if (chkInputDate(obj) && !checkFdateEdate(datePresent(), obj.value)) {
		alert(MyAlert[33] + MyAlert[37] + " ( " + datePresent() + MyAlert[7] + obj.value + " )");
		obj.value = datePresent();
		obj.focus();
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบวันที่กรอกต้องไม่มากกว่าวันที่ปัจจุบัน
/// ACTION :: RETURN ALERT
/// CALL :: chkInputDate(obj) , checkFdateEdate(str1,str2)
function chkNotMoreThanPresent(obj) {
	var temp = obj.value;
	var tempdate = obj.value.split("-");
	if (chkInputDate(obj) && !checkFdateEdate(obj.value, datePresent())) {
		alert(MyAlert[33] + MyAlert[34] + " ( " + obj.value + MyAlert[7] + datePresent() + " )");
		obj.value = datePresent();
		obj.focus();
	}
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบดูว่าวันที่กรอกถูกต้องตามรูปแบบ วัน เดือน ปี หรือไม่ เช่น 32-01-2000 เพราะวันที่ 32 ไม่มี
/// ACTION :: RETURN BOOLEAN <PROCESS>
function checkTrueDay(str) {
	var checktrue = true;
	var day = eval(str.substring(0, 2));
	month = eval(str.substring(2, 4));
	year = eval(str.substring(4, 8));
	if ((day > 31) || (month > 12) || (month < 1) || (day < 1)) checktrue = false;
	else if ((month == 1) || (month == 3) || (month == 5) || (month == 7) || (month == 8) || (month == 10) || (month == 12)) {
		if (day > 31) checktrue = false;
	} else if ((month == 4) || (month == 6) || (month == 9) || (month == 11)) {
		if (day > 30) checktrue = false;
	} else if (month == 2) {
		if ((year % 4) != 0) {
			if (day > 28) checktrue = false;
		} else if ((year % 4) == 0) {
			if (day > 29) checktrue = false;
		}
	}
	return checktrue;
}

//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบตัวเลขแบบทศนิยม [ generate name object ] ลืมใช้ยังไง
/// ACTION :: RETURN BOOLEAN <PROCESS>
/*
		checkNumFloat(temp,0,900000000)
*/
function checkNumFloat$round(obj, str) {
	var temp = document.getElementsByName(chkNextObj(obj, str));
	checkNumFloat(temp, 0, 900000000);
}


//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS ::  ตรวจสอบเงื่อนไขตาม radio
/// ACTION ::
/// CALL ::
function chkYearRadio(radiostat) {
	if (radiostat[0].checked)
		window.event.returnValue = false;
	else
		chkInteger();
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: พิมอักษรอังกฤษได้อย่างเดียว
/// RETURN TO CAUSE <onKeypress>
function chkEng(e) {
	var keyCode = getKeyCode(e);
	if (((keyCode > 122) || (keyCode < 65)) || (((keyCode > 90) && (keyCode < 97))))
		cancelEvents(e);
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: พิมอักษรไทยได้อย่างเดียว
/// RETURN TO CAUSE <onKeypress>
function chkThai(e) {
	var keyCode = getKeyCode(e);
	if ((keyCode < 3585) || (keyCode > 3630))
		cancelEvents(e);
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: พิมอักษรไทยกับอักษรอังกฤษได้อย่างเดียว
/// RETURN TO CAUSE <onKeypress>
function chkThaiEng(e) {
	var keyCode = getKeyCode(e);
	if ((keyCode < 3585 || keyCode > 3660) &&
		(keyCode > 122 || keyCode < 65) ||
		(keyCode > 90 && keyCode < 97))
		cancelEvents(e);
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: พิมได้เฉพาะตัวเลข
/// RETURN TO CAUSE  <onKeypress>
/// SCRIPT OF P'PAE
function chkInteger(e) {
	var keyCode = getKeyCode(e);
	if ((keyCode < 48) || (keyCode > 57))
		cancelEvents(e);
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ห้ามพิมตัวเลข
/// RETURN TO CAUSE  <onKeypress>
function chkNotInteger(e) {
	var keyCode = getKeyCode(e);
	if ((keyCode >= 48) && (keyCode <= 57))
		cancelEvents(e);
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: พิมตัวเลขกับจุดทศนิยมได้อย่างเดียว
/// RETURN TO CAUSE  <onKeypress>
/// SCRIPT OF P'PAE
function chkIntAndComma(e) {
	var keyCode = getKeyCode(e);
	if ((keyCode != 46) && (keyCode < 48) || (keyCode > 57))
		cancelEvents(e);
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตรวจสอบตามเงื่อนไขถ้าค่ามีจุดทศนิยมแล้วจะพิมอีกไม่ได้
/// ACTION :: EVENT WINDOW <onKeypress>
function checkWordNumber(str) {
	if (str.indexOf(".") >= 0)
		chkInteger();
	else
		chkIntAndComma();
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ไม่ใช้แล้ว <USE DATE INPUT>
/// RETURN TO CAUSE  <onKeypress>
/// SCRIPT OF P'PAE
function chkIntegerOfDate(e) {
	var keyCode = getKeyCode(e);
	if ((keyCode < 48) || (keyCode > 57))
		cancelEvents(e);
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ห้ามพิมทุกอย่าง
/// RETURN TO CAUSE  <onKeypress>
function blockWord(e) {
	cancelEvents(e);
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: พิมได้เฉพาะ $ และ ฿ เท่านั้น
/// RETURN TO CAUSE  <onKeypress>
function chkMoneySymbol(e) {
	var keyCode = getKeyCode(e);
	if ((keyCode != 36) && (keyCode != 3647)) {
		cancelEvents(e);
	}
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: พิมได้เฉพาะตัวเลข และลูกน้ำ ( , ) ได้เท่านั้น
/// RETURN TO CAUSE  <onKeypress>
function chkInputNumPhone(e) {
	var keyCode = getKeyCode(e);
	// if ((keyCode != 44) && (keyCode < 48) || (keyCode > 57))
	if ((keyCode != 44) && (keyCode != 45) && (keyCode < 48) || (keyCode > 57))
		cancelEvents(e);
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ทดสอบ alert keycode
/// RETURN TO CAUSE  <onKeypress>
function a(e) {
	var keyCode = getKeyCode(e);
	alert(keyCode);
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ห้ามพิมอักขระพิเศษ
/// RETURN TO CAUSE  <onKeypress>
/// 59= ; , 60= > , 62= < , 34= " , 35= # , 39= ' , 92= \
// (keyCode == 34) || (keyCode == 35) ||
function chkSpecialStr(e) {
	var keyCode = getKeyCode(e);
	if ((keyCode == 59) || (keyCode == 60) || (keyCode == 62) || (keyCode == 92))
		cancelEvents(e);
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ห้ามพิมอักษรไทยอย่างเดียว
/// RETURN TO CAUSE  <onKeypress>
function chkNotThaiChaOnly(e) {
	var keyCode = getKeyCode(e);
	if (keyCode >= 3585 && keyCode <= 3673) {
		cancelEvents(e);
	}
}
//========================================= กรุณาเขียนสคริปต่อหลังนะครับอย่าแทรก ===========================================//
/// ABOUT FUNCTION IS :: ตัดช่องว่างหน้าและหลังข้อความออก <system use>
/// RETURN TO CAUSE  <onKeypress>
function trimValue(obj) {
	var temp = Trim(obj.value);
	obj.value = temp;
}

// ============================================= End My Script Of Sin ================================================= //
// ============================================= อย่าลบหรือเพิ่มต่อนะคับ =================================================== \\

//for training start
function notBlankOnThisPage() {
	return notBlankOnPage(document.cscform);
}

function notBlankOnParentPage() {
	return notBlankOnPage(window.parent.document.cscform);
}

function notBlankOnPage(frm) {
	with(frm) {
		var tmp = setFieldListOnPage(frm);
		var tmp_chk = tmp.split(",");
		var i = 0;
		for (; i < tmp_chk.length && notBlankInIt(frm, tmp_chk[i]); i++) {}
	}
	return (i == tmp_chk.length);
}

function notBlankInIt(frm, target) {
	var tmp = "__" + target;
	with(frm) {
		for (i = 0; i < elements.length; i++) {
			if (elements[i].type != "hidden" && elements[i].name == tmp) {
				if (elements[i].value == null || elements[i].value == "") {
					elements[i].focus()
					alert(MyCode[0]);
					return false;
				}
			}
		}
		return true;
	}
}

function setFieldListOnPage(frm) {
	with(frm) {
		var tmp = __notNull.value;
		var tmp_chk = tmp.split(",");
		tmp = "";
		for (i = 0; i < elements.length; i++) {
			if (elements[i].type != "hidden") {
				for (j = 0; j < tmp_chk.length; j++) {
					if (elements[i].name == ("__" + tmp_chk[j])) {
						tmp += tmp_chk[j] + ",";
					}
				}
			}
		}
		return tmp;
	}
}
//for training end

/*
function name : linkHelp_Return2
write by : james
parameter :
		help : hele name
		input : fields for return value
		fixCon = fix filter
*/
function linkHelp_Return2(help, input, fixCon) {
	with(document.cscform) {
		var nInput = input;
		if (input.indexOf(":") > 0) {
			nInput = input.substring(0, input.indexOf(":"));
		}
		obj = eval("document.cscform." + nInput);
		if ((obj == "") || (obj.value == "")) {
			var param = "PRU084.jsp?__helpName=" + help + "&__helpReturn=" + input + "&__pageCall=" + __screen.value + "&__fixCon=" + fixCon + "&__checkVerify=off";
		} else {
			var param = "PRU084.jsp?__helpName=" + help + "&__helpReturn=" + input + "&__pageCall=" + __screen.value + "&__fixCon=" + fixCon + "&__checkVerify=off" + "&__valueSearch=" + obj.value;
		}

		var win = window.open(param, "Help", "left=150,top=150,width=800,height=400,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
		if (window.focus) {
			win.focus();
		}
	}
}

//-----------------------------------------------------
// getKeyCode ใช้สำหรับดักจับ keypress จากหน้าจอ
function getKeyCode(e) {
	var keynum;
	if (!e) {
		e = window.event;
	}
	if (window.event) { // for IE, e.keyCode or window.event.keyCode can be used
		keynum = e.keyCode;
	} else if (e.which) { // for  NS4, FF compatible
		keynum = e.which;
	} else if (e.charCode) { //also NS 6+, Mozilla 0.9+
		keynum = e.charCode;
	} else { // no event, so pass through
		keynum = 0;
	}
	return keynum;
}

function cancelEvents(e) {
	if (window.event) {
		window.event.returnValue = false;
		//window.event.cancelBubble = true;
	} else {
		if (e.charCode > 0 && e.which > 0) {
			e.preventDefault();
		}
	}
}

function stopEvent(e) {
	e || window.event;
	if (e.stopPropagation) {
		e.stopPropagation();
		e.preventDefault();
	} else if (typeof e.cancelBubble != "undefined") {
		e.cancelBubble = true;
		e.returnValue = false;
	}
	return false;
}


//____________________________________________________________________
//1DSOFT EDIT
function addNew() {
	erChildSysIsEdit();
	if (nullCheckER()) {
		bcon = confirm(ThaiCode[1]);
		if (bcon) {
			with(document.cscform) {
				if (editac.value == "true") {
					cmd.value = "editChild";
				} else {
					cmd.value = "addChild";
				}
				successed.value = "true";
				submit();
			}
		}
	}
}

function nullCheckER() {
	for (var i = 0; i < document.cscform.length; i++) {
		if (nullField(i)) {
			if (((document.cscform.elements[i].value == null) || (document.cscform.elements[i].value == "")) && (document.cscform.elements[i].type != "hidden")) {
				alert(MyCode[0]);
				document.cscform.elements[i].focus();
				with(document.cscform) {
					if ((typeof __actioned) != "undefined") {
						__actioned.value = "";
					}
				}
				return false;
			}
		}
	}
	return true;
}

function chkSuccessed() {
	if (document.cscform.successed.value == "true") {
		window.opener.document.cscform.submit();
		//window.close();
	}
}

function delChild() {
	bcon = confirm(ThaiCode[4]);
	if (bcon) {
		with(document.cscform) {
			cmd.value = "delChild";
			submit();
		}
	}
}

function erChildSysIsEdit() {
	if ((typeof window.opener.parent.parent.leftFrame) != "undefined") {
		with(window.opener.parent.parent.leftFrame.cscform) {
			__sysisedit.value = "true";
		}
	}
}
// Nuball Edit for HelpEntry Value 07-12-07
function chonKeyup(input, data) {
	var cType = chType();
	if (cType == "Float") {
		checkComma(input, 2);
	} else {
		if (cType == "Double") {
			checkComma(input, 2);
		} else {
			if (cType == "Integer") {

			} else {
				if (cType == "Date") {
					formatDate(input);
				}
			}
		}
	}
}

function chonBlur(input, data) {
	var cType = chType();
	trimValue(input);
	if (cType == "Float") {
		checkNumFloat(input, 0, 900000000);
	} else {
		if (cType == "Double") {
			checkNumFloat(input, 0, 900000000);
		} else {
			if (cType == "Integer") {
				checkNumInt(input, 0, 900000000);
			} else {
				if (cType == "Date") {
					chkInputDate(input);
				}
			}
		}
	}
}

function chonFocus(input, data) {
	var cType = chType();
	if (cType == "Float") {
		callDelComma(input);
	} else {
		if (cType == "Double") {
			callDelComma(input);
		} else {
			if (cType == "Integer") {
				callDelComma(input);
			} else {
				if (cType == "Date") {
					with(document.cscform) {
						var tmp_Date = __valueSearch.value.split("-");

						if (tmp_Date[0].length > 3)
							__valueSearch.value = tmp_Date[2] + '-' + tmp_Date[1] + '-' + tmp_Date[0];
					}
				}
			}
		}
	}
}

function chonKeyPress(input, data, e) {
	var cType = chType();
	if (cType == "Float") {
		checkWordNumber(data, e);
	} else {
		if (cType == "Double") {
			checkWordNumber(data, e);
		} else {
			if (cType == "Integer") {
				chkInteger(e);
			} else {
				if (cType == "Date") {
					chkIntegerOfDate(data, e);
				}
			}
		}
	}
}

function chType() {
	with(document.cscform) {
		var tmp_chk = __searchBy.value.split(".");
		var tmp_field = __listtypefield.value.split("#");
		for (i = 0; i < tmp_field.length; i++) {
			var tmp_type = tmp_field[i].split(":");
			if (tmp_type[0] == tmp_chk[1]) {
				return tmp_type[1];
			}
		}
		return "";
	}
}

function clsValueSearch() {
	document.cscform.__valueSearch.value = "";
}

function searchH() {
	var cType = chType();
	with(document.cscform) {
		if (cType == "Date") {
			var tmp_Date = __valueSearch.value.split("-");
			if (tmp_Date[0].length < 3)
				__valueSearch.value = tmp_Date[2] + '-' + tmp_Date[1] + '-' + tmp_Date[0];

		} else {
			if ((cType == "Integer") || (cType == "Double") || (cType == "BigDecimal")) {
				__valueSearch.value = delComma(__valueSearch.value);
			}
		}
		__cmd.value = "search";
		submit();
	}
}
/***********************************/
//lambkin 20080513 for KKB
function setEmpIdformenu(empid) {
	//alert(empid);
	with(window.parent.document.cscform) {
		__empid.value = empid;
	}
}

function setYearOfMarry(obj, yearofmarry) {
	with(document.cscform) {
		if (obj && yearofmarry) {
			var _date = obj.value;
			if (_date) {
				var tmp_Date = _date.split("-");
				if (tmp_Date && tmp_Date.length === 3 && tmp_Date[2].length === 4) {
					yearofmarry.value = tmp_Date[2];
				}
			}
		}
	}
}

/// ABOUT FUNCTION IS :: ห้ามพิมอักขระพิเศษ
/// RETURN TO CAUSE  <onKeypress>
/// 59= ; , 60= > , 62= < , 34= " , 35= # , 39= ' , 92= \  44= ,   ,45= -  , 46=.  ,47=/,58=:  ,61= =  ,91=[ ,93= ] ,96= `
//  41 = ) , 33 = ! , 64 = @ , 35 = # , 36 = $  , 37 = % , 94 = ^ , 38 = & , 42 = * , 40= (  ,
// (keyCode == 34) || (keyCode == 35) ||
function chkSpecialKey(e) {
	var keyCode = getKeyCode(e);
	//alert(keyCode);
	//if (!((keyCode == 32) || (keyCode >= 47 && keyCode <= 57) || (keyCode >= 65 && keyCode <= 90)  || (keyCode >= 3585 && keyCode <= 3652) || (keyCode >= 97 && keyCode <= 122) ) ){
	if (!((keyCode == 32) || (keyCode == 95) || (keyCode >= 45 && keyCode <= 57) || (keyCode >= 65 && keyCode <= 90) || (keyCode >= 3585 && keyCode <= 3652) || (keyCode >= 97 && keyCode <= 122))) {
		cancelEvents(e);
	}
}

function chkexceedingyear(obj1, obj2) {
	with(document.cscform) {
		var val1 = obj1.value * 1;
		var val2 = obj2.value * 1;
		if (val1 > val2) {
			alert(MyCode[200]);
			obj1.value = obj2.value;
		}
	}
}

function chkexceedingmonth(obj1, obj2) {
	with(document.cscform) {
		var val1 = obj1.value * 1;
		var val2 = obj2.value * 1;
		if (val1 > val2) {
			alert(MyCode[201]);
			obj1.value = obj2.value;
		}
	}
}

function swaplang2() {
	this.file_name = this.setTarget();
	this.objDOM = this.setXML();
};
swaplang2.prototype = {
	setTarget: function () {
		var path = window.location.pathname;
		var lang = getLang().toUpperCase();
		var module;
		file_name = 'XML/' + lang + '_CENTER_SWAPLANG.xml';
		if (path.substring(0, path.lastIndexOf("/")) !== '/hr') {
			module = path.substring(path.indexOf("/", 1) + 1, path.lastIndexOf("/"));
			file_name = '../XML/' + lang + '_' + module + '_SWAPLANG.xml';
		}
		return file_name;
	},
	setXML: function () {
		if (window.ActiveXObject) {
			objDOM = new ActiveXObject("Msxml.DOMDocument");
			objDOM.async = false;
			objDOM.load(file_name);
		} else if (window.XMLHttpRequest) {
			var xmlDoc = new XMLHttpRequest();
			xmlDoc.open('GET', file_name, false);
			try {
				xmlDoc.responseType = 'msxml-document';
			} catch (e) {}
			xmlDoc.send(null);
			objDOM = xmlDoc.responseXML;
		}
		return objDOM;
	},
	swap2String: function (codeid) {
		return objDOM.selectSingleNode("/changelanguage/" + codeid).firstChild.nodeValue;
	},
	write: function (codeid) {
		document.write(this.swap2String(codeid));
	}
}

function goExport(scrn, reftype, clsname) {
	if (scrn == "EXPORTSALARY") {
		jsppage = "PRT005.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname;
	} else if (scrn == "EXPORTLOAN") {
		jsppage = "PRT006.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname;
	} else if (scrn == "EXPORTBANK") {
		jsppage = "PRT003-BANK.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname;
	} else if (scrn == "EXPORTVIEW") {
		jsppage = "PRT007.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname;
	} else if (scrn == "EXPORTTAXINTERNET") {
		jsppage = "PRT008.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname;
	} else if (scrn == "EXPORTBANKSCB") {
		jsppage = "PRT003-BANKSCB.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname;
	} else if (scrn == "EXPORTBANKBBL") {
		jsppage = "PRT003-BANKBBL.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname;
	} else if (scrn == "EXPORTBANKKBK") {
		jsppage = "PRT003-BANKKBK.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname;
	}
	$("#mainFrame").attr('src', jsppage);
}

function goExportBank(scrn, reftype, clsname, bankid, bankcode) {
	jsppage = "PRT003-BANKV2.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname + "&__bankid=" + bankid + "&__bankcode=" + bankcode;
	$("#mainFrame").attr('src', jsppage);
}

function goExport1(scrn, reftype, clsname, path, fold) {
	jsppage = "PRT003-EASYBUY.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname + "&__path=" + path + "&__dir=" + fold;
	$("#mainFrame").attr('src', jsppage);
}

function goExport2(scrn, reftype, clsname) {
	jsppage = "PRT004.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname;
	$("#mainFrame").attr('src', jsppage);
}

function goExportSOC(scrn, reftype, clsname, path, fold, xmlfile) {
	jsppage = "PRT003-SOC.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname + "&__path=" + path + "&__dir=" + fold + "&__xmlfile=" + xmlfile;
	$("#mainFrame").attr('src', jsppage);
}

function goExportPVF(scrn, reftype, clsname, path, fold, xmlfile) {
	jsppage = "ASR001.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname + "&__path=" + path + "&__dir=" + fold + "&__xmlfile=" + xmlfile;
	$("#mainFrame").attr('src', jsppage);
}

function goExportPVF2(scrn, reftype, clsname, path, fold, xmlfile) {
	with(document.cscform) {
		action = "PRT003-PVF.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname + "&__path=" + path + "&__dir=" + fold + "&__xmlfile=" + xmlfile;
		submit();
	}
}

function goExportPVF_HIS(scrn, reftype, clsname, path, fold, xmlfile) {
	with(document.cscform) {
		action = "PRT003-PVFHIS.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname + "&__path=" + path + "&__dir=" + fold + "&__xmlfile=" + xmlfile;
		submit();
	}
}

function goExportTAX(scrn, reftype, clsname, path, fold, xmlfile) {
	jsppage = "PRT003-TAX.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname + "&__path=" + path + "&__dir=" + fold + "&__xmlfile=" + xmlfile;
	$("#mainFrame").attr('src', jsppage);
}

function goExportSalary(scrn, reftype, clsname) {
	jsppage = "PRT005.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname;
	$("#mainFrame").attr('src', jsppage);
}

function goExportExcel(scrn, reftype, clsname, fold) {
	jsppage = "PRT010.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname + "&__dir=" + fold;
	$("#mainFrame").attr('src', jsppage);
}

function showHelpPage(module, filename) {
	jsppage = "/hr/HELPPAGE.jsp?__module=" + module + "&__filename=" + filename;
	window.open(jsppage, "Help", "left=150,top=150,width=900,height=500,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
}

function golinkpageSSO(scrn, reftype, clsname) {
    jsppage = "PRT003-SSO.jsp?__screen=" + scrn + "&__ref_type=" + reftype + "&__classname=" + clsname;
    $("#mainFrame").attr('src', jsppage);
}

/*Edited by Kanok :: 08-01-2015*/
/// ABOUT FUNCTION IS :: CREAT DATE PRESENT FORMAT YYYY-MM-DD [แสดงวันปัจจุบัน]
function datePresentreport() {
	var date, formatdate, day, month;
	date = new Date();
	day = date.getDate() + "";
	month = date.getMonth() + 1 + "";
	if (day.length == 1) day = "0" + date.getDate();
	if (month.length == 1) month = "0" + (date.getMonth() + 1);
	formatdate = date.getFullYear() + "-" + month + "-" + day;
	return formatdate;
}


/*Edit By kanok */


function chkInputDatereport(obj) {
	var temp = obj.value;
	var tempdate = obj.value.split("-");
	var chk = true;
	//ตรวจสอบดูว่าพิมเป็นตัวอักษรหรือไม่
	if (!chkIntNotChar(temp)) {
		alert(MyAlert[30]);
		obj.value = datePresentreport();
		obj.focus();
		chk = false;
	}
	//ตรวจสอบดูว่ากรอกตัวเลขครบแปดหลักแล้วหรือไม่
	else if ((obj.value.length < 8) && (obj.value.length > 0)) {
		alert(MyAlert[38]);
		obj.value = datePresentreport();
		obj.focus();
		chk = false;
	}
	//ตรวจสอบดูว่าถ้ากรอกวันที่ครบแปดตัวเลขแล้ว กรอก วัน เดือน ปี ถูกต้องหรือไม่ ( โดยเรียก script checkTrueDaySTD(str) )
	else if ((tempdate[0].length == 4) && (tempdate[1].length == 2) && (tempdate[2].length == 2) && (temp.length > 0) && (!checkTrueDaySTD(delWordDate(temp)))) {
		alert(MyAlert[38]);
		obj.focus();
		chk = false;
	}
	//ตรวจสอบดูว่ากรอก วันเป็นเลขสองหลัก เดือนเป็นเลขสองหลัก และปีเป็นเลขสี่หลักหรือป่าว
	else if ((tempdate[0].length != 4 || tempdate[1].length != 2 || tempdate[2].length != 2) && temp.length > 0) {
		alert(MyAlert[38]);
		obj.focus();
		chk = false;
	}
	//ตรวจสอบดูว่ากรอกวันเกินสิบตัวเลขหรือไม่ ( กรณีที่เกิดคือ copy คำมาแปะอาจเป็นภาษาไทย หรือ อักษร )
	else if ((temp != delWordDate(obj.value)) && (temp.length > 10)) {
		obj.value = datePresentreport();
		alert(MyAlert[38]);
		obj.focus();
		chk = false;
	}
	//ตรวจสอบดูว่ารูปแบบวันที่อยู่ในรูปของ ddmmyyyy หรือ dd-mm-yyyy แล้วหรือยัง
	else if (tempdate.length != 3) {
		obj.value = datePresentreport();
		alert(MyAlert[38]);
		obj.focus();
		chk = false;
	}
	//ตรวจสอบดูว่า วันที่กรอกเป็นเลขสองหลัก เดือนเป็นเลขสองหลัก และปีเป็นเลขสี่หลักหรือไม่
	else if ((tempdate[0].length != 4) && (tempdate[1].length != 2) && (tempdate[2].length != 2)) {
		obj.value = datePresentreport();
		alert(MyAlert[38]);
		obj.focus();
		chk = false;
	}
	//ตรวจสอบดูว่ากรอกจำนวนปีเกินที่กำหนดหรือไม่
	else if (!chkLimitYearSTD(obj, 80)) {
		alert(MyAlert[39]);
		obj.focus();
		chk = false;
	}
	return chk; //ถ้ากรอกวันที่ถูกต้องตามเงื่อนไขแล้วจะ retrun เป็น true
}

function checkTrueDaySTD(str) {
	var checktrue = true;
	//var day = eval(str.substring(0,2));  month = eval(str.substring(2,4));  year = eval(str.substring(4,8));
	var day = eval(str.substring(6, 8));
	month = eval(str.substring(4, 6));
	year = eval(str.substring(0, 4));
	if ((day > 31) || (month > 12) || (month < 1) || (day < 1)) checktrue = false;
	else if ((month == 1) || (month == 3) || (month == 5) || (month == 7) || (month == 8) || (month == 10) || (month == 12)) {
		if (day > 31) checktrue = false;
	} else if ((month == 4) || (month == 6) || (month == 9) || (month == 11)) {
		if (day > 30) checktrue = false;
	} else if (month == 2) {
		if ((year % 4) != 0) {
			if (day > 28) checktrue = false;
		} else if ((year % 4) == 0) {
			if (day > 29) checktrue = false;
		}
	}
	return checktrue;
}

function chkLimitYearSTD(obj, limityear) {
	var yearpresent = datePresentreport().substring(0, 4),
		check = true,
		yearbd = obj.value.substring(0, 4);
	if (obj.value != '1900-01-01' && obj.value != '2100-12-31') {
		if (obj.value.length == 4) {
			if ((eval(obj.value) > eval(yearpresent) + limityear) || (eval(obj.value) < eval(yearpresent) - limityear)) check = false;
		} else if (obj.value.length == 10) {
			if ((eval(obj.value.substring(0, 4)) > eval(yearpresent) + limityear) || (eval(obj.value.substring(0, 4)) < eval(yearpresent) - limityear)) {
				check = false;
			}
		}
	}
	return check;
}

function formatDatereport(obj) {
	var textValue;
	var chkValue
	chkValue = obj.value.split("-");
	textValue = obj.value;
	if (chkIntNotChar(textValue) && (textValue.length == 8) && (textValue == delWordDate(obj.value)) && (chkValue.length < 2)) { // CHECK LENGTH OF VAR X
		if (checkTrueDaySTD(textValue)) { // CHECK DAY NOT FALSE < EX :: 32012004 ==> is false >
			textValue = textValue.substring(0, 4) + "-" + textValue.substring(4, 6) + "-" + textValue.substring(6, 8);
			textValue = formatEngYear(textValue);
			obj.value = textValue;
		} else {
			//alert(MyAlert[29]);
			obj.value = datePresentreport();
			obj.focus();
		}
	} else if ((chkValue.length == 2) && (chkValue[0].length == 4 && chkValue[1].length == 4)) {
		textValue = chkValue[0].substring(0, 2) + "-" + chkValue[0].substring(2, 4) + "-" + chkValue[1];
		obj.value = textValue;
	} else if ((chkValue.length == 2) && (chkValue[0].length == 2 && chkValue[1].length == 6)) {
		textValue = chkValue[0] + "-" + chkValue[1].substring(0, 2) + "-" + chkValue[1].substring(2, 6);
		obj.value = textValue;
	} else if (!chkIntNotChar(obj.value)) {
		obj.value = datePresentreport();
	}
}

/*
 * == เพิ่ม function สำหรับการ Return ค่าเวลาที่ใช้งาน help กับ angular ==
 * Natthapong Maiwan
 * 13-09-2016
 * linkHelp_Angular, backPage_ReturnAngular , backPageAngular , postReturnAngular
 */
function linkHelp_Angular(helpname, helpreturn, fixcon) {
	with(document.cscform) {
		var param = "PRU084_angular.jsp?__helpName=" + helpname + "&__pageCall=" + __screen.value + "&__fixCon=" + fixcon + "&tdeq=1&__helpReturn=" + helpreturn;
		var win = this.open(param, "Help2", "left=300,top=150,width=700,height=400,resizable=yes,scrollbars=yes,toolbar=no,status=yes");
		if (window.focus) {
			win.focus();
		}
	}
}

function backPage_ReturnAngular(valueList) {
	with(window.opener) {
		var item = valueList.split(';');
		for (var i = 0; i < item.length; i++) {
			var objlist = item[i].split('$$');
			var objname = objlist[0];
			var proplist = objlist[1].split('#');
			var propname = proplist[0];
			var propvalue = proplist[1];


			var scope = angular.element(document.cscform).scope();
			scope.$apply(function () {
				scope[objname][propname] = propvalue;
			});
		}
		if (typeof postReturn != "undefined") { // เอาให้ทำให้หน้าที่เรียกทำ การsubmit ค่าเพื่อแสดงข้แมูลออกมา
			postReturn();
		}
	}
	this.close();
}

function backPageAngular(valueList) {
	with(window.opener.document.cscform) {
		window.opener.postReturnAngular(valueList);
	}
	window.close();
}

function postReturnAngular(valueList) {
	/*
	*ตัวอย่างการใช้งาน
	* valueList จะได้เป็นชื่อ field +value ตย. __questionset4id#Test1 , __questionset4id คือชื่อ input และ Test1 คือ value
		var scope = angular.element($("form[name=cscform]")).scope();
		scope.$apply(function(){
			//ชื่อ function ที่ต้องกา่ร call ใน angular
		});
	*/
}

function clearSearch(inputName) {
	with(document.cscform) {
		var input_arr = inputName.split(",");
		for (var i = 0; i < input_arr.length; i++) {
			var inputObj = document.getElementsByName(input_arr[i])[0];
			inputObj.value = "";
		}
	}
}
/* IN EMPVIEW/SHOWPAYSLIP.JSP */
function demoTable() {
	var jsonString = jQuery.parseJSON($("input[name=json_string]").val().replace(/'/g, '"'));
	jsonString.forEach(function (jsondata) {
		jsondata.datalist.forEach(function (keys) {
			$("." + keys).text($("input[name=" + keys + "]").text())
		})
	});
}
/* END EMPVIEW/SHOWPAYSLIP.JSP */