
	// Function Name : Paging_CheckAll(objCheckHeader,txtCheckBoxFirstName,intTotalItems)
	// Create Date : 01-07-2004
	// Last Update : 01-07-2004
	// Function Desc : ??????? Paging_CheckAll ?????????????? checkbox ?????????????
	
	function Paging_CheckAll(objCheckHeader,txtCheckBoxFirstName,intTotalItems)
	{
		if(intTotalItems>0)
			for(i=1;i<=intTotalItems;i++)
				document.getElementById(txtCheckBoxFirstName+i).checked = objCheckHeader.checked;			
		return true;
	
	}

	// Function Name : Paging_CheckAllHandle(objCheckHeader,txtCheckBoxFirstName,intTotalItems)
	// Create Date : 01-07-2004
	// Last Update : 01-07-2004
	// Function Desc : ??????? Paging_CheckAllHandle ?????????????? checkbox ?????????????
	
	function Paging_CheckAllHandle(objCheckHeader,txtCheckBoxFirstName,intTotalItems)
	{
		var isCheckedAll = true;
		if(intTotalItems>0)
			for(i=1;i<=intTotalItems;i++)
				if(!document.getElementById(txtCheckBoxFirstName+i).checked) 
				isCheckedAll = false;
		objCheckHeader.checked = isCheckedAll;
		return true;
	}
	
	// Function Name : Paging_CountChecked(txtCheckBoxFirstName,intTotalItems)
	// Create Date : 01-07-2004
	// Last Update : 01-07-2004
	// Function Desc : ??????? Paging_CountChecked ?????????????????????? Checkbox ??????????????????????

	function Paging_CountChecked(txtCheckBoxFirstName,intTotalItems)
	{
		var intChecked = 0;
		if(intTotalItems>0)
			for(i=1;i<=intTotalItems;i++)
				if(document.getElementById(txtCheckBoxFirstName+i).checked) 
				intChecked ++;
		return intChecked ;
	}

	// Function Name : Paging_CheckedThisItem(objCheckHeader,indexing,txtCheckBoxFirstName,intTotalItems)
	// Create Date : 01-07-2004
	// Last Update : 01-07-2004
	// Function Desc : ??????? Paging_CheckedThisItem ????????????????????????????????? Checkbox

	function Paging_CheckedThisItem(objCheckHeader,indexing,txtCheckBoxFirstName,intTotalItems)
	{
		if(intTotalItems>0)
			for(i=1;i<=intTotalItems;i++)
				if(i==indexing) {
					document.getElementById(txtCheckBoxFirstName+i).checked = true;
				} else {
					document.getElementById(txtCheckBoxFirstName+i).checked = false;
				}
		objCheckHeader.checked = false;
		return true;
	}

	// Function Name : Check_Field_For_View(Form,CheckBoxID,TotalCheckBoxID)
	// Create Date : 01-07-2004
	// Last Update : 01-07-2004
	// Function Desc : ??????? Check_Field_For_View ??????????????????????? action ??????? view ????????????????????????? ???????????????????????????????????????????????

	function Check_Field_For_View(Form,CheckBoxID,TotalCheckBoxID)
	{
		if(Paging_CountChecked('CheckBoxID',TotalCheckBoxID)==1) {
			Form.action.value='view';
			Form.submit();
		} else {
			alert('กรุณาเลือกรายารที่ต้องการแสดง 1 รายการ');
		}
	}

	// Function Name : Check_Field_For_Addnew(Form)
	// Create Date : 01-07-2004
	// Last Update : 01-07-2004
	// Function Desc : ??????? Check_Field_For_Addnew ????????????????? action ??????? addnew ??????????????????????????????
	
	function Check_Field_For_Addnew(Form)
	{
		Form.action.value='add';
		Form.submit();
	}

	// Function Name : Check_Field_For_Edit(Form)
	// Create Date : 01-07-2004
	// Last Update : 01-07-2004
	// Function Desc : ??????? Check_Field_For_Edit ??????????????????????? action ??????? edit ??????????????????????????? ???????????????????????????????????????????????
	
	function Check_Field_For_Edit(Form,CheckBoxID,TotalCheckBoxID)
	{
		if(Paging_CountChecked('CheckBoxID',TotalCheckBoxID)==1) {
			Form.action.value='edit';
			Form.submit();
		} else {
			alert('กรุณาเลือกรายการที่ต้องการแก้ไข 1 รายการ');
		}
	}

	// Function Name : Check_Field_For_Edit(Form)
	// Create Date : 01-07-2004
	// Last Update : 01-07-2004
	// Function Desc : ??????? Check_Field_For_Edit ??????????????????????? action ??????? edit ??????????????????????????? ???????????????????????????????????????????????

	function Check_Field_For_Delete(Form,CheckBoxID,TotalCheckBoxID)
	{
		if(Paging_CountChecked('CheckBoxID',TotalCheckBoxID)>0) {
			if(confirm('คุณต้องการลบรายการนี้ใช่ หรือ ไม่')) {
				Form.action.value='delete';
				Form.submit();
			}
		} else {
			alert('คุณต้องการลบรายการนี้ใช่ หรือ ไม่?');
		}
	}
	
	// Function Name : isBlank(myObj)
	// Create Date : 02-07-2004
	// Last Update : 02-07-2004
	// Function Desc : ??????? isBlank ??????????????????????????????????

	function isBlank(myObj) {
		if(myObj.value=='') { return true; }
		return false;
	}

	// Function Name : CloseSubModule(Form)
	// Create Date : 02-07-2004
	// Last Update : 02-07-2004
	// Function Desc : ??????? CloseSubModule  ???????????????????????????????????????????????
	
	function CloseSubModule(Form)
	{
		if(confirm('คุณต้องการปิดหน้าต่างนี้ใช่หรือไม่?')){
			Form.submit();
		}
	}

	// Function Name : isEmail(str) 
	// Create Date : 05-07-2004
	// Last Update : 05-07-2004
	// Function Desc : ??????? isEmail(str)  ?????????????????????????????
		
	function isEmail(str) {
	  var supported = 0;
	  if (window.RegExp) {
	    var tempStr = "a";
	    var tempReg = new RegExp(tempStr);
	    if (tempReg.test(tempStr)) supported = 1;
	  }
	  if (!supported) 
	  return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	  return (!r1.test(str) && r2.test(str));
	}	

	// Function Name : HideShowSpan(SpanID)
	// Create Date : 12-07-2004
	// Last Update : 12-07-2004
	// Function Desc : ??????? HideShowSpan ?????????????????????????? span code
		
	function HideShowSpan(SpanID)
	{
		if(document.getElementById(SpanID).style.display=='')
		{
			document.getElementById(SpanID).style.display='none';
		}else{
			document.getElementById(SpanID).style.display='';
		}
	}
	
	// Function Name : currencyFormat(fld, milSep, decSep, e)
	// Create Date : 12-07-2004
	// Last Update : 12-07-2004
	// Function Desc : ??????? currencyFormat ???????????????????????????????????????????????????????
		
	function currencyFormat(fld, milSep, decSep, e) {
		var sep = 0;
		var key = '';
		var i = j = 0;
		var len = len2 = 0;
		var strCheck = '0123456789';
		var aux = aux2 = '';
		var whichCode = (window.Event) ? e.which : e.keyCode;
		//if (whichCode == 13) return true;  // Enter
		key = String.fromCharCode(whichCode);  // Get key value from key code
		if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
		len = fld.value.length;
		for(i = 0; i < len; i++)
			if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
			aux = '';
			for(; i < len; i++)
			if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
				aux += key;
				len = aux.length;
				if (len == 0) fld.value = '';
				if (len == 1) fld.value = '0'+ decSep + '0' + aux;
				if (len == 2) fld.value = '0'+ decSep + aux;
				if (len > 2) {
					aux2 = '';
					for (j = 0, i = len - 3; i >= 0; i--) {
						if (j == 3) {
						aux2 += milSep;
						j = 0;
						}
						aux2 += aux.charAt(i);
						j++;
					}
					fld.value = '';
					len2 = aux2.length;
					for (i = len2 - 1; i >= 0; i--)
						fld.value += aux2.charAt(i);
						fld.value += decSep + aux.substr(len - 2, len);
				}
				return false;
		}
		
		function PhoneFormat(fld,e)
		{
			var strCheck = '0123456789-#';
			var len = 0;
			var whichCode = (window.Event) ? e.which : e.keyCode;
			key = String.fromCharCode(whichCode); 
			if (strCheck.indexOf(key) == -1) return false;
		}
		function numberFormat(fld,e)
		{
			var strCheck = '0123456789';
			var len = 0;
			var whichCode = (window.Event) ? e.which : e.keyCode;
			key = String.fromCharCode(whichCode); 
			if (strCheck.indexOf(key) == -1) return false;
		}
		function floatFormat(fld,e)
		{
			var strCheck = '0123456789.';
			var len = 0;
			var whichCode = (window.Event) ? e.which : e.keyCode;
			key = String.fromCharCode(whichCode); 
			if (strCheck.indexOf(key) == -1) return false;
		}
		function checkcharactorEng(fld,e)
		{
			var strCheck = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz';
			var len = 0;
			var whichCode = (window.Event) ? e.which : e.keyCode;
			key = String.fromCharCode(whichCode); 
			if (strCheck.indexOf(key) == -1) return false;
		}
		
		function CheckImageType(myfiles)
		{
				myfile=myfiles.value;
				myfile = myfile.toLowerCase();
				Temp = myfile.charAt(myfile.length-4) + myfile.charAt(myfile.length-3) + myfile.charAt(myfile.length-2) + myfile.charAt(myfile.length-1);
				if(Temp!='.jpg' && Temp!='.gif' && Temp!='jpeg') {
					alert('???????????????????????????????????.');
					return false;
				}
		}
		
		function CheckFileVDOType(myfiles)
		{
				myfile=myfiles.value;
				myfile = myfile.toLowerCase();
				Temp = myfile.charAt(myfile.length-4) + myfile.charAt(myfile.length-3) + myfile.charAt(myfile.length-2) + myfile.charAt(myfile.length-1);
				if(Temp!='.wmv'&& Temp!='.wma' && Temp!='.mpeg' && Temp!='.mp3' && Temp!='.wav') {
					alert('?????????????????????????????????????????????????????????.');
					return false;
				}else{ return true;}
		}		
		
	
		function CheckFileFlashType(myfiles)
		{
				myfile=myfiles.value;
				myfile = myfile.toLowerCase();
				Temp = myfile.charAt(myfile.length-4) + myfile.charAt(myfile.length-3) + myfile.charAt(myfile.length-2) + myfile.charAt(myfile.length-1);
				if(Temp!='.swf'  ) {
					alert('?????????????? Flash Presentation ????????');
					return false;
				}
		}			
