	function $(id)
	{ 
		return document.getElementById(id);
	}
	function ChuanXauNoiDung(str){
		strChuan = str;
		strChuan = ThayThe(strChuan,"&nbsp;");
		strChuan = ThayThe(strChuan," ");
		if(strChuan=="") strChuan="<p></p>";
		return strChuan;
	}
	function Sorry(){
		alert("Chuc nang nay chua cai dat. Xin ban quay lai sau.");
	}
	function CancelBubble(){
		if(document.all) window.event.cancelBubble = true;
	}
	function Trim(s){
	  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r')){
	    s = s.substring(1,s.length);
	  }
	  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r')){
	    s = s.substring(0,s.length-1);
	  }
	  if(s=="<p></p>")
	  	s="";
	  return s;
	}
	function ThayThe(str,KyTu){
		while (str.indexOf(KyTu)>=0){
			str = str.replace(KyTu,"");	
		} 
		return str;
	}
	function ChuanXau(str){
		strChuan=str;
		strChuan=ThayThe(strChuan,"~");
		strChuan=ThayThe(strChuan,"%");
		strChuan=ThayThe(strChuan,"@");
		strChuan=ThayThe(strChuan,"#");
		strChuan=ThayThe(strChuan,"$");
		strChuan=ThayThe(strChuan,"^");
		strChuan=ThayThe(strChuan,"&");
		strChuan=ThayThe(strChuan,"*");
		strChuan=ThayThe(strChuan,"'");
		strChuan=Trim(strChuan);		
		return strChuan;
		
	}
	function ChuanXau_Email(str){
		strChuan = str;
		return strChuan;
	}
	
	function CheckFileImg(FileName){
		var dotpos;
		FileName = FileName.substring(FileName.lastIndexOf("\\")+1,FileName.length);
		dotpos = FileName.lastIndexOf('.');
		ext = FileName.substr(dotpos+1,FileName.length-dotpos);
		ext = ext.toLowerCase();	
		if (ext != ""){
			if (ext != "gif" && ext != "jpg" && ext != "bmp" && ext != "png") {
				return false;
			}else{
				return true;
			}
		}else{
			return true;
		}
	}
	
	function CheckFileFilm(FileName){
		var dotpos;
		FileName = FileName.substring(FileName.lastIndexOf("\\")+1,FileName.length);
		dotpos = FileName.lastIndexOf('.');
		ext = FileName.substr(dotpos+1,FileName.length-dotpos);
		ext = ext.toLowerCase();	
		if (ext != ""){
			if (ext != "mp3" && ext != "avi" && ext != "asf" && ext != "mpg" && ext != "wma" && ext != "wmv" && ext != "wav"){
				return false;					
			}else{
				return true;
			}
		}else{
			return true;
		}
	}
	
	function CompDate(strDate1,strDate2){
		var m1, d1, y1;
		var m2, d2, y2;
		var s, pos1, pos2;
		var s = strDate1, s1 = strDate2;
		if (s.length == 0 || s1.length == 0) return true;

		pos1 = s.indexOf("/",0);
		pos2 = s.indexOf("/",pos1+1);
		d1 = parseInt(s.substr(0,pos1),10);
		m1 = parseInt(s.substr(pos1+1,pos2-pos1-1),10);
		y1 = parseInt(s.substr(pos2+1,s.length-pos2),10);
		
		pos1 = s1.indexOf("/",0);
		pos2 = s1.indexOf("/",pos1+1);
		d2 = parseInt(s1.substr(0,pos1),10);
		m2 = parseInt(s1.substr(pos1+1,pos2-pos1-1),10);
		y2 = parseInt(s1.substr(pos2+1,s1.length-pos2),10);
		
		var d1 = new Date(y1,m1,d1);
		var d2 = new Date(y2,m2,d2);
		if (d1 >= d2) 
			return true;
		else
			return false;
	}
	function CompDateE(strDate1,strDate2){
		var m1, d1, y1;
		var m2, d2, y2;
		var s, pos1, pos2;
		var s = strDate1, s1 = strDate2;
		if (s.length == 0 || s1.length == 0) return true;

		pos1 = s.indexOf("/",0);
		pos2 = s.indexOf("/",pos1+1);
		d1 = parseInt(s.substr(0,pos1),10);
		m1 = parseInt(s.substr(pos1+1,pos2-pos1-1),10);
		y1 = parseInt(s.substr(pos2+1,s.length-pos2),10);
		
		pos1 = s1.indexOf("/",0);
		pos2 = s1.indexOf("/",pos1+1);
		d2 = parseInt(s1.substr(0,pos1),10);
		m2 = parseInt(s1.substr(pos1+1,pos2-pos1-1),10);
		y2 = parseInt(s1.substr(pos2+1,s1.length-pos2),10);
		
		var d1 = new Date(y1,m1,d1);
		var d2 = new Date(y2,m2,d2);
		if (d1 == d2) 
			return true;
		else
			return false;
	}	
	
	function ViewNote(url){
		args = "width=600px,height=400px,top=0px,left=0px,resizable=0,status=0,scrollbars=";
		window.open(url,"ViewNote",args);
	}
	
	function ViewImg(strCommon,Path,wimg,himg){
		var w1,h1;
		w1 = 750;
		h1 = 480;
		w = parseInt(wimg);
		h = parseInt(himg);
		if (w <= 750) w1 = w;
		if (h <= 480) h1 = h;
		w1 += 58;
		h1 += 48;
		var strTop = parseInt((screen.height - h1)/2)-20;
		var strLeft = parseInt((screen.width - w1)/2);
		args = "width=" + w1 + "px,height=" + h1 + "px,top=" + strTop + "px,left=" + strLeft + "px,resizable=0,status=0,scrollbars=";
		if ((wimg>=750)||(himg>=480)){
			args += "1";
		}else{
			args += "0";
		}
		url = strCommon+"ViewImg.asp?Path=" + Path + "&Height=" + himg + "&Width=" +wimg;		
		window.open(url,"ViewImages",args);		
	}
	function ViewImgDetail(Path,wimg,himg,strMa){
		var w1,h1
		w1 = 650;
		h1 = 500;
		w = parseInt(wimg);
		h = parseInt(himg);
		if (w <= 630) w1 = w;
		if (h <= 580) h1 = h;
		w1 += 48;
		h1 += 30;
		var strTop = parseInt((screen.height - h1)/2)-20;
		var strLeft = parseInt((screen.width - w1)/2);
		args = "width=" + w1 + "px,height=" + h1 + "px,top=" + strTop + "px,left=" + strLeft + "px,resizable=no,scrollbars=yes,status=0";
		url = "ViewImage.asp?Path=" + Path + "&Height=" + himg + "&Width=" + wimg + "&Ma=" + strMa;
		window.open(url,"test",args);
	}
	
	function CheckAll(){
		frm = document.getElementById("frmExe");
		chk = frm.chkAllBox;
		Num = (frm.elements.length-1);
		for (i=0;i<=Num;i++){
			if (frm.elements[i].name=="chkBox"){
				frm.elements[i].checked = chk.checked;
			}
		}
	}
	
	
	function ChkExe(flag){
		frm = document.getElementById("frmExe");	
		chk = document.getElementsByTagName("input");
		hid = frm.hidDk;
		
		strMsg = "";
		vExe = 0;
		num = frm.elements.length;
		for (i=1;i<=(num-1);i++){
			allchk = frm.elements[i];					
			if (allchk.type=="checkbox"){
				if (allchk.checked){
					vExe = 1;
					break;
				}
			}
		}
		
		if (vExe==0){
			strMsg += "\n- Please choose record that you want to delete !";
		}
		if (strMsg==""){
			if (flag==1){
				if (confirm("Do you want to update status record?")){
					hid.value = "UNPASS";
					return true;
				}else{
					return false;
				}
			}else{
				if (confirm("Do you want to delete?")){
					hid.value = "DEL";
					return true;
				}else{
					return false;
				}
			}
		}else{
			strMsg = strMsg.substr(1);
			alert(strMsg);
			return false;
		}
	}
	
	function CheckFileImg(FileName){
		var dotpos;
		FileName = FileName.substring(FileName.lastIndexOf("\\")+1,FileName.length);
		dotpos = FileName.lastIndexOf('.');
		ext = FileName.substr(dotpos+1,FileName.length-dotpos);
		ext = ext.toLowerCase();	
		if (ext != ""){
			if (ext != "gif" && ext != "jpg" && ext != "bmp"){
				return false;					
			}else{
				return true;
			}
		}else{
			return true;
		}
	}
	
	function CheckFileDoc(FileName){
		var dotpos;
		FileName = FileName.substring(FileName.lastIndexOf("\\")+1,FileName.length);
		dotpos = FileName.lastIndexOf('.');
		ext = FileName.substr(dotpos+1,FileName.length-dotpos);
		ext = ext.toLowerCase();	
		if (ext != ""){
			if (ext != "doc" && ext != "txt" && ext != "pdf"){
				return false;					
			}else{
				return true;
			}
		}else{
			return true;
		}
	}
	
	function __doDuyet(){
		document.frmExe.submit();
	}
	
	function __doDel(){
		document.frmExe.submit();
	}
	
	function __doAdd(Url){
		window.location.href = Url;
	}
	
	function funDelImage(){
		frm = document.getElementById("frmNew")
		frm.chkDelImage.value = (frm.chkDelImage.checked)?"1":"0"
	}
	
	function funDelDoc(){
		frm = document.getElementById("frmNew")
		frm.chkDelDoc.value = (frm.chkDelDoc.checked)?"1":"0"
	}
	
	function Tab_HuyClick(){
		window.event.returnValue = false;
	}
	
	
	function height(){
		var a 	= document.getElementById("div_main_content").clientHeight;
		var b 	= document.getElementById("div_main_menu").clientHeight;
		var tmp = (a>b)?a:b;
		document.getElementById("main_content").style.height = tmp;
		document.getElementById("div_main_menu").style.height = tmp;
		document.getElementById("main_content").style.backgroundColor = "#FFFDE8";
	}

	/*Danh cho nut nhap lai*/
	function DeleteTexteditor(objname,html) {
		 var editor_obj = document.all["_" +objname + "_editor"];
		  var isTextarea = (editor_obj.tagName.toLowerCase() == 'textarea');
		
		  if (isTextarea) { editor_obj.value = html; }
		  else            { editor_obj.contentWindow.document.body.innerHTML = html; }
	}
	
	function callJump(f){
		window.location.href = f;
	}
	
	function specchar(para) {
		var arrSpecChar = '~@#$%^&*\'';
		var len = arrSpecChar.length;
		for(i=0;i<len;i++){
			if(para.indexOf(arrSpecChar[i])>0) return false;
		}
		return true;
	}
	function getEditorValue( instanceName ) 
    { 
        // Get the editor instance that we want to interact with.
        var oEditor = FCKeditorAPI.GetInstance( instanceName.name ) ;
        // Get the editor contents as XHTML.
        return ChuanXauNoiDung(oEditor.GetXHTML( true )) ; // "true" means you want it formatted.
    } 
