	var SelectCounter=0;

	function onColOver(thisObj, bg, cur){
		thisObj.style.backgroundColor= '#FFFFFF';
		thisObj.style.border='1px solid '+ bg ;
		if(cur != null){
			thisObj.style.cursor=cur;
		}
		else{
			thisObj.style.cursor='hand';
		}
		return true;
	}

	function onColOut(thisObj){
		thisObj.style.backgroundColor='';
		thisObj.style.border='';
		return true;
	}

	function onRowOver(thisObj, bg, cur){
		thisObj.style.backgroundColor= bg;
		if(cur != null){
			thisObj.style.cursor=cur;
		}
		else{
			thisObj.style.cursor='hand';
		}
		return true;
	}

	function onRowOut(thisObj){
		thisObj.style.backgroundColor='';
		return true;
	}
	
	function onBtnOver(thisObj, bg, cur){
		thisObj.style.background= "url(../imgs/"+bg+".gif)";
		//thisObj.style.color= bg;
		if(cur != null){
			thisObj.style.cursor=cur;
		}
		else{
			thisObj.style.cursor='hand';
		}
		return true;
	}

	function onBtnOut(thisObj){
		thisObj.style.background='#FFFFFF';
		thisObj.style.color= "";
		return true;
	}

	function setCheck(Line){
		if(document.getElementById("isCheck" + Line).value=="no"){
			document.getElementById("isCheck" + Line).value="yes";
			SelectCounter++;
		}
		else{
			document.getElementById("isCheck" + Line).value="no";
			SelectCounter--;
		}
		document.getElementById("imgCheck" + Line).src="images/icon/check_" + document.getElementById("isCheck" + Line).value + ".gif";
		return true;
	}

	function HideShowSendDetail(Line,maxSendDetail) {
		for(i=1;i<=maxSendDetail;i++){
			if (document.getElementById("SendDetail" + Line + "_" + i).style.display == 'none' ){
				document.getElementById("SendDetail" + Line + "_" + i).style.display = '';
			}
			else{
				document.getElementById("SendDetail" + Line + "_" + i).style.display = 'none';	
			}		
		}
		return true;	
	}

	function Popup(pname, purl, w, h, s){
		LeftPosition = (screen.width) ? (screen.width-w-8)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h-50)/2 : 0;
		window.open(purl,pname,"width="+w+",height="+h+",top="+TopPosition+",left="+LeftPosition+",resizable=no,scrollbars="+s);
	}	

	function MM_swapImgRestore() { //v3.0
		var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}

	function MM_preloadImages() { //v3.0
		var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}

	function MM_findObj(n, d) { //v4.01
		var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  		if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

	function MM_swapImage() { //v3.0
  		var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   		if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}

	function CheckAll(FName, CheckBoxname) {
  		for (var i=0; i<FName.elements.length; i++) {
    		var c = FName.elements[i];
			if(c.type == CheckBoxname.type){
	    		if (c.name != CheckBoxname.name) {
    	  			c.checked = CheckBoxname.checked;
    			}
			}
  		}
	}

	function CheckBoxAll(chkName, chkAll){
		if(chkName){
			if(!chkName.length){
				if(chkAll.checked == true){
					// check
					if(chkName.checked == false){
						chkName.checked = true;
					}
				}
				else{
					// uncheck
					if(chkName.checked == true){
						chkName.checked = false;
					}
				}
			}
			else{
				for(var cnt=0;cnt<chkName.length;cnt++){
					if(chkAll.checked == true){
						// check
						if(chkName[cnt].checked == false){
							chkName[cnt].checked = true;
						}
					}
					else{
						// uncheck
						if(chkName[cnt].checked == true){
							chkName[cnt].checked = false;
						}
					}
				}
			}
		}
	}

	function Popup_Open(pname, purl, w, h, s, m, r, t, cc){

		cc = (!cc)? 0 : 1;

		if(cc){
			LeftPosition = (screen.width) ? (screen.width-w-8)/2 : 0;
			TopPosition = (screen.height) ? (screen.height-h-50)/2 : 0;
		}
		else{
			LeftPosition = 0;
			TopPosition = 0;
		}

		s = (!s)? 0 : 1;
		m = (!m)? 0 : 1;
		r = (!r)? 0 : 1;		
		t = (!t)? 0 : 1;		
		rr = (r == 0) ? "no" : "yes";
		opt = "width=" + w + ",height=" + h + ",top=" + TopPosition + ",left=" + LeftPosition + ",resizable=" + rr + ",scrollbars=" + s + ",menubar=" + m + ",status=" + t;
		window.open(purl, pname, opt);
	}	

	function Popup_Dialog(doc){
		opt = "resizable: yes; help: no; status: no; scroll: no;";
		showModalDialog(doc, window, opt);
	}

	function Check_Email(email, extension) {
		if(email.indexOf("@")<2){
			//alert(" This email address seems wrong. Please"
			//+" check the prefix and '@' sign.");
			return false;
		}
		if(extension){
			if((email.indexOf(".com")<5)&&(email.indexOf(".org")<5)
				&&(email.indexOf(".gov")<5)&&(email.indexOf(".net")<5)
				&&(email.indexOf(".co.uk")<7)&&(email.indexOf(".nl")<4)
				&&(email.indexOf(".mil")<5)&&(email.indexOf(".edu")<5)
				&&(email.indexOf(".co.th")<7)&&(email.indexOf(".in.th")<7)){
				//alert(" This email address seems wrong. Please"
				//+" check the suffix. (It should include a .com, .edu,"
				//+" .net, .org, .gov, .co.uk, .nl or .mil)");
				return false;
			}
		}
		return true;
	}

	function MM_openBrWindow(theURL,winName,features) { 	
		win=open(theURL,"","toolbar=0,directories=0,status=1,scrollbars=0,menubar=0,resizable=0,"+features+"?>,top=100,left=50")
	}
	
	function checkThai(frm) {
		txt = frm.msg.value;
		for(var i = 0;i < txt.length; i++) {
			if( (txt.charCodeAt(i) > 127) || (txt.charCodeAt(i)==94) || (txt.charCodeAt(i)==92) ) {
				alert("Thai");
				return;
			}
		}
	  frm.msgtype.value = "E";
	  return;
	} //End checkThai

	function CheckNumberOnly(){
		if (event.keyCode < 48 || event.keyCode > 57){ 
			alert('Only Number'); 
			event.returnValue = false;
		}
	}

	/*onKeyPress="if (event.keyCode < 48 || event.keyCode > 57){ alert('ใช้ได้แต่ตัวเลขเท่านั้น'); event.returnValue = false;}" 
	onKeyDown="if (event.keyCode == 17) alert('ไม่อนุญาตให้ทำการ Paste');" 
	
	onMouseDown="if (event.button == 2) { alert('ไม่อนุญาตให้ทำการ Paste'); this.value=''; }" 
	onpaste="return false;" 
	ondrop="return false;"*/

	