function ckblk(chkval){
	if(chkval == "")
		return false;
	else {
		tmpval = "";
		for(i=0;i<chkval.length;i++) tmpval += " ";
		if (chkval == tmpval) return false;
		else return true;
	}
}
 /*
function checkemail(em){
	if(em == "") return false;
	if(em.indexOf('@',0) < 1) { return false; }
	else if(em.indexOf('.',0) == -1 || em.lastIndexOf('.') == em.length-1 || em.lastIndexOf('@') != em.indexOf('@',0)) { return false; }
	else if(em.indexOf('.',0) == em.indexOf('@',0)+1) { return false; }
	else {
		if (chk_char(em, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@-_.")) {
			return true;
		}
		else {
			return false;
		}
	}
}*/

function checkemail(em) {
	//if (em.search(/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,6}|[0-9]{1,3})(\]?)$/) != -1)
	if (em.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
	return false;
}


function chk_char(chkmsg, chkstr) {
	for (count = 0;count < chkmsg.length;count++) {
		chk_ok = 0;
		for (count2 = 0;count2 < chkstr.length;count2++) {
			if (chkmsg.charAt(count) == chkstr.charAt(count2)) {
				chk_ok = 1;
				break;
			}
		}
		if (chk_ok == 0) {
			if (chkmsg.charCodeAt(count) != 13 && chkmsg.charCodeAt(count) != 10) {
				return false;
			}
		}
	}
	return true;
}

function chk_repeat(chkmsg, limit) {
	for (count = 0;count < chkmsg.length - limit;count++) {
		chk_ok = 1;
		for (count2 = 1;count2 <= limit;count2++) {
			if (chkmsg.charAt(count) == chkmsg.charAt(count+count2)) {
				chk_ok++;
			}
			else {
				break;
			}
		}
		if (chk_ok > limit) {
			return false;
		}
	}
	return true;
}

function checkext(filename){
	if (filename.indexOf('.') < 1) return false;
	else if (filename.indexOf('.') == filename.length - 1) return false;
	else {
		ext = filename.substring(filename.lastIndexOf('.')+1,filename.length);
		if (ext.toUpperCase() == "JPG" || ext.toUpperCase() == "JPEG" || ext.toUpperCase() == "JPE" || ext.toUpperCase() == "GIF") return true;
		else return false;
	 }
}

function isTelFormat(em){
	if(em == "") return false;
	var strlen = em.length;
	var FirstDigitIsZero = em.toString().substr(0,1);
	if(strlen < 9 || FirstDigitIsZero != '0')
		return false;
	else
		return true;
/*
	if (em.search(/^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,3})|(\(?\d{2,3}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/) != -1)
		return true;
	else
		return false;*/
}

function isMobileFormat(em){
	if(em == "") return false;
	var strlen = em.length;
	var FirstDigitIsZero = em.toString().substr(0,2);
	if(strlen != 10 || FirstDigitIsZero != '08')
		return false;
	else
		return true;
}

function space_replace(str){
  do{
		str = str.replace(' ','');
   }while(str.indexOf(' ') != ( -1));				 
   return str;
}

/*
function AllowedNumberOnly()
{
	self = this
var keynum
var keychar
var numcheck
if(window.event) // IE
{
keynum = e.keyCode
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which
}
keychar = String.fromCharCode(keynum)
numcheck = /\d/
return !numcheck.test(keychar)
}*/


function AllowedNumberOnly(uiLang){
	//if(!e) var  e = window.event;
	//var keycode = window.event ? event.keyCode: e.which;
	var keycode = window.event.keyCode;

	if( keycode >=37 && keycode <=40 ) return true;  // arrow left, up, right, down  
	if( keycode >=48 && keycode <=57 ) return true;  // key 0-9
	if( keycode ==8  ) return true;  // backspace
	if( keycode ==9 ) return true;  // tab
	if( keycode ==13  ) return true; 	 //enter
	if( keycode ==116  ) return true; 	 //enter

	if(keycode ==35 || keycode ==36) return true;  // insert, del, end, home

	if(uiLang == 'th'){
	  alert("¡ÃØ³ÒãÊèµÑÇàÅ¢¤èÐ !");
	}else{
	  alert("This data no number !");
	}
	return false;
}

function isNumeric(strString){   //  check for valid numeric strings   
   var strValidChars = "0123456789";//"0123456789.-";
   var strChar;
   var blnResult = true;
   if (strString.length == 0) return false;
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++){
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1){
         blnResult = false;
         }
    }
   return blnResult;
}