function jsCommunicationQueryCondition() { }
/*条件对象*/
jsCommunicationQueryCondition.queryObj=[{
_Type:'',
_BeginTime:'',
_EndTime:'',
_EmpName:'',
_Sex:'',
_Customer:'',
_Address:'',
_strQuickSearch:'',/*快速查询列表条件串*/
_AdvancedSearch:'',/*高级搜索*/
_curTelNum:''/*来电号码*/
}];
/*快速查询表*/
jsCommunicationQueryCondition.quickQueryTable = null;
/*已经创建内容串*/
jsCommunicationQueryCondition.createBandGroupString="";
/*分组树中当前选择的节点*/
jsCommunicationQueryCondition.curSelNode=null;
/*分组管理是否选择全部(checkbox)：true:1,flase:0*/
jsCommunicationQueryCondition.allTypeChk =null;
/*当前查询条件是属于哪一种*/
jsCommunicationQueryCondition.SearchWay="divFamiliar";

jsCommunicationQueryCondition.showContent = function(value) {
    jsCommunicationQueryCondition.SearchWay= value;
    var domItem=$(".h2TitleContent");
    for(var i=0;i<domItem.length;i++)
    {
        domItem[i].style.display="none";
    }
    
    var dom = document.getElementById(value);
    if (dom.style.display == "none") {
        dom.style.display = "";
    } 
//    else {
//        dom.style.display = "none";
//    }
    domItem.length=0;
    domItem=null;
    dom = null;
    CollectGarbage();
}
jsCommunicationQueryCondition.showPage = function() {
    jsCommunicationQueryCondition.inputDom();
    jsCommunicationQueryCondition.ShowGroup(document.getElementById("Group0"));
    document.getElementById("Group0_Item").style.height = document.body.clientHeight - 50;
    document.getElementById("divGroupTree").style.height = document.body.clientHeight - 80;
    document.getElementById("divGroupTree").parentNode.parentNode.parentNode.style.height = document.body.clientHeight - 50;
}
/*加载dom*/
jsCommunicationQueryCondition.inputDom = function() {
    var dom = document.getElementById("queryCondition");
    var groupHtml=new Array();
    groupHtml.push('<table style="width: 99%;" cellpadding="0" cellspacing="0">');
    /*组管理*/
    groupHtml.push('<tr class="Group" style=" height: 25px;background-color: #fff;background:url(\'../AppFrame/APICss/default/form/top-bottom.gif\');font-weight:bold;color:#15428b;">');
    groupHtml.push('<td id="Group0" class="title" style="height: 25px;">');
    groupHtml.push('分组管理');
    groupHtml.push('</td>');
    groupHtml.push('</tr>');
    groupHtml.push('<tr class="Group_CurrentItem" id="Group0_Item" style="height: 170px;background-color: #FFFFFF;">');
    groupHtml.push('<td valign="top">');
    groupHtml.push('</td>');
    groupHtml.push('</tr>');
    /*查询条件*/
    groupHtml.push('<tr class="Group" style=" height: 25px;background-color: #fff;cursor: hand;background:url(\'../AppFrame/APICss/default/form/top-bottom.gif\');font-weight:bold;color:#15428b;">');
    groupHtml.push('<td id="Group1" class="title" style="height: 25px;" onclick="jsCommunicationQueryCondition.ShowGroup();">');
    groupHtml.push('查询条件');
    groupHtml.push('<span id="spGroup1_Item" style="background:url(\'../AppFrame/APICss/default/form/down.png\');">　</span></td>');
    groupHtml.push('</tr>');
    groupHtml.push('<tr class="Group_Item" id="Group1_Item" style="height: 400px;background-color: #FFFFFF;">');
    groupHtml.push('<td valign="top">');
    groupHtml.push('</td>');
    groupHtml.push('</tr>');    
    groupHtml.push('</table>');
    dom.innerHTML = groupHtml.join("");
    groupHtml.length=0;
    groupHtml=null;
    CollectGarbage();
}

/*快速查询列表*/
jsCommunicationQueryCondition.initColumnGrid = function() {
    try 
    {
        var w = $("#queryCondition").width() - 20;
        var gh = 125;
        var tableGridOption =
        {
            height: gh,
            width: w,
            colModel:
            [
                {display: '查询信息', name: 'FieldName', width: (w * 0.5), sortable: false, align: 'left', process:jsCommunicationQueryCondition.FormatQuickSearchField,processType:'select' },
                { display: '值', name: 'Value', width: (w * 0.4), sortable: false, align: 'left' ,process:jsCommunicationQueryCondition.FormatValueContent,processType:'text'},
                { display: '删除', name: 'ID', width: (w * 0.12), sortable: true,process: jsCommunicationQueryCondition.delQuickSeaGridButton}
            ],
            usepager:false,
            rp:100000,        
            rowHeight:24,    
            customFunction: jsCommunicationQueryCondition.ShowQuickSearGridPage
        };
        jsCommunicationQueryCondition.quickQueryTable = $("#quickQueryTable").ikegrid(tableGridOption);
        tableGridOption = null;
    }
    catch (e) {
        alert(e.message);
    }
    CollectGarbage();
};
/*快速查询查询信息下拉框*/
jsCommunicationQueryCondition.FormatQuickSearchField=function(value,pid,rows){
    var tableNameList = [{ GroupName: "T_EMPLOYEE", GruopText: "个人资料", jsName: "jsPersonalInformation" }, { GroupName: "T_COMPANY", GruopText: "单位资料", jsName: "jsDepartmentInformation"}];
    var selectData = "<select  style='width:98%' id='selQuickSear_" + pid + "' >";
    if (tableNameList.length > 0) 
    {
        for (var j = 0; j < tableNameList.length; j++) 
        {
            if(App.FileIsExist(escape(App.ApplicationPath()+"Application\\TeleSecretary\\js\\"+tableNameList[j].jsName+".js")))   
            {
                var inputJs = document.createElement("script");
                var _head = document.getElementsByTagName("head");
                inputJs.src = "js/" + tableNameList[j].jsName + ".js";
                inputJs.type = "text/javascript";
                inputJs.id = tableNameList[j].jsName;
                _head[0].appendChild(inputJs);
                inputJs = null;
                _head = null;
 
            selectData += "<OPTGROUP LABEL='" + tableNameList[j].GruopText + "' style='background-color:#c8d9f6;'>";
            var arrayList = $.parseJSON(unescape(eval(tableNameList[j].jsName + ".dataJSON")));
            for (var i = 0; i < arrayList.length; i++) {
                for (var p = 0; p < arrayList[i].length; p++) {
                    if (arrayList[i][p].IsOrNotSel == "true") {
                        selectData += "<OPTION value='" + tableNameList[j].GroupName + "." + arrayList[i][p].Field + "'style='background-color:white;' content='" + arrayList[i][p].content + "'>" + arrayList[i][p].title + "</OPTION>";
                    }
                }
             }
            arrayList = null;
            selectData += "</OPTGROUP>";
         }
      }         
    }
    selectData += "</select>"
    tableNameList = null;
    selectDom = null;
    CollectGarbage();
    return selectData;
};
/*值输入框*/
jsCommunicationQueryCondition.FormatValueContent=function(value,pid,rows){
    return '<input id="txtValueContent_'+pid+'" class="inputList"  type="text" style="width:80px;"/>';
};
/*新增行*/
jsCommunicationQueryCondition.QuickSearchGridAddNewRow=function(){
        var newRowObj=jsCommunicationQueryCondition.quickQueryTable.addRow(0);
        var initValue = [{ 'FieldName': '', 'Value': ''}];
        jsCommunicationQueryCondition.quickQueryTable.setRowData(newRowObj,initValue);
        CollectGarbage();
};
/*删除行*/
jsCommunicationQueryCondition.delQuickSeaGridButton=function(value,pid,rows){
    return '<div onclick="jsCommunicationQueryCondition.delDetailInfoMethod(\''+pid+'\');" style="cursor:pointer;"><img src="../AppFrame/APICss/default/ico/user_delete.gif" />删除</div>';
}
/*删除行方法*/
jsCommunicationQueryCondition.delDetailInfoMethod = function(rowID) {
    var rowObj=jsCommunicationQueryCondition.quickQueryTable.getRowByID(rowID);
    jsCommunicationQueryCondition.quickQueryTable.deleteRow(rowObj.rowIndex);
}
/*数据*/
jsCommunicationQueryCondition.ShowQuickSearGridPage = function() {
    var result=$.parseJSON('[{"result" :"0","returnval" :"暂时没有结果"}]');
    return result[0];
};
/*菜单组类型*/
jsCommunicationQueryCondition.GroupType={
    Group:"Group",
    Group_CurrentItem:"Group_CurrentItem",
    Group_Item:"Group_Item",
    Group_Item_Content:"<table style='width:100%;height:100%;'><tr><td></td></tr></table>"
};
/*当前选择菜单组ID，默认是第一个*/
jsCommunicationQueryCondition.CurrentGroupID="Group0";
/*当前选择菜单组对象*/
jsCommunicationQueryCondition.SelectGroupObj=null;
/*刚才选择菜单组ID*/
jsCommunicationQueryCondition.OldSelectGroupID="";
/*加载菜单内容*/
jsCommunicationQueryCondition.ShowGroup = function(obj) {
    try {
        /*判断当前选中菜单组是否为空，如果为空那么默认为第一个菜单组*/
//        var obj = null;
        if (event != undefined && event.srcElement != undefined) {
            obj = event.srcElement;
            jsCommunicationQueryCondition.SelectGroupObj = obj;
        }
        else if (jsCommunicationQueryCondition.SelectGroupObj != null) {
            obj = jsCommunicationQueryCondition.SelectGroupObj;
        }
//        else {
//            obj = document.getElementById("Group1");//Group1
//            jsCommunicationQueryCondition.SelectGroupObj = obj;
//        }
        /*点击的对象是菜单组，则改变菜单高度和隐藏别的菜单组*/
        if (obj.parentElement.className == jsCommunicationQueryCondition.GroupType.Group) {
            jsCommunicationQueryCondition.CurrentGroupID = obj.id;
            //            if (jsCommunicationQueryCondition.OldSelectGroupID != jsCommunicationQueryCondition.CurrentGroupID) {
            jsCommunicationQueryCondition.OldSelectGroupID = jsCommunicationQueryCondition.CurrentGroupID;
            var AimObjID = obj.id + "_Item";
            var AimObj = document.getElementById(AimObjID);
            AimObj.className = jsCommunicationQueryCondition.GroupType.Group_CurrentItem;
            if (obj.id != "Group0") 
            {
                AimObj.style.height = 400;
                document.getElementById("Group0_Item").style.height = 170;
                if (event.srcElement != null) 
                {
                    document.getElementById("divGroupTree").style.height = 140;
                    document.getElementById("divGroupTree").parentNode.parentNode.parentNode.style.height = 170;
                }
                if (AimObj.style.display == "") 
                {
                    if (event.srcElement != null) 
                    {
                        AimObjID += "0";
                        document.getElementById("Group0_Item").style.height = document.body.clientHeight - 50;
                        document.getElementById("divGroupTree").style.height = document.body.clientHeight - 80;
                        document.getElementById("divGroupTree").parentNode.parentNode.parentNode.style.height = document.body.clientHeight - 50;
                    }
                }
            } 
            else 
            {
                AimObj.style.height = document.body.clientHeight - 50; //185;
            }
            AimObj.style.display = "";

            var arr = document.getElementById("queryCondition").getElementsByTagName("TR");

            for (i = 0; i < arr.length; i++) {
                if (document.getElementById("sp" + arr[i].id)) {
                    var spArr = document.getElementById("sp" + arr[i].id);
                    spArr.style.background = "url('../AppFrame/APICss/default/form/down.png')";
                    if (arr[i].id != AimObjID && arr[i].id != "Group0_Item" && 
                    (arr[i].className == jsCommunicationQueryCondition.GroupType.Group_CurrentItem || arr[i].className == jsCommunicationQueryCondition.GroupType.Group_Item)
                    ) {
                        var spArr = document.getElementById("sp" + arr[i].id);
                        arr[i].className = jsCommunicationQueryCondition.GroupType.Group_Item;
                        arr[i].style.height = "100%";
                        arr[i].style.display = "none";
                        arr[i].style.backGroundColor = "#FFFFFF";
                        spArr.style.background = "url('../AppFrame/APICss/default/form/right.png')";
                    }
                }
            }
            /*只有为加载过内容的菜单组才需要创建内容，如果已经加载的菜单组不做内容创建*/
            if (jsCommunicationQueryCondition.createBandGroupString.indexOf("[" + jsCommunicationQueryCondition.CurrentGroupID + "]") == -1) {
                jsCommunicationQueryCondition.createBandGroupString += "[" + jsCommunicationQueryCondition.CurrentGroupID + "]";
                jsCommunicationQueryCondition.BandGroupNode();
            }
            //            }
        }
    }
    catch (e) {
        alert("jsCommunicationQueryCondition.ShowGroup：" + e.message);
    }
};

/*绑定显示各个菜单组的内容*/
jsCommunicationQueryCondition.BandGroupNode=function()
{
   /* var ItemObjID=jsCommunicationQueryCondition.CurrentGroupID+"_Item";
    var ItemObj=document.getElementById(ItemObjID);
    var CotentContain=ItemObj.childNodes(0);*/
    var ItemObjID = "Group0_Item";
    var ItemObj=document.getElementById(ItemObjID);
    var CotentContain=ItemObj.childNodes(0);
    try
    {
        var contentDivHeight=(document.body.clientHeight-93);
       /* if(jsCommunicationQueryCondition.CurrentGroupID=="Group0")
        {*/
            /*分组管理*/
            var arrContent=new Array();
            /*arrContent.push('<div class="div-left-menu-content" style="height:'+(parseInt(contentDivHeight)+11)+';overflow:auto;">');*/
            arrContent.push('<div class="div-left-menu-content" style="height:170px;">');
            arrContent.push('<div id = "advancedQuick" style="line-height:25px;">');
             
            arrContent.push('<div id="divGroupOperate" class="div-left-menu-operation">');
            /*arrContent.push('<input id="chkIsAll"  title="查看全部" style="cursor: pointer;" type="checkbox" onclick="jsCommunicationQueryCondition.changChkAllType()" /><span>全部</span>');
            arrContent.push('<span id="hrAll" title="全部" style="cursor: pointer;" onclick="jsCommunicationQueryCondition.ShowAllAddrInformartion()">');
            arrContent.push('<img src="../AppFrame/APICss/default/images/icons/Item.Input.gif" alt="全部" />全部</span>');*/
                       
            arrContent.push('<span id="hrAdd" title="添加" style="cursor: pointer;" onclick="jsCommunicationQueryCondition.OpenGroupTypeWin()">');
            arrContent.push('<img src="../AppFrame/APICss/default/images/icons/Item.Add.gif" alt="添加" />添加</span>');
     
            arrContent.push('<span id="hfModify" title="修改" style="cursor:pointer" onclick="jsCommunicationQueryCondition.OpenGroupTypeWin(\'Edit\')">');
            arrContent.push('<img src="../AppFrame/APICss/default/images/icons/Item.Edit.gif" alt="修改" />修改</span>');
       
             arrContent.push('<span id="hrRemove" title="删除" style="cursor: pointer" onclick="jsCommunicationQueryCondition.DeleteCurrGroupType()">');
             arrContent.push('<img src="../AppFrame/APICss/default/images/icons/Item.Delete.gif" alt="删除" />删除</span></div>');


         /*arrContent.push('<div class="div-left-menu-operation" style="cursor: pointer;" onclick="jsCommunicationQueryCondition.ShowAllAddrInformartion()"><span id="hrAll" title="全部分组" >');
            arrContent.push('全部分组</span></div>');*/
             arrContent.push('<div style="display:none;"><input type="text" id="txtGroupSearchName" style="width:100px;" class="inputbox"/>&nbsp;<input type="button" class="button" value="查询" onclick="jsCommunicationQueryCondition.RelaodGroupTree()"/></div><div id="divGroupTree" style="height:140px;overflow:auto;"></div></div></div></div>');
            arrContent.push('<div id="divTypeTree" ></div>');
            arrContent.push('</div>');
            CotentContain.innerHTML=arrContent.join("");
            arrContent.length=0;
            arrContent=null;
            
            jsCommunicationQueryCondition.LoadGroupTree();/*加载分组树*/
        /*}
        else if(jsCommunicationQueryCondition.CurrentGroupID=="Group1")
        {*/
            ItemObjID = "Group1_Item";
            ItemObj = document.getElementById(ItemObjID);
            CotentContain = ItemObj.childNodes(0);
            /*查询条件*/
            var arrContent=new Array();
            arrContent.push('<div class="div-left-menu-content" style="height:'+(parseInt(contentDivHeight)+11)+';overflow:auto;position:relative;">');
            arrContent.push('<div id="div-left-menu-content" class="div-left-menu-content" style="line-height:25px;padding-left:10px;">');
           arrContent.push('<form id="frQuickSearch">');
            arrContent.push('<h2 style="margin-left:-9px;">快速查询 >></h2>');
            arrContent.push('<div id="quickQuery">');
            arrContent.push('<div id="div_QuickHide">姓名: <input id="txtSearchName" type="text" style="width:110px;" class="ipt"/><br />');
            arrContent.push('性别:<label><input type="radio" name="userSex" checked="checked" value="全部"/>全部</label><label><input type="radio" name="userSex"  value="男"/>男</label>&nbsp;<label><input type="radio" name="userSex" value="女"/>女</label><br /></div>');
            arrContent.push('单位: <input id="txtSearchCompany" type="text" style="width:110px;"/><br />地址: <input id="txtSearchAddress" type="text" style="width:110px;"/><br />');    
//            arrContent.push('<div id="div_QuickToolbar" class="toolBotton" style="width:149px;">');
//            arrContent.push('<a id="QuickGridAddRow" class="imgbtn" onclick="jsCommunicationQueryCondition.QuickSearchGridAddNewRow();" ><span class="Edit"  title="新增行">新增行</span></a> '  );                 
//            arrContent.push("</div>");
//            arrContent.push('<table id="quickQueryTable" ></table>');
       //<form>
            arrContent.push('</div>');
            arrContent.push('<div style="clear:left;"></div>');
            arrContent.push('<h2 style="margin-left:-9px;cursor:pointer;" onclick="jsCommunicationQueryCondition.showContent(\'divFamiliar\');" >熟悉度查询 >></h2>');
            arrContent.push('<div id="divFamiliar" style="float:left;" class="h2TitleContent">');
            arrContent.push('<ul id="Familiar" style="overflow:auto;width:150px;height:120px;position:relative;">');
             arrContent.push('<li><label><input type="radio" name="familiarTalkTime" value="0" onclick="jsCommunicationQueryCondition.ShowFamiliarFixedTime(this)" checked="checked"/>全部</label></li>');
            arrContent.push('<li><label><input type="radio" name="familiarTalkTime" value="1" onclick="jsCommunicationQueryCondition.ShowFamiliarFixedTime(this)"/>今日联系</label></li>');
            arrContent.push('<li><label><input type="radio" name="familiarTalkTime" value="2" onclick="jsCommunicationQueryCondition.ShowFamiliarFixedTime(this)"/>最近一周联系过</label></li>');
            arrContent.push('<li><label><input type="radio" name="familiarTalkTime" value="3" onclick="jsCommunicationQueryCondition.ShowFamiliarFixedTime(this)"/>最近一个月联系过</label></li>');
            arrContent.push('<li><label><input type="radio" name="familiarTalkTime" value="4" onclick="jsCommunicationQueryCondition.ShowFamiliarFixedTime(this)"/>最近三个月联系过</label></li>');
            arrContent.push('<li><label><input type="radio" name="familiarTalkTime" value="5" onclick="jsCommunicationQueryCondition.ShowFamiliarFixedTime(this)"/>最近一年联系过</label></li>');
            arrContent.push('<li><label><input type="radio" name="familiarTalkTime" value="6" onclick="jsCommunicationQueryCondition.ShowFamiliarFixedTime(this)"/>指定时间</label><div id="divFamiliarFixedTime" style="display:none;">从<input name="txt_FamiliarBeginTime" type="text" maxlength="30" id="txt_FamiliarBeginTime" readonly="readonly"/>到<input name="txt_FamiliarEndTime" type="text" maxlength="30" id="txt_FamiliarEndTime" readonly="readonly"/></div></li></ul>');
            arrContent.push('</div>');
            arrContent.push('<div style="clear:left;"></div>');
            arrContent.push('<h2 style="margin-left:-9px;cursor:pointer;" onclick="jsCommunicationQueryCondition.showContent(\'divStrange\');" >陌生度查询 >></h2>');
            arrContent.push('<div id="divStrange" style="float:left;list-style:none;display:none" class="h2TitleContent">');
            arrContent.push('<ul id="strange" style="overflow:auto;width:150px;height:120px;position:relative;">');
            arrContent.push('<li><label><input type="radio" name="strangeTalkTime" value="0" onclick="jsCommunicationQueryCondition.ShowStrangeFixedTime(this)"/>全部</label></li>');
            arrContent.push('<li><label><input type="radio" name="strangeTalkTime" value="2" onclick="jsCommunicationQueryCondition.ShowStrangeFixedTime(this)"/>最近一周没联系</label></li>');
            arrContent.push('<li><label><input type="radio" name="strangeTalkTime"  value="3" onclick="jsCommunicationQueryCondition.ShowStrangeFixedTime(this)"/>最近一个月没联系</label></li>');
            arrContent.push('<li><label><input type="radio" name="strangeTalkTime"  value="4" onclick="jsCommunicationQueryCondition.ShowStrangeFixedTime(this)"/>最近三个月没联系</label></li>');
            arrContent.push('<li><label><input type="radio" name="strangeTalkTime" value="5" onclick="jsCommunicationQueryCondition.ShowStrangeFixedTime(this)"/>最近一年没联系</label></li>');
            arrContent.push('<li><label><input type="radio" name="strangeTalkTime" value="6" onclick="jsCommunicationQueryCondition.ShowStrangeFixedTime(this)"/>指定时间</label><div id="divStrangeFixedTime" style="display:none;">从<input name="txt_StrangeBeginTime" type="text" maxlength="30" id="txt_StrangeBeginTime" readonly="readonly"/>到<input name="txt_StrangeEndTime" type="text" maxlength="30" id="txt_StrangeEndTime" readonly="readonly"/></div></li></ul>');
             arrContent.push('</div>');
            arrContent.push('<div style="clear:left;"></div>');
            arrContent.push('<h2 style="margin-left:-9px;cursor:pointer;"  onclick="jsCommunicationQueryCondition.AdvancedQuery();">高级搜索 >><span style="font-weight:normal;font-size:13px;color:#000;" id="divAdvanceSearch" style="display:none;">查询结果：<span id="fontAdvanceCount">0</span></span></h2>');
//            arrContent.push('<div id="divAdvanceSearch" style="display:none;">高级查询结果：<span id="fontAdvanceCount">0</span></div>');
            arrContent.push('</form>');
            arrContent.push('<div id="divDetailSearch" class="h2TitleContent"></div>');
            arrContent.push('<div><input type="button" class="button" value="查询" onclick = "jsCommunicationQueryCondition.searchStringWay()"/>&nbsp;<input type="button" class="button" value="清空条件" onclick = "jsCommunicationQueryCondition.ClearQuickSearch()"/></div>');
            arrContent.push('</div>');
            CotentContain.innerHTML=arrContent.join("");
            arrContent.length=0;
            arrContent=null;
            showTime("txt_FamiliarBeginTime", "txt_FamiliarEndTime", false, 80);
            showTime("txt_StrangeBeginTime", "txt_StrangeEndTime", false, 80);
//            jsCommunicationQueryCondition.initColumnGrid();
            /*当前是公司模式快速查询则隐藏性别和姓名*/
            jsCommunicationQueryCondition.HideQuickSearchDiv(jsCallBookList.GetCurComOrEmpModel());
        /*}*/
        contentDivHeight=null;
    }
    catch(e)
    {
        alert("jsCommunicationQueryCondition.BandGroupNode："+e.message);
    }
    ItemObjID=null;
    ItemObj=null;
    CotentContain=null;
    CollectGarbage();
};

/*查询条件——查询*/
jsCommunicationQueryCondition.searchStringWay = function() {
    var strSearchType = "quick";
    if (jsCommunicationQueryCondition.SearchWay == "divFamiliar") {
        strSearchType = "familiar";
    }
    if (jsCommunicationQueryCondition.SearchWay == "divStrange") {
        strSearchType = "strange";
    }
    jsCommunicationQueryCondition.LeftSearchBtnClick(strSearchType);
    //strSearchType=null;
    CollectGarbage();
};
/*加载分组树*/
jsCommunicationQueryCondition.LoadGroupTree=function(strWhere){
    try
        {
            var strSql="select -1 as DataIndex,-1 as ID,'无分组' as Name,0 as ParentID,0 as EndFlag from  T_GROUPDEF";
            strSql+=" union ";
            strSql+="select -2 as DataIndex,-2 as ID,'全部分组' as Name,0 as ParentID,0 as EndFlag from  T_GROUPDEF";
            strSql+=" union ";
            strSql+="select 0 as DataIndex,ID,GROUPNAME as Name,PID as ParentID,0 as EndFlag from T_GROUPDEF where 1=1 ";
            if(strWhere!="" && strWhere!=undefined)
            {
                strSql+=strWhere;
            }
            strSql+=" ORDER BY DataIndex,Name ";
            var treeString=GetTree(strSql,"T_GROUPDEF","0");
            var menudata= $.parseJSON(treeString);             
            var op = { data: menudata, onnodeclick:jsCommunicationQueryCondition.ClickGroupTreeNode,foldtheme: "yellow", theme: "bbit-tree-no-lines" ,spacepic:"../AppFrame/APICss/Shared/images/s.gif"};
            $("#divGroupTree").treeview(op);
            
            treeString=null;
            menudata=null;
            CollectGarbage();
         }
         catch(e)
         {
            alert(e.message);
         }     
}
/*根据名称重新搜索分组树*/
jsCommunicationQueryCondition.RelaodGroupTree=function(){
        var strName=$.trim($("#txtGroupSearchName").val()).split('\"').join('“');strName=strName.split('\'').join('‘');
        if(strName!="")
        {
            var strWhere=" and GROUPNAME like '*"+strName+"*'";
            jsCommunicationQueryCondition.LoadGroupTree(strWhere);
            strWhere="";
        }
        else
        {
            jsCommunicationQueryCondition.LoadGroupTree();
        }
        strName="";
        CollectGarbage();
};

/*单击分组节点时执行的操作*/
jsCommunicationQueryCondition.ClickGroupTreeNode=function(item){
    if(item.id==-1 || item.id==-2){
        //$("#hrAdd").hide();
        $("#hfModify").hide();
        $("#hrRemove").hide();    
    }else{
       //$("#hrAdd").show();
        $("#hfModify").show();
        $("#hrRemove").show();  
    }
    if(item.id==-2){
        jsCommunicationQueryCondition.curSelNode=null;
    }else{
        jsCommunicationQueryCondition.curSelNode=item;        
    }
    jsCommunicationQueryCondition.LeftSearchBtnClick();/*刷新通讯簿主列表*/
};

/*分组管理：选择全部*/
jsCommunicationQueryCondition.changChkAllType=function(){
    /*$("#chkIsAll").attr("checked")==true?$("#chkIsAll").attr("checked",false):$("#chkIsAll").attr("checked",true);*/
     var checked = $("#chkIsAll").attr("checked");
      jsCommunicationQueryCondition.allTypeChk = (checked == true ? 1 : 0);   
      jsBookListModle.BookListSearchString();/*刷新通讯簿主列表*/
};

/*显示全部，去掉分组查询 */
jsCommunicationQueryCondition.ShowAllAddrInformartion=function(){
    jsCommunicationQueryCondition.curSelNode=null;
    jsCommunicationQueryCondition.LoadGroupTree();
    jsCommunicationQueryCondition.LeftSearchBtnClick();/*刷新通讯簿主列表*/
};

/*添加或修改分组弹出框*/
jsCommunicationQueryCondition.OpenGroupTypeWin = function(isEdit) {
    try {
        var FormIndex = ShowWindow.getFormIdx();
        if (isEdit != "" && isEdit != undefined) {
            if (jsCommunicationQueryCondition.curSelNode != null) {
                ShowWindow.ShowMoledDialog("Application/TeleSecretary/frmCommunication/frmGroupTypeDetail.htm?FormIndex=" + FormIndex + "&LoadAction=jsCommunicationQueryCondition.LoadGroupTree()&PageState=Edit&TypeID=" + jsCommunicationQueryCondition.curSelNode.id + "", "修改分组", 360, 132);
            }
            else {
                alert("请选择要修改的分组！");
            }
        }
        else {
            var pageUrl = "Application/TeleSecretary/frmCommunication/frmGroupTypeDetail.htm?FormIndex=" + FormIndex + "&LoadAction=jsCommunicationQueryCondition.LoadGroupTree()&PageState=Add";
            if (jsCommunicationQueryCondition.curSelNode != null) {
               if(jsCommunicationQueryCondition.curSelNode.id>0){ 
                   pageUrl = pageUrl + "&TypeID=" + jsCommunicationQueryCondition.curSelNode.id + "&TypeName=" + jsCommunicationQueryCondition.curSelNode.text;
                }
            }
            ShowWindow.ShowMoledDialog(pageUrl, "添加分组", 360, 132);
        }
        FormIndex = null;
        CollectGarbage();
    }
    catch (e) {
        alert(e.message);
    }
};

/*删除分类及相关明细*/
jsCommunicationQueryCondition.DeleteData=function(currTypeID){
         var txtSql="DELETE * FROM T_GROUPDEF WHERE ID="+currTypeID+"";
         DBReader.execSql(txtSql);
         txtSql = null;
         return true;
};

/*删除分组*/
jsCommunicationQueryCondition.DeleteCurrGroupType=function(){
     if(jsCommunicationQueryCondition.curSelNode!=null)
      {
            if(confirm("您确定要删除吗！"))
            {
                   var  currSelTypeID=jsCommunicationQueryCondition.curSelNode.id;
                   if(jsCommonLogic.selColumnData("count(*)","T_GROUPDEF","where PID="+ currSelTypeID)==0)
                   {/*是否有子集*/
                        if(jsCommonLogic.selColumnData("count(*)","T_COMPANY","where GROUP_ID="+currSelTypeID)==0 && jsCommonLogic.selColumnData("count(*)","T_EMPLOYEE","where GROUP_ID="+currSelTypeID)==0)
                        {
                                /*是否被使用*/
                                var result= jsCommunicationQueryCondition.DeleteData(currSelTypeID);
                                if(result)
                                {
                                        alert("删除成功！");
                                        jsCommunicationQueryCondition.curSelNode=null;
                                        jsCommunicationQueryCondition.LoadGroupTree("");
                                }
                                else
                                {
                                        alert("删除失败！");
                                }
                                result=null;
                                CollectGarbage();
                        }
                        else
                        {
                            alert("该分组已被使用，不能删除！");
                        }
                  }
                  else
                  {
                         alert("该分组有子集，不能删除！");
                  }
             }
      }
      else
      {
             alert(" 请选择要删除的项！");
      }  
};

/*查询条件*/
jsCommunicationQueryCondition.GetQueryPara=function(strType){
    try
    {
            var htxt_BeginTime="";
            var htxt_EndTime="";
//            
//            if(strType=="quick")        
//            {
                jsCommunicationQueryCondition.queryObj[0]._EmpName=$.trim($("#txtSearchName").val()).split('\"').join('“').split('\'').join('‘');
                var strSex=$("input[name='userSex'][checked]").val();
                if(strSex=="全部")
                {
                     jsCommunicationQueryCondition.queryObj[0]._Sex='';
                }
                else
                {
                    jsCommunicationQueryCondition.queryObj[0]._Sex=strSex;
                }
                strSex=null;
                jsCommunicationQueryCondition.queryObj[0]._Customer=$.trim($("#txtSearchCompany").val()).split('\"').join('“').split('\'').join('‘');
                jsCommunicationQueryCondition.queryObj[0]._Address=$.trim($("#txtSearchAddress").val()).split('\"').join('“').split('\'').join('‘');
          
                /*快速查询列表条件串*/
                if(jsCommunicationQueryCondition.quickQueryTable!=null)
                {
                    var searhStore=jsCommunicationQueryCondition.quickQueryTable.getRowData();
                    jsCommunicationQueryCondition.queryObj[0]._strQuickSearch='';
                    if(searhStore.length>0)
                    {
                        for(var i=0;i<searhStore.length;i++)
                        {
                            var strField=searhStore[i].FieldName;
                            var strValue=unescape(searhStore[i].Value);
                            if(strField!="" && strValue!="")
                            {
                                jsCommunicationQueryCondition.queryObj[0]._strQuickSearch+=" and "+strField+"='"+strValue+"'";
                            }
                            strField=null;
                            strValue=null;   
                         }
                    }
                }
//             }
            
            var curToday=DBReader.ServerTime().ServerFormat("yyyy-MM-dd");
            var selTime=0;
            if(strType=="familiar")
            { 
                 selTime=$("input[name='familiarTalkTime'][checked]").val();
            }
            else if(strType=="strange")
            {
                 selTime=$("input[name='strangeTalkTime'][checked]").val();
            }
            switch(selTime)
            {
                case "1":
                {  /*今日联系*/             
                    htxt_BeginTime="#"+ curToday+" 00:00:00"+"#";
                    htxt_EndTime="#"+curToday+" 23:59:59"+"#";
                }
                break;
                case "2":
                {/*最近一周*/
                    htxt_EndTime="#"+curToday+" 23:59:59"+"#";
                    htxt_BeginTime="#"+jsCommonLogic.TimeFormatSpace(curToday,'day',7,'minus')+" 23:59:59"+"#";
                }
                break;
                case "3":
                {/*最近一个月*/
                    htxt_EndTime="#"+curToday+" 23:59:59"+"#";
                    htxt_BeginTime="#"+jsCommonLogic.TimeFormatSpace(curToday,'month',1,'minus')+" 00:00:00"+"#";
                }
                break;
                case "4":
                {/*最近三个月*/
                    htxt_EndTime="#"+curToday+" 23:59:59"+"#";
                    htxt_BeginTime="#"+jsCommonLogic.TimeFormatSpace(curToday,'month',3,'minus')+" 00:00:00"+"#";
                }
                break;
                case "5":
                {/*最近一年*/
                    htxt_EndTime="#"+curToday+" 23:59:59"+"#";
                    htxt_BeginTime="#"+jsCommonLogic.TimeFormatSpace(curToday,'year',1,'minus')+" 00:00:00"+"#";
                }
                break;
                case "6":
                {/*指定时间*/  
                    if(strType=="familiar")
                    { 
                        if($("#txt_FamiliarBeginTime").val()!=""){
                            htxt_BeginTime="#"+$("#txt_FamiliarBeginTime").val()+" 00:00:00"+"#";
                        }
                        if($("#txt_FamiliarEndTime").val()!=""){
                            htxt_EndTime="#"+$("#txt_FamiliarEndTime").val()+" 23:59:59"+"#";
                        }
                    }
                    else if(strType=="strange")
                    {
                        if($("#txt_StrangeBeginTime").val()!=""){
                            htxt_BeginTime="#"+$("#txt_StrangeBeginTime").val()+" 00:00:00"+"#";                            
                        }
                        if($("#txt_StrangeEndTime").val()!=""){
                            htxt_EndTime="#"+$("#txt_StrangeEndTime").val()+" 23:59:59"+"#";
                        }
                    }
                }
             break;
             default:break;
         }
    }
    catch(e)
    {
        alert("jsTelBillQueryCondition.queryString:"+e.message);
    }
    jsCommunicationQueryCondition.queryObj[0]._BeginTime=htxt_BeginTime;
    jsCommunicationQueryCondition.queryObj[0]._EndTime=htxt_EndTime;
    curToday=null;
    selTime=null;
    htxt_BeginTime=null;
    htxt_EndTime=null;
    searhStore=null;
    CollectGarbage();
};
/*熟悉度查询*/
jsCommunicationQueryCondition.ShowFamiliarFixedTime=function(obj){
    if($(obj).val()==6)
    {
        $("#divFamiliarFixedTime").show();
    }
    else
    {
        $("#divFamiliarFixedTime").hide(); 
        if($(obj).val()==0)
        {
            jsCommunicationQueryCondition.LeftSearchBtnClick();
        }
        else
        {
            jsCommunicationQueryCondition.LeftSearchBtnClick("familiar");
        }
    }   
};
/*陌生度查询*/
jsCommunicationQueryCondition.ShowStrangeFixedTime=function(obj){
    if($(obj).val()==6)
    {
        $("#divStrangeFixedTime").show();
    }
    else
    {
        $("#divStrangeFixedTime").hide();
        if($(obj).val()==0)
        { 
             jsCommunicationQueryCondition.LeftSearchBtnClick();
        }
         else
        {
            jsCommunicationQueryCondition.LeftSearchBtnClick("strange");
        } 
    }
};
/*高级搜索*/
jsCommunicationQueryCondition.AdvancedQuery = function() {
   // jsCommunicationQueryCondition.SearchWay="HighSearch";
    var getIndexForm = ShowWindow.getFormIdx();
    ShowWindow.OpenItemForm("Application/TeleSecretary/ConditionSetting/frmConditionSetting.htm?formIdx=" + getIndexForm + "&action=jsIndexPage.freshItemPage('tab-addressBook','jsCommunicationQueryCondition.QueryOperating(\"@str\")')", "高级查询", 1000, 560, 0);/*width:1000,height:700*/
}

/*高级搜索返回查询操作*/
jsCommunicationQueryCondition.QueryOperating = function(dataStr) {
    jsCommunicationQueryCondition.queryObj[0]._AdvancedSearch=unescape(dataStr);
    //jsCommunicationQueryCondition.LeftSearchBtnClick("advanced");
    jsCommunicationQueryCondition.curSelNode=null;
    jsCommunicationQueryCondition.searchStringWay();
    
    /*显示高级查询结果数*/
    document.getElementById("divAdvanceSearch").style.display="";
    if(jsCallBookList.GetCurComOrEmpModel()=="Com"){
         document.getElementById("fontAdvanceCount").innerHTML=jsAdrBookForCompany.CurComGridAllCount;
    }else if(jsCallBookList.GetCurComOrEmpModel()=="Emp"){
         document.getElementById("fontAdvanceCount").innerHTML=jsBookListModle.CurEmpGridAllCount;
    }     
}

/*执行联系人模式OR公司模式的列表查询*/
jsCommunicationQueryCondition.LeftSearchBtnClick=function(searchType){
        var curModel=jsCallBookList.GetCurComOrEmpModel();
        if(curModel=="Emp")
        {
            jsCallBookList.IsListOrCardModle('Card');
            jsBookListModle.BookListSearchString(searchType);
        }
        else if(curModel=="Com")
        {    
            if(searchType=="InComCall"){
                 jsAdrBookForCompany.EmployeeGridSearchString("",searchType);
            }
            else{
                jsAdrBookForCompany.CompanyListSearchString("",searchType);
            }
        }
//        switch (jsCallMiddlePanel.listNo) {
//            case "HistoryRecord":
//                jsHistoryRecord.HistoryRecordSearchString();
//                break;
//            case "OtherInfo":
//                jsOtherInfo.OtherInfoSearchString();
//                break;
//            default:
//                break;
//        }
        /*其它资料——新增行*/
        document.getElementById("imgAddOtherInfoRow").style.display="none";
}

jsCommunicationQueryCondition.HideQuickSearchDiv=function(strType){    
    if(strType=="Com"){
        $("#div_QuickHide").hide();
    }
    else if(strType=="Emp"){
        $("#div_QuickHide").show();
    } 
};

/*清空快速查询*/
jsCommunicationQueryCondition.ClearQuickSearch=function(){
    $("#frQuickSearch").resetForm();
    var chkItem = document.getElementsByName("userSex");
    chkItem[0].checked=true;  
     
    var radName=""; 
    var divName="";
    if(jsCommunicationQueryCondition.SearchWay=="divFamiliar" ){
        radName="familiarTalkTime";
        divName="divFamiliarFixedTime";
    }
    if(jsCommunicationQueryCondition.SearchWay=="divStrange" ){
        radName="strangeTalkTime";
        divName="divStrangeFixedTime";
    }    
    if(radName!=""){
        var radItem = document.getElementsByName(radName);
        radItem[0].checked=true;  
        $("#"+divName).hide(); 
        radItem=null; 
    }    
    jsCommunicationQueryCondition.queryObj[0]._AdvancedSearch=null;/*清空高级查询*/
    jsCommunicationQueryCondition.LoadGroupTree();
    document.getElementById("divAdvanceSearch").style.display="none";/*去掉高级查询结果*/
    
    var curModel=jsCallBookList.GetCurComOrEmpModel();   
    if(curModel=="Emp")
    {
        jsCallBookList.IsListOrCardModle('Card');
        jsBookListModle.BookListSearchString();
    }
    else if(curModel=="Com")
    {    
        if(jsCommunicationQueryCondition.queryObj[0]._Type=="InComCall"){
             jsAdrBookForCompany.EmployeeGridSearchString("","");
        }
        else{
            jsAdrBookForCompany.CompanyListSearchString("","");
        }
    }
   // jsCommunicationQueryCondition.SearchWay=null;
    chkItem=null;
    radName=null;
    divName=null;
    CollectGarbage();
};