var srvID = "";
var userID = "";
var aryau = "";
jQuery(function ($) {
    $('[data-rel=tooltip]').tooltip();
    $('[data-rel=popover]').popover({ html: true });
});
function ClickEvent() {
    $('[data-rel=tooltip]').tooltip();
    $('[data-rel=popover]').popover({ html: true });
}
function LoadData() {

    var l = layer.load('正在加载数据......');
    LoadCaution();
    $.ajax({
        url: "Handlers/CustomerInformation/PublicManagement/PublicMg.aspx?Method=count&srvid=" + srvID + "&userid=" + userID + "",
        type: "get",
        cache: false,
        dataType: "json",
        success: function (data) {
            $("#spkh").text(data);
            resize_r();
        },
        error: function () {
            layer.msg('网络请求错误！', 2, 5);
        }
    });
    $.ajax({
        url: "Handlers/SalesManagement/sellChance/sellChance.aspx?Method=count&srvid=" + srvID + "&userid=" + userID + "",
        type: "get",
        cache: false,
        dataType: "json",
        success: function (data) {
            $("#spjh").text(data);
            resize_r();
        },
        error: function () {
            layer.msg('网络请求错误！', 2, 5);
        }
    });
    $.ajax({
        url: "Handlers/Order/Order.aspx?Method=count&srvid=" + srvID + "&userid=" + userID + "",
        type: "get",
        cache: false,
        dataType: "json",
        success: function (data) {
            $("#spht").text(data);
            resize_r();
        },
        error: function () {
            layer.msg('网络请求错误！', 2, 5);
        }
    });
    $.ajax({
        url: "Handlers/Order/Order.aspx?Method=loadAllOrder&srvid=" + srvID + "&page=1&rows=5&one=select&user=" + userID,
        type: "get",
        cache: false,
        dataType: "json",
        success: function (data) {
            if (data.rows.length > 0) {
                HtTb(data);
            }
            resize_r();
        },
        error: function () {
            layer.msg('网络请求错误！', 2, 5);
        }
    });
    $.ajax({
        url: "/Handlers/CustomerInformation/CustomerManagement/CustomerManagement.aspx?Method=LoadAll&srvid=" + srvID + "&userid=" + userID + "&page=1&rows=5",
        type: "get",
        cache: false,
        dataType: "json",
        success: function (data) {
            if (data.rows.length > 0) {
                KhTb(data);
            } 
            resize_r();
        },
        error: function () {
            layer.msg('网络请求错误！', 2, 5);
        }
    });
    $.ajax({
        url: "Handlers/SalesManagement/sellChance/sellChance.aspx?Method=loaddata&srvid=" + srvID + "&page=1&rows=5",
        type: "get",
        cache: false,
        dataType: "json",
        success: function (data) {
            if (data.rows.length > 0) {
                JhTb(data);
            } 
            resize_r();
        },
        error: function () {
            layer.msg('网络请求错误！', 2, 5);
        }
    });
    $.ajax({
        url: "Handlers/system/GongGao.aspx?Method=LoadNews&srvid=" + srvID + "&userid=" + userID + "&page=1&rows=5",
        type: "get",
        cache: false,
        dataType: "json",
        success: function (data) {
            if (data.rows.length > 0) {
                NewsTb(data);
            }
            resize_r();
        },
        error: function () {
            layer.msg('网络请求错误！', 2, 5);
        }
    });
    $.ajax({
        url: "/Handlers/system/Mission.aspx?Method=LoadReceive&srvid=" + srvID + "&userid=" + userID + "&page=1&rows=5",
        type: "get",
        cache: false,
        dataType: "json",
        success: function (data) {
            if (data.rows.length > 0) {
                MissonTb(data);
            }
            resize_r();
        },
        error: function () {
            layer.msg('网络请求错误！', 2, 5);
        }
    });
    $.ajax({
        url: "/Handlers/system/SetInfo.aspx?Method=LoadNotice&srvid=" + srvID + "&userID=" + userID + "&page=1&rows=5",
        type: "get",
        cache: false,
        dataType: "json",
        success: function (data) {
            if (data.rows.length > 0) {
                NoticeTb(data);
            } 
            layer.close(l);
            resize_r();
        },
        error: function () {
            layer.msg('网络请求错误！', 2, 5);
        }
    });
    ClickEvent();
}
function LoadCaution() {
    $.ajax({
        url: "Handlers/system/GongGao.aspx?Method=Caution",
        type: "get",
        cache: false,
        dataType: "text",
        success: function (data) {
            $("#spcaution").text(data);
            resize_r();
        },
        error: function () {
            layer.msg('网络请求错误！', 2, 5);
        }
    });
}

function Refresh() {
    LoadCaution();
}

function NoticeTb(data) {
    var tb = document.getElementById("tbNotice");
    for (var i = tb.rows.length - 1; i > 0; i--) {
        tb.deleteRow(i);
    }
    for (var i = 0; i < data.rows.length; i++) {
        var _tr1 = $('<tr></tr>');
        var _td1 = $('<td></td>');
        if (data.rows[i].Hyperlink != "0") {
            _td1.append('<a href="' + data.rows[i].noticeContent + '" target="_blank" style="cursor:pointer;color:#428bca;">' + data.rows[i].notice + '</a>');
        } else {
            if (data.rows[i].TemplateNewsNotice != "0") {
                _td1.append('<a onclick="Notice(this)" rel=\'' + data.rows[i].ID + '\' style="cursor:pointer;color:#428bca;">' + data.rows[i].notice + '</a>');

            } else {
                if (data.rows[i].notice.length >= 20) {
                    _td1.append('<span onclick="Notice(this)" rel=\'' + data.rows[i].ID + '\' style="cursor:pointer;color:#428bca;" class="tooltip-info"  data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].notice + '">' + data.rows[i].notice.substring(0, 18) + "..." + '</span>');
                } else {
                    _td1.append('<span onclick="Notice(this)" rel=\'' + data.rows[i].ID + '\' style="cursor:pointer;color:#428bca;" class="tooltip-info" data-rel="tooltip" data-placement="right" data-original-title="' + data.rows[i].notice + '">' + data.rows[i].notice + '</span>');
                }
            }
        }            
        var _td2 = $('<td class="center"></td>');
        _td2.append(data.rows[i].TimeStr);
        _tr1.append(_td1);
        _tr1.append(_td2);
        $('#tbNotice tbody').append(_tr1);
    }
    ClickEvent();
}
function DailyTb(data) {
    var tb = document.getElementById("tbDaily");
    for (var i = tb.rows.length - 1; i > 0; i--) {
        tb.deleteRow(i);
    }
    for (var i = 0; i < data.rows.length; i++) {
        var _tr1 = $('<tr></tr>');
        var _td1 = $('<td></td>');
        _td1.append("<a href='javascript:void(0)' onclick='DailyCheck(this)' style='color:#428bca;' rel='" + data.rows[i].ID + "'>查看</a>");
        var _td2 = $('<td class="center"></td>');
        if (data.rows[i].Type == "0") {
            _td2.append("日报");
        }
        else if (data.rows[i].Type == "1") {
            _td2.append("周报");
        }
        else if (data.rows[i].Type == "2") {
            _td2.append("月报");
        }
        var _td3 = $('<td></td>');
        if (data.rows[i].Respond.length >= 20) {
            _td3.append('<span style="cursor:pointer;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].Respond + '">' + data.rows[i].Respond.substring(0, 20) + "..." + '</span>');
        } else {
            _td3.append('<span style="cursor:pointer;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].Respond + '">' + data.rows[i].Respond + '</span>');
        }
        var _td4 = $('<td class="center"></td>');
        _td4.append(data.rows[i].TimeStr);

        _tr1.append(_td1);
        _tr1.append(_td2);
        _tr1.append(_td3);
        _tr1.append(_td4);
        $('#tbDaily tbody').append(_tr1);
    }
    ClickEvent();
}
function MissonTb(data) {
    var tb = document.getElementById("tbMission");
    for (var i = tb.rows.length - 1; i > 0; i--) {
        tb.deleteRow(i);
    }
    for (var i = 0; i < data.rows.length; i++) {
        var _tr1 = $('<tr></tr>');
        var _td1 = $('<td></td>');
        if (data.rows[i].ContentStr.length >= 10) {
            _td1.append('<span onclick="MissionCheck(this)" rel=\'' + data.rows[i].ID + '\' style="cursor:pointer;color:#428bca;" class="tooltip-info" txt="查看任务" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].ContentStr + '">' + data.rows[i].ContentStr.substring(0, 10) + "..." + '</span>');
        } else {
            _td1.append('<span onclick="MissionCheck(this)" rel=\'' + data.rows[i].ID + '\' style="cursor:pointer;color:#428bca;" class="tooltip-info" txt="查看任务" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].ContentStr + '">' + data.rows[i].ContentStr + '</span>');
        }
        var _td2 = $('<td class="center"></td>');
        _td2.text(data.rows[i].sendername);
        var _td3 = $('<td class="center"></td>');
        _td3.append(data.rows[i].State);
        var _td4 = $('<td class="center"></td>');
        _td4.text(data.rows[i].TimeStr);

        _tr1.append(_td1);
        _tr1.append(_td2);
        _tr1.append(_td3);
        _tr1.append(_td4);
        $('#tbMission tbody').append(_tr1);
    }
    ClickEvent();
}
function NewsTb(data) {
    var tb = document.getElementById("tbNews");
    for (var i = tb.rows.length - 1; i > 0; i--) {
        tb.deleteRow(i);
    }
    for (var i = 0; i < data.rows.length; i++) {
        var _tr1 = $('<tr></tr>');
        var _td1 = $('<td></td>');
        if (data.rows[i].Title.length >= 20) {
            _td1.append('<span onclick="News(this)"  rel=' + data.rows[i].ID + ' style="cursor:pointer;color:#428bca;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].Title + '">' + data.rows[i].Title.substring(0, 18) + "..." + '</span>');
        } else {
            _td1.append('<span onclick="News(this)" rel=' + data.rows[i].ID + ' style="cursor:pointer;color:#428bca;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].Title + '">' + data.rows[i].Title + '</span>');
        }
        var _td2 = $('<td class="center"></td>');
        _td2.text(data.rows[i].Familiar);
        var _td3 = $('<td class="center"></td>');
        _td3.text(data.rows[i].TimeStr);

        _tr1.append(_td1);
        _tr1.append(_td2);
        _tr1.append(_td3);
        $('#tbNews tbody').append(_tr1);
    }
    ClickEvent();
}
function JhTb(data) {
    var tb = document.getElementById("tbChance");
    for (var i = tb.rows.length - 1; i > 0; i--) {
        tb.deleteRow(i);
    }
    for (var i = 0; i < data.rows.length; i++) {
        var _tr1 = $('<tr></tr>');
        var _td1 = $('<td></td>');
        if (data.rows[i].KeHuMingCheng.length >= 13) {
            _td1.append('<span  rel=\'' + data.rows[i].ID + '\' style="cursor:pointer;color:#428bca;" class="tooltip-info" txt="销售机会管理" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].KeHuMingCheng + '">' + data.rows[i].KeHuMingCheng.substring(0, 11) + "..." + '</span>');
        } else {
            _td1.append('<span  rel=\'' + data.rows[i].ID + '\' style="cursor:pointer;color:#428bca;" class="tooltip-info" txt="销售机会管理" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].KeHuMingCheng + '">' + data.rows[i].KeHuMingCheng + '</span>');
        }
        var _td2 = $('<td class="center"></td>');
        _td2.text(data.rows[i].ChuangJianRen.substring(0, 4));
        var _td4 = $('<td class="center"></td>');
        _td4.text(data.rows[i].TimeStr);

        _tr1.append(_td1);
        _tr1.append(_td2);
        _tr1.append(_td4);
        $('#tbChance tbody').append(_tr1);
    }
    ClickEvent();
}
function KhTb(data) {
    var tb = document.getElementById("tbKh");
    for (var i = tb.rows.length - 1; i > 0; i--) {
        tb.deleteRow(i);
    }
    for (var i = 0; i < data.rows.length; i++) {
        var _tr1 = $('<tr></tr>');
        var _td1 = $('<td></td>');
        var khname=data.rows[i].KeHuMingCheng;
        if(khname.length>=13)
        {
            khname=khname.substring(0, 11) + "...";
        }
        if (data.rows[i].ChuangJianRen == userID) {
            _td1.append('<span  rel=\'' + data.rows[i].ID + '\' style="cursor:pointer;color:#428bca;" class="tooltip-info" txt="客户信息管理" data-placement="right" data-rel="tooltip" onclick="CreateKh(\'' + data.rows[i].ID + '\',1)"  data-original-title="' + khname + '">' + khname + '</span>');
        }
        else {
            _td1.append('<span  rel=\'' + data.rows[i].ID + '\' style="cursor:pointer;color:#428bca;" class="tooltip-info" txt="客户信息管理" data-placement="right" data-rel="tooltip" onclick="CreateKh(\'' + data.rows[i].ID + '\',0)"  data-original-title="' + khname + '">' + khname + '</span>');
        }
        var _td2 = $('<td class="center"></td>');
        _td2.text(data.rows[i].userXm.substring(0, 4));
        var _td4 = $('<td class="center"></td>');
        _td4.text(data.rows[i].TimeStr);

        _tr1.append(_td1);
        _tr1.append(_td2);
        _tr1.append(_td4);
        $('#tbKh tbody').append(_tr1);
    }
    ClickEvent();
}
function HtTb(data) {
    var tb = document.getElementById("HeTong");
    for (var i = tb.rows.length - 1; i > 0; i--) {
        tb.deleteRow(i);
    }
    for (var i = 0; i < data.rows.length; i++) {
        var _tr1 = $('<tr></tr>');
        var _td1 = $('<td></td>');
        if (data.rows[i].KeHuMingCheng.length >= 15) {
            _td1.append('<span  rel=\'' + data.rows[i].orderID + '\' style="cursor:pointer;color:#428bca;" class="tooltip-info" txt="合同维护" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].KeHuMingCheng + '">' + data.rows[i].KeHuMingCheng.substring(0, 15) + "..." + '</span>');
        } else {
            _td1.append('<span  rel=\'' + data.rows[i].orderID + '\' style="cursor:pointer;color:#428bca;" class="tooltip-info" txt="合同维护" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].KeHuMingCheng + '">' + data.rows[i].KeHuMingCheng + '</span>');
        }
        var _td2 = $('<td></td>');
        if (data.rows[i].orderID.length >= 16) {
            _td2.append('<span style="cursor:pointer;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].orderID + '">' + data.rows[i].orderID.substring(0, 13) + "..." + '</span>');
        } else {
            _td2.append('<span style="cursor:pointer;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].orderID + '">' + data.rows[i].orderID + '</span>');
        }
        var _td3 = $('<td style="text-align:left;padding-right:15px;"></td>');
        _td3.text(data.rows[i].userXM);
        var _td4 = $('<td class="center"></td>');
        _td4.text(data.rows[i].timeStr);

        _tr1.append(_td1);
        _tr1.append(_td2);
        _tr1.append(_td3);
        _tr1.append(_td4);
        $('#HeTong tbody').append(_tr1);
    }
    ClickEvent();
}
function WorkTb(data) {
    var tb = document.getElementById("tbWork");
    for (var i = tb.rows.length - 1; i > 0; i--) {
        tb.deleteRow(i);
    }
    for (var i = 0; i < 5; i++) {
        var _tr1 = $('<tr></tr>');
        var _td1 = $('<td></td>');
        if (data.rows[i].Content.length >= 20) {
            _td1.append('<span style="cursor:pointer;color:#428bca;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].Content + '">' + data.rows[i].Content.substring(0, 20) + "..." + '</span>');
        } else {
            _td1.append('<span style="cursor:pointer;color:#428bca;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].Content + '">' + data.rows[i].Content + '</span>');
        }
        var _td2 = $('<td class="center"></td>');
        _td2.append(data.rows[i].StartTime);

        _tr1.append(_td1);
        _tr1.append(_td2);
        $('#tbWork tbody').append(_tr1);
    }
    ClickEvent();
}
function resize_r() {
    //    $($(window.parent.document).find('iframe[id=ifrm]')).height($(document).outerHeight());
//    var s = 0;
//    var ss = $(window.parent.document).find('iframe[id= "ifrm"]');
//    var l = $(window.parent.document).height() - ss.offset().top;
//    var t = $(document).height();
//    if (l > t) {
//        s = l;
//    }
//    else {
//        s = $(document).height();
//    }

//    $($(window.parent.document).find('iframe[id="ifrm"]')).height(s);
    window.parent.sidebar_r();
}
function iniParms() {
    var coks = document.cookie.substring(document.cookie.indexOf('userinf_tcwl'));
    var ary = coks.split(';');
    var ary1 = ary[0].split('=');
    if (!ary1[2]) {
        $('html').empty();
        return;
    }
    userID = ary1[2].split('&')[0];
    srvID = ary1[3];
    $('#Huserid').val(userID);
    $('#Hsrvid').val(srvID);

    var coksau = document.cookie.substring(document.cookie.indexOf('TCWL_All'));
    aryau = coksau.split(';')[0].split('=')[2];
    if (aryau.indexOf("M_100_W") != -1) {
        $(".bg_ly").attr("onclick", "KhTab_week(this)");
        $(".bg_ly").css("cursor", "pointer");
    }
    if (aryau.indexOf("M_104_W") != -1) {
        $(".bg_lo").attr("onclick", "HtTab_week(this)");
        $(".bg_lo").css("cursor", "pointer");
    }
    if (aryau.indexOf("M_111_W") != -1) {
        $(".bg_ls").attr("onclick", "JhTab_week(this)");
        $(".bg_ls").css("cursor", "pointer");
    }
    LoadData();
    resize_r();
}

function CreateTabs(url, tabname, _this) {
    var l = tab_exist(_this);
    if (l.toString().length > 0) {
        parent.$('#tctabs a:eq(' + l + ')').tab('show');
        return;
    }
    parent.$('#tctabs').append($('<li ><a href="#a_' + $(_this).attr('rel') + '" data-toggle="tab">' + tabname + '<span class="fa fa-times" style=" margin-left:8px;width:10px;height:10px;" onclick="tab_close(this);" onmouseover ="close_over(this);" onmouseout ="close_out(this);"></span></a></li>'));
    parent.$('#tctabcontent').append($('<div class="tab-pane" id="a_' + $(_this).attr('rel') + '" scrolling="no" style="height:100%;margin-top:5px;"><iframe  id="m' + $(_this).attr('rel') + '"  src="' + url + '" style="border:0px;width:100%;height:100%;position:absolute;"></iframe></div>'));
    parent.$('#tctabs a:last').tab('show');
}

function News(_this) {
    CreateTabs("System/News.htm?id=" + $(_this).attr("rel") + "", "资讯", _this);
}

function NewsTab(_this) {
    CreateTabs("System/NewsList.htm?&name=m" + $(_this).attr('rel') + "", "资讯列表", _this);
}

function Notice(_this) {
    CreateTabs("System/News.htm?xt=xt&id=" + $(_this).attr("rel") + "", "系统公告", _this);
}

function NoticeTab(_this) {
    CreateTabs("System/GGlist.htm?&name=m" + $(_this).attr('rel') + "", "公告列表", _this);
}

function HtTab(_this) {
    var txt = $(_this).attr('txt');
    if (Exists(txt)) {
        CreateTabs("../Order/order_B.htm?userid=" + userID + "&srvid=" + srvID + "&name=m" + $(_this).attr('rel') + "", "合同维护", _this);
    }
}
function HtCheck(_this) {
    var txt = $(_this).attr('txt');
    if (Exists(txt)) {
        CreateTabs("../Order/order_B.htm?userid=" + userID + "&srvid=" + srvID + "&check=m" + $(_this).attr("rel") + "", "合同维护", _this);
    }
}

function HtTab_week(_this) {
    var u = "../Order/Order_First.htm?srvID=" + srvID + "&user=" + userID + "&name=m_0107";
    parent.$('#tctabs').append($('<li ><a href="#ht_0107" data-toggle="tab">本月合同查看<span class="fa fa-times" style=" margin-left:8px;width:10px;height:10px;" onclick="tab_close(this);" onmouseover ="close_over(this);" onmouseout ="close_out(this);"></span></a></li>'));
    parent.$('#tctabcontent').append($('<div class="tab-pane" id="ht_0107" scrolling="no" style="height:100%;margin-top:5px;"><iframe id="m_0107" src="' + u + '" style="border:0px;width:100%;height:100%;"></iframe></div>'));
    parent.$('#tctabs a:last').tab('show');
}

function KhTab(_this) {
    var txt = $(_this).attr('txt');
    if (Exists(txt)) {
        CreateTabs("../CustomerInformation/CustomerManagement/CustomerManagement_B.htm?userid=" + userID + "&srvid=" + srvID + "&name=m" + $(_this).attr('rel') + "", txt, _this);
    }
}
function KhCheck(_this) {
    var txt = $(_this).attr('txt');
    if (Exists(txt)) {
        CreateTabs("../CustomerInformation/CustomerManagement/CustomerManagement_B.htm?userid=" + userID + "&srvid=" + srvID + "&check=m" + $(_this).attr("rel") + "", txt, _this);
    }
}
function KhTab_week(_this) {
    var u = "../CustomerInformation/CustomerManagement/CustomerManagement_First.htm?srvID=" + srvID + "&user=" + userID + "&name=m_0108";
    parent.$('#tctabs').append($('<li ><a href="#kh_0108" data-toggle="tab">本月客户查看<span class="fa fa-times" style=" margin-left:8px;width:10px;height:10px;" onclick="tab_close(this);" onmouseover ="close_over(this);" onmouseout ="close_out(this);"></span></a></li>'));
    parent.$('#tctabcontent').append($('<div class="tab-pane" id="kh_0108" scrolling="no" style="height:100%;margin-top:5px;"><iframe id="m_0108" src="' + u + '" style="border:0px;width:100%;height:100%;"></iframe></div>'));
    parent.$('#tctabs a:last').tab('show');
}

function JhTab(_this) {
    var txt = $(_this).attr('txt');
    if (Exists(txt)) {
        CreateTabs("MarketingManagement/sellChance/chanceMantance_B.htm?userid=" + userID + "&srvid=" + srvID + "&name=m" + $(_this).attr('rel') + "", "销售机会管理", _this);
    }
}
function JhCheck(_this) {
    var txt = $(_this).attr('txt');
    if (Exists(txt)) {
        CreateTabs("MarketingManagement/sellChance/chanceMantance_B.htm?userid=" + userID + "&srvid=" + srvID + "&check=m" + $(_this).attr("rel") + "", "销售机会管理", _this);
    }
}
function JhTab_week(_this) {
    var u = "MarketingManagement/sellChance/chanceMantance_First.htm?srvID=" + srvID + "&user=" + userID + "&name=m_0109";
    parent.$('#tctabs').append($('<li ><a href="#jh_0109" data-toggle="tab">本月销售机会查看<span class="fa fa-times" style=" margin-left:8px;width:10px;height:10px;" onclick="tab_close(this);" onmouseover ="close_over(this);" onmouseout ="close_out(this);"></span></a></li>'));
    parent.$('#tctabcontent').append($('<div class="tab-pane" id="jh_0109" scrolling="no" style="height:100%;margin-top:5px;"><iframe id="m_0109" src="' + u + '" style="border:0px;width:100%;height:100%;"></iframe></div>'));
    parent.$('#tctabs a:last').tab('show');
}

function MissionTab(_this) {
    var txt = $(_this).attr('txt');
    if (Exists(txt)) {
        CreateTabs("System/MissionCheck.htm?userid=" + userID + "&srvid=" + srvID + "&name=m" + $(_this).attr('rel') + "", "查看任务", _this);
    }
}
function MissionCheck(_this) {
    var txt = $(_this).attr('txt');
    if (Exists(txt)) {
        CreateTabs("System/MissionCheck.htm?userid=" + userID + "&srvid=" + srvID + "&check=m" + $(_this).attr("rel") + "", "任务查看", _this);
    }
}

function DailyTab(_this) {
    var txt = $(_this).attr('txt');
    if (Exists(txt)) {
        CreateTabs("System/Daily.htm?userid=" + userID + "&srvid=" + srvID + "", "日志管理", _this);
    }
}
function DailyCheck(_this) {
    CreateTabs("System/Daily.htm?userid=" + userID + "&srvid=" + srvID + "&check=" + $(_this).attr("rel") + "", "日志管理", _this);
}

function WorkTab(_this) {
    var txt = $(_this).attr('txt');
    if (Exists(txt)) {
        CreateTabs("IndividualCenter/WorkingLog.htm", "工作薄", _this);
    }
}

function GgTab(_this) {
    var txt = $(_this).attr('txt');
    if (Exists(txt)) {
        CreateTabs("System/GongGao.htm", "资讯管理", _this);
    }
}

function Exists(txt) {
    var dd = false;
    var l = parent.$("li a[rel]").each(function (i, e) {
        if ($(e).attr('txt') == txt) {
            dd = true;
        }
    });
    return dd;
}

function tab_exist(_this) {
    var c = parent.$("#tctabs li a");
    var aid = "";
    for (var i = 0; i < c.length; i++) {
        if (parent.$(c[i]).text() == $(_this).attr("txt")) {
            aid = i;
        }
    }
    return aid;
}

function CreateKh(id,flag) {
    var u = "";
    u = "../CustomerInformation/CustomerCommunicationRecord/CustomerCommunicationRecord_B.aspx?ID=" + id + "&srvID=" + srvID + "&user=" + userID + "&name=m" + id + "&f="+flag+"";
    parent.$('#tctabs').append($('<li ><a href="#kh' + id + '" data-toggle="tab">客户详细信息<span class="fa fa-times" style=" margin-left:8px;width:10px;height:10px;" onclick="tab_close(this);" onmouseover ="close_over(this);" onmouseout ="close_out(this);"></span></a></li>'));
    parent.$('#tctabcontent').append($('<div class="tab-pane" id="kh' + id + '" scrolling="no" style="height:100%;margin-top:5px;"><iframe id="m' + id + '" src="' + u + '" style="border:0px;width:100%;height:100%;"></iframe></div>'));
    parent.$('#tctabs a:last').tab('show');
}