function jsRightMessage(){

};
/*短信平台里的grid*/
jsRightMessage.messageTable = null;
/*拨号台里的grid*/
jsRightMessage.DialTable = null;
/*今日通话号码grid*/
jsRightMessage.TodayContactTable = null;
/*右边框高度*/
jsRightMessage.RightHeight = null;
/*今日拨打号码的查询类型*/
jsRightMessage.KuDayType=null;

/*短信平台grid*/
jsRightMessage.initMessageGrid = function() {
    try {
        var w = $("#rightContainer").width() - 30;
        var gh = 125;
        var tableGridOption =
        {
            height: gh,
            width: w,
            colModel:
            [
                { display: '号码', name: 'Number', width: (w * 0.4), sortable: false, align: 'left', process: jsRightMessage.inputNOContorl },
                { display: '称呼', name: 'Appellation', width: (w * 0.3), sortable: false, align: 'left', process: jsRightMessage.inputContorl },
                { display: '', name: 'Operating', width: (w * 0.15), sortable: false,process: jsRightMessage.delButtonForMessage }
            ]
            , usepager: false
            , customFunction: jsRightMessage.ShowPage
        };
        jsRightMessage.messageTable = $("#quickQueryTable").ikegrid(tableGridOption);
        tableGridOption = null;
    }
    catch (e) {
        alert("ERROR for jsRightMessage.initMessageGrid:" + e.message);
    }
    CollectGarbage();
};

/*拨号台grid*/
jsRightMessage.initDialGrid = function() {
    try {
        var w = $("#rightContainer").width() - 30;
        var gh = 125;
        var tableGridOption =
        {
            height: gh,
            width: w,
            colModel:
            [
                { display: '号码', name: 'TELNUM', width: (w * 0.4), sortable: false, align: 'left', process: jsRightMessage.inputNOContorl },
                { display: '称呼', name: 'Appellation', width: (w * 0.3), sortable: false, align: 'left', process: jsRightMessage.inputContorl },
                { display: '', name: 'Operating', width: (w * 0.15), sortable: false, process: jsRightMessage.delButtonForDial }
            ]
            , usepager: false
            , customFunction: jsRightMessage.ShowPage
        };
        jsRightMessage.DialTable = $("#waitContactTable").ikegrid(tableGridOption);
        
        tableGridOption = null;
    }
    catch (e) {
        alert("ERROR for jsRightMessage.initMessageGrid:" + e.message);
    }
    CollectGarbage();
};

/*今日通话号码grid*/
jsRightMessage.initTodayContactGrid = function() {
    try {
        var w = $("#rightContainer").width() - 30;
        var gh = 100;
        var tableGridOption =
        {
            height: gh,
            width: w,
            colModel:
            [
                { display: 'ID', name: 'BILLID', width: (w * 0.3), sortable: false, align: 'left',hide:true},               
                { display: '号码', name: 'TELNUM', width: (w * 0.38), sortable: true, align: 'left' },
                { display: '状态', name: 'Type', width: (w * 0.4), sortable: true, align: 'left',process:jsRightMessage.selTodayContactCallType,processType:'select' },
                { display: '通话时间', name: 'CALLTIME', width: (w * 0.3), sortable: false, align: 'left'}//,process:jsRightMessage.FormatCallTime}
            ],
             usepager: false,
            customFunction: jsRightMessage.ShowTodayContactPage,
            rp: 1000000,
            rowbinddata:true,
            sortname: 'BILLID',
            sortorder: 'desc'
        };
        jsRightMessage.TodayContactTable = $("#todayContact").ikegrid(tableGridOption);
        tableGridOption = null;
    }
    catch (e) {
        alert("ERROR for jsRightMessage.initMessageGrid:" + e.message);
    }
    CollectGarbage();
};
jsRightMessage.ShowPage = function() {
    return null;
}

/*今日拨打电话时间格式*/
jsRightMessage.FormatCallTime=function(value,pid,rows){
    if(value.toString()!="")
    {
         var arrTime=DBReader.ServerTime(value.toString()).ServerFormat("hh:mm:ss");
         return  arrTime;
     }
};


/*今日拨打号码的类型*/
jsRightMessage.selTodayContactCallType=function(value,pid,rows){
    var valueArr=new Array();
    valueArr.push("无");
    valueArr.push("对方已接");
    valueArr.push("对方拒接");
    valueArr.push("对方没空");
    valueArr.push("非本人接听");
    valueArr.push("无人接听");
    valueArr.push("号码不对");
    valueArr.push("对方回拨");
    valueArr.push("稍候再拨");
    var strSelect='<select id="selCallType_'+pid+'" onchange="jsRightMessage.WhenChangTodayContCallType(this,\''+rows["BILLID"]+'\')">';
   for(var i=0;i< valueArr.length;i++)
   {
        if(valueArr[i]==value.toString())
        {
           strSelect+=" <option selected='selected'>"+valueArr[i]+"</option>";
        }
        else
        {
            strSelect+=" <option>"+valueArr[i]+"</option>";
        }
   }
    strSelect+= "</select>";
    valueArr.length=0;
    valueArr=null;
    CollectGarbage();
    return strSelect;
};
/*修改今日拨打号码的状态*/
jsRightMessage.WhenChangTodayContCallType=function(obj,billID){
    var curSelType=obj.options[obj.selectedIndex].text; 
    var entity=jsEntity.CreateEntityByTableName_access("T_CALLBILL","","","","BILLID");   
    entity.Fields.BILLID=billID;
    entity.Fields.Type=curSelType;
    var result = entity.Update(entity);
    if(result)
    {
        jsTelBillCenterContent.CallRecordSearchString();/*刷新通话记录列表*/
    }    
    curSelType=null;
    DBReader.DisposeEntity(entity);
    CollectGarbage();
};

/*绑定显示数据*/        
jsRightMessage.ShowTodayContactPage = function(pageSize, pageIndex, searchStr,extpara,order) {
     var countTop=pageSize*(pageIndex-1);
     var strSql = "SELECT T_CALLBILL.BILLID, T_CALLBILL.CALLTIME,T_CALLBILL.TELNUM,T_CALLBILL.Type FROM T_CALLBILL ";     
     var strWhere =" where  T_CALLBILL.CALLTYP=2" ;
     if(searchStr!="" && searchStr!=undefined)
     {
         if(searchStr[0]._startTime!="" && searchStr[0]._startTime!=null)
        {
            strWhere = strWhere + " and T_CALLBILL.CALLTIME >= "+ searchStr[0]._startTime ;
         }
          else
         {
            strWhere = strWhere + " and T_CALLBILL.CALLTIME >=#"+  DBReader.ServerTime().ServerFormat("yyyy-MM-dd")+" 00:00:00"+"#";
         }
     }
     else
     {
        strWhere = strWhere + " and T_CALLBILL.CALLTIME >=#"+  DBReader.ServerTime().ServerFormat("yyyy-MM-dd")+" 00:00:00"+"#";
     }
    if(searchStr!="" && searchStr!=undefined)
     {
         if( searchStr[0]._endTime !="" && searchStr[0]._endTime != null)
         {
            strWhere = strWhere + " and T_CALLBILL.CALLTIME <= "+  searchStr[0]._endTime  ;
         } 
               else
         {
            strWhere = strWhere + " and T_CALLBILL.CALLTIME >=#"+  DBReader.ServerTime().ServerFormat("yyyy-MM-dd")+" 00:00:00"+"#";
         }
     }
     else
     {
        strWhere = strWhere + " and T_CALLBILL.CALLTIME <=#"+ DBReader.ServerTime().ServerFormat("yyyy-MM-dd")+" 23:59:59"+"#" ;
     }
     var strOrderBy="";
    if(order !="" && order != null)
    {
         strOrderBy="T_CALLBILL."+order;
    }
    strSql = strSql + strWhere+" Order By "+strOrderBy; 
//    window.clipboardData.setData("text",strSql);

    /*分页代码*/
    if(countTop >0)
    {
         strSql="select TOP "+ pageSize +" (select count(BILLID) from ( " + strSql +")) as AllCount, * from (" + strSql +") where BILLID NOT IN (SELECT TOP "+ countTop +" BILLID from (" + strSql + "))";
    }
    else
    {
        strSql="select TOP "+ pageSize +" (select count(BILLID) from ( " + strSql +")) as AllCount,  * from (" + strSql +") ";
    }    
    var strResult=DBReader.selectSqlForJson(strSql);
    var result;
    if(strResult!=null)
    {
        result=eval("[{"+strResult+"}]");
        result[0].pageIndex=pageIndex;    
    }
    
    countTop=null; 
    strSql=null;   
    strWhere=null;
    strPara=null;
    strResult=null;
    CollectGarbage();
    return strResult=null?null:result[0];
}

/*通话记录列表搜索*/
jsRightMessage.TodayContactTableSearchString=function()
{
    try
    {
        var strWhere=[];       
        var htxt_BeginTime="";
        var htxt_EndTime="";
        if(jsRightMessage.KuDayType=="Pre")
        {/*前一天*/
            var preDay=jsCommonLogic.TimeFormatSpace($("#hidekuCurDate").val(),'day',1,'minus'); 
            htxt_BeginTime="#"+preDay+" 00:00:00"+"#";
            htxt_EndTime="#"+preDay+" 23:59:59"+"#";                                           
            $("#hidekuCurDate").val(preDay);
            preDay=null;
        }
        else if(jsRightMessage.KuDayType=="Next")
        {/*后一天*/
            var nextDay=jsCommonLogic.TimeFormatSpace($("#hidekuCurDate").val(),'day',1,'add');
            htxt_BeginTime="#"+nextDay+" 00:00:00"+"#";
            htxt_EndTime="#"+nextDay+" 23:59:59"+"#";  
            $("#hidekuCurDate").val(nextDay); 
            nextDay=null;
        }
        else 
        {/*默认今天*/
            htxt_BeginTime="#"+  $("#hidekuCurDate").val()+" 00:00:00"+"#";
            htxt_EndTime="#"+ $("#hidekuCurDate").val()+" 23:59:59"+"#";
        }        
        strWhere.push({_startTime:htxt_BeginTime,_endTime:htxt_EndTime});

        $("#todayContact").DoSearch(strWhere);
        
        htxt_BeginTime=null;
        htxt_EndTime=null;
        strWhere.length=0;
        strWhere=null;
    }
    catch(e)
    {
        alert("jsRightMessage.TodayContactTableSearchString:"+e.message);
    }
    CollectGarbage();
}

/*加载显示短信平台页面*/
jsRightMessage.LoadRightMessageUI = function() {
    var arrString = [];
    var marginValue = App.ieMargin();
    var menuHeight = document.body.clientHeight - marginValue - 40;
    arrString.push('<div id="div-left-menu" class="div-left-menu" style="width:100%;">');
    arrString.push('<div class="div-left-menu-header" style="cursor:pointer;" onclick="jsRightMessage.RightUIShow(\'DialCondition\');"><div class="div-left-menu-title-name" id="divDial">拨号台</div></div>');
    arrString.push('<div id="DialCondition" class="quickChannel" style="width:100%;overflow-y:scroll;height:100%;display:none;position:relative;">');
    arrString.push('<table cellpadding="0" cellspacing="0"  border="0"  class="formtable" style="background-color:#ffffff; margin:0px;width:180px;"><tr><td>');
    arrString.push('<label style="float:left;"><input type="checkbox" id="chkIsAutoDial" onclick="jsRightMessage.setHoldOnDial(this);"/>摘机拨号</label>');
    arrString.push('<input type="button" value="拨号" id="btnDial" class="btn" style="float:right;display:none" onclick="jsRightMessage.PeopleDial();"/>');
    arrString.push('<input type="button" value="挂机" id="btnHoldOff" class="btn" style="float:right;display:none" disabled=true onclick="jsRightMessage.HoldOff();"/>');
    arrString.push('<div style="clear:both;"></div></td></tr><tr><td>');
    arrString.push('<span style="float:left;">待通话号码</span><span id="sapWaitDialNumberListTitle">[0]</span>个');
    //    arrString.push('<div style="float:right;"><label><input id="rdoDialText" name="raoDial" type="radio" value="text" checked="checked" onclick="jsRightMessage.MessageShow(\'raoDial\')"/><span>文本</span></label>');
    //    arrString.push(' <label><input id="rdoDialList" name="raoDial" type="radio" value="grid" onclick="jsRightMessage.MessageShow(\'raoDial\')"/><span>列表</span></label></div>');
    arrString.push('<div style="clear:both;"></div></td></tr><tr><td>请输入待通话号码：<span onclick="jsRightMessage.ClearWaitDialNumberList()" style="cursor:hand">[清空]</span><div id="divDialTelNo"><textarea id="txtDialTelNo" ></textarea></div><input type="button" class="btn" value="添加行" id="btnDialAddColumn" style="display:none;" onclick="jsRightMessage.AddGridColumn(\'DialTable\');"/>&nbsp;<input type="button" class="btn" value="保存" id="btnSaveColumn"  onclick="jsRightMessage.SaveGridColumn(\'WaitCallNum\');" style="display:none;"/><div id="waitContact" style="display:none;"><table id="waitContactTable"></table></div></td></tr><tr style="display:none;"><td>');
    arrString.push('<p>今日拨打号码</p><div style="display:none;"><input id="btnKuPreDay" type="button" class="button" onclick="jsRightMessage.KuPreDateOnClick()" value="前一天" />&nbsp;<input id="btnKuNextDay" type="button" value="后一天" class="button" onclick="jsRightMessage.KuNextDateOnClick()" /><input id="hidekuCurDate" type="hidden" /></div><table id="todayContact"></table></td></tr></table></div>');
    arrString.push('<div class="div-left-menu-header" style="cursor:pointer;display:none;" onclick="jsRightMessage.RightUIShow(\'MessagePalte\');">');
    arrString.push('<div class="div-left-menu-title-name" id="divMessage" >短信平台</div></div>');
    arrString.push('<div id="MessagePalte" class="quickChannel" style="width:100%;overflow-y:scroll;height:100%;position:relative;">');
    arrString.push('<table id="tbMessagePalte"  cellpadding="0" cellspacing="0"  border="0"  class="formtable" style="background-color:#ffffff; margin:0px;width:180px;">');
    arrString.push('<tr><td><span style="float:left;">号码</span><div style="float:right;" id="rdoContanier">');
    //    arrString.push('<label><input id="rdoText" name="raoMOrA" type="radio" value="text" checked="checked" onclick="jsRightMessage.MessageShow(\'raoMOrA\')"/><span>文本</span></label>');
    //    arrString.push('<label><input id="rdoList" name="raoMOrA" type="radio" value="grid" onclick="jsRightMessage.MessageShow(\'raoMOrA\')"/><span>列表</span></label>');
    arrString.push('</div><div style="clear:both;"></div></td></tr><tr><td>');
    arrString.push('<div id="divTelNo"><textarea id="txtTelNo"></textarea></div><input type="button" class="btn" value="添加行" style="display:none;" id="btnMessageAddColumn" onclick="jsRightMessage.AddGridColumn(\'messageTable\');"/>&nbsp;<input type="button" class="btn" value="保存" id="btnSaveColumn"  onclick="jsRightMessage.SaveGridColumn(\'MesCallNum\');" style="display:none;"/><div id="messageTable" style="display:none;"><table id="quickQueryTable"></table></div>');
    arrString.push('</td></tr><tr><td>内容</td></tr><tr><td><textarea id="txtMsnContent"></textarea></td></tr><tr><td>');
    arrString.push('<label><input id="chkSign" type="checkbox" /><span>附加落款</span></label></td></tr><tr><td><input id="txtSign" type="text" class="ipt" /></td></tr><tr><td>字数：<input id="btnSend" type="button" value="发送" class="btn"/></td></tr></table></div>');
    arrString.push(' <div class="div-left-menu-header" style="cursor:pointer;" onclick="jsRightMessage.RightUIShow(\'audioCondition\');"><div class="div-left-menu-title-name" id="divRecording">录音播放器</div></div>');
    arrString.push('<div id="audioCondition" class="quickChannel"  style="width:100%;overflow-y:none;height:100%;display:none;position:relative;"></div>');
    arrString.push(' <div class="div-left-menu-header" style="cursor:pointer;" ><div class="div-left-menu-title-name" id="divCallRemark">通话备注</div></div>');
    arrString.push('<div  style="width:100%;overflow-y:auto;height:95%;position:relative;">');
    arrString.push('<table id="tbCallRemark" cellpadding="2" cellspacing="2" style="background-color:#ffffff; margin:0px;width:100%">');
    arrString.push('<tr><td><textarea id="txtCallRemark" name="txtCallRemark" ></textarea></td></tr>');
    arrString.push('<tr><td align="right"><div id="divCallReRemark" style="display:none;line-height:22px;">请输入通话备注，挂机自动保存！</div><input id="btnSaveAudio" type="button" value="保存" class="button" onclick="jsRightMessage.SaveCallBillRemark()"/></td></tr>');
    arrString.push('</table>');
    arrString.push('</div>');
    arrString.push('</div>');
    document.getElementById("rightContainer").innerHTML = arrString.join("");
    App.SetNullHref(0);
    $("#txtMsnContent").ikeEditor({ width: 160, HiddentToolBar: true, height: menuHeight * 0.32, ValueMode: 'Text' });
    $("#txtTelNo").ikeEditor({ width: 160, HiddentToolBar: true, height: menuHeight * 0.35, ValueMode: 'Text' });
    $("#txtDialTelNo").ikeEditor({ width: 160, HiddentToolBar: true, height: menuHeight * 0.45, ValueMode: 'Text' });
    var Sys = {};
    var ua = navigator.userAgent.toLowerCase();
    if (window.ActiveXObject) {
        Sys.ie = ua.match(/msie ([\d.]+)/)[1]
    }
    if (Sys.ie == "6.0") {
        $("#txtCallRemark").ikeEditor({ width: 180, HiddentToolBar: true, height: menuHeight * 0.245, ValueMode: 'Text' });
    } else { 
        $("#txtCallRemark").ikeEditor({ width: 182, HiddentToolBar: true, height: menuHeight * 0.23, ValueMode: 'Text' });
    }
    App.SetNullHref(1);
    /*jsRightMessage.initMessageGrid(); 短信平台*/
    /*jsRightMessage.initDialGrid(); 拨号台*/
    /*jsRightMessage.initTodayContactGrid(); 今日通话号码表*/
    jsRightMessage.RightUIShow('DialCondition'); /*初始右边选项条高度*/
    setInterval("jsRightMessage.getWaitDialNumberCount()", 15 * 1000);
    /*设置挂机动作*/
    /*注册挂机动作，挂机时刷新列表*/
    jsTitle.regHoldOffAction("jsRightMessage.reviewDialButton()");
    /*注册摘机默认动作*/
    jsTitle.regHoldOnAction("jsRightMessage.changeOffOrUp()");

    /*今天拨打号码记录今日时间*/
    $("#hidekuCurDate").val(DBReader.ServerTime().ServerFormat("yyyy-MM-dd"));

    /*加载待通话号码*/
    setTimeout(' jsRightMessage.OnLoadWaitCallNumber("Call")', 500);
    //    setTimeout('jsRightMessage.OnLoadWaitCallNumber("Message")',550);   

    /*注册挂机前动作,将通话备注转移到JSTitle*/
    jsTitle.regBeforeHoldOffAction("jsRightMessage.SetTitleControlValue()");

    /*注册默认响铃动作，停止录音
    var ringActionString="jsIndexPage.freshItemPage('tab-callRecord','jsRightAudio.StopPlay(true)')";
    window.parent.execScript("jsTitle.regPhoneRingAction(\""+ringActionString+"\");");
    ringActionString=null; */
    /*获取话机类型名称，如果是：E8那么就隐藏拨号和挂机按钮，如果是E6或E7那么就是现实拨号和挂机按钮*/
    var PhoneTypeName = jsTitle.TelephoneTypeName;
    if (PhoneTypeName == "E8") {
        document.getElementById("btnDial").style.display = 'none';
        document.getElementById("btnHoldOff").style.display = 'none';
        //     document.getElementById("chkIsAutoDial").disabled=true;
        document.getElementById("chkIsAutoDial").checked = true;
        /*选择状态的时候要摘机执行指定动作*/
        jsRightMessage.setHoldOnDial(document.getElementById("chkIsAutoDial"));
    }
    else if (PhoneTypeName == "E6" || PhoneTypeName == "E7") {
        document.getElementById("btnDial").style.display = '';
        document.getElementById("btnHoldOff").style.display = '';
        //        document.getElementById("chkIsAutoDial").disabled=false;
    }
};
/*清空待拨号台*/
jsRightMessage.ClearWaitDialNumberList=function()
{
    try
    {
        $("#txtDialTelNo").value('');
    }
    catch(e)
    {
    
    }
    CollectGarbage();
};
/*来电信息弹出框*/
jsRightMessage.ShowCallRingNumberWin=function(_number){
   try
    {     
        var IsBlakNum=jsCommonLogic.selColumnData("count(*)","T_BlackList"," where CallNum='"+_number+"'");
        if(IsBlakNum>0)
        {
            jsTitle.HoldUp();
            setTimeout("jsRightMessage.HoldOff()",1000);
        }
    
          ShowWindow.ShowMessageDialog('Application/TeleSecretary/frmRingCallWin.htm?CallNum='+_number+'&formIndex='+ShowWindow.getFormIdx(),'来电信息',250,150,App.clientScreenSize().Width-250,App.clientScreenSize().Height-180);
    }
    catch(e)
    {
        alert("jsRightMessage.ShowCallRingNumberWin:"+e.message);
    }
    CollectGarbage();
};

/*挂机前将通话备注转移到JSTitle*/
jsRightMessage.SetTitleControlValue=function(){
    var strRemark=$("#txtCallRemark").value()==""?"":$("#txtCallRemark").value();
    if(strRemark!="")
    {
        jsTitle.GetCallRemark(escape(strRemark));
    }
    strRemark="";
    CollectGarbage();
};
/*挂机动作，挂机时刷新列表*/
jsRightMessage.OpenItemLoadAction=null;
jsRightMessage.RefreshGridListWhenCutLine=function(){
    /*更改按钮状态
    document.getElementById("btnDial").disabled=false;
    document.getElementById("btnHoldOff").disabled=true;  */
    $("#btnSaveAudio").show();
    $("#divCallReRemark").hide();
    jsRightMessage.DeleteWaitNumFromTable(jsTitle.CurrentNumber);/*删除待拨号码表中的记录*/
                     
    /*jsRightMessage.TodayContactTable.flexReload();刷新今日拨打号码列表*/
     if(jsIndexPage.listIndexNo=="tab-callRecord")
     {
        jsIndexPage.freshItemPage("tab-callRecord","jsTelBillCenterContent.CurrentColumnGrid.flexReload()");/*刷新通话记录列表*/  
     }  
     else if(jsIndexPage.listIndexNo=="tab-addressBook")
     {
        window.frames["tab_item_frame_tab-addressBook"].execScript("jsHistoryRecord.HistoryRecordSearchString('InComCall')");
        if(jsRightMessage.OpenItemLoadAction!=null){
            window.frames["tab_item_frame_tab-addressBook"].execScript(jsRightMessage.OpenItemLoadAction);
            jsRightMessage.OpenItemLoadAction=null;
        }
     }
};

jsRightMessage.RightUIShow = function(id) {
    var displayDom = $(".quickChannel");
    var i = displayDom.length - 1;
    if (jsRightMessage.RightHeight == null) {
        jsRightMessage.RightHeight = displayDom[0].parentNode.parentNode.parentNode.scrollHeight;
       /*jsRightMessage.RightHeight = displayDom[0].parentNode.clientHeight;*/
    }
    for (i; i > -1; i--) {
        displayDom[i].style.display = "none";
        if (displayDom[i].id == id) {
            displayDom[i].style.display = "";
            displayDom[i].style.height = jsRightMessage.RightHeight - displayDom.length *157;// 170;
        }
    }
};
/*短信里切换*/
jsRightMessage.MessageShow = function(name) {
    var ISMOrA = $("input[name='" + name + "'][checked]").val();
    if (name == "raoMOrA") {
        if (ISMOrA == "text") {
            $("#divTelNo").show();
            $("#btnMessageAddColumn").hide();
            $("#messageTable").hide();
            jsRightMessage.textareaLoadData("messageTable");
        }
        else {
            $("#divTelNo").hide();
            $("#btnMessageAddColumn").show();
            $("#messageTable").show();
            jsRightMessage.gridLoadData("messageTable");
        }
    } else if (name == "raoDial") {
        if (ISMOrA == "text") {
            $("#divDialTelNo").show();
            $("#btnDialAddColumn").hide();
            $("#waitContact").hide();
            jsRightMessage.textareaLoadData("DialTable");
        }
        else {
            $("#divDialTelNo").hide();
            $("#btnDialAddColumn").show();
            $("#waitContact").show();
            jsRightMessage.gridLoadData("DialTable");
        }
    }
}
/*添加行*/
jsRightMessage.AddGridColumn = function(tableName) {
    if (tableName == "messageTable") {
        jsRightMessage.messageTable.addRow(0);
    } else if (tableName == "DialTable") {
        jsRightMessage.DialTable.addRow(0);
    }
}
/*拨号台列表中删除按钮*/
jsRightMessage.delButtonForDial = function(value, pid, rows, rowIndex) {
    return '<div onclick="jsRightMessage.delMethod(\'' + pid + '\',\'DialTable\');" style="cursor:pointer;"><img src="../AppFrame/APICss/default/customer/icons/operation-cancel.gif" /></div>';
}
/*短信平台列表中删除按钮*/
jsRightMessage.delButtonForMessage = function(value, pid, rows, rowIndex) {
    return '<div onclick="jsRightMessage.delMethod(\'' + pid + '\',\'messageTable\');" style="cursor:pointer;"><img src="../AppFrame/APICss/default/customer/icons/operation-cancel.gif" /></div>';
}
/*号码*/
jsRightMessage.inputNOContorl = function(value, pid, rows, rowIndex) {
    return '<input type="text" size="15" style="width:120px;" onblur="jsRightMessage.validate(-3,this);"/>';
}
/*称呼*/
jsRightMessage.inputContorl = function(value, pid, rows, rowIndex) {
    return '<input type="text" size="15" style="width:120px;" onblur="jsRightMessage.validate(-200,this);"/>';
}
/*实现删除行*/
jsRightMessage.delMethod = function(pid, tableName) {
    var rowObj = null;
    if (tableName == "messageTable") {
        rowObj = jsRightMessage.messageTable.getRowByID(pid);
        jsRightMessage.messageTable.deleteRow(rowObj.rowIndex);
    } else if (tableName == "DialTable") {
        rowObj = jsRightMessage.DialTable.getRowByID(pid);
        jsRightMessage.DialTable.deleteRow(rowObj.rowIndex);
    }
    rowObj = null;
    CollectGarbage();
}
/*多行文本加载数据*/
jsRightMessage.textareaLoadData = function(tableName) {
    var gridSourceStr = "";
    if (tableName == "messageTable") {
        $("tr", jsRightMessage.messageTable).each(function() {
            var RowValue = jsRightMessage.messageTable.getRowByID(this.id);
            gridSourceStr += "<p>" + RowValue.cells[0].children[0].children[0].value + "|" + RowValue.cells[1].children[0].children[0].value + "</p>";
            //            var RowValue = jsRightMessage.messageTable.getRowData(this, 'string');
            //            var valueObj = eval("[" + RowValue + "]");
        });
        $("#txtTelNo").value(gridSourceStr);
    } else if (tableName == "DialTable") {
        $("tr", jsRightMessage.DialTable).each(function() {
            var RowValue = jsRightMessage.DialTable.getRowByID(this.id);
            gridSourceStr += "<p>" + RowValue.cells[0].children[0].children[0].value + "|" + RowValue.cells[1].children[0].children[0].value + "</p>";
//                       var RowValue = jsRightMessage.DialTable.getRowData(this, 'string');$(this).attr("")
//                        var valueObj = eval("[" + RowValue + "]");
        });
//        $("#txtDialTelNo").value(gridSourceStr);
        $("#txtDialTelNo").appendControl(gridSourceStr);
    }
    textareaObj = null;
    gridSourceStr = null;
    CollectGarbage();
}
/*grid加载数据*/
jsRightMessage.gridLoadData = function(tableName) {
    var gridSourceStr = "";
    if (tableName == "messageTable") {
        /*获取号码列表内容*/
        var editorbody = $("#txtTelNo").EditorBody();
        /*创建号码集合载体*/
        if (editorbody.innerHTML != "" && editorbody.getElementsByTagName("P").length == 0) {/*第一次在文本加入数据时判断*/
            editorbody.innerHTML = "<p>" + editorbody.innerHTML + "</p>";
        }
        if (editorbody.innerText == "") {
            editorbody.innerHTML = "";
        } 
        var NumberList = editorbody.getElementsByTagName("P");
        var i = NumberList.length - 1;
        var rowLength = jsRightMessage.messageTable[0].rows.length - 1;
        if (rowLength > -1 || i > -1) {
            for (; rowLength > -1; rowLength--) {
                jsRightMessage.messageTable.deleteRow(rowLength);
            }
            for (i; i > -1; i--) {
                var textaresaText = NumberList[i].innerText.split("|");
                var newRowObj = jsRightMessage.messageTable.addRow(0);
                newRowObj.children[0].children[0].children[0].value = $.trim(textaresaText[0]);
                if (textaresaText[1] != undefined) {
                    newRowObj.children[1].children[0].children[0].value = $.trim(textaresaText[1]);
                }
                newRowObj = null;
                textaresaText.length = 0;
                textaresaText = null;
            }
        }
        //        $("tr", jsRightMessage.messageTable).each(function() {
        //            var RowValue = jsRightMessage.messageTable.getRowByID(this.id);
        //            gridSourceStr += RowValue.cells[0].children[0].children[0].value.replace(/'\\'/g, "＼") + "|" + RowValue.cells[1].children[0].children[0].value.replace(/'\\'/g, "＼") + "\n";
        //        });
    } else if (tableName == "DialTable") {
        /*获取号码列表内容*/
        var editorbody = $("#txtDialTelNo").EditorBody();
        /*创建号码集合载体*/
        if (editorbody.innerHTML != "" && editorbody.getElementsByTagName("P").length == 0) {/*第一次在文本加入数据时判断*/
            editorbody.innerHTML = "<p>" + editorbody.innerHTML + "</p>";
        }
        if (editorbody.innerText == "") {
            editorbody.innerHTML = "";
        } 
        var NumberList = editorbody.getElementsByTagName("P");
        var i = NumberList.length - 1;
        var rowLength = jsRightMessage.DialTable[0].rows.length - 1;
        if (rowLength > -1 || i > -1) {
            for (; rowLength > -1; rowLength--) {
                //                var rowDel = jsRightMessage.DialTable.getRowByID(jsRightMessage.DialTable[0].rows[rowLength].id);
                jsRightMessage.DialTable.deleteRow(rowLength);
            }
            for (i; i > -1; i--) {
                var textaresaText = NumberList[i].innerText.split("|");
                var newRowObj = jsRightMessage.DialTable.addRow(0);
                //                var initValue = [{ 'Number': '<input type="text" size="15" style="width:120px;" value="' + textaresaText[0] + '" onblur="jsRightMessage.validate(3,this);"/>', 'Appellation': '<input type="text" size="15" style="width:120px;" value="' + textaresaText[1] + '" onblur="jsRightMessage.validate(200,this);"/>'}];
                newRowObj.children[0].children[0].children[0].value = $.trim(textaresaText[0]);
                if (textaresaText[1] != undefined) {
                    newRowObj.children[1].children[0].children[0].value = $.trim(textaresaText[1]);
                }
                newRowObj = null;
                textaresaText.length = 0;
                textaresaText = null;
            }
            i = null;
        }
        //        $("#txtDialTelNo").value(gridSourceStr);      
        //            gridSourceStr += RowValue.cells[0].children[0].children[0].value.replace(/'\\'/g, "＼") + "|" + RowValue.cells[1].children[0].children[0].value.replace(/'\\'/g, "＼") + "\n";
        //        });
    }
    textareaObj = null;
    gridSourceStr = null;
    CollectGarbage();
}

/*加载待通话号码*/
jsRightMessage.OnLoadWaitCallNumber=function(strType){
    var strSql="";
    if(strType=="Call")
    {
         strSql="SELECT Number,NickName FROM T_WAITCALLNUM WHERE Type=1"
    }
    else if(strType=="Message")
    {
        strSql="SELECT Number,NickName FROM T_WAITCALLNUM WHERE Type=2"
    }
    var obj=DBReader.selectSqlForJson(strSql);
     if(obj!=null)
     {         
        var result=eval("[{"+obj+"}]");    
        if(result[0].result=1 && result[0].table!=undefined)
        {
            var strInnerHtml="";
            for(var i=0;i<result[0].table.length;i++)
            {
                if(strType=="Call")
                {
                    document.getElementById("sapWaitDialNumberListTitle").innerHTML="["+result[0].table.length+"]";   
                }
                if(result[0].table[i].NickName!="")
                {
                   strInnerHtml+="<p>"+result[0].table[i].Number+"|"+result[0].table[i].NickName+"</p>"
                }
                else
                {
                    strInnerHtml+="<p>"+result[0].table[i].Number+"</p>"
                }
            }
            if(strType=="Call")
            {
                 $("#txtDialTelNo").appendControl(strInnerHtml);
            }
           else if(strType=="Message")
            {
                 $("#txtTelNo").appendControl(strInnerHtml);
            }
            strInnerHtml=null;
        }
        result=null;
     }
     obj=null;
     strSql="";
     CollectGarbage()
};

/*保存待通话号码*/
jsRightMessage.SaveGridColumn = function(strSaveType) { 
   var delStrSql="";
    if(strSaveType=="WaitCallNum"){
         delStrSql="DELETE * FROM T_WAITCALLNUM WHERE Type=1";
    }
    else if(strSaveType=="MesCallNum"){
        delStrSql="DELETE * FROM T_WAITCALLNUM WHERE Type=2";
    }
    DBReader.execSql(delStrSql);
    var editorbody="";
    if(strSaveType=="WaitCallNum"){
          /*获取号码列表内容*/
         editorbody=$("#txtDialTelNo").EditorBody();
    }
    else if(strSaveType=="MesCallNum"){
         editorbody=$("#txtTelNo").EditorBody();
    }         
     /*创建号码集合载体*/
     var NumberList=editorbody.getElementsByTagName("P");
      if(NumberList.length==0){
           if(strSaveType=="WaitCallNum"){
                 jsRightMessage.SaveWaitCallNum(editorbody.innerText,1);
            }
            else if(strSaveType=="MesCallNum"){
                 jsRightMessage.SaveWaitCallNum(editorbody.innerText,2);
            }
        }
        else{ 
            try{
                var entity=jsEntity.CreateEntityByTableName_access("T_TemporaryTable","","","","ID");   
                for(var i=0;i<NumberList.length;i++){
                    var number="";
                    var nickName="";
                    if(NumberList[i].innerText.indexOf("|")!=-1){
                        var arr=NumberList[i].innerText.split("|");
                        number=jsCommonLogic.stripscript(arr[0]);
                        nickName=arr[1];       
                    }
                    else{
                        number=jsCommonLogic.stripscript(NumberList[i].innerText);
                    }
                    if(number!=""){
                        var waitCallEntity=jsEntity.CreateEntityByTableName_access("T_WAITCALLNUM","","","","ID");   
                        if(waitCallEntity!=null ){
                            waitCallEntity.Fields.Number=number;
                            waitCallEntity.Fields.NickName=nickName;
                            if(strSaveType=="WaitCallNum"){
                                waitCallEntity.Fields.Type=1;
                            }
                            else if(strSaveType=="MesCallNum"){
                                waitCallEntity.Fields.Type=2;
                            }                               
                            waitCallEntity.Fields.UserID=jsTitle.UserID;
                            waitCallEntity.Fields.UserName=jsTitle.UserName;  
                          /*  var curId=jsCommonLogic.selColumnData("ID","T_WAITCALLNUM","WHERE Number='"+number+"'");
                            if(curId>0){         
                                waitCallEntity.Fields.ID=curId;
                                waitCallEntity.Fields.EditTime="@Time";   
                                entity.appendEntity(waitCallEntity,App.SqlAction.Update);
                            }
                            else {  */                    
                               waitCallEntity.Fields.CreateTime="@Time";   
                               entity.appendEntity(waitCallEntity,App.SqlAction.Insert);
                          /*  }*/            
                            number=null;
                            nickName=null;    
                            curId=null;        
                            DBReader.DisposeEntity(waitCallEntity);
                        }
                    }          
                }   
                entity.Fields.DataID=1;
                var result=jsCommonLogic.rcTemporary_Update(entity);
            }
            catch(e){
                alert("jsRightMessage.SaveWaitCallNum:"+e.message);
            }
            DBReader.DisposeEntity(entity);
            CollectGarbage();
        }
        NumberList=null;
        editorbody=null;
        CollectGarbage()
}
/*保存号码到数据库*/
jsRightMessage.SaveWaitCallNum=function(strRowCon,type){
    try{
        var number="";
        var nickName="";
        if(strRowCon.indexOf("|")!=-1)
        {
            var arr=strRowCon.split("|");
            number=jsCommonLogic.stripscript(arr[0]);
            nickName=arr[1];       
        }
        else
        {
            number=jsCommonLogic.stripscript(strRowCon);
        }
        if(number!="")
        {
            var entity=jsEntity.CreateEntityByTableName_access("T_WAITCALLNUM","","","","ID");   
            if(entity!=null )
            {
                entity.Fields.Number=number;
                entity.Fields.NickName=nickName;
                entity.Fields.Type=type;
                entity.Fields.UserID=jsTitle.UserID;
                entity.Fields.UserName=jsTitle.UserName;   
                entity.Fields.CreateTime="@Time";   
               /* var curId=jsCommonLogic.selColumnData("ID","T_WAITCALLNUM","WHERE Number='"+number+"'");
                if(curId>0){         
                    entity.Fields.ID=curId;
                    entity.Update(entity);  
                }
                else {*/
                     entity.Insert(entity);   
                /*}*/
                curId=null;       
                DBReader.DisposeEntity(entity);
            }
        }
    }
    catch(e){
        alert("jsRightMessage.SaveWaitCallNum:"+e.message);
    };
    number=null;
    nickName=null;   
    CollectGarbage();
};

/*提供为多行文本框赋值的接口*/
jsRightMessage.LoadInfoToTxtWaitCall=function(strInnerHTML){     
     $("#txtDialTelNo").appendControl(strInnerHTML);
};

/*提供获取多行文本框内容的接口*/
jsRightMessage.GetTxtWaitCallItem=function(){
     return  $("#txtDialTelNo").EditorBody();
};

/*删除待拨号码表中的记录*/
jsRightMessage.DeleteWaitNumFromTable=function(telNum){
    var txtSql="DELETE * FROM T_WAITCALLNUM WHERE Number='"+telNum+"'";       
    DBReader.execSql(txtSql);
    txtSql=null;
    CollectGarbage();
};

/*验证*/
jsRightMessage.validate = function(validate, obj) {
    if ($.trim(obj.value) != "") {
        var _reTimeReg = "";
        var _val = obj.value;
        var alertTxt = "";
        if (validate == 3 || validate == 20) {
            _reTimeReg = /^$|^[]{0,1}[0-9]{1,}$/;
            alertTxt = "错误的格式，请重新输入正整数格式如：1或27";
        } else if (validate == 5 || validate == 6 || validate == 131) {
            _reTimeReg = /^[1-9]d*.d*|0.d*[1-9]d*$/;
            alertTxt = "错误的格式，请重新输入小数格式如：1.14或27.95";
        } else if (validate == 200) {
        _reTimeReg = new RegExp(/([\'])|([\"])|([\#])|([\<])|([\>])|([\\])|([\?])$/);
            alertTxt = "错误的输入，不允许输入" + "( ' )," + '( " ),' + "( \\ )," + "( # )," + "( ? )" + "( < )," + "( > )," + "，请重新输入!";
        }
        if (_reTimeReg != "" && (_val != null || $.trim(_val) != "")) {
            if (validate == 3 || validate == 20 || validate == 5 || validate == 6 || validate == 131) {/*数字验证*/
                if ((!(_reTimeReg.test(_val))) || _val.indexOf("[") != -1 || _val.indexOf("]") != -1 || _val.indexOf("{") != -1 || _val.indexOf("}") != -1) {
                    alert(alertTxt);
                    obj.value = "";
                    obj.focus();
                }
            } else if (validate == 200 || validate == 129 || validate == 130 || validate == 203 || validate == 202 || validate == 201) {/*文本验证*/
                if ((_reTimeReg.test(_val)) || _val.indexOf("[") != -1 || _val.indexOf("]") != -1 || _val.indexOf("{") != -1 || _val.indexOf("}") != -1) {
                    alert(alertTxt);
                    obj.value = "";
                    obj.focus();
                }
            }
        }
        _reTimeReg = null;
        _val = null;
        alertTxt = null;
        validate = null;
    }
    obj = null
    CollectGarbage();
};
/*定时刷新获取待拨号台数量；15秒钟执行一次*/
jsRightMessage.getWaitDialNumberCount=function()
{
    try
    {
        var NumberCount=0;
        /*获取号码列表内容*/
        var editorbody=$("#txtDialTelNo").EditorBody();
        /*创建号码集合载体*/
        var NumberList=editorbody.getElementsByTagName("P");
        /*在集合中取出第一个号码作为拨打号码的对象*/
        if(NumberList.length==0)
        {
            if(editorbody.innerText!="" && $("#txtDialTelNo").value()!="")
            {
                NumberCount=1;
            }
            else
            {
                NumberCount=0;
            }
        }
        else
        {
            if($("#txtDialTelNo").value()!="")
            {
                NumberCount=NumberList.length;
            }
        }
        document.getElementById("sapWaitDialNumberListTitle").innerHTML="["+NumberCount+"]";       
        jsRightMessage.SaveGridColumn("WaitCallNum");/*保存待通话号码*/
//        jsRightMessage.SaveGridColumn("MesCallNum");/*保存待发短信号码*/
        editorbody=null;
        NumberList=null;
    }
    catch(e)
    {
        alert("jsRightMessage.getWaitDialNumberCount:"+e.message);
    }
    CollectGarbage();
};
/*获取即将拨打号码*/
jsRightMessage.getDialNumber=function()
{
    var dialNumber="";
    try
    {
        /*获取号码列表内容*/
        var editorbody=$("#txtDialTelNo").EditorBody();
        /*创建号码集合载体*/
        var NumberList=editorbody.getElementsByTagName("P");
        /*在集合中取出第一个号码作为拨打号码的对象*/
        if(NumberList.length==0)
        {
            if(editorbody.innerText.indexOf("|")!=-1)
            {
                 dialNumber=editorbody.innerText.split("|")[0];
            }
            else
            {
                dialNumber=editorbody.innerText;
            }
            editorbody.innerText="";
        }
        else
        {
            if(NumberList[0].innerText.indexOf("|")!=-1)
            {
                 dialNumber=NumberList[0].innerText.split("|")[0];
            }
            else
            {
                 dialNumber=NumberList[0].innerText;
            }
            editorbody.removeChild(NumberList[0]);            
        }
        NumberList=null;
        editorbody=null;
    }
    catch(e)
    {
        alert("jsRightMessage.getDialNumber:"+e.message);
    }
    CollectGarbage();
    return dialNumber;
}
/*正在通话标志*/
jsRightMessage.isPhoning=false;
/*手工拨号*/
jsRightMessage.PeopleDial=function()
{
    try
    {
        if(PhoneHelper.Telphone_IsConnection()){
        /*只有不是在拨打电话的状态下才能促发拨号事件*/
        if(jsRightMessage.isPhoning==false)
        {
            var dialNumber=jsRightMessage.getDialNumber();
            if(dialNumber!="")
            {
                jsRightMessage.isPhoning=true;
                jsTitle.Dial(dialNumber);
                jsRightMessage.changeOffOrUp();
            }
            dialNumber=null;
        }
        }else{
            alert("话机未连接！");
        }
    }
    catch(e)
    {
        alert("jsRightMessage.PeopleDial:"+e.message);
    }
    CollectGarbage();
};
/*切换提机状态*/
jsRightMessage.changeOffOrUp=function()
{
    try
    {
        /*提机的时候停止播放录音*/
        jsRightAudio.StopPlay(true);
        
        document.getElementById("btnDial").disabled=true;    
        document.getElementById("btnHoldOff").disabled=false;
        if(jsIndexPage.listIndexNo=="tab-callRecord")
        {
            if( window.frames["tab_item_frame_tab-callRecord"].jsTelBillCenterContent.CurBillListSelectedMainRow!=null)
            {
                jsIndexPage.freshItemPage("tab-callRecord","jsTelBillCenterContent.CallRecordSearchString()");/*刷新通话记录列表*/
            }
        }
        jsRightMessage.LoadRemarkWhenClickCallBillRow('');/*清空通话备注*/
        $("#btnSaveAudio").hide();/*隐藏保存备注按钮*/
        $("#divCallReRemark").show();
    }
    catch(e)
    {
        alert("jsRightMessage.changeOffOrUp:"+e.message);
    }
    CollectGarbage();
};
/*摘机自动拨号*/
jsRightMessage.AutoDial=function()
{
    try
    {
        if(PhoneHelper.Telphone_IsConnection()){
            /*提机的时候停止播放录音*/
            jsRightAudio.StopPlay(true);
            
            /*只有不是在拨打电话的状态下才能促发拨号事件*/
            if(jsRightMessage.isPhoning==false)
            {
                jsRightMessage.isPhoning=true;
                var dialNumber=jsRightMessage.getDialNumber();
                if(dialNumber!="")
                {
                    jsTitle.Dial(dialNumber,true);
                    jsRightMessage.changeOffOrUp();
                }
                dialNumber=null;
            }
        }else{
            alert("话机未连接！");
        }
    }
    catch(e)
    {
        alert("jsRightMessage.AutoDial:"+e.message);
    }
    CollectGarbage();
};
/*挂机*/
jsRightMessage.HoldOff=function()
{
    try
    { 
        if(PhoneHelper.Telphone_IsConnection()){
            jsTitle.CutLine();     
        }else{
            alert("话机未连接！");
        }        
    }
    catch(e)
    {
        alert("jsRightMessage.HoldOff:"+e.message);
    }
    CollectGarbage();
};
/*恢复手工拨号动作*/
jsRightMessage.reviewDialButton=function()
{
    try
    {
        jsRightMessage.isPhoning=false;
        document.getElementById("btnDial").disabled=false;
        document.getElementById("btnHoldOff").disabled=true;
        jsRightMessage.RefreshGridListWhenCutLine();/*刷新及删除待拨号码*/
    }
    catch(e)
    {
        alert("jsRightMessage.reviewDialButton:"+e.message);
    }
    CollectGarbage();
};
/*设置摘机动作*/
jsRightMessage.setHoldOnDial=function(clickObj)
{
    try
    {
        if(clickObj.checked==true)
        {
            /*选择状态的时候要摘机执行指定动作*/
            /*摘机后不能整段拨号，只能单个字符触发拨号*/
            jsTitle.regHoldOnAction("jsRightMessage.AutoDial();jsRightMessage.changeOffOrUp();");
        }
        else
        {
            /*不选择的时候要清除摘机指定动作*/
            jsTitle.regHoldOnAction("jsRightMessage.changeOffOrUp()");
            actionString=null;
        }
    }
    catch(e)
    {
    
    }
    CollectGarbage();
};


/*今日拨打号码列表：前一天*/
jsRightMessage.KuPreDateOnClick=function(){
    jsRightMessage.KuDayType="Pre";
    jsRightMessage.TodayContactTableSearchString();
};

/*今日拨打号码列表：后一天*/
jsRightMessage.KuNextDateOnClick=function(){
    jsRightMessage.KuDayType="Next";
    jsRightMessage.TodayContactTableSearchString();
};

/*点击通话列表行时加载备注*/
jsRightMessage.LoadRemarkWhenClickCallBillRow=function(strRemark){
        jsTitle.CurNewBILLID="";
        if(strRemark!="" && strRemark!=undefined)
        {
             $("#txtCallRemark").value(unescape(strRemark));
        }
        else
        {
             $("#txtCallRemark").value('');
        }
}
/*保存通话备注*/
jsRightMessage.SaveCallBillRemark=function(){
    var billID="";
     if(jsIndexPage.listIndexNo=="tab-callRecord")
     {
        if( window.frames["tab_item_frame_tab-callRecord"].jsTelBillCenterContent.CurBillListSelectedMainRow!=null && jsTitle.CurNewBILLID==0){
           billID=window.frames["tab_item_frame_tab-callRecord"].jsTelBillCenterContent.CurBillListSelectedMainRow.attr("BILLID");
        }else if(jsTitle.CurNewBILLID>0){
            billID=jsTitle.CurNewBILLID;
        }
    }
    else if(jsIndexPage.listIndexNo=="tab-addressBook")
    {
        if(window.frames["tab_item_frame_tab-addressBook"].jsCallMiddlePanel.listNo=="HistoryRecord" && window.frames["tab_item_frame_tab-addressBook"].jsHistoryRecord.CurHistoryListSelectedMainRow!=null && jsTitle.CurNewBILLID==0){
            billID=window.frames["tab_item_frame_tab-addressBook"].jsHistoryRecord.CurHistoryListSelectedMainRow.attr("BILLID")
        }else if(jsTitle.CurNewBILLID>0){
            billID=jsTitle.CurNewBILLID;
        }
    }
    else if(jsTitle.CurNewBILLID>0)
    {
        billID=jsTitle.CurNewBILLID;
    }
    if(billID>0)
    {
        var strRemark=$("#txtCallRemark").value()==""?"":$("#txtCallRemark").value();
        strRemark=sysKit.strToString(strRemark);
//        if(strRemark!="" && strRemark!=undefined)
//        {
             var entity=jsEntity.CreateEntityByTableName_access("T_CALLBILL","","","","BILLID");   
             entity.Fields.BILLID=billID;
             entity.Fields.REMARK=strRemark;
             var result = entity.Update(entity);
             if(result)
             {
                  if(jsIndexPage.listIndexNo=="tab-callRecord")
                   {
                        jsIndexPage.freshItemPage("tab-callRecord","jsTelBillCenterContent.CurrentColumnGrid.flexReload()");
                   }else if(jsIndexPage.listIndexNo=="tab-addressBook" && window.frames["tab_item_frame_tab-addressBook"].jsCallMiddlePanel.listNo=="HistoryRecord"){
                       window.frames["tab_item_frame_tab-addressBook"].jsHistoryRecord.HistoryCallGrid.flexReload();
                   }
             }
             else
             {
                alert("保存没有成功！");
             }
             strRemark="";
             DBReader.DisposeEntity(entity);
//        }
    }
    billID=null;
    CollectGarbage();
}
/*是否显示保存通话备注按钮*/
jsRightMessage.showRemarkSaveBtn=function(){
     if(jsIndexPage.listIndexNo=="tab-callRecord")
     {
        $("#btnSaveAudio").show();
     }
     else if(jsIndexPage.listIndexNo=="tab-addressBook")
     {
        $("#btnSaveAudio").hide();
     }
};