//function Key In Numberic Only
function numbericOnly(e)  
{
   var key;
   var keychar;
          
   if (event)   
   {
      key = event.keyCode;
   }
   else if (e) 
   {
      key = e.which;
   }
   else 
   {
      return true;
   }
   keychar = String.fromCharCode(key);
   // control keys
   if ((key==null) || (key==0) || (key==8) || (key==9) || (key==27) )  
   {
      return true;
   }
   // numbers 
   else if ((("0123456789").indexOf(keychar) > -1))  
   { 
      return true;
   }
   else
   {
      return false;
   }
}  //close number only function

//----------------------------------------------------------------------------------------------------------------

//function Key In English Language And Numberic
function englishOnly(e)    
{
   var key;
   var keychar;
      
  if (event)   
  { 
      key = event.keyCode;
   }
   else if (e)   
   { 
      key = e.which;
   }
   else  
   {
      return true;
   }
          
   keychar = String.fromCharCode(key);
   keychar = keychar.toLowerCase();
   // control keys
   if ((key==null) || (key==0) || (key==8) || (key==9) ||  (key==27) )
   {
      return true;
   }
   // alphas and numbers
   else if ((("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789").indexOf(keychar) > -1))    
   {
      return true;
   }
   else  
   {
      return false;
   }
} // close english char only  function

//----------------------------------------------------------------------------------------------------------------

//function Key In Mail English Language And Numberic
function mailOnly(e)    
{
   var key;
   var keychar;
      
  if (event)   
  { 
      key = event.keyCode;
   }
   else if (e)   
   { 
      key = e.which;
   }
   else  
   {
      return true;
   }
          
   keychar = String.fromCharCode(key);
   keychar = keychar.toLowerCase();
   // control keys
   if ((key==null) || (key==0) || (key==8) || (key==9) ||  (key==27) )
   {
      return true;
   }
   // alphas and numbers
   else if ((("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789*@._-$&").indexOf(keychar) > -1))    
   {
      return true;
   }
   else  
   {
      return false;
   }
} // close mail char only  function

//----------------------------------------------------------------------------------------------------------------

//function Key In Thai Language Only
function thOnly(e)    //input for thai char only
{   
   var key;
    var keychar;

    if (event)   
    {
      key = event.keyCode;
   }
   else if (e)   
   {
      key = e.which;
   }
   else 
   {
      return true;
   }
    
   keychar = String.fromCharCode(key);
   keychar = keychar.toLowerCase();
   // control keys charCode of thai 161 - 251
   if ((key==null) || (key==0) || (key==8) || (key==9) || (key==27) || (key>=161))
   {
      return true;
   }   
   else
   {
      return false;
   }
} // close thai char only  function


//----------------------------------------------------------------------------------------------------------------

//function trim Text [must use function RTrim and LTrim]
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;
   }
} //End Function Trim 

//----------------------------------------------------------------------------------------------------------------

//function trim right Text 
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 trim left Text 
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 Check Charactor [ Onblur ] display Alert Message
function checkText(ret)
{
	var L = ret.length;
	for(var i = 0; i <= L; i++)
	{
		var ch = ret.substring(i,i+1);
		if(ch=='\$' || ch=='\_' || ch=='\^' ||ch=='\;' ||ch=='\?' ||ch=='\{' ||ch=='\}' ||ch=='\[' ||ch=='\]' ||ch=='\*' ||ch=='\-' ||ch=='\+' ||ch=='\=' ||ch=='\~' ||ch=='\#' ||ch=='\@' ||ch=='\.' ||ch=='\:' ||ch=='\\' ||ch=='\,' || ch=='\/' || ch=='\|'|| ch=='\&' || ch=='\(' || ch=='\)' || ch=='\"'|| ch=='\!'|| ch=='\%' || ch=='\>' || ch=='\<' || ch == '\'' )
		{
			alert("Error : "+ch);	
         return false;
		}
	}
}

function checkStrText(ret)
{
	var L = ret.length;
	for(var i = 0; i <= L; i++)
	{
		var ch = ret.substring(i,i+1);
		if(ch=='\'' || ch=='\"')
		{
			alert("¡ÃØ³ÒäÁèãÊÍÑ¡¢ÃÐ ("+ch+") ¹Õé");	
         return false;
		}
	}
}