﻿<!--Script for AddressBook-->
 var temp = 6;
	//adding address book
    function addAddress(form) {

        if (form.txtName.value == ""){ alert("Bạn phải nhập họ và tên");	return true;}
        if (form.txtMobile.value == null || form.txtMobile.value == ""){ alert("Bạn phải nhập số điện thoại");	return true;}
        if (form.txtMobile.value != null && form.txtMobile.value != "") {

            if (!checkphonenumber(form.txtMobile.value)) {
	            alert("Số điện thoại không hợp lệ!\nXin vui lòng nhập lại số điện thoại!");
                form.txtMobile.focus();
                return false;

            }



        }

        if (form.cboGroup.value == "0") {
			alert("Bạn phải chọn nhóm chứa địa chỉ của người này!");return true;
		}

        form.actionState.value = "addAddress";
var url = "/vn/address/index.jsp?actionState=" + document.frmNewAddress.actionState.value + "&opt=" + document.frmNewAddress.opt.value + "&cboSelGroup=" + document.frmNewAddress.cboSelGroup.value + "&txtName=" + document.frmNewAddress.txtName.value + "&txtFixPhone=" + document.frmNewAddress.txtFixPhone.value + "&txtMobile=" + document.frmNewAddress.txtMobile.value + "&txtAddress=" + document.frmNewAddress.txtAddress.value + "&txtEmail=" + document.frmNewAddress.txtEmail.value + "&txtJob=" + document.frmNewAddress.txtJob.value + "&txtBirthday=" + document.frmNewAddress.txtBirthday.value + "&cboGroup=" + document.frmNewAddress.cboGroup.value + "&repairId=" + document.frmNewAddress.repairId.value + "&repairValue=" + document.frmNewAddress.repairValue.value + "&optGroup=" + document.frmNewAddress.optGroup.value + "&txtGrName=" + document.frmNewAddress.txtGrName.value;
		getData(url,'divMain');
//        form.submit();
    }
	/*===  Change option ===*/
    function GroupSelect_onchange(form){
		var url = "/vn/address/index.jsp?actionState=" + document.frmNewAddress.actionState.value + "&opt=" + document.frmNewAddress.opt.value + "&cboSelGroup=" + document.frmNewAddress.cboSelGroup.value + "&txtName=" + document.frmNewAddress.txtName.value + "&txtFixPhone=" + document.frmNewAddress.txtFixPhone.value + "&txtMobile=" + document.frmNewAddress.txtMobile.value + "&txtAddress=" + document.frmNewAddress.txtAddress.value + "&txtEmail=" + document.frmNewAddress.txtEmail.value + "&txtJob=" + document.frmNewAddress.txtJob.value + "&txtBirthday=" + document.frmNewAddress.txtBirthday.value + "&cboGroup=" + document.frmNewAddress.cboGroup.value + "&repairId=" + document.frmNewAddress.repairId.value + "&repairValue=" + document.frmNewAddress.repairValue.value + "&optGroup=" + document.frmNewAddress.optGroup.value + "&txtGrName=" + document.frmNewAddress.txtGrName.value;
		getData(url,'divMain');
//        frmNewAddress.submit();
    }
	/*=== Edit address book ===*/
    function repair_address_row(id) {
        form = document.frmNewAddress;
        form.repairId.value = id;
        form.actionState.value = "repairRow";
		var url = "/vn/address/index.jsp?actionState=" + document.frmNewAddress.actionState.value + "&opt=" + document.frmNewAddress.opt.value + "&cboSelGroup=" + document.frmNewAddress.cboSelGroup.value + "&txtName=" + document.frmNewAddress.txtName.value + "&txtFixPhone=" + document.frmNewAddress.txtFixPhone.value + "&txtMobile=" + document.frmNewAddress.txtMobile.value + "&txtAddress=" + document.frmNewAddress.txtAddress.value + "&txtEmail=" + document.frmNewAddress.txtEmail.value + "&txtJob=" + document.frmNewAddress.txtJob.value + "&txtBirthday=" + document.frmNewAddress.txtBirthday.value + "&cboGroup=" + document.frmNewAddress.cboGroup.value + "&repairId=" + document.frmNewAddress.repairId.value + "&repairValue=" + document.frmNewAddress.repairValue.value + "&optGroup=" + document.frmNewAddress.optGroup.value + "&txtGrName=" + document.frmNewAddress.txtGrName.value;
		getData(url,'divMain');
//        form.submit();
    }
	/*==  Remove address book  ==*/
    function deleteAddress(form,value){
        var checkedNumber =0;
        for (i=0; i<temp; i++){
                    if (form.chked[i] != null){
                        if (form.chked[i].checked) checkedNumber++;
                    } else if(i==0) if (form.chked.checked) checkedNumber=1;
        }
        if (checkedNumber>0){
            if (checkedNumber>1){
                if (confirm("Bạn có chắc chắn xóa không?")) {
                    form.opt.value = value;
					var url = "/vn/address/index.jsp?actionState=" + document.frmNewAddress.actionState.value + "&opt=" + document.frmNewAddress.opt.value + "&cboSelGroup=" + document.frmNewAddress.cboSelGroup.value + "&txtName=" + document.frmNewAddress.txtName.value + "&txtFixPhone=" + document.frmNewAddress.txtFixPhone.value + "&txtMobile=" + document.frmNewAddress.txtMobile.value + "&txtAddress=" + document.frmNewAddress.txtAddress.value + "&txtEmail=" + document.frmNewAddress.txtEmail.value + "&txtJob=" + document.frmNewAddress.txtJob.value + "&txtBirthday=" + document.frmNewAddress.txtBirthday.value + "&cboGroup=" + document.frmNewAddress.cboGroup.value + "&repairId=" + document.frmNewAddress.repairId.value + "&repairValue=" + document.frmNewAddress.repairValue.value + "&optGroup=" + document.frmNewAddress.optGroup.value + "&txtGrName=" + document.frmNewAddress.txtGrName.value;
		getData(url,'divMain');
//                    form.submit();
                }
            } else {
                if (confirm("Bạn có chắc chắn xóa không?")) {
                    form.opt.value = value;
					var url = "/vn/address/index.jsp?actionState=" + document.frmNewAddress.actionState.value + "&opt=" + document.frmNewAddress.opt.value + "&cboSelGroup=" + document.frmNewAddress.cboSelGroup.value + "&txtName=" + document.frmNewAddress.txtName.value + "&txtFixPhone=" + document.frmNewAddress.txtFixPhone.value + "&txtMobile=" + document.frmNewAddress.txtMobile.value + "&txtAddress=" + document.frmNewAddress.txtAddress.value + "&txtEmail=" + document.frmNewAddress.txtEmail.value + "&txtJob=" + document.frmNewAddress.txtJob.value + "&txtBirthday=" + document.frmNewAddress.txtBirthday.value + "&cboGroup=" + document.frmNewAddress.cboGroup.value + "&repairId=" + document.frmNewAddress.repairId.value + "&repairValue=" + document.frmNewAddress.repairValue.value + "&optGroup=" + document.frmNewAddress.optGroup.value + "&txtGrName=" + document.frmNewAddress.txtGrName.value;
		getData(url,'divMain');
//                    form.submit();
                }
            }
        } else alert("Không địa chỉ nào được đánh dấu!");
    }
	/*=== Remove group ===*/
    function deleteGroup(form,value){
        if (form.cboSelGroup.value<1) {
            alert("Bạn phải chọn nhóm cần xóa.");
            form.cboSelGroup.focus();
        } else {
            if (confirm("Bạn có chắc chắn xóa nhóm này?")) {
                form.opt.value = value;
				var url = "/vn/address/index.jsp?actionState=" + document.frmNewAddress.actionState.value + "&opt=" + document.frmNewAddress.opt.value + "&cboSelGroup=" + document.frmNewAddress.cboSelGroup.value + "&txtName=" + document.frmNewAddress.txtName.value + "&txtFixPhone=" + document.frmNewAddress.txtFixPhone.value + "&txtMobile=" + document.frmNewAddress.txtMobile.value + "&txtAddress=" + document.frmNewAddress.txtAddress.value + "&txtEmail=" + document.frmNewAddress.txtEmail.value + "&txtJob=" + document.frmNewAddress.txtJob.value + "&txtBirthday=" + document.frmNewAddress.txtBirthday.value + "&cboGroup=" + document.frmNewAddress.cboGroup.value + "&repairId=" + document.frmNewAddress.repairId.value + "&repairValue=" + document.frmNewAddress.repairValue.value + "&optGroup=" + document.frmNewAddress.optGroup.value + "&txtGrName=" + document.frmNewAddress.txtGrName.value;
		getData(url,'divMain');
//                form.submit();
            }
        }
    }
	/*=== Add new group ===*/
    function addGroup(form,val){
        if (form.txtGrName.value=="") {
            alert("Bạn phải nhập tên nhóm mới!");
            form.txtGrName.focus();
        } else {
            form.optGroup.value = val;
			var url = "/vn/address/index.jsp?actionState=" + document.frmNewAddress.actionState.value + "&opt=" + document.frmNewAddress.opt.value + "&cboSelGroup=" + document.frmNewAddress.cboSelGroup.value + "&txtName=" + document.frmNewAddress.txtName.value + "&txtFixPhone=" + document.frmNewAddress.txtFixPhone.value + "&txtMobile=" + document.frmNewAddress.txtMobile.value + "&txtAddress=" + document.frmNewAddress.txtAddress.value + "&txtEmail=" + document.frmNewAddress.txtEmail.value + "&txtJob=" + document.frmNewAddress.txtJob.value + "&txtBirthday=" + document.frmNewAddress.txtBirthday.value + "&cboGroup=" + document.frmNewAddress.cboGroup.value + "&repairId=" + document.frmNewAddress.repairId.value + "&repairValue=" + document.frmNewAddress.repairValue.value + "&optGroup=" + document.frmNewAddress.optGroup.value + "&txtGrName=" + document.frmNewAddress.txtGrName.value;
		getData(url,'divMain');
//            form.submit();
        }
    }
	/*=== Search address book ===*/
    function submitMe(form,value){
        form.actionState.value = value;
		var url = "/vn/address/index.jsp?actionState=" + document.frmNewAddress.actionState.value + "&opt=" + document.frmNewAddress.opt.value + "&cboSelGroup=" + document.frmNewAddress.cboSelGroup.value + "&txtName=" + document.frmNewAddress.txtName.value + "&txtFixPhone=" + document.frmNewAddress.txtFixPhone.value + "&txtMobile=" + document.frmNewAddress.txtMobile.value + "&txtAddress=" + document.frmNewAddress.txtAddress.value + "&txtEmail=" + document.frmNewAddress.txtEmail.value + "&txtJob=" + document.frmNewAddress.txtJob.value + "&txtBirthday=" + document.frmNewAddress.txtBirthday.value + "&cboGroup=" + document.frmNewAddress.cboGroup.value + "&repairId=" + document.frmNewAddress.repairId.value + "&repairValue=" + document.frmNewAddress.repairValue.value + "&optGroup=" + document.frmNewAddress.optGroup.value + "&txtGrName=" + document.frmNewAddress.txtGrName.value;
		getData(url,'divMain');
//        form.submit();
    }



function CheckAll(checked) {
    len = document.frmNewAddress.elements.length;
    var i;
    for (i=0; i < len; i++) {
        if (document.frmNewAddress.elements[i].name=='chked') {
            if (document.frmNewAddress.elements[i].checked == false) {
                document.frmNewAddress.elements[i].checked=checked;
            } else {
                document.frmNewAddress.elements[i].checked=false;
            }
        }
    }
}

<!--Script for SmallAdd-->
 var enable;
  var maxLen = 160;
  function checkLength() {
     var currLen, delta;
	 var len4Content,leftLen;
     currLen = document.frmSend.txtName.value.length + document.frmSend.txtSubject.value.length + 1;
     len4Content = maxLen - (document.frmSend.txtName.value.length + 1);
     leftLen = maxLen - currLen;

     if (document.frmSend.txtSubject.value != leftLen) {
         if (leftLen > 0)  {
             document.frmSend.txtCharsLeft.value = leftLen;
	 } else if (leftLen < 0)  {
             document.frmSend.txtCharsLeft.value = 0;
             document.frmSend.txtSubject.value = document.frmSend.txtSubject.value.substring(0, len4Content);
         }
     }
  }

  function timer() {
      enable = setInterval(checkLength, 50);
  }
    function openAllTemplate() {
        window.open("/vn/address/template.jsp","SMSTemplate",'resizable=no,scrollbars=no,width=400,height=450');
    }

	      function doSubmit() {
      var listUser = document.frmSend.txtTo.value;
      var a=new Array(10);
      var index = listUser.indexOf(",");
      var i = 1;
      var temp;
      var index1;

      while (index > 0) {
        temp = listUser.substr(0, index);
        index1 = temp.indexOf(" ");
        if (index1 >0 && temp.length == 11) temp = temp.substr(index1+1);
        a[i] = temp;
        listUser = listUser.substr(index+1);
        index = listUser.indexOf(",");
        i++;
      }
      temp = listUser;
      index1 = temp.indexOf(" ");
      if (index1 >=0 && temp.length == 11) temp = temp.substr(index1+1);
      a[i] = temp;
      for(var j =0; j<i;j++) {

	  if(!checkphonenumber(a[j+1]) || !cmf_isNum1(a[j+1])){
	        alert("Số điện thoại không chính xác!\nXin vui lòng nhập lại.");
            document.frmSend.txtTo.focus();
            return false;


	  }

      }
	  var url = "/vn/address/addressprocess.jsp?txtTo=" + document.frmSend.txtTo.value + "&txtName=" + document.frmSend.txtName.value + "&txtPhone=" + document.frmSend.txtPhone.value + "&txtSubject=" + document.frmSend.txtSubject.value;
	  getData(url,'divMain');
      return true;
    }


      function doSubmitSendAddress() {
	    var url = "/vn/address/addressprocess.jsp?addId=" + document.frmSend.addId.value + "&txtName=" + document.frmSend.txtName.value + "&txtPhone=" + document.frmSend.txtPhone.value + "&txtSubject=" + document.frmSend.txtSubject.value + "&ckRaovat=" + document.frmSend.ckRaovat.value;
	  getData(url,'divMain');
      return true;
    }
<!---->
<!--Script for Calendar-->
function content_onkeypress() {
		if (document.frmCalendar.txtContent.value.length >160) {
			alert("Noi dung lich lam viec khong duoc nhieu hon 160 ky tu.");
			document.frmCalendar.txtContent.value = document.frmCalendar.txtContent.value.substring(0,160);
		}
	}

	function add_new_row() {

        var mobile = document.frmCalendar.txtMobile.value;
        if (document.frmCalendar.txtTitle.value == "") {
            alert("Ban phai nhap tieu de lich lam viec!");
        } else if (document.frmCalendar.txtTitle.value.length > 80) {
            alert("Tieu de lich lam viec khong duoc qua 80 ky tu!");
        } else if (document.frmCalendar.txtContent.value == "") {
            alert("Ban phai nhap noi dung lich lam viec!");
        } else if (document.frmCalendar.txtContent.value.length > 150) {
            alert("Noi dung lich lam viec khong duoc qua 150 ky tu!");
        } else if (!checkphonenumber(mobile)) {
            alert("So dien thoai khong chinh xac.\n Xin vui long nhap so dien thoai");
        } else {
            var id = 0;

            var content = document.frmCalendar.txtContent.value;
            for (id=0;id<content.length;id++) {
                if (content.substring(id,id+1)=="&") {
                    content = content.substring(0,id)+"&amp;"+content.substring(id+1,content.length);
                    id = id + 4;
                }
            }

            document.frmCalendar.content.value=content;
            document.frmCalendar.cmd.value = "them"
/*
	var url = "/vn/calendar/once.jsp?cmd=" + document.frmCalendar.cmd.value + "&txtTitle=" + document.frmCalendar.txtTitle.value + "&cboType=" + document.frmCalendar.cboType.value + "&txtContent=" + document.frmCalendar.txtContent.value + "&cboHour=" + document.frmCalendar.cboHour.value + "&cboMinute=" + document.frmCalendar.cboMinute.value + "&txtMobile=" + document.frmCalendar.txtMobile.value + "&txtTimeSend=" + document.frmCalendar.txtTimeSend.value + "&chkSms=" + document.frmCalendar.chkSms.value + "&repair=" + document.frmCalendar.repair.value + "&calendar_id=" + document.frmCalendar.calendar_id.value + "&action=" + document.frmCalendar.action.value + "&day=" + document.frmCalendar.day.value + "&month=" + document.frmCalendar.month.value + "&year=" + document.frmCalendar.month.year;
	getData(url,'divMain');
	*/
	        var url = "/vn/calendar/once.jsp";
			var params =  "cmd=" + document.frmCalendar.cmd.value + "&txtTitle=" + document.frmCalendar.txtTitle.value + "&cboType=" + document.frmCalendar.cboType.value + "&txtContent=" + document.frmCalendar.txtContent.value + "&cboHour=" + document.frmCalendar.cboHour.value + "&cboMinute=" + document.frmCalendar.cboMinute.value + "&txtMobile=" + document.frmCalendar.txtMobile.value + "&txtTimeSend=" + document.frmCalendar.txtTimeSend.value + "&chkSms=" + document.frmCalendar.chkSms.value + "&repair=" + document.frmCalendar.repair.value + "&calendar_id=" + document.frmCalendar.calendar_id.value + "&action=" + document.frmCalendar.action.value + "&day=" + document.frmCalendar.day.value + "&month=" + document.frmCalendar.month.value + "&year=" + document.frmCalendar.month.year;
            getDataByPost(url,params,'divMain');
            //document.frmCalendar.submit();
        }
	}

		function add_row() {
        var mobile = document.frmCalendar.txtMobile.value;
        if (document.frmCalendar.txtTitle.value == "") {
            alert("Ban phai nhap tieu de lich lam viec!");
        } else if (document.frmCalendar.txtTitle.value.length > 80) {
            alert("Tieu de lich lam viec khong duoc qua 80 ky tu!");
        } else if (document.frmCalendar.txtContent.value == "") {
            alert("Ban phai nhap noi dung lich lam viec!");
        } else if (document.frmCalendar.txtContent.value.length > 150) {
            alert("Noi dung lich lam viec khong duoc qua 150 ky tu!");
        } else if (!checkphonenumber(mobile)) {
            alert("So dien thoai khong chinh xac.\n Xin vui long nhap so dien thoai");
        } else {
            var id = 0;

            var content = document.frmCalendar.txtContent.value;
            for (id=0;id<content.length;id++) {
                if (content.substring(id,id+1)=="&") {
                    content = content.substring(0,id)+"&amp;"+content.substring(id+1,content.length);
                    id = id + 4;
                }
            }

            document.frmCalendar.content.value=content;
            document.frmCalendar.cmd.value = "them"
          /*
		  var url = "/vn/calendar/month.jsp?cmd=" + document.frmCalendar.cmd.value + "&txtTitle=" + document.frmCalendar.txtTitle.value + "&cboType=" + document.frmCalendar.cboType.value + "&txtContent=" + document.frmCalendar.txtContent.value + "&cboHour=" + document.frmCalendar.cboHour.value + "&cboMinute=" + document.frmCalendar.cboMinute.value + "&txtMobile=" + document.frmCalendar.txtMobile.value + "&txtTimeSend=" + document.frmCalendar.txtTimeSend.value + "&chkSms=" + document.frmCalendar.chkSms.value + "&repair=" + document.frmCalendar.repair.value + "&calendar_id=" + document.frmCalendar.calendar_id.value + "&action=" + document.frmCalendar.action.value + "&month=" + document.frmCalendar.month.value + "&year=" + document.frmCalendar.year.value;
            getData(url,'divMain');
			*/
            //document.frmCalendar.submit();
			var url = "/vn/calendar/month.jsp";
			var params = "cmd=" + document.frmCalendar.cmd.value + "&txtTitle=" + document.frmCalendar.txtTitle.value + "&cboType=" + document.frmCalendar.cboType.value + "&txtContent=" + document.frmCalendar.txtContent.value + "&cboHour=" + document.frmCalendar.cboHour.value + "&cboMinute=" + document.frmCalendar.cboMinute.value + "&txtMobile=" + document.frmCalendar.txtMobile.value + "&txtTimeSend=" + document.frmCalendar.txtTimeSend.value + "&chkSms=" + document.frmCalendar.chkSms.value + "&repair=" + document.frmCalendar.repair.value + "&calendar_id=" + document.frmCalendar.calendar_id.value + "&action=" + document.frmCalendar.action.value + "&month=" + document.frmCalendar.month.value + "&year=" + document.frmCalendar.year.value;
            getDataByPost(url,params,'divMain');
        }
	}

	//****************************
	function isNum(field) {
            var valid = "0123456789";
            var ok = "yes";
            var temp
            for (var i=0; i < field.value.length; i++){
                temp = "" + field.value.substring(i, i+1)
                if (valid.indexOf(temp) == "-1") ok = "no"
            }
            if (ok == "no")	return true
            else return false
	}
    //***************************
	function delete_this_row(id) {
            document.frmCalendar.cmd.value = "xoa";
            document.frmCalendar.calendar_id.value = id;

			/*var url = "/vn/calendar/once.jsp?cmd=" + document.frmCalendar.cmd.value + "&calendar_id=" + document.frmCalendar.calendar_id.value + "&action=" + document.frmCalendar.action.value + "&day=" + document.frmCalendar.day.value + "&month=" + document.frmCalendar.month.value + "&year=" + document.frmCalendar.month.year;
            getData(url,'divMain');
			*/
//            document.frmCalendar.submit();
			var url = "/vn/calendar/once.jsp";
			var params = "cmd=" + document.frmCalendar.cmd.value + "&calendar_id=" + document.frmCalendar.calendar_id.value + "&action=" + document.frmCalendar.action.value + "&day=" + document.frmCalendar.day.value + "&month=" + document.frmCalendar.month.value + "&year=" + document.frmCalendar.month.year;
            getDataByPost(url,params,'divMain');
	}
    //***************************
	function repair_this_row(id) {
            document.frmCalendar.cmd.value = "sua";
            document.frmCalendar.calendar_id.value = id;
            document.frmCalendar.repair.value = "edit";
            document.frmCalendar.cmdAddEdit.value="Cập nhật";

		   /*var url = "/vn/calendar/once.jsp?cmd=" + document.frmCalendar.cmd.value + "&calendar_id=" + document.frmCalendar.calendar_id.value + "&repair=" + document.frmCalendar.repair.value + "&action=" + document.frmCalendar.action.value + "&day=" + document.frmCalendar.day.value + "&month=" + document.frmCalendar.month.value + "&year=" + document.frmCalendar.month.year;
            getData(url,'divMain');*/
			var url = "/vn/calendar/once.jsp";

			var params = "cmd=" + document.frmCalendar.cmd.value + "&calendar_id=" + document.frmCalendar.calendar_id.value + "&repair=" + document.frmCalendar.repair.value + "&action=" + document.frmCalendar.action.value + "&day=" + document.frmCalendar.day.value + "&month=" + document.frmCalendar.month.value + "&year=" + document.frmCalendar.month.year;
           getDataByPost(url,params,'divMain');
//            document.frmCalendar.submit();
	}
    //***************************
	function other_date(day) {
            document.frmCalendar.cmd.value = "";
            document.frmCalendar.day.value = day;
          /*  var url = "/vn/calendar/once.jsp?cmd=" + document.frmCalendar.cmd.value + "&action=" + document.frmCalendar.action.value + "&day=" + document.frmCalendar.day.value + "&month=" + document.frmCalendar.month.value + "&year=" + document.frmCalendar.month.year;
            getData(url,'divMain');*/
           // document.frmCalendar.submit();
		     var url = "/vn/calendar/once.jsp";
			 var params = "cmd=" + document.frmCalendar.cmd.value + "&action=" + document.frmCalendar.action.value + "&day=" + document.frmCalendar.day.value + "&month=" + document.frmCalendar.month.value + "&year=" + document.frmCalendar.month.year;
            getDataByPost(url,params,'divMain');
	}
    //***************************
	function updateSendSms(day) {
            document.frmCalendar.cmd.value = "sendsms";
           /* var url = "/vn/calendar/once.jsp?cmd=" + document.frmCalendar.cmd.value + "&chkID=" + document.frmCalendar.chkID.value + "&status=" + document.frmCalendar.status.value + "&action=" + document.frmCalendar.action.value + "&day=" + document.frmCalendar.day.value + "&month=" + document.frmCalendar.month.value + "&year=" + document.frmCalendar.month.year;
            getData(url,'divMain');*/
//            document.frmCalendar.submit();
			 var url = "/vn/calendar/once.jsp";
			 var params = "cmd=" + document.frmCalendar.cmd.value + "&chkID=" + document.frmCalendar.chkID.value + "&status=" + document.frmCalendar.status.value + "&action=" + document.frmCalendar.action.value + "&day=" + document.frmCalendar.day.value + "&month=" + document.frmCalendar.month.value + "&year=" + document.frmCalendar.month.year;
            getDataByPost(url,params,'divMain');
	}
    //***************************
	function checkBoxClick(id, f) {
            for (var i=0;i<document.frmCalendar.chkID.length;i++) {
                var old_value = document.frmCalendar.chkID[i].value;
                if (document.frmCalendar.chkID[i].checked)
                {
                    document.frmCalendar.status[i].value = old_value + "_1";
                } else {
                    document.frmCalendar.status[i].value = old_value + "_0";
                }
            }
	}

<!--Script for Calendar -->
//-------------------------------------------------------------
function set_loading_message(msg) {
 	please_wait = msg;
}
function checkphonenumber1(phonenumber){

		var region=new Array ("3503","5113","650","651","510","373","383","773", "780","781","343","351","3203", "321","313","280", "281","240","241","210", "211","18", "19", "20", "22", "23",  "25", "26", "27","29","30","31","33", "36", "38", "39","50",  "52", "53", "54", "55", "56", "57","58", "59", "60", "61", "62", "63", "64", "66", "67", "68", "70","71", "72", "73", "74", "75", "76", "79", "8","4");
	//09xxxxxxxx
	if((phonenumber.length==10)&&(phonenumber.search(/^09[0,1,2,3,4,5,6,7,8]/)!=-1)){
		return true;
	}
	//849xxxxxxxx
	else if((phonenumber.length==11)&&(phonenumber.search(/^849[0,1,2,3,4,5,6,7,8]/)!=-1)){
		return true;
	}else if((phonenumber.length==12) &&(phonenumber.search(/^84168[0,1,2,3,4,5,6,7,8,9]/) != -1 || phonenumber.search(/^84122[0,1,2,3,4,5,6,7,8,9]/) != -1)){
		return true;
	}else if((phonenumber.length==11) && (phonenumber.search(/^0168[0,1,2,3,4,5,6,7,8,9]/) != -1 || phonenumber.search(/^0122[0,1,2,3,4,5,6,7,8,9]/) != -1)){
		return true;
	}

	if(phonenumber.indexOf("84") == 0){
		phonenumber = phonenumber.substring(2,phonenumber.length);
	}else if(phonenumber.indexOf("0") == 0){
		phonenumber = phonenumber.substring(1,phonenumber.length);
	}else{
		return false;
	}
	for(var i=0;i<region.length;i++){
	var header1 = region[i] + "20";
	var header2 = region[i] + "21";
	var header3 = region[i] + "22";
	var header4 = region[i] + "23";
	var header5 = region[i] + "24";
	var header6 = region[i] + "46";
	var header7 = region[i] + "47";
    var header8 = region[i] + "26";


	if(phonenumber.indexOf(header1) == 0 || phonenumber.indexOf(header2) == 0 || phonenumber.indexOf(header3) == 0 || phonenumber.indexOf(header4) == 0 || phonenumber.indexOf(header5) == 0 || phonenumber.indexOf(header6) == 0 || phonenumber.indexOf(header7) == 0 || phonenumber.indexOf(header8) == 0){
		return true;
	}
}

	return false;
}

function checkphonenumber(phonenumber){

                                    var region=new Array ("3503","5113","650","651","510","373","383","773", "780","781","343","351","3203", "321","313","280", "281","240","241","210", "211","18", "19", "20", "22", "23",  "25", "26", "27","29","30","31","33", "36", "38", "39","50",  "52", "53", "54", "55", "56", "57","58", "59", "60", "61", "62", "63", "64", "66", "67", "68", "70","71", "72", "73", "74", "75", "76", "79", "8","4");

                        //09xxxxxxxx

                        if((phonenumber.length==10)&&(phonenumber.search(/^09[0,1,2,3,4,5,6,7,8]/)!=-1)){

                                    return true;

                        }

                        //849xxxxxxxx

                        else if((phonenumber.length==11)&&(phonenumber.search(/^849[0,1,2,3,4,5,6,7,8]/)!=-1)){

                                    return true;

                        }else if((phonenumber.length==12) &&(phonenumber.search(/^8416[4,5,6,7,8,9]/) != -1 || phonenumber.search(/^8412[1,2,3,5,6,7,8]/) != -1)){

                                    return true;

                        }else if((phonenumber.length==11) && (phonenumber.search(/^016[4,5,6,7,8,9]/) != -1 || phonenumber.search(/^012[1,2,3,5,6,7,8]/) != -1)){

                                    return true;

                        }

            

                        if(phonenumber.indexOf("84") == 0){

                                    phonenumber = phonenumber.substring(2,phonenumber.length);

                        }else if(phonenumber.indexOf("0") == 0){

                                    phonenumber = phonenumber.substring(1,phonenumber.length);

                        }else{

                                    return false;

                        }

                        for(var i=0;i<region.length;i++){

                        var header1 = region[i] + "20";

                        var header2 = region[i] + "21";

                        var header3 = region[i] + "22";

                        var header4 = region[i] + "23";

                        var header5 = region[i] + "24";

                        var header6 = region[i] + "46";

                        var header7 = region[i] + "47";

                        var header8 = region[i] + "26";

            

            

                        if(phonenumber.indexOf(header1) == 0 || phonenumber.indexOf(header2) == 0 || phonenumber.indexOf(header3) == 0 || phonenumber.indexOf(header4) == 0 || phonenumber.indexOf(header5) == 0 || phonenumber.indexOf(header6) == 0 || phonenumber.indexOf(header7) == 0 || phonenumber.indexOf(header8) == 0){

                                    return true;

                        }

            }           

            return false;

}

/*------------------------------------------------------------------*/
/*  Kiem tra object empty                                           */
/*    obj       :			                                        */
/*    msg       : message can thong bao                             */
/*    alt       : co alert ra hay khong                             */
/*    fcs       : co focus tro lai hay khong                        */
/*------------------------------------------------------------------*/
function cmf_isEmpty(obj,msg,alt,fcs) {
    var rtn = cmf_isEmpty2(obj.value);
    if (rtn == true) {
        if (alt == "1") { alert(msg); }
        if (fcs == "1") { obj.focus(); }
    }
    return rtn;
}

function cmf_isEmpty2(inputstr) {
    if (inputstr == null || inputstr == "") {
        return true;
    }
    for (var i = 0; i < inputstr.length; i++) {
        var onechar = inputstr.charAt(i);
        if (onechar != " ") {
            return false;
        }
    }
    return true;
}


function cmf_isSelectEmpty(obj,msg,v_alt,v_fcs) {
    if (obj.selectedIndex==0||obj.selectedIndex=="") {
        if (v_alt == 1) { alert(msg); }
        if (v_fcs == 1) { obj.focus(); }
        return true;
    }
    return false;
}
function cmf_isNumber(obj,len1,len2,mi,msg,alt,fcs) {
    var rtn = cmf_isNumber2(obj.value,len1,len2,mi);
    //if (msg == null || msg == "") { msg = ""; }
    //else                          { msg = "["+msg+"]"; }
    if (rtn == false) {
        if (alt == "1") { alert(msg+" must be number"); }
        if (fcs == "1") { obj.focus(); }
    }
    return rtn;
}

function cmf_isNumber2(inputval,len1,len2,mi) {
    onedecimal = false;
    inputstr = "" + inputval;
    vallen1 = 0;
    vallen2 = 0;
    for (var i = 0; i < inputstr.length; i++) {
        var onechar = inputstr.charAt(i);
        if (i == 0 && onechar == "-") {
            if (!mi) {
                return false;
            }
            continue;
        }
        if (onechar == "." && !onedecimal) {
            if (len2 == 0) {
                return false;
            }
            onedecimal = true;
            continue;
        }
        if (onechar < "0" || onechar > "9") {
            return false;
        }
        else {
            if (onedecimal) {
                vallen2 += 1;
            }
            else {
                vallen1 += 1;
            }
        }
    }
    if (len1 < vallen1 || len2 < vallen2) {
        return false;
    }
    return true;
}

function cmf_isNum(field)
{
	var valid = "0123456789";
	var ok = "yes";
	var temp;
	for (var i=0; i < field.value.length; i++)
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") {
			ok = "no";
			break;
		}
	}
	if (ok == "no")
	{
		return false;
	}else
	{
		return true
	}
}
function cmf_isNum1(field)
{
	var valid = "0123456789";
	var ok = "yes";
	var temp;
	for (var i=0; i < field.length; i++)
	{
		temp = "" + field.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") {
			ok = "no";
			break;
		}
	}
	if (ok == "no")
	{
		return false;
	}else
	{
		return true
	}
}

function getHistoryByPage(ilink,sYYYY,sMonth){
/*
var url = "/vn/member/history.jsp?page=" + ilink + "&year=" + sYYYY + "&month=" + sMonth;
   getData(url,'divMain');
   */
var url = "/vn/member/history.jsp#"+randomNumber(100);
var params = "page=" + ilink + "&year=" + sYYYY + "&month=" + sMonth;
   getDataByPost(url,params,'divMain');

}
function randomNumber(limit){
  return Math.floor(Math.random()*limit);
}

function getHistory(){
/*
var url = "/vn/member/history.jsp?year=" + document.frmHistory.year.value + "&month=" + document.frmHistory.month.value;
   getData(url,'divMain');
   */
   var url = "/vn/member/history.jsp";
   var params = "year=" + document.frmHistory.year.value + "&month=" + document.frmHistory.month.value;
   getDataByPost(url,params,'divMain');
}
function modifyDetail(){
   if (document.frmModify.txtFullName.value.length > 50){
      alert("Họ tên quá dài, bạn vui lòng nhập lại")
      document.frmModify.txtFullName.focus();
      return false;
   }
   if (document.frmModify.txtPhone.value.length > 15){
      alert("Số điện thoại quá dài, bạn vui lòng nhập lại")
      document.frmModify.txtPhone.focus();
      return false;
   }
   if (document.frmModify.txtAddress.value.length > 50){
      alert("Địa chỉ quá dài, bạn vui lòng nhập lại")
      document.frmModify.txtAddress.focus();
      return false;
   }
   var url="/vn/member/detail.jsp?txtFullName=" + document.frmModify.txtFullName.value + "&txtPhone=" + document.frmModify.txtPhone.value + "&txtAddress=" + document.frmModify.txtAddress.value + "&cmbGender=" + document.frmModify.cmbGender.value + "&cmbJob=" + document.frmModify.cmbJob.value + "&cmbProvinces=" + document.frmModify.cmbProvinces.value;

		getData(url,'divMain');

   return true;
}

 function doSubmitPassChange() {
     var tf=window.document.pass_forget;
     if (tf.txtPassOld.value.length < 6) {
          alert("Xin vui lòng nhập mật khẩu cũ");
          tf.txtPassOld.focus();
          return false;
     }
     if (tf.txtPassNew.value.length < 6) {
          alert("Mật khẩu phải có ít nhất 6 ký tự. Xin vui lòng nhập lại");
          tf.txtPassNew.focus();
          return false;
     }
     if (tf.txtConPassNew.value != tf.txtPassNew.value) {
          alert("Mật khẩu khẳng định không chính xác. Xin vui lòng nhập lại");
          tf.txtConPassNew.focus();
          return false;
     }
	 var url = "/vn/member/passchange.jsp?txtPassOld=" + tf.txtPassOld.value + "&txtPassNew=" + tf.txtPassNew.value;
	 getData(url,'divMain');
     return true;
  }

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
<!---->
<!--Script for HotNews-->
filmtypeCount = 0;
arrFilmType = new Array(5);
    type1= new FilmType('RAP','Rạp');
type1.addItem('HN','Hà Nội');
type1.addItem('HCM','TP.Hồ Chí Minh');
type3= new FilmType('TH','Truyền hình');
type3.addItem('VTV1','VTV1');
type3.addItem('VTV3','VTV3');
function changeImages() {
  if (document.images) {
    for (var i=0; i<changeImages.arguments.length; i+=2) {
      document[changeImages.arguments[i] ].src = eval(changeImages.arguments[i+1] + ".src");
    }
  }
}

function deleteNews(){


  var idList = "";
if(document.frmHotNews.chkDelete.length == null){
idList = document.frmHotNews.chkDelete.value;
	}else{
  for(var i=0;i<document.frmHotNews.chkDelete.length;i++){
    if(document.frmHotNews.chkDelete[i].checked){

	idList = idList + "," + document.frmHotNews.chkDelete[i].value;

	}

}

	}



  window.document.frmHotNews.Action.value = "Delete";
  window.document.frmHotNews.IDArr.value = idList;
 window.location = "tinnong.jsp?Action=" + window.document.frmHotNews.Action.value + "&Code=" + window.document.frmHotNews.Code.value + "&Code1=" + window.document.frmHotNews.Code1.value + "&Code2=" + window.document.frmHotNews.Code2.value + "&TelNum=" + window.document.frmHotNews.TelNum.value + "&IDArr=" + window.document.frmHotNews.IDArr.value;
//  window.document.frmHotNews.submit();
}

function btnClick_1() {
  if(window.document.frmHotNews.sltLotterySelect.value == "-1"){
    alert("Bạn phải chọn tỉnh, thành!");
    window.document.frmHotNews.sltLotterySelect.focus();
    return;
  }
  if(window.document.frmHotNews.txtLotteryPhone.value == "" || !checkphonenumber(window.document.frmHotNews.txtLotteryPhone.value)){
    alert("Bạn phải nhập số điện thoại!");
    window.document.frmHotNews.txtLotteryPhone.focus();
    return;
  }
  window.document.frmHotNews.Action.value = "1";
  window.document.frmHotNews.Code.value = "XS";
  window.document.frmHotNews.Code1.value = window.document.frmHotNews.sltLotterySelect.value;
  window.document.frmHotNews.Code2.value = "";
  window.document.frmHotNews.TelNum.value = window.document.frmHotNews.txtLotteryPhone.value;
  window.location = "tinnong.jsp?Action=" + window.document.frmHotNews.Action.value + "&Code=" + window.document.frmHotNews.Code.value + "&Code1=" + window.document.frmHotNews.Code1.value + "&Code2=" + window.document.frmHotNews.Code2.value + "&TelNum=" + window.document.frmHotNews.TelNum.value + "&IDArr=" + window.document.frmHotNews.IDArr.value;

//  window.document.frmHotNews.submit();
}
function btnClick_2() {
  if(window.document.frmHotNews.sltService.value == "-1"){
    alert("Bạn phải chọn loại hình dịch vụ!");
    window.document.frmHotNews.sltService.focus();
    return;
  }
  if(window.document.frmHotNews.txtNewsPhone.value == "" || !checkphonenumber(window.document.frmHotNews.txtNewsPhone.value)){
    alert("Bạn phải nhập số điện thoại!");
    window.document.frmHotNews.txtNewsPhone.focus();
    return;
  }
  window.document.frmHotNews.Action.value = "2";
  window.document.frmHotNews.Code.value = "NEW";
  window.document.frmHotNews.Code1.value = window.document.frmHotNews.sltService.value;
  window.document.frmHotNews.Code2.value = "";
  window.document.frmHotNews.TelNum.value = window.document.frmHotNews.txtNewsPhone.value;
  window.location = "tinnong.jsp?Action=" + window.document.frmHotNews.Action.value + "&Code=" + window.document.frmHotNews.Code.value + "&Code1=" + window.document.frmHotNews.Code1.value + "&Code2=" + window.document.frmHotNews.Code2.value + "&TelNum=" + window.document.frmHotNews.TelNum.value + "&IDArr=" + window.document.frmHotNews.IDArr.value;
//   window.document.frmHotNews.submit(); ok
}
//-------------
function btnClick_3() {
  if(window.document.frmHotNews.sltPhim.value == "-1"){
    alert("Bạn phải chọn loại phim!");
    window.document.frmHotNews.sltPhim.focus();
    return;
  }
  if(window.document.frmHotNews.sltArea.value == "-1"){
    alert("Bạn phải chọn địa điểm (kênh)!");
    window.document.frmHotNews.sltArea.focus();
    return;
  }
  if(window.document.frmHotNews.txtFilmPhone.value == "" || !checkphonenumber(window.document.frmHotNews.txtFilmPhone.value)){
    alert("Bạn phải nhập số điện thoại!");
    window.document.frmHotNews.txtFilmPhone.focus();
    return;
  }
  window.document.frmHotNews.Action.value = "3";
  window.document.frmHotNews.Code.value = "FILM";
  window.document.frmHotNews.Code1.value = window.document.frmHotNews.sltPhim.value;
  window.document.frmHotNews.Code2.value = window.document.frmHotNews.sltArea.value;
  window.document.frmHotNews.TelNum.value = window.document.frmHotNews.txtFilmPhone.value;
  window.location = "tinnong.jsp?Action=" + window.document.frmHotNews.Action.value + "&Code=" + window.document.frmHotNews.Code.value + "&Code1=" + window.document.frmHotNews.Code1.value + "&Code2=" + window.document.frmHotNews.Code2.value + "&TelNum=" + window.document.frmHotNews.TelNum.value + "&IDArr=" + window.document.frmHotNews.IDArr.value;
//  window.document.frmHotNews.submit();
}
//---------

function sel3_change()
{
  var selCode = "";
  var selType = null;
  var theSel = document.frmHotNews.sltPhim;

  for(var i=0; i < theSel.length; i++)
  {
          if(theSel.options[i].selected)
          {
                  selCode = theSel.options[i].value;
          }
  }

  theSel = document.frmHotNews.sltArea;
  for(i=theSel.length-1; i>0; i--)
  {
          deleteOption(theSel, i);
  }
  if(selCode == "-1") return;
  for(i=0; i < filmtypeCount; i++){
    if(arrFilmType[i].code == selCode){

      selType = arrFilmType[i];
    }
  }

    for(var j=0; j<selType.itemCount; j++){
      addOption(theSel, selType.items[j].name, selType.items[j].code);
    }

}
//-------
function addOption(theSel, theText, theValue)
{
	var newOpt = new Option(theText, theValue);
	var selLength = theSel.length;
	theSel.options[selLength] = newOpt;
}
function deleteOption(theSel, theIndex)
{
	var selLength = theSel.length;
	if(selLength>0)
	{
		theSel.options[theIndex] = null;
	}
}


function FilmType(code, name)
{
  this.code = code;
  this.name = name;
  this.items = new Array(10);
  this.itemCount = 0;
  arrFilmType[filmtypeCount++] = this;
  this.addItem = FilmType_AddItem;
}
function FilmItem(code, name)
{
  this.code = code;
  this.name = name;
}
function FilmType_AddItem(code, name)
{
  var filmitem = new FilmItem(code, name);
  this.items[this.itemCount++] = filmitem;
}

<!---->
