function isNum(str) {
  if(!str) return false;
  for(var i=0; i<str.length; i++){
    var ch=str.charAt(i);
    if ("0123456789.".indexOf(ch) ==-1) return false;
  }
  return true;
} 

function chknum(obj)
{
	if ((obj.value) && (!isNum(obj.value)))
	{
		window.alert("please insert only numeric input..!");
		if(!obj.disabled)obj.focus();
		return false;
	}
	return true;
}

function isThai(str) {
  if(!str) return false;
  for(var i=0; i<str.length; i++){
    var ch=str.charCodeAt(i);
    if ((ch>=3585) && (ch<=3673)) return true;
  }
  return false;
}

function chksame(o1,o2)
{
	var obj1 = document.all(o1);
	var obj2 = document.all(o2);
	if (obj1.value==obj2.value)return true;
	else
	{
		window.alert(o1+" and "+o2+" not same...!");
		obj1.value="";
		obj2.value="";
		if(!obj1.disabled)obj1.focus();
		return false;
	}
}

function chkblank(o1)
{
	var obj1 = document.all(o1);
	if (obj1.value=="")
	{
		window.alert("please enter "+o1);
		if(!obj1.disabled)obj1.focus();
		return false;
	}
	else return true;
}

function chkpasswd(o1)
{
	var obj1 = document.all(o1);
	var obj2 = document.all("old_"+o1);
	if (obj1.value==obj2.value)return true;
	var confirm = window.prompt ("Re-enter "+o1+" ->","");
	if (confirm!=obj1.value)
		{
			window.alert("input data not same please re-enter!");
			if(!obj1.disabled)obj1.focus();
			return false;
		}
	return true;
}

function chknewpasswd(o1)
{
	var obj1 = document.all(o1);
	var confirm = window.prompt ("Re-enter "+o1+" ->","");
	if (confirm!=obj1.value)
		{
			window.alert("input data not same please re-enter!");
			if(!obj1.disabled)obj1.focus();
			return false;
		}
	return true;
}

function chkemail(str){
	var emailFilter=/^.+@.+\..{2,3}$/;
	if (!(emailFilter.test(str))) { 		   
		   return false;
	}
    return true;
}

function BlockSign() {
	// 33 - 47 ! " # $ % & ' ( ) * + , - . /
	// 58 - 64 : ; < = > ? @
	// 91 - 96 [ \ ] ^ _ `
	// 123 - 126 { | } ~
	if ((event.keyCode>32&&event.keyCode<48)||(event.keyCode>57&&event.keyCode<65)||(event.keyCode>90&&event.keyCode<97)||(event.keyCode>122 && event.keyCode<127))
		event.returnValue = false
}

function BlockQuote() {
	// 34 "
	// 39 '
	if (event.keyCode==34||event.keyCode==39)
		event.returnValue = false
}

function BlockNum() {
	// 48 - 57 0 1 2 3 4 5 6 7 8 9
	if (event.keyCode>=48 && event.keyCode<=57)
		event.returnValue = false;
}

function NumOnly() {
	if(event.keyCode==8)
	{
		event.returnValue = true;
		return;
	}
	if (event.keyCode>='0'.charCodeAt()&&event.keyCode <= '9'.charCodeAt())
		event.returnValue = true;
	else
		event.returnValue = false;
}
