﻿//公共变量定义
var ClientSiteKey; //站点ID

var AppFunctionUrlOnlineOffice; //应用数据处理URL，主要用作应用数据信息获取

var AppHelperUrl = "/Applications/AppHelper.ashx"; //本地应用数据处理页面

var page;

function S4() {
    return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);g
}

function guid() {
    return (S4() + S4() + S4() + S4() + S4() + S4() + S4() + S4()); //(S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
}

var _caseApplyID = guid();

var _caseID = null;


function UpFile(txtFileName) {
    var url = AppFunctionUrlOnlineOffice.substr(0, AppFunctionUrlOnlineOffice.indexOf("/AppFunctions.ashx"));

    var html = MyShowDlg(url + "/upload.aspx?InfoID=" + _caseApplyID + "&txtId=" + txtFileName, window, 460, 130);

    $.getJSON(
        url + "/upload.aspx?getLastedFileName=1&r=" + Math.random() + "&callback=?",
        function (msg) {
            $("#" + txtFileName).val(msg.Result);
        });
}

/*
日期格式化
strDate：日期字符串
strFormat：格式化字符串
*/
MyDateFormat = function (strDate, strFormat) {
    try {
        var dt = eval('new Date(' + strDate.replace(/\d+(?=-[^-]+$)/, function (a) { return parseInt(a, 10) - 1; }).match(/\d+/g) + ')');
        var o = {
            "M+": dt.getMonth() + 1, //month
            "d+": dt.getDate(),    //day
            "h+": dt.getHours(),   //hour
            "m+": dt.getMinutes(), //minute
            "s+": dt.getSeconds(), //second
            "q+": Math.floor((dt.getMonth() + 3) / 3),  //quarter
            "S": dt.getMilliseconds() //millisecond
        }
        if (/(y+)/.test(strFormat))
            strFormat = strFormat.replace(RegExp.$1, (dt.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(strFormat))
                strFormat = strFormat.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
        return strFormat;
    }
    catch (e) {
        return "";
    }
}


$(document).ready(function () {
    page = parseInt(getQuery('page', 1)); //当前页码
    _caseID = getQuery('InfoID', 1);
});

//应用页面初始化初始化
//pageToBeInit，页面初始化标记
//isShowHeaderFooter，是否显示页头页脚，true显示，false不显示
function InitAppPageOnlineOffice(pageToBeInit, isShowHeaderFooter) {

    var query = "?OperType=InitGlobalVariable&AppName=" + escape("办事大厅") + "&callback=?";
    $.getJSON(AppHelperUrl + query, function (data) {
        var result = data;
        if (result.IsSuc) {
            ClientSiteKey = result.Result.SiteKey;
            AppFunctionUrlOnlineOffice = result.Result.AppFunctionsUrl;

            switch (pageToBeInit) {
                case "OfficeApplyAdd.htm":      //事项申请
                    GetCaseName("CaseName");
                    ShowCaseAccessoriesOnApplyAdd("showAccessories", _caseApplyID);
                    break;
                case "OfficeReferAdd.htm":      //事项咨询
                    InitOfficeReferAdd();
                    break;
                case "index.htm":               //首页
                    InitDataIndexHtm();
                    break;
                case "OfficeReferList.htm":     //咨询列表页
                    InitDataOfficeReferList();
                    break;
                case "OfficeShow":          //事项详细
                    InitDataOfficeShow();
                    break;
                case "OfficeReferShow.htm":     //事项咨询详细
                    InitDataOfficeReferShow();
                    break;
                case "OfficeApplyList.htm":     //事项申请列表页
                    InitDataShowCaseApplyList();
                    break;
                case "OfficeApplyShow.htm":     //事项申请详细
                    InitDataShowCaseApply();
                    break;
                case "MainSite":
                    //GetCaseAccessories("con_two_4",1,7,"",false,16);
                    InitDataMainSite();
                    break;
                case "ListOnlineOffice":
                    InitDataListOnlineOffice();
                    break;
                case "ListOnlineOfficeApply":
                    InitDataListOnlineOfficeApply();
                    break;
                case "ListOnlineOfficeRefer":
                    InitDataListOnlineOfficeRefer();
                    break;
                case "OfficeType": ///首页初始化
                    InitDataOfficeType();
                    break;
                case "OnlineOfficeType": //在线办事信息列表
                    InitDataOfficeTypeCaseList();
                    break;
                case "OfficeTypeCaseList": //在线办事
                    InitDataOfficeTypeOnlineCaseList();
                    break;
                case "OfficeTypeCaseGongGao": //办事公告
                    InitDataOfficeTypeOnlineGongGao();
                    break;
                case "OfficeList.htm": //事项列表
                    InitOfficeList();
                    break;
            }
        }
    });

    if (isShowHeaderFooter) {
        //页面标题
        query = "?OperType=GetSiteTitle" + "&callback=?";
        $.getJSON(AppHelperUrl + query, function (data) {
            if (!data.IsSuc)
                return;
            window.document.title = data.Result;
        });

        //页头数据获取
        query = "?OperType=GetLableCode&LableName=" + escape("{HZ_[网站头部]}") + "&callback=?";
        $.getJSON(AppHelperUrl + query, function (data) {
            if (!data.IsSuc)
                return;
            $("#Header").html(unescape(data.Result));
        });

        //页脚数据获取
        query = "?OperType=GetLableCode&LableName=" + escape("{HZ_[网站底部]}") + "&callback=?";
        $.getJSON(AppHelperUrl + query, function (data) {
            if (!data.IsSuc)
                return;
            $("#myFooter").html(unescape(data.Result));
        });
    }
}


//输出分页
function ShowPerPageForInitOfficeList(pageSize, recordCount, linkPage) {
    var pageCount = Math.ceil(recordCount / pageSize);
    var result = "";

    if (linkPage.indexOf("?") >= 0 && linkPage.indexOf("=") >= 0)
        linkPage += "&page=";
    else
        linkPage += "?page=";

    result = "共计： " + recordCount + "条 " + pageCount + "页&nbsp;&nbsp;&nbsp;&nbsp;当前第" + page + "页&nbsp;&nbsp;"
    if (page <= 1) {
        result += "第一页&nbsp;";
        result += "上一页&nbsp;";
    }
    else {
        result += "<a href='" + linkPage + 1 + "'>第一页</a>&nbsp;";
        result += "<a href='" + linkPage + (page - 1) + "'>上一页</a>&nbsp;";
    }
    if (page >= pageCount) {
        result += "下一页&nbsp;";
        result += "尾页";
    }
    else {
        result += "<a href='" + linkPage + (page + 1) + "'>下一页</a>&nbsp;";
        result += "<a href='" + linkPage + pageCount + "'>尾页</a>";
    }
    result += '&nbsp;<select name="select" id="select" style="width:50px;height:20px;" onchange="window.location=\'' + linkPage + '\'+this.value"> '
    for (var i = 1; i <= pageCount; i++) {
        result += '<option value="' + i + '"';
        if (page == i)
            result += ' selected="selected"';
        result += '>' + i + '</option>';
    }

    return result;
}
//获取事项列表页
function InitOfficeList() {
    var infoTree = getQuery('InfoTreeID', ''); //事项分类ID
    var pageSize = 20; //每页最大信息数量
    var linkType = getQuery('LinkType', ''); //事项链接类型（1:链接到事项申请页，否则链接到详细事项信息页）

    /*
    PID：服务导航栏目的父ID，默认指定为 000200030005；
    GetAllChild：是否获取所有事项子分类，1是，0不是
    现在进行左边导航的信息绑定
    */
    $("#ulCaseTreeList").html('');
    $.getJSON(AppFunctionUrlOnlineOffice + "?action=GetCaseType&PID=000200030005&GetAllChild=0&ClientSiteKey=" + ClientSiteKey + "&callback=?", function (data) {
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {
            $("#ulCaseTreeList").html('<li class="Current">信息获取失败</li>');
            return;
        }
        var title = "";
        for (var i = 0; i < infoes.Result.length; i++) {
            title = infoes.Result[i].Name;
            if (title.length > 30) {
                title = infoes.Result[i].Name.substr(0, intMaxTitleLength) + '...';
            }
            strResult = '    <li';
            if (infoTree == infoes.Result[i].RulesId)//当前选定事项分类的判断
            {
                strResult += ' class="Current" '
            }
            strResult += '><a href="/AppFrontPage/OnlineOffice/OfficeList.htm?InfoTreeID=' + infoes.Result[i].RulesId;
            if (linkType == "1")
                strResult += '&LinkType=1';
            strResult += '" title="' + infoes.Result[i].Name + '">' + title + '</a></li>';
            $("#ulCaseTreeList").append(strResult);
        }
    });

    /*
    现在进行办事信息列表的绑定
    */
    $("#ulCaseList").html('');
    var query = "?action=GetCase&ClientSiteKey=" + ClientSiteKey + "&IsOnline=1&page=" + page + "&pageSize=" + pageSize + "&OfficeType=" + infoTree;
    query += "&callback=?";
    $.getJSON(AppFunctionUrlOnlineOffice + query, function (data) {
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {
            $("#ulCaseList").html('<li>暂无信息</li>');
            return;
        }

        for (var i = 0; i < infoes.Result.length; i++) {
            strResult = '<li>';
            title = infoes.Result[i].Name;
            if (title.length > 30)
                title = infoes.Result[i].Name.substr(0, 30) + '...';
            if (linkType == '1') {
                if (infoes.Result[i].IsOnline == '1')
                    strResult += '<a href="/List.aspx?KindID=39987814-cbb0-4099-b007-c569961a92bc&InfoID=' + infoes.Result[i].CaseId + '&InfoTreeID=' + infoes.Result[i].CategoryId + '" title="' + infoes.Result[i].Name + '" target="_blank">' + title + '</a>';
                else
                    strResult += '<div style="cursor:pointer;" onclick=alert("该事项暂未开放在线申请") title="' + infoes.Result[i].Name + '">' + title + '</div>'
            }
            else {
                strResult += '<a href="/List.aspx?KindID=1d717884-02ca-4f56-8fee-8d8f3d37898f&CaseID=' + infoes.Result[i].CaseId + '" title="' + infoes.Result[i].Name + '" target="_blank">' + title + '</a>';
            }
            strResult += '</li>';
            $("#ulCaseList").append(strResult);
        }

        /*
        输出分页
        */
        var linkUrl = '/AppFrontPage/OnlineOffice/OfficeList.htm';
        if (infoTree != "")
            linkUrl += "?InfoTreeID=" + infoTree;
        if (linkType == "1")
            linkUrl += "&LinkType=1";
        strResult = ShowPerPageForInitOfficeList(pageSize, parseInt(infoes.RecordCount), linkUrl);

        $("#divPager").append(strResult);
    });

}

//获取办事事项名称
function GetCaseName(targetObjID) {
    var infoid = getQuery('InfoID', '');
    var infoTree = getQuery('InfoTreeID', '');

    $.getJSON(
        AppFunctionUrlOnlineOffice + "?action=GetCaseName&InfoID=" + infoid + "&InfoTreeID=" + infoTree + "&callback=?",
        function (msg) {
            $("#" + targetObjID).html('<h1>' + msg.Result + '&nbsp;在线申请表</h1>');
        });
}

//获取办事事项名称
function ShowCaseAccessoriesOnApplyAdd(targetObjID, caseApplyID) {
    var infoid = getQuery('InfoID', '');
    var infoTree = getQuery('InfoTreeID', '');

    $.getJSON(
    AppFunctionUrlOnlineOffice + "?action=ShowCaseAccessoriesOnApplyAdd&InfoID=" + infoid + "&InfoTreeID=" + infoTree + "&caseApplyID=" + caseApplyID + "&callback=?",
    function (msg) {
        $("#" + targetObjID).html(msg.Result);
    });
}

//添加事项
function AddCaseApply() {
    if ($("#txtName").val() == "") {
        alert("请填写姓名！")
        return;
    }
    if ($("#txtVerificationCode").val() == "") {
        alert("请填写验证码！")
        return;
    }
    var parm = "?action=AddCA";
    parm += "&txtName=" + escape($("#txtName").val());
    parm += "&txtAddress=" + escape($("#txtAddress").val());
    parm += "&txtEmail=" + $("#txtEmail").val();
    parm += "&txtTelephone=" + $("#txtTelephone").val();
    parm += "&txtFax=" + $("#txtFax").val();
    parm += "&txtMobile=" + $("#txtMobile").val();
    parm += "&txtRemark=" + escape($("#txtRemark").val());
    parm += "&txtVerificationCode=" + $("#txtVerificationCode").val();
    parm += "&CaseID=" + _caseID;
    parm += "&CaseApplyId=" + _caseApplyID;
    parm += "&isSecret=" + ($("input[id='rbYes']").attr("checked") ? 1 : 0);


    $.getJSON(
    AppFunctionUrlOnlineOffice + parm + "&callback=?",
    function (msg) {
        if (msg.IsSuc) {
            alert("提交成功！\n\n您的受理号为：" + _caseApplyID.substr(4, 12) + "\n查询码为：" + _caseApplyID.substr(20, 6) + "\n\n请牢记您的受理号和查询码，进行办事申请查询时会用到。");
            //$("#imgCode").attr("src","/Applications/Program/48CEF446-2833-497f-B6BF-27FD4F952C63/ImageCode.aspx?etc="+new Date().getTime());
            window.location = "/index.aspx";
        }
        else {
            $("#imgCode").attr("src", "/Applications/Program/48CEF446-2833-497f-B6BF-27FD4F952C63/ImageCode.aspx?etc=" + new Date().getTime());
            alert("提交失败，原因：" + msg.Message);

        }
    });
}

//检测

function checkvalue() {
    if (form1.txtName.value == "") {
        window.alert("请填写您的姓名！");
        form1.txtName.focus();
        return false
    }
    return true;
}

//初始化事项咨询
function InitOfficeReferAdd() {
    _referCaseID = getQuery('CaseID', '');

    ShowCaseSelect();
}

//获取咨询列表
var _referCaseID = null;
function ShowCaseSelect() {
    $.getJSON(
        AppFunctionUrlOnlineOffice + "?action=ShowCaseSelect&ClientSiteKey=" + ClientSiteKey + "&CaseID=" + _referCaseID + "&callback=?",
        function (msg) {
            $("#tdCaseList").html(msg.Result);
        });
}


function AddCaseRefer() {
    if ($("#txtTitle").val() == "") {
        alert("请填写主题！")
        return;
    }
    if ($("#txtContent").val() == "") {
        alert("请填写内容！")
        return;
    }
    if ($("#txtName").val() == "") {
        alert("请填写姓名！")
        return;
    }
    if ($("#txtVerificationCode").val() == "") {
        alert("请填写验证码！")
        return;
    }
    var url = AppFunctionUrlOnlineOffice
    var parm = "?action=AddCR";
    parm += "&CaseID=" + $("#CaseID").val();
    parm += "&txtName=" + escape($("#txtName").val());
    parm += "&txtTitle=" + escape($("#txtTitle").val());
    parm += "&txtContent=" + escape($("#txtContent").val());
    parm += "&txtEmail=" + escape($("#txtEmail").val());
    parm += "&txtVerificationCode=" + $("#txtVerificationCode").val();

    $.getJSON(
        url + parm + "&callback=?",
        function (msg) {
            if (msg.IsSuc) {
                $("#imgCode").attr("src", "/Applications/Program/48CEF446-2833-497f-B6BF-27FD4F952C63/ImageCode.aspx?etc=" + new Date().getTime());
                alert('咨询添加成功，请耐心等待管理员回复')
                window.close();
            }
            else {
                alert(msg.Message);
                $("#imgCode").attr("src", "/Applications/Program/48CEF446-2833-497f-B6BF-27FD4F952C63/ImageCode.aspx?etc=" + new Date().getTime());
            }
        });
}

//输出分页
function ShowPerPage(pageSize, recordCount, linkPage) {
    var pageCount = Math.ceil(recordCount / pageSize);
    var result = "";

    if (linkPage.indexOf("?") >= 0 && linkPage.indexOf("=") >= 0)
        linkPage += "&page=";
    else
        linkPage += "?page=";

    result = "共计： " + recordCount + "条 " + pageCount + "页&nbsp;&nbsp;&nbsp;&nbsp;当前第" + page + "页&nbsp;&nbsp;"
    if (page <= 1) {
        result += "第一页&nbsp;";
        result += "上一页&nbsp;";
    }
    else {
        result += "<a href='" + linkPage + 1 + "'>第一页</a>&nbsp;";
        result += "<a href='" + linkPage + (page - 1) + "'>上一页</a>&nbsp;";
    }
    if (page >= pageCount) {
        result += "下一页&nbsp;";
        result += "尾页";
    }
    else {
        result += "<a href='" + linkPage + (page + 1) + "'>下一页</a>&nbsp;";
        result += "<a href='" + linkPage + pageCount + "'>尾页</a>";
    }

    return result;
}

function ShowCaseReferList(objID, pageSize, intMaxTitleLength) {
    var Keyword = escape(getQuery("Keyword", ""));
    var CaseID = getQuery("CaseID", "");
    var KindID = getQuery("KindID", "");
    var linkPage = "/List.aspx?KindID=36160f46-2fb3-4637-8ad1-3868ceee428d&KindID=" + KindID;
    if (CaseID != "")
        linkPage += "&CaseID=" + CaseID;

    //State，状态：0未回复，1已回复，为空则获取全部
    var query = "?action=GetCaseRefer&ClientSiteKey=" + ClientSiteKey + "&page=" + page + "&pageSize=" + pageSize;
    if (Keyword != "")
        query += "&Keyword=" + Keyword;
    if (CaseID != "")
        query += "&CaseID=" + CaseID;
    query += "&callback=?";

    $.getJSON(AppFunctionUrlOnlineOffice + query, function (data) {
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {
            EndWait();
            $("#" + objID).append('<tr>' +
            '<td colspan="3" align="center"><span style="color:Red;">' + infoes.Message + '</span></td></tr>'
            );
            return;
        }

        for (var i = 0; i < infoes.Result.length; i++) {

            if (infoes.Result[i].State == '1')
                state = '已答复';
            else
                state = '未答复';
            strResult = '<tr>';
            title = infoes.Result[i].Title;
            if (title.length > intMaxTitleLength)
                title = infoes.Result[i].Title.substr(0, intMaxTitleLength) + '...';
            strResult += '    <td style="width:70%;"><a href="/List.aspx?KindID=85643794-ece9-4769-9abf-f5d2904376e8&CaseID=' + CaseID + '&CaseReferID=' + infoes.Result[i].CaseReferId +
                '" title="' + infoes.Result[i].Title + '" target="_blank">' + title + '</a></td>';
            strResult += '  <td style="width:15%;" align="center">' + MyDateFormat(infoes.Result[i].AddTime, "yyyy-MM-dd") + '</td>';
            strResult += '  <td style="width:15%;" align="center">' + state + '</td>';
            strResult += '</tr>';
            $("#" + objID).append(strResult);
        }

        strResult = '<tr>';
        strResult += '  <td colspan="3" class="Page">';
        strResult += '      <div class="RecordList">';
        strResult += ShowPerPage(pageSize, parseInt(infoes.RecordCount), linkPage);
        strResult += '      </div>';
        strResult += '  </td>';
        strResult += '</tr>';

        $("#" + objID).append(strResult);

        EndWait();
    });
}

function ShowCaseList(objID, pageSize, intMaxTitleLength) {
    var Keyword = escape(getQuery("Keyword", ""));
    var OfficeType = getQuery("OfficeType", "");
    //PID：服务导航栏目的父ID，默认指定为 000200030005；
    //GetAllChild：是否获取所有事项子分类，1是，0不是
    var query = "?action=GetCase&ClientSiteKey=" + ClientSiteKey + "&page=" + page + "&pageSize=" + pageSize;
    if (Keyword != "")
        query += "&Keyword=" + Keyword;
    if (OfficeType != "")
        query += "&OfficeType=" + OfficeType;
    query += "&callback=?";

    $.getJSON(AppFunctionUrlOnlineOffice + query, function (data) {
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {
            $("#" + objID).html('<tr>' +
            '<span style="color:Red;">暂无信息</span></tr>'
            );
            return;
        }

        for (var i = 0; i < infoes.Result.length; i++) {
            strResult = '<tr>';
            title = infoes.Result[i].Name;
            if (title.length > intMaxTitleLength)
                title = infoes.Result[i].Name.substr(0, intMaxTitleLength) + '...';
            strResult += '    <td width="350"><a href="/List.aspx?KindID=1d717884-02ca-4f56-8fee-8d8f3d37898f&CaseID=' + infoes.Result[i].CaseId +
                '" title="' + infoes.Result[i].Name + '" target="_blank">' + title + '</a></td>';
            strResult += '  <td width="80" align="center"><a class="lnk" href="/List.aspx?KindID=5a54d2f4-92c6-4c12-bfed-025636b3c240&DeptID=' + infoes.Result[i].DeptId +
                '&CaseId=' + infoes.Result[i].CaseId + '" target="_blank">我要咨询</a></td>';
            strResult += '  <td width="80" align="center"><a class="lnk" href="/List.aspx?KindID=36160f46-2fb3-4637-8ad1-3868ceee428d&&CaseID=' + infoes.Result[i].CaseId +
                '" target="_blank">查看咨询</a></td>';
            if (infoes.Result[i].IsOnline == '1')
                strResult += '    <td width="80" align="center"><a href="/List.aspx?KindID=39987814-cbb0-4099-b007-c569961a92bc&InfoID=' + infoes.Result[i].CaseId + '&InfoTreeID=' + infoes.Result[i].CategoryId + '" target="_blank">在线申请</a></td>'
            else
                strResult += '    <td width="80" align="center">在线申请</td>';
            strResult += '</tr>';
            $("#" + objID).append(strResult);
        }

        var linkUrl = '/AppFrontPage/OnlineOffice/index.htm';
        if (OfficeType != "")
            linkUrl += "?OfficeType=" + OfficeType;
        strResult = '<tr>';
        strResult += '  <td colspan="4" class="Page">';
        strResult += '      <div class="RecordList">';
        strResult += ShowPerPage(pageSize, parseInt(infoes.RecordCount), linkUrl);
        strResult += '      </div>';
        strResult += '  </td>';
        strResult += '</tr>';

        $("#" + objID).append(strResult);
    });
}

//输出办事头几条
function ShowCaseTop(objID, pageSize, intMaxTitleLength) {
    //PID：服务导航栏目的父ID，默认指定为 000200030005；
    //GetAllChild：是否获取所有事项子分类，1是，0不是
    var query = "?action=GetCase&ClientSiteKey=" + ClientSiteKey + "&GetAllChild=1&page=1&pageSize=" + pageSize;
    query += "&callback=?";
    $.getJSON(AppFunctionUrlOnlineOffice + query, function (data) {
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {
            EndWait();
            $("#" + objID).append('<li>' +
            '<span style="color:Red;">' + infoes.Message + '</span></li>'
            );
            return;
        }

        var caseName = "";
        for (var i = 0; i < infoes.Result.length && i < pageSize; i++) {
            caseName = infoes.Result[i].Name;
            if (caseName.length > intMaxTitleLength)
                caseName = infoes.Result[i].Name.substring(0, intMaxTitleLength);

            strResult = '<li><span><a href="/List.aspx?KindID=1d717884-02ca-4f56-8fee-8d8f3d37898f&CaseID=' + infoes.Result[i].CaseId + '" target="_blank">';
            strResult += '  <img src="/Templates/GMS/Default/images/online01.gif" width="16" height="16" /></a>';

            var CACount = parseInt(infoes.Result[i].CACount);
            if (CACount > 0) {
                strResult += '<a href="/List.aspx?KindID=1d717884-02ca-4f56-8fee-8d8f3d37898f&CaseID=' + infoes.Result[i].CaseId + '" target="_blank">';
                strResult += '  <img src="/Templates/GMS/Default/images/online02.gif" width="16" height="16" /></a>';
            }
            else {
                strResult += '  <img src="/Templates/GMS/Default/images/online06.gif" width="16" height="16" />';
            }

            strResult += '<a href="list.aspx?KindID=d723a1ae-0787-45d5-a10f-6743557496a6&CaseID=' + infoes.Result[i].CaseId + '" target="_blank">';
            strResult += '  <img src="/Templates/GMS/Default/images/online03.gif" width="16" height="16" /></a>';
            if (infoes.Result[i].IsOnline == "1") {
                strResult += '<a href="/List.aspx?KindID=39987814-cbb0-4099-b007-c569961a92bc&InfoID=' + infoes.Result[i].CaseId + '&InfoTreeID=' + infoes.Result[i].CategoryId + '" target="_blank">';
                strResult += '  <img src="/Templates/GMS/Default/images/online04.gif" width="16" height="16" /></a>';
            }
            else {
                strResult += '  <img src="/Templates/GMS/Default/images/online06.gif" width="16" height="16" />';
            }
            strResult += '<a href="/List.aspx?KindID=5a54d2f4-92c6-4c12-bfed-025636b3c240&DeptID=' + infoes.Result[i].DeptId + '&CaseId=' + infoes.Result[i].CaseId + '" target="_blank">';
            strResult += '  <img src="/Templates/GMS/Default/images/online05.gif" width="16" height="16" /></a>';

            strResult += '</span><a href="/List.aspx?KindID=1d717884-02ca-4f56-8fee-8d8f3d37898f&CaseID=' + infoes.Result[i].CaseId + '" target="_blank" title="' + infoes.Result[i].Name + '">';
            strResult += (i + 1) + '.' + caseName + '</a> </li>';

            $("#" + objID).append(strResult);
        }

        EndWait();
    });
}

function ShowCaseNavigation(objID, intNumPerLine, intMaxTitleLength) {
    //PID：服务导航栏目的父ID，默认指定为 000200030005；
    //GetAllChild：是否获取所有事项子分类，1是，0不是
    $.getJSON(AppFunctionUrlOnlineOffice + "?action=GetCaseType&PID=000200030005&GetAllChild=0&ClientSiteKey=" + ClientSiteKey + "&callback=?", function (data) {

        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {

            $("#tdCaseNavigationName").html('<span style="color:Red;">暂无信息</span>');
            return;
        }

        $("#tdCaseNavigationName").attr("colspan", intNumPerLine);

        var title = "";
        strResult = "<tr>";
        for (var i = 0; i < infoes.Result.length; i++) {


            title = infoes.Result[i].Name;
            if (title.length > intMaxTitleLength)
                title = infoes.Result[i].Name.substr(0, intMaxTitleLength) + '...';
            strResult += '    <td align="center"><a href="/AppFrontPage/OnlineOffice/index.htm?OfficeType=' + infoes.Result[i].RulesId +
                '" title="' + infoes.Result[i].Name + '"">' + title + '</a>（<span class="Color_Red">' +
                infoes.Result[i].Count + '</span>）</td>';
            if ((i + 1) % intNumPerLine == 0 && i != 0) {
                strResult += "</tr>";
                $("#" + objID).append(strResult);
                strResult = "<tr>";
            }
        }
    });
}

function ShowCaseTypeSelect(objID) {
    //PID：服务导航栏目的父ID，默认指定为 000200030005；
    //GetAllChild：是否获取所有事项子分类，1是，0不是
    $.getJSON(AppFunctionUrlOnlineOffice + "?action=GetCaseType&PID=000200030005&GetAllChild=0&ClientSiteKey=" + ClientSiteKey + "&callback=?", function (data) {

        var SeletedOfficeType = getQuery('OfficeType', '');
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {
            $("#ShowCaseNavigation").html('<table width="100%" border="0" cellspacing="0" class="MarginBottom" cellpadding="6"><tr><td  align="center">' +
            '<span style="color:Red;">暂无信息</span></td></tr></table>'
            );
            return;
            //alert($("#ShowCaseNavigation").attr("outerHTML"))
        }
        strResult += '<select name="OfficeType" id="OfficeType">';
        strResult += '    <option value="">请选择事项类型</option>';

        for (var i = 0; i < infoes.Result.length; i++) {
            if (infoes.Result[i].RulesId == SeletedOfficeType)
                strResult += '<option selected value="' + infoes.Result[i].RulesId + '">' + infoes.Result[i].Name + '</option>';
            else
                strResult += '<option value="' + infoes.Result[i].RulesId + '">' + infoes.Result[i].Name + '</option>';
        }
        strResult += '</select>';
        $("#" + objID).attr("outerHTML", strResult);
    });
}

function InitDataIndexHtm() {
    SetItemValue("Keyword", getQuery("Keyword", "")); //关键词的设置

    ShowCaseNavigation("tableCaseNavigation", 4, 5);
    ShowCaseTypeSelect("ShowCaseTypeSelect");
    ShowCaseList('tableCaseList', 10, 15)
}

function InitDataOfficeReferList() {
    SetItemValue("Keyword", getQuery("Keyword", "")); //关键词的设置
    ShowCaseReferList('tableCaseReferList', 10, 15);
}

function ShowCase() {
    var maxCaseAccessoriesNameLength = 50;
    var CaseID = getQuery("CaseID", "");
    var query = "?action=GetCase&ClientSiteKey=" + ClientSiteKey + "&CaseID=" + CaseID;
    query += "&callback=?";

    $.getJSON(AppFunctionUrlOnlineOffice + query, function (data) {
        var infoes = data;
        if (!infoes.IsSuc)
            return;

        $("#LinkForCaseRefer").html(
            '<a href="/List.aspx?KindID=5a54d2f4-92c6-4c12-bfed-025636b3c240&DeptID=' + infoes.Result[0].DeptId + '&CaseId=' + CaseID +
            '" target="_blank"><img src="/templates/gms/default/images/b02.gif" border="0"></a>&nbsp;' +
            '<a href="/List.aspx?KindID=36160f46-2fb3-4637-8ad1-3868ceee428d&CaseId=' + CaseID +
            '" target="_blank"><img src="/templates/gms/default/images/b01.gif" border="0"></a>&nbsp;'
            );
        if (infoes.Result[0].IsOnline == "1") {
            $("#LinkForCaseRefer").html($("#LinkForCaseRefer").html() +
                '<a href="/List.aspx?KindID=39987814-cbb0-4099-b007-c569961a92bc&InfoID=' + CaseID + '&InfoTreeID=' + infoes.Result[0].CategoryId +
                '" target="_blank"><img src="/templates/gms/default/images/b03.gif" border="0"></a>&nbsp;'
                );
        }
        //部门名称
        var DeptName = "";
        $.getJSON(AppFunctionUrlOnlineOffice + "?action=GetDeptName&DeptID=" + infoes.Result[0].DeptId + "&callback=?", function (deptData) {
            if (!deptData.IsSuc)
                return;
            DeptName = deptData.Message;
            $("#DeptName").html(DeptName + " ");                          //部门名称
        });
        //事项分类名称
        var CaseType = "";
        $.getJSON(AppFunctionUrlOnlineOffice + "?action=GetCaseType&ClientSiteKey=" + ClientSiteKey + "&OfficeType=" + infoes.Result[0].CategoryId + "&callback=?", function (CaseTypeData) {
            if (!CaseTypeData.IsSuc)
                return;
            CaseType = CaseTypeData.Result[0].Name;
            $("#CaseType").html(CaseType + " ");                          //事项类型名称
        });
        var isOnline = "";
        if (infoes.Result[0].IsOnline == "1")
            isOnline = "是";
        else
            isOnline = "否";
        $("#Title").html(infoes.Result[0].Name + " ");                //事项名称
        $("#IsOnline").html((infoes.Result[0].IsOnline == "1" ? "在线办理" : "现场办理"));         //是否在线办理
        $("#TimeLimit").html(infoes.Result[0].TimeLimit + " ");       //承诺时间
        $("#Cost").html(infoes.Result[0].Cost + " ");                 //收费标准
        $("#Link").html(infoes.Result[0].Link + " ");                 //联系方式
        $("#Guide").val(infoes.Result[0].Guide + " ");                //办事指南
        //$("#Policy").val(infoes.Result[0].Policy+" ");            //相关政策
        $("#DeclareData").val(infoes.Result[0].DeclareData + " ");    //申报材料

        $("#CaseCode").html(infoes.Result[0].CaseCode + " ");                 //事项编号
        $("#CheckLevel").html(infoes.Result[0].CheckLevel + " ");             //审批层级
        $("#LegalUnit").html(infoes.Result[0].LegalUnit + " ");               //法定实施许可主体
        $("#ActualUnit").html(infoes.Result[0].ActualUnit + " ");             //实际实施许可主体
        $("#BlameDept").html(infoes.Result[0].BlameDept + " ");               //责任处室
        $("#RelatedDept").html(infoes.Result[0].RelatedDept + " ");           //审批关联部门
        $("#AllowPersons").html(infoes.Result[0].AllowPersons + " ");         //许可申请人种类
        $("#LegalTimeLimit").html(infoes.Result[0].LegalTimeLimit + " ");     //法定期限
        $("#AnnualInspection").html(infoes.Result[0].AnnualInspection + " "); //年检情况
        $("#AccordingTo").html(infoes.Result[0].AccordingTo + " ");           //设立依据

        $("#AccordingTo").html(infoes.Result[0].AccordingTo + " ");           //设立依据
        $("#AccordingFiles").html(infoes.Result[0].AccordingFiles + " ");     //文件名称及文号
        $("#ApplyCondition").html(infoes.Result[0].ApplyCondition + " ");     //申报条件
        $("#Address").html(infoes.Result[0].Address + " ");                   //受理地点

        $("#Guide").html(infoes.Result[0].Guide + " ");                   //办理流程

        $.getJSON(AppFunctionUrlOnlineOffice + "?action=GetCaseAccessories&CaseID=" + CaseID + "&callback=?",
        function (CaseAccessoriesData) {
            $("#CaseAccessories").html('');
            if (!CaseAccessoriesData.IsSuc) {
                $("#CaseAccessories").append('<li>' + CaseAccessoriesData.Message + '</li>');
                return;
            }
            for (var i = 0; i < CaseAccessoriesData.Result.length; i++) {
                var title = CaseAccessoriesData.Result[i].Name;
                if (CaseAccessoriesData.Result[i].Name.length > maxCaseAccessoriesNameLength)
                    title = title.substring(0, maxCaseAccessoriesNameLength) + "...";
                $("#CaseAccessories").append('<li><a href="' + CaseAccessoriesData.Result[i].Url +
                    '" title="' + CaseAccessoriesData.Result[i].Name + '" target="_blank"><font color="blue">' +
                    title + '</font></a></li>');
            }
        });

    });
}

function InitDataOfficeShow() {
    ShowCase();
}

function ShowCaseRefer() {
    var CaseReferID = getQuery("CaseReferID", "");
    var CaseID = getQuery("CaseID", "");
    var query = "?action=GetCaseRefer&ClientSiteKey=" + ClientSiteKey + "&CaseID=" + CaseID + "&CaseReferID=" + CaseReferID;
    query += "&callback=?";

    $.getJSON(AppFunctionUrlOnlineOffice + query, function (data) {
        var infoes = data;
        if (!infoes.IsSuc)
            return;
        //部门名称
        var DeptName = "";
        $.getJSON(AppFunctionUrlOnlineOffice + "?action=GetDeptName&DeptID=" + infoes.Result[0].DeptId + "&callback=?", function (deptData) {
            if (!deptData.IsSuc)
                return;
            DeptName = deptData.Message;
            $("#DeptAsk").html(DeptName);                          //部门名称
        });
        //事项名称
        var CaseName = "";
        $.getJSON(AppFunctionUrlOnlineOffice + "?action=GetCase&ClientSiteKey=" + ClientSiteKey + "&CaseID=" + infoes.Result[0].CaseId + "&callback=?", function (CaseData) {
            if (!CaseData.IsSuc)
                return;
            CaseName = CaseData.Result[0].Name;
            $("#CaseAsk").html(CaseName);                          //事项名称
        });
        var state = "";
        if (infoes.Result[0].State == "1")
            state = "已回复";
        else
            state = "未回复";
        $("#NameAsk").html(infoes.Result[0].Name + " ");      //姓名
        $("#Title").html(infoes.Result[0].Title + " ");       //标题
        $("#myContent").val(infoes.Result[0].Content);   //咨询内容
        $("#DateAsk").html(infoes.Result[0].AddTime + " ");   //咨询时间
        $("#State").html(state + " ");                        //状态
        $("#Reply").val(infoes.Result[0].Reply);       //回复内容
        $("#DateReply").html(infoes.Result[0].ReplyTime + " ");   //回复时间

    });
}

function InitDataOfficeReferShow() {
    ShowCaseRefer();
}

//申请列表
function ShowCaseApplyList(objID, pageSize, linkPage) {
    var CaseID = getQuery("CaseID", "");
    var query = "?action=GetCaseApply&ClientSiteKey=" + ClientSiteKey + "&page=" + page + "&pageSize=" + pageSize;
    query += CaseID == "" ? "" : ("&CaseID=" + CaseID);
    query += "&callback=?";
    $.getJSON(AppFunctionUrlOnlineOffice + query, function (data) {
        var infoes = data;

        var strResult = "";
        if (!infoes.IsSuc) {
            $("#" + objID).html('<tr colspan="3">' +
            '<span style="color:Red;">' + infoes.Message + '</span></tr>'
            );
            return;
        }

        var myUrl = "";
        var addDate;
        var state = "";
        for (var i = 0; i < infoes.Result.length; i++) {
            if (infoes.Result[i].IsSecret == "1")
                myUrl = '/List.aspx?KindID=09294231-9169-457c-ba21-30053bc8f2be';
            else
                myUrl = '/List.aspx?KindID=066fecaa-f689-4895-8da4-0ebf1165dc7d&CaseApplyID=' + infoes.Result[i].CaseApplyId;
            switch (infoes.Result[i].CaseState) {
                case "0":
                    state = "未受理";
                    break;
                case "1":
                    state = "已受理";
                    break;
                case "2":
                    state = "已办结";
                    break;
                default:
                    state = "未受理";
                    break;
            }

            strResult = '<tr>';
            strResult += '    <td><a href="' + myUrl + '" target="_blank">' + infoes.Result[i].CaseApplyId + '</a></td>';
            strResult += '    <td align="center">' + MyDateFormat(infoes.Result[i].AddTime, "yyyy-MM-dd") + '</td>';
            strResult += '    <td align="center">' + state + '</td>';
            strResult += '</tr>';

            $("#" + objID).append(strResult);
        }

        strResult = '<tr>';
        strResult += '  <td colspan="4" class="Page">';
        strResult += '      <div class="RecordList">';
        strResult += ShowPerPage(pageSize, parseInt(infoes.RecordCount), linkPage);
        strResult += '      </div>';
        strResult += '  </td>';
        strResult += '</tr>';

        $("#" + objID).append(strResult);

        EndWait();
    });
}


//申请最近列表
function ShowCaseApplyTop(objID, count) {
    var query = "?action=GetCaseApply&ClientSiteKey=" + ClientSiteKey + "&page=1&pageSize=" + count + "&State=2";
    query += "&callback=?";


    $.getJSON(AppFunctionUrlOnlineOffice + query, function (data) {
        var infoes = data;

        var strResult = "";
        if (!infoes.IsSuc) {
            $("#" + objID).html('<tr colspan="3">' +
            '<span style="color:Red;">暂无信息</span></tr>'
            );
            return;
        }

        var myUrl = "";
        var addDate;
        var state = "";

        for (var i = 0; i < infoes.Result.length; i++) {
            strResult = "";
            if (infoes.Result[i].IsSecret == "1")
                myUrl = '/List.aspx?KindID=09294231-9169-457c-ba21-30053bc8f2be';
            else
                myUrl = '/List.aspx?KindID=066fecaa-f689-4895-8da4-0ebf1165dc7d&CaseApplyID=' + infoes.Result[i].CaseApplyId;
            switch (infoes.Result[i].CaseState) {
                case "0":
                    state = "未受理";
                    break;
                case "1":
                    state = "已受理";
                    break;
                case "2":
                    state = "已办结";
                    break;
                default:
                    state = "未受理";
                    break;
            }

            caseID = infoes.Result[i].CaseApplyId;

            strResult += '<tr>';
            strResult += '    <td width="70" align="right">受理编号</td>';
            strResult += '    <td><a href="' + myUrl + '" target="_blank">' + caseID + '</a></td>';
            strResult += '</tr>';

            strResult += '<tr>';
            strResult += '    <td width="70" align="right">受理单位</td>';
            strResult += '    <td id="depTd' + i + '">' + infoes.Result[i].DeptName; +'</td>';
            strResult += '</tr>';

            strResult += '<tr>';
            strResult += '    <td width="70" align="right">受理时间</td>';
            strResult += '    <td>' + MyDateFormat(infoes.Result[i].AddTime, "yyyy-MM-dd") + '</td>';
            strResult += '</tr>';

            strResult += '<tr>';
            strResult += '    <td width="70" align="right">受理结果</td>';
            strResult += '    <td>成功</td>';
            strResult += '</tr>';

            if (i != infoes.Result.length - 1) {
                strResult += '<tr class="Line"><td colspan="2">----------------------------------</td></tr>';
            }

            $("#" + objID).append(strResult);

        }
    });
}

function InitDataMainSite() {
    //ShowCaseTop("ulCaseTop", 5, 15);
    ShowCasebanshi1("ulCaseTop", "599667e743554fba8ac027b1828c2830", 15, 15);
    ShowCasebanshi1("ulCaseTop1", "930486865a2b48ea97da2d093bc899e2", 15, 15);
    //ShowCasebanshi1("ulCaseTop2",OfficeType,  5, 15);

}

function InitDataListOnlineOffice() {
    ShowCaseTop("ulCaseTop", 999, 15);
}

function InitDataListOnlineOfficeApply() {
    var linkPage = "/list.aspx?KindID=d723a1ae-0787-45d5-a10f-6743557496a6";
    var CaseID = getQuery("CaseID", "");
    linkPage += CaseID == "" ? "" : ("&CaseID=" + CaseID)
    ShowCaseApplyList("tableCaseApplyList", 10, linkPage);
    ShowCaseReferListSingle("ulCaseApply", 7);
    ShowCaseReferListSingle("gongshigonggao", 5);
}

function InitDataShowCaseApplyList() {
    ShowCaseApplyList("tableCaseApplyList", 10, "/List.aspx?KindID=889fab15-b2e8-4499-a73c-97c9d95a92e6");
}

//办事申请列表
function ShowCaseApply() {
    var CaseApplyID = getQuery('CaseApplyID', '');
    var CheckKey = getQuery('CheckKey', '');
    var backUrl = getQuery('backUrl', '');
    var query = "?action=GetCaseApply&ClientSiteKey=" + ClientSiteKey + "&CaseApplyID=" + CaseApplyID;
    if (CheckKey != "")
        query += "&CheckKey=" + CheckKey
    query += "&callback=?";

    $.getJSON(AppFunctionUrlOnlineOffice + query, function (data) {
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {
            if (backUrl != "") {
                alert(infoes.Message);
                window.location = backUrl;
            }
            return;
        }
        var state = "";
        switch (infoes.Result[0].CaseState) {
            case "0":
                state = "未受理";
                break;
            case "1":
                state = "已受理";
                break;
            case "2":
                state = "已办结";
                break;
            default:
                state = "未受理";
                break;
        }
        //事项名称
        $.getJSON(AppFunctionUrlOnlineOffice + "?action=GetCase&ClientSiteKey=" + ClientSiteKey + "&CaseID=" + infoes.Result[0].CaseId + "&callback=?", function (CaseData) {
            if (!CaseData.IsSuc)
                return;
            $("#CaseName").html(CaseData.Result[0].Name + " "); //事项名称
        });

        $("#Name").html(infoes.Result[0].Name + " ");
        $("#AddTime").html(infoes.Result[0].AddTime + " ");
        $("#State").html(state + " ");
        $("#Result").val(infoes.Result[0].Result);
    });
}

function InitDataShowCaseApply() {
    ShowCaseApply();
}

function InitDataListOnlineOfficeRefer() {
    ShowCaseReferList("tableCaseReferList", 10, 15);
}




function EndWait() {
    try {
        $("#_wznWait").remove();
    }
    catch (err) {
    }
}

///Mr.yang
//办事列表首页
function ShowCasebanshi1(objID, OfficeType, pageSize, intMaxTitleLength) {
    $("#" + objID).html("");
    //PID：服务导航栏目的父ID，默认指定为 000200030005；
    //GetAllChild：是否获取所有事项子分类，1是，0不是
    var KindID = OfficeType;
    var linkPage = "?OfficeType=" + KindID;
    var query = "?action=GetCase&OfficeType=" + KindID + "&ClientSiteKey=" + ClientSiteKey + "&GetAllChild=1&page=" + page + "&pageSize=" + pageSize;
    query += "&callback=?";
    $.getJSON(AppFunctionUrlOnlineOffice + query, function (data) {
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {
            $("#" + objID).append('<li>' +
            '<span style="color:Red;">' + infoes.Message + '</span></li>'
            );
            return;
        }

        var caseName = "";
        for (var i = 0; i < infoes.Result.length && i < pageSize; i++) {
            caseName = infoes.Result[i].Name;
            if (caseName.length > intMaxTitleLength)
                caseName = infoes.Result[i].Name.substring(0, intMaxTitleLength);
            switch (OfficeType) {
                case '599667e743554fba8ac027b1828c2830':
                    strResult = '<li><span><a href="/List.aspx?KindID=1d717884-02ca-4f56-8fee-8d8f3d37898f&CaseID=' + infoes.Result[i].CaseId + '" target="_blank">';
                    strResult += '  <img src="/Templates/GMS/Default/images/online01.gif" width="16" height="16" /></a>';

                    var CACount = parseInt(infoes.Result[i].CACount);
                    if (CACount > 0) {
                        strResult += '<a href="/List.aspx?KindID=1d717884-02ca-4f56-8fee-8d8f3d37898f&CaseID=' + infoes.Result[i].CaseId + '" target="_blank">';
                        strResult += '  <img src="/Templates/GMS/Default/images/online02.gif" width="16" height="16" /></a>';
                    }
                    else {
                        strResult += '  <img src="/Templates/GMS/Default/images/online06.gif" width="16" height="16" />';
                    }

                    if (infoes.Result[i].IsOnline == "1") {
                        strResult += '<a href="/List.aspx?KindID=09294231-9169-457c-ba21-30053bc8f2be&CaseID=' + infoes.Result[i].CaseId + '" target="_blank">';
                        strResult += '  <img src="/Templates/GMS/Default/images/online03.gif" width="16" height="16" /></a>';
                        strResult += '<a href="/List.aspx?KindID=39987814-cbb0-4099-b007-c569961a92bc&InfoID=' + infoes.Result[i].CaseId + '&InfoTreeID=' + infoes.Result[i].CategoryId + '" target="_blank">';
                        strResult += '  <img src="/Templates/GMS/Default/images/online04.gif" width="16" height="16" /></a>';
                    }
                    else {
                        strResult += '  <img src="/Templates/GMS/Default/images/online06.gif" width="16" height="16" />';
                        strResult += '  <img src="/Templates/GMS/Default/images/online06.gif" width="16" height="16" />';
                    }
                    strResult += '<a href="/List.aspx?KindID=5a54d2f4-92c6-4c12-bfed-025636b3c240&DeptID=' + infoes.Result[i].DeptId + '&CaseId=' + infoes.Result[i].CaseId + '" target="_blank">';
                    strResult += '  <img src="/Templates/GMS/Default/images/online05.gif" width="16" height="16" /></a>';

                    strResult += '</span><a href="/List.aspx?KindID=1d717884-02ca-4f56-8fee-8d8f3d37898f&CaseID=' + infoes.Result[i].CaseId + '" target="_blank" title="' + infoes.Result[i].Name + '">';
                    strResult += (i + 1) + '.' + caseName + '</a> </li>';
                    break;
                case '930486865a2b48ea97da2d093bc899e2':
                    strResult = '<li><span><a href="/List.aspx?KindID=1d717884-02ca-4f56-8fee-8d8f3d37898f&CaseID=' + infoes.Result[i].CaseId + '" target="_blank">';
                    strResult += '  <img src="/Templates/GMS/Default/images/online01.gif" width="16" height="16" /></a>';

                    var CACount = parseInt(infoes.Result[i].CACount);
                    if (CACount > 0) {
                        strResult += '<a href="/List.aspx?KindID=1d717884-02ca-4f56-8fee-8d8f3d37898f&CaseID=' + infoes.Result[i].CaseId + '" target="_blank">';
                        strResult += '  <img src="/Templates/GMS/Default/images/online02.gif" width="16" height="16" /></a>';
                    }
                    else {
                        strResult += '  <img src="/Templates/GMS/Default/images/online06.gif" width="16" height="16" />';
                    }

                    strResult += '<a href="/List.aspx?KindID=09294231-9169-457c-ba21-30053bc8f2be&CaseID=' + infoes.Result[i].CaseId + '" target="_blank">';
                    strResult += '  <img src="/Templates/GMS/Default/images/online03.gif" width="16" height="16" /></a>';
                    if (infoes.Result[i].IsOnline == "1") {
                        strResult += '<a href="/List.aspx?KindID=39987814-cbb0-4099-b007-c569961a92bc&InfoID=' + infoes.Result[i].CaseId + '&InfoTreeID=' + infoes.Result[i].CategoryId + '" target="_blank">';
                        strResult += '  <img src="/Templates/GMS/Default/images/online04.gif" width="16" height="16" /></a>';
                    }
                    else {
                        strResult += '  <img src="/Templates/GMS/Default/images/online06.gif" width="16" height="16" />';
                    }
                    strResult += '<a href="/List.aspx?KindID=5a54d2f4-92c6-4c12-bfed-025636b3c240&DeptID=' + infoes.Result[i].DeptId + '&CaseId=' + infoes.Result[i].CaseId + '" target="_blank">';
                    strResult += '  <img src="/Templates/GMS/Default/images/online05.gif" width="16" height="16" /></a>';

                    strResult += '</span><a href="/List.aspx?KindID=1d717884-02ca-4f56-8fee-8d8f3d37898f&CaseID=' + infoes.Result[i].CaseId + '" target="_blank" title="' + infoes.Result[i].Name + '">';
                    strResult += (i + 1) + '.' + caseName + '</a> </li>';
                    break;
                default:
                    return;
            }
            $("#" + objID).append(strResult);
        }
        /*
        strResult = '      <div class="page">';
        strResult += ShowPerPage(pageSize, parseInt(infoes.RecordCount), linkPage);
        strResult += '      </div>';
        */


        //$("#"+objID).append(strResult);
    });
}

//获取附件
function GetCaseAccessories(objID, page, pageSize, CaseID, IsPage, intMaxTitleLength) {
    $("#" + objID).html("");

    var KindID = getQuery("KindID", "");
    var strCaseID = "";
    if (CaseID != "")
        strCaseID = "&CaseID=" + CaseID;
    var linkPage = "/list.aspx?KindID=" + KindID + "&action=GetCaseAccessories" + strCaseID + "&page=" + page + "&pageSize=" + pageSize;
    var query = "?action=GetCaseAccessories" + strCaseID + "&page=" + page + "&pageSize=" + pageSize;
    query += "&callback=?";
    $.getJSON(AppFunctionUrlOnlineOffice + query, function (data) {
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {
            $("#" + objID).append('<li>' +
            '<span style="color:Red;">' + infoes.Message + '</span></li>'
            );
            return;
        }

        var CaseAccessoriesName = "";
        strResult = "<ul>";
        for (var i = 0; i < infoes.Result.length && i < pageSize; i++) {
            CaseAccessoriesName = infoes.Result[i].Name;
            if (CaseAccessoriesName.length > intMaxTitleLength)
                CaseAccessoriesName = infoes.Result[i].Name.substring(0, intMaxTitleLength);

            strResult += "<li><a href='" + infoes.Result[i].Url + "'>" + CaseAccessoriesName + "</a></li>";
        }
        strResult += "</ul>";
        if (IsPage) {
            strResult += '<div class="page">';
            strResult += ShowPerPage(pageSize, parseInt(infoes.RecordCount), linkPage);
            strResult += '</div>';
        }
        $("#" + objID).append(strResult);
    });
}

///Mr.yang
//办事列表
function ShowCasebanshi(objID, pageSize, intMaxTitleLength) {
    $("#" + objID).html("");
    //PID：服务导航栏目的父ID，默认指定为 000200030005；
    //GetAllChild：是否获取所有事项子分类，1是，0不是
    var KindID = getQuery("OfficeType", "");
    var linkPage = "?OfficeType=" + KindID;
    var query = "?action=GetCase&OfficeType=" + KindID + "&ClientSiteKey=" + ClientSiteKey + "&GetAllChild=1&page=" + page + "&pageSize=" + pageSize;
    query += "&callback=?";
    $.getJSON(AppFunctionUrlOnlineOffice + query, function (data) {
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {
            $("#" + objID).append('<li>' +
            '<span style="color:Red;">' + infoes.Message + '</span></li>'
            );
            return;
        }

        var caseName = "";
        for (var i = 0; i < infoes.Result.length && i < pageSize; i++) {
            caseName = infoes.Result[i].Name;
            if (caseName.length > intMaxTitleLength)
                caseName = infoes.Result[i].Name.substring(0, intMaxTitleLength);

            strResult = '<li><span><a href="/List.aspx?KindID=1d717884-02ca-4f56-8fee-8d8f3d37898f&CaseID=' + infoes.Result[i].CaseId + '" target="_blank">';
            strResult += '  <img src="/Templates/GMS/Default/images/online01.gif" width="16" height="16" /></a>';

            var CACount = parseInt(infoes.Result[i].CACount);
            if (CACount > 0) {
                strResult += '<a href="/List.aspx?KindID=1d717884-02ca-4f56-8fee-8d8f3d37898f&CaseID=' + infoes.Result[i].CaseId + '" target="_blank">';
                strResult += '  <img src="/Templates/GMS/Default/images/online02.gif" width="16" height="16" /></a>';
            }
            else {
                strResult += '  <img src="/Templates/GMS/Default/images/online06.gif" width="16" height="16" />';
            }

            if (infoes.Result[i].IsOnline == "1") {
                strResult += '<a href="/List.aspx?KindID=39987814-cbb0-4099-b007-c569961a92bc&InfoID=' + infoes.Result[i].CaseId + '&InfoTreeID=' + infoes.Result[i].CategoryId + '" target="_blank">';
                strResult += '  <img src="/Templates/GMS/Default/images/online04.gif" width="16" height="16" /></a>';
                strResult += '<a href="/List.aspx?KindID=09294231-9169-457c-ba21-30053bc8f2be&CaseID=' + infoes.Result[i].CaseId + '" target="_blank">';
                strResult += '  <img src="/Templates/GMS/Default/images/online03.gif" width="16" height="16" /></a>';
            }
            else {
                strResult += '  <img src="/Templates/GMS/Default/images/online06.gif" width="16" height="16" />';
                strResult += '  <img src="/Templates/GMS/Default/images/online06.gif" width="16" height="16" />';
            }
            strResult += '<a href="/List.aspx?KindID=5a54d2f4-92c6-4c12-bfed-025636b3c240&DeptID=' + infoes.Result[i].DeptId + '&CaseId=' + infoes.Result[i].CaseId + '" target="_blank">';
            strResult += '  <img src="/Templates/GMS/Default/images/online05.gif" width="16" height="16" /></a>';

            strResult += '</span><a href="/List.aspx?KindID=1d717884-02ca-4f56-8fee-8d8f3d37898f&CaseID=' + infoes.Result[i].CaseId + '" target="_blank" title="' + infoes.Result[i].Name + '">';
            strResult += (i + 1) + '.' + caseName + '</a> </li>';

            $("#" + objID).append(strResult);
        }
        strResult = '      <div class="page">';
        strResult += ShowPerPage(pageSize, parseInt(infoes.RecordCount), linkPage);
        strResult += '      </div>';


        $("#" + objID).append(strResult);
    });
}
//办事指南
function ShowbanshiList(objID, pageSize, intMaxTitleLength) {
    var Keyword = escape(getQuery("Keyword", ""));
    var CaseID = getQuery("CaseID", "");

    $("#" + objID).html("");

    if (CaseID != "")
        linkPage += "&CaseID=" + CaseID;

    //State，状态：0未回复，1已回复，为空则获取全部
    var query = "?action=GetCaseRefer&ClientSiteKey=" + ClientSiteKey + "&page=1&pageSize=" + pageSize;
    if (Keyword != "")
        query += "&Keyword=" + Keyword;
    if (CaseID != "")
        query += "&CaseID=" + CaseID;
    query += "&callback=?";

    $.getJSON(AppFunctionUrlOnlineOffice + query, function (data) {
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {
            EndWait();
            $("#" + objID).append('<tr>' +
            '<td colspan="3" align="center"><span style="color:Red;">' + infoes.Message + '</span></td></tr>'
            );
            return;
        }

        for (var i = 0; i < infoes.Result.length && i < 6; i++) {

            if (infoes.Result[i].State == '1')
                state = '已答复';
            else
                state = '未答复';
            strResult = '<tr>';
            title = infoes.Result[i].Title;
            if (title.length > intMaxTitleLength)
                title = infoes.Result[i].Title.substr(0, intMaxTitleLength) + '...';
            strResult += '    <td><a  style="margin-left:30px;" href="/List.aspx?KindID=85643794-ece9-4769-9abf-f5d2904376e8&CaseID=' + CaseID + '&CaseReferID=' + infoes.Result[i].CaseReferId +
                '" title="' + infoes.Result[i].Title + '" target="_blank">' + title + '</a></td>';
            strResult += '  <td align="center">' + infoes.Result[i].CaseName + '</td>';
            strResult += '  <td align="center">' + state + '</td>';
            strResult += '  <td align="center">' + infoes.Result[i].DeptName + '</td>';
            strResult += '  <td align="center">' + MyDateFormat(infoes.Result[i].AddTime, "yyyy-MM-dd") + '</td>';
            strResult += '</tr>';

        }
        $("#" + objID).append(strResult);

        EndWait();
    });
}
//公示公告
function ShowCaseReferListSingle(objID, pageSize) {
    var Keyword = escape(getQuery("Keyword", ""));
    var CaseID = getQuery("CaseID", "");
    var KindID = getQuery("KindID", "");
    var linkPage = "";
    
    if (CaseID != "")
        linkPage += "&CaseID=" + CaseID;

    //State，状态：0未回复，1已回复，为空则获取全部
    var query = "?action=GetCaseApply&ClientSiteKey=" + ClientSiteKey + "&State=2&page=1&pageSize=" + pageSize;
    query += "&callback=?";
    
    $.getJSON(AppFunctionUrlOnlineOffice + query, function (data) {
        
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {
            EndWait();
            $("#" + objID).append('<li>' + infoes.Message + '</li>'
            );
            return;
        }
        if (infoes.Result.length <= 0) {
            $("#" + objID).append('<li>暂无信息！</li>');
            return;
        }
        var myUrl = "";
        for (var i = 0; i < infoes.Result.length; i++) {
            var addDate = eval('new Date(' + infoes.Result[i].AddTime.replace(/\d+(?=-[^-]+$)/, function (a) { return parseInt(a, 10) - 1; }).match(/\d+/g) + ')');
            if (infoes.Result[i].IsSecret == "1")
                myUrl = '/List.aspx?KindID=09294231-9169-457c-ba21-30053bc8f2be';
            else
                myUrl = '/List.aspx?KindID=066fecaa-f689-4895-8da4-0ebf1165dc7d&CaseApplyID=' + infoes.Result[i].CaseApplyId;

            strResult = " <li><a href='" + myUrl + "' target='_blank'>编号：" + infoes.Result[i].CaseApplyId + "</a>";
            strResult += "&nbsp;&nbsp;&nbsp;&nbsp;<a href='" + myUrl + "' target='_blank'>单位：" + infoes.Result[i].DeptName + "</a>";
            var dt = infoes.Result[i].AddTime.split(" ")[0];//new Date(infoes.Result[i].AddTime);
            strResult += "&nbsp;&nbsp;&nbsp;&nbsp;时间：" + dt + "";
            strResult += "&nbsp;&nbsp;&nbsp;&nbsp;状态：已办结</li>";
            $("#" + objID).append(strResult);
        }
        
        //$("#"+objID).append(strResult);

        EndWait();
    });
}
//事项名称
function ShowCaseTypeName(objID) {
    //PID：服务导航栏目的父ID，默认指定为 000200030005；
    //GetAllChild：是否获取所有事项子分类，1是，0不是
    //var test=AppFunctionUrlOnlineOffice + "?action=GetCaseType&OfficeType=000200030005&GetAllChild=1&ClientSiteKey=" + ClientSiteKey+"&callback=?";
    $.getJSON(AppFunctionUrlOnlineOffice + "?action=GetCaseType&PID=000200030005&GetAllChild=1&ClientSiteKey=" + ClientSiteKey + "&callback=?", function (data) {
        var SeletedOfficeType = getQuery('OfficeType', '');
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {
            $("#" + objID).append('<li>' + infoes.Message + '</li>');
            return;
            //alert($("#ShowCaseNavigation").attr("outerHTML"))
        }
        if (infoes.Result.length <= 0) {
            $("#" + objID).append('<li>暂无信息！</li>');
            return;
        }
        for (var i = 0; i < infoes.Result.length; i++) {
            if (infoes.Result[i].RulesId == SeletedOfficeType) {
                $("#" + objID).append("<li onmouseover='govTab('one',1,1)' id='one1' class='l_home'><a href='/List.aspx?KindID=7c2246ff-ffe2-40eb-9cce-eb1928264663&OfficeType=" + infoes.Result[i].RulesId + "'>" + infoes.Result[i].Name + "</a></li>");
                break;
            }
        }
    });
}
//事项分类列表
function ShowCaseType(objID, Pid) {
    //PID：服务导航栏目的父ID，默认指定为 000200030005；
    //GetAllChild：是否获取所有事项子分类，1是，0不是
    $.getJSON(AppFunctionUrlOnlineOffice + "?action=GetCaseType&PID=" + Pid + "&GetAllChild=0&ClientSiteKey=" + ClientSiteKey + "&callback=?", function (data) {
        $("#" + objID).html("");
        var SeletedOfficeType = getQuery('OfficeType', '');
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {
            $("#" + objID).append('<li>' + infoes.Message + '</li>');
            return;
            //alert($("#ShowCaseNavigation").attr("outerHTML"))
        }
        if (infoes.Result.length <= 0) {
            $("#" + objID).append('<li>暂无信息！</li>');
            return;
        }
        for (var i = 0; i < infoes.Result.length; i++) {
            if (infoes.Result[i].RulesId == SeletedOfficeType)
                $("#" + objID).append("<li><a href='/List.aspx?KindID=0ca8c9d4-c1dd-411f-ba69-023798c98cb5&OfficeType=" + infoes.Result[i].RulesId + "'>" + infoes.Result[i].Name + "</a></li>");
            else
                $("#" + objID).append("<li><a href='/List.aspx?KindID=0ca8c9d4-c1dd-411f-ba69-023798c98cb5&OfficeType=" + infoes.Result[i].RulesId + "'>" + infoes.Result[i].Name + "</a></li>");
        }
    });
}

function ShowCaseChannel(objID, intMaxTitleLength) {

    $.getJSON(AppFunctionUrlOnlineOffice + "?action=GetCaseChannel&ClientSiteKey=" + ClientSiteKey + "&callback=?", function (data) {
        $("#" + objID).html("");
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {

            $("#" + objID).html('<li><span style="color:Red;">暂无信息</span></li>');
            return;
        }

        var title = "";
        strResult = "";
        for (var i = 0; i < infoes.Result.length && i < 23; i++) {
            title = infoes.Result[i].Name;
            if (title.length > intMaxTitleLength)
                title = infoes.Result[i].Name.substr(0, intMaxTitleLength);
            strResult = '    <li><a href="/List.aspx?KindID=0ca8c9d4-c1dd-411f-ba69-023798c98cb5&ChannelID=' + infoes.Result[i].CustomerId +
                '" title="' + infoes.Result[i].Name + '"">' + title + '</a></li>';
            $("#" + objID).append(strResult);
        }
    });
}

///事项分类初始化
function InitDataOfficeType() {
    ShowCaseType('ulCaseType', '0002000300050002');
    ShowCaseType('ulCaseType1', '0002000300050001');
    ShowCaseChannel('ulCaseType2', 4);
    ShowCaseType('ulCaseType3', '0002000300050004');

    ShowCaseChannel('ulCaseChannle', 4);
}
//办事列表初始化
function InitDataOfficeTypeCaseList() {
    ShowCaseTypeName("OfficeCaseTypeName");
    ShowCaseReferListSingle("gongshigonggao", 1);
    ShowCasebanshi("caseList", 15, 30);
}
//在线办事
function InitDataOfficeTypeOnlineCaseList() {
    InitDataOfficeType();
    //ShowCaseTypeName("OfficeCaseTypeName");
    ShowCaseReferListSingle("gongshigonggao", 2);
    ShowbanshiList("banshizhinan", 6, 30);
}
//办事公告
function InitDataOfficeTypeOnlineGongGao() {
    ShowCaseApplyList("tableCaseApplyList", 10, "/List.aspx?KindID=889fab15-b2e8-4499-a73c-97c9d95a92e6");
    ShowCaseReferListSingle("gongshigonggao", 1);
}
