	/*======================================================*/
	// MANAGEMENT DATA
	/*======================================================*/
	/*===============Check All===============*/
	function CheckAll() 
	{
		intTotalItems=document.myForm.TotalCheckBoxID.value;
		isCheckAll=document.myForm.CheckBoxAll.checked;
		if(intTotalItems>0)
		{
			for(i=0;i<=intTotalItems-1;i++)
			{
				   document.getElementById("CheckBoxID"+i).checked=isCheckAll;
				  if(document.getElementById("CheckBoxID"+i).checked==true)
				  {
					//document.getElementById("CheckBoxID"+i).style.background="#FFCC99";
				  }	
				  else
				  {
					//document.getElementById("CheckBoxID"+i).style.background="";
				  }		
			}
		}
	} //end function CheckAll
	
	/*===============CheckID ===============*/
	function CheckID(id)
	{
		if(document.getElementById("CheckBoxID"+id).checked==true)
		{
			//document.getElementById("CheckBoxID"+id).style.background="#FF9933"
		}
		else
		{
			//document.getElementById("CheckBoxID"+id).style.background="";
		}		
	} //end function CheckAll

	/*===================Click ID==========*/
	function EditID(id) 
	{
		document.getElementById("CheckBoxID"+id).checked=true;
		document.myForm.Action.value='edit';
		if(Paging_CountChecked('CheckBoxID',document.myForm.TotalCheckBoxID.value)!=1) 
		{
			alert('กรุณาเลือกเพียง 1 รายการ!');
		}
		else
		{
			document.myForm.submit();
		}
	} //end function CheckAll
	/*===================Click ID==========*/
	function ordering(id) 
	{
		document.myForm.Action.value='order';
		document.myForm.submit();
	
	} //end function CheckAll
	/*===================Click ID==========*/
	function ViewID(id)
	{
	    document.getElementById("CheckBoxID"+id).checked=true;
		document.myForm.Action.value='view';
		if(Paging_CountChecked('CheckBoxID',document.myForm.TotalCheckBoxID.value)!=1) 
		{
			alert('Please choose only  1 item');
		}
		else
		{
			document.myForm.submit();
		}

	} //end function

	/*===================================*/
	function DeleteID(id) 
	{
		document.getElementById("CheckBoxID"+id).checked=true;
		document.myForm.Action.value='delete';
		if(confirm('คุณแน่ใจหรือไม่ ที่ต้องการลบรายการที่เลือก?')) 
		{
			document.myForm.submit();
		}
		else
		{
			document.getElementById("CheckBoxID"+id).checked=false;
		}
	} //end function 
	
	/*===================================*/
	function UpdateID(id) 
	{
		document.getElementById("CheckBoxID"+id).checked=true;
		document.myForm.Action.value='status';
		if(confirm('คุณแน่ใจหรือไม่ ที่ต้องการปรับปรุงรายการที่เลือก ?')) 
		{
			document.myForm.submit();
		}
		else
		{
			document.getElementById("CheckBoxID"+id).checked=false;
		}
	} //end function 
	
	/*===================================*/
	function VisibleID(id) 
	{
		document.getElementById("CheckBoxID"+id).checked=true;
		document.myForm.Action.value='visible';
		if(confirm('คุณแน่ใจหรือไม่ ที่ต้องการปรับปรุงรายการที่เลือก ?'))
		{
			document.myForm.submit();
		}
		else
		{
			document.getElementById("CheckBoxID"+id).checked=false;
		}
	} //end function 
	
	/*============Page Count ==============*/
	function Paging_CountChecked(txtCheckBoxFirstName,intTotalItems) 
	{
		var intChecked = 0;
		if(intTotalItems>0){
			for(i=0;i<=intTotalItems-1;i++)
			{
				if(document.getElementById("CheckBoxID"+i).checked)
				{ 
					intChecked ++;
				}
			}	
		}	
		return intChecked;	
	} //end function 
	/*============End Page Count ==============*/
	
	function setPageAction_value(pg_action_value)
	{
		err_count=0;
		/*==========View Edit================*/
		

		
		if(pg_action_value=="new"){
			if(document.myForm.categories_id!=null){
				if(document.myForm.categories_id.value=="")
				{
					alert('กรุณาเลือก หมวดหมู่ !');
					document.myForm.categories_id.focus();
					err_count++;
					return false;	
				}
			}	
		}	
		
		if ((pg_action_value=="view")||(pg_action_value=="edit")||(pg_action_value=="move"))
		{
			if(Paging_CountChecked('CheckBoxID',document.myForm.TotalCheckBoxID.value)!=1) 
			{
				alert('กรุณาเลือกเพียง 1 รายการ !');
				err_count++;
			}
		}// end if 
	  /*==========End View Edit================*/
	  
	  /*==========Delete================*/
		if (pg_action_value=="delete"){
			if(Paging_CountChecked('CheckBoxID',document.myForm.TotalCheckBoxID.value)>0) 
			{
				if(confirm('คุณแน่ใจหรือไม่ ที่ต้องการลบรายการที่เลือก ?'))
				{
					// $form_process come from index.php
				}
				else
				{
					err_count++;
				}// end if (confirm....
			} 
			else
			{
				alert('กรุณาเลือกอย่างน้อย 1 ราบการ !');
				err_count++;
			}// end if (Paging_CountChecked
		}// end if 'delete'
		
	  /*==========End View Edit================*/
	  /*==========status================*/
		if (pg_action_value=="status")
		{
			if(Paging_CountChecked('CheckBoxID',document.myForm.TotalCheckBoxID.value)>0) 
			{
				if(confirm('คุณแน่ใจหรือไม่ ที่ต้องการปรับปรุงรายการที่เลือก ?')) 
				{
					// $form_process come from index.php
				}
				else
				{
					err_count++;
				}// end if (confirm....
			} 
			else 
			{
				alert('กรุณาเืลือกอย่างน้อย 1 รายการ !');
				err_count++;
			}// end if (Paging_CountChecked
		}// end if 'delete'
	  /*==========End View Edit================*/
	  /*==========status================*/
		if (pg_action_value=="sort_order")
		{
				if(confirm('คุณแน่ใจหรือไม่ ที่ต้องการจัดเรียงข้อมูล ?')) 
				{
					// $form_process come from index.php
				}
				else
				{
					err_count++;
				}// end if (confirm....
		}// end if 'delete'
	  /*==========End View Edit================*/
		// pass all condition...no error...submit value
		if (err_count==0)
		{
				document.myForm.Action.value=pg_action_value;
				document.myForm.submit();
		}
		/*==============================*/
	 }
	 
		/*=====ChangePage*/
	function ChangePage()
	{
		  document.myFormPage.CheckClick.value='ChangePage';
		  document.myFormPage.submit();
	}
	function ChangePage2()
	{
		  document.myFormPage2.CheckClick.value='ChangePage';
		  document.myFormPage2.submit();
	}
	/*========== verify =============*/
	function checkform()
	{
		var showpage=document.myFormPage.btn_PageShow.value;
		var recordstart=document.myFormPage.btn_RecordStart.value;
		var repeat=document.myFormPage.btn_RepeatHeader.value;
		var showpage2=document.myFormPage2.btn_PageShow.value;
		var recordstart2=document.myFormPage2.btn_RecordStart.value;
		var repeat2=document.myFormPage2.btn_RepeatHeader.value;
		  if(showpage<0 || isNaN(showpage))
		  {
			 alert(showpage+"  is not a valid row number!");
			 document.myFormPage.btn_PageShow.focus();
			 return false;
		  }
		  if(recordstart<0 || isNaN(recordstart))
		  {
			 alert(recordstart+"  is not a valid row number!");
			 document.myFormPage.btn_RecordStart.focus();
			 return false;
		  }
		  if(repeat<0 || isNaN(repeat))
		  {
			 alert(repeat+"  is not a valid row number!");
			 document.myFormPage.btn_RepeatHeader.focus();
			 return false;
		  }
	 /*=============================================*/
		  if(showpage2<0 || isNaN(showpage))
		  {
			 alert(showpage2+"  is not a valid row number!");
			 document.myFormPage2.btn_PageShow.focus();
			 return false;
		  }
		  if(recordstart2<0 || isNaN(recordstart))
		  {
			 alert(recordstart2+"  is not a valid row number!");
			 document.myFormPage2.btn_RecordStart.focus();
			 return false;
		  }
		  if(repeat2<0 || isNaN(repeat))
		  {
			 alert(repeat2+"  is not a valid row number!");
			 document.myFormPage2.btn_RepeatHeader.focus();
			 return false;
		  } 
		  return true;
	}
	 /*=============================================*/
	function ShowPage()
	{
		document.myFormPage.CheckClick.value='ShowPage';
		if(checkform()==true)
		{
			document.myFormPage.submit();
		}
	}
	 /*=============================================*/
	function ShowPage2()
	{
		document.myFormPage2.CheckClick.value='ShowPage';
		if(checkform()==true)
		{
			document.myFormPage2.submit();
		}
	}
	 /*=============================================*/
	function Go2Page(gotopage){
		if (gotopage=="MoveFirst")
		{
			document.myFormPage.btn_PageNumper.value=1;
			document.myFormPage.CheckClick.value='MoveFirst';
		}
		
		if (gotopage=="MovePrevious")
		{
			document.myFormPage.btn_PageNumper.value--;	
			document.myFormPage.CheckClick.value='MovePrevious';	
		}
		
		if (gotopage=="MoveNext")
		{
			if(document.myFormPage.btn_EndOfPage.value==document.myFormPage.btn_PageNumper.value){
				document.myFormPage.btn_PageNumper.value=document.myFormPage.btn_EndOfPage.value;
			}
			else
			{
				document.myFormPage.btn_PageNumper.value++;
			}
		}
		
		if (gotopage=="MoveLast")
		{
			document.myFormPage.btn_PageNumper.value=document.myFormPage.btn_EndOfPage.value;
			document.myFormPage.CheckClick.value='MoveLast';	
		}
		
		if (gotopage=="ReSet")
		{
			document.PageSearch.ClickSearch.value=0;
			document.myFormPage.btn_SqlQuery.value="";
			document.myFormPage.btn_FieldSearch.value="";
			document.myFormPage.btn_Operator.value="";
			document.myFormPage.btn_Keyword.value="";
			document.myFormPage.btn_RepeatHeader.value=31;
			document.myFormPage.btn_PageShow.value=30;
			document.myFormPage.btn_RecordStart.value=0;
			document.myFormPage.btn_PageNumber.value=1;
			document.myFormPage.OrderBy.value="";
		}
		if(checkform()==true)
		{
			   document.myFormPage.submit();
		}
	}
	
	 /*=============================================*/
	function GoPageSearch()
	{
		document.PageSearch.btn_PageShow.value=document.myFormPage.btn_PageShow.value;
		document.PageSearch.btn_RepeatHeader.value=document.myFormPage.btn_RepeatHeader.value;
		if(document.PageSearch.btn_Keyword.value=="")
		{
			alert("กรุณากรอกข้อมูล !");	
			document.PageSearch.btn_Keyword.focus();
			return false;
		}
		else
		{
			document.PageSearch.submit();
			return true;
		}
	}
	function GoPageSearch2()
	{
		document.PageSearch2.btn_PageShow.value=document.myFormPage2.btn_PageShow.value;
		document.PageSearch2.btn_RepeatHeader.value=document.myFormPage2.btn_RepeatHeader.value;
		if(document.PageSearch2.btn_Keyword.value=="")
		{
			alert("กรุณากรอกข้อมูล !");	
			document.PageSearch2.btn_Keyword.focus();
			return false;
		}
		else
		{
		document.PageSearch2.submit();
		return true;
		}
	}
	/*======= Order By ============*/
	function Orderby(FieldName)
	{
		document.myFormPage.CheckClick.value='ChangePage';
		var orderby=document.myFormPage.OrderBy.value;
		var DESC="ORDER BY "+FieldName+" DESC";
		var ASC="ORDER BY "+FieldName+" ASC";
		if(orderby==DESC)
		{
			document.myFormPage.OrderBy.value=ASC;
		}
		else
		{
			document.myFormPage.OrderBy.value=DESC;
		}
		if(checkform()==true)
		{
			document.myFormPage.submit();
		}
	}	//END FUNCTION OrderBy
	
		function CheckNumericKeyInfo($char, $mozChar) { 
		  if($mozChar != null) { // Look for a Mozilla-compatible browser 
			if(($mozChar >= 48 && $mozChar <= 57) || $mozChar == 0 || $char == 
		8 || $mozChar == 13) $RetVal = true; 
			else { 
			  $RetVal = false; 
			  alert('กรุณากรอกตัวเลขเท่านั้น.'); 
			} 
		  } 
		  else { // Must be an IE-compatible Browser 
			if(($char >= 48 && $char <= 57) || $char == 13) $RetVal = true; 
			else { 
			  $RetVal = false; 
			  alert('กรุณากรอกตัวเลขเท่านั้น.'); 
			} 
		  } 
		  return $RetVal; 
		} 
	function CheckEnterSearch($char)
	{
		alert($char);
	}	
	/*======================================================*/
	///END MANAGEMENT DATA
	/*======================================================*/
