﻿//公共变量定义
var ClientSiteKey = "";//站点ID

var AppFunctionUrlOnlineOffice="";//应用数据处理URL，主要用作应用数据信息获取

var AppHelperUrl="/Applications/AppHelper.ashx";//本地应用数据处理页面
var AppNameOnlineOffice = escape("办事大厅"); //应用名称

var SiteTitle="";//站点标题信息
var PageHeader="";//页面头

var PageFooter = ""; //页面脚

var page = null;

function S4() {
    return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
}

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;


$(document).ready(function()
{
 page = parseInt(MyGetQuery('page', 1));//当前页码
 _caseID =MyGetQuery('InfoID', 1);
 });

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);
        });
}



//应用页面初始化初始化
//pageToBeInit，页面初始化标记
//isShowHeaderFooter，是否显示页头页脚，true显示，false不显示
function InitAppPageOnlineOffice(pageToBeInit,isShowHeaderFooter)
{ 
   
    var query="?OperType=InitGlobalVariable&AppName="+AppNameOnlineOffice+"&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("lbCaseName");
                    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":
                    //InitDataOfficeType();
                    InitDataMainSite();
                    break;
                case "ListOnlineOffice":
                    InitDataListOnlineOffice();
                    GetOfficeTypeName("CurrentCaseType", unescape(MyGetQuery("Type", "")));
                    break;
                case "ListOnlineOfficeApply":
                    InitDataListOnlineOfficeApply();
                    break;
                case "ListOnlineOfficeRefer":
                    InitDataListOnlineOfficeRefer();
                    break;
                case "OfficeType":
                InitDataOfficeType();
                break;
            case "OnlineOffice_CaseTypeList.html":
                ShowSubCaseTypeNavigation("CaseTypeBlock1", "0002000300050001", 10);
                ShowSubCaseTypeNavigation("CaseTypeBlock2", "0002000300050002", 10);
                ShowSubCaseTypeNavigation("CaseTypeBlock3", "0002000300050003", 10);
                ShowSubCaseTypeNavigation("CaseTypeBlock4", "0002000300050004", 10);
                ShowCaseReferTopBlock("TableCaseReferList", 6, 20);
                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 GetCaseName(targetObjID)
{
    var infoid = MyGetQuery('InfoID','');
    var infoTree = MyGetQuery('InfoTreeID','');
    
    $.getJSON(
        AppFunctionUrlOnlineOffice + "?action=GetCaseName&InfoID=" + infoid + "&InfoTreeID=" + infoTree + "&callback=?",
        function(msg) {
            $("#" + targetObjID).text(msg.Result);
        });
}

//获取办事事项名称
function ShowCaseAccessoriesOnApplyAdd(targetObjID, caseApplyID) 
{
    var infoid = MyGetQuery('InfoID','');
    var infoTree = MyGetQuery('InfoTreeID','');

    $.getJSON(
    AppFunctionUrlOnlineOffice + "?action=ShowCaseAccessoriesOnApplyAdd&InfoID=" + infoid + "&InfoTreeID=" + infoTree + "&caseApplyID=" + caseApplyID + "&callback=?",
    function(msg) {
        $("#" + targetObjID).html(msg.Result);
    });
}

//添加事项
function AddCaseApply() {
    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 += "&CaseID=" + _caseID;
    parm += "&CaseApplyId=" + _caseApplyID;
    parm += "&isSecret=" + ($("input[id='rbYes']").attr("checked")?1:0);
    

    $.getJSON(
    AppFunctionUrlOnlineOffice + parm + "&callback=?",
    function(msg) {
        if (msg.IsSuc) {
            alert("提交成功!");
        }
        else {
            alert("提交失败，原因：" + msg.Message);
        }
    });
}

//检测

function checkvalue() {
    if (form1.txtName.value == "") {
        window.alert("请填写您的姓名！");
        form1.txtName.focus();
        return false
    }
    return true;
}

//初始化事项咨询
function InitOfficeReferAdd()
{
    _referCaseID = MyGetQuery('CaseID','');
    
    ShowCaseSelect();
}

//获取咨询列表
var _referCaseID = null;
function ShowCaseSelect()
{
        $.getJSON(
        AppFunctionUrlOnlineOffice + "?action=ShowCaseSelect&ClientSiteKey="+ClientSiteKey+"&CaseID=" + _referCaseID + "&callback=?",
        function(msg) {
            $("#tdCaseList").html(msg.Result);
        });
}


function AddCaseRefer() 
{     
    var url = AppFunctionUrlOnlineOffice
    var parm = "?action=AddCR";
    parm += "&CaseID="+ $("#OfficeType").val();
    parm +="&txtName="+ escape($("#txtName").val());
    parm +="&txtTitle="+ escape($("#txtTitle").val());
    parm +="&txtContent="+ escape($("#txtContent").val());
    parm +="&txtEmail="+ escape($("#txtEmail").val());

    $.getJSON(
        url + parm +  "&callback=?",
        function(msg) {
            if(msg.IsSuc)
            {
                alert('咨询添加成功，请耐心等待管理员回复')
                window.close();
            }
            else
            {
                alert(msg.Message);
            }
        });
}

//输出分页
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( MyGetQuery("Keyword",""));
    var CaseID=MyGetQuery("CaseID","");
    var KindID=MyGetQuery("KindID","");
    var linkPage="/AppFrontPage/OnlineOffice/OfficeReferList.htm?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++) {
            
            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].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 href="/AppFrontPage/OnlineOffice/OfficeReferShow.htm?CaseID='+CaseID+'&CaseReferID=' + infoes.Result[i].CaseReferId +
                '" title="' + infoes.Result[i].Title + '" target="_blank">' + title + '</a></td>';
            strResult += '  <td align="center">'+(addDate.getYear()+'-'+(addDate.getMonth()+1)+'-'+addDate.getDate())+'</td>';
            strResult += '  <td 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( MyGetQuery("Keyword",""));
    var OfficeType=MyGetQuery("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="/AppFrontPage/OnlineOffice/OfficeShow.htm?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="/AppFrontPage/OnlineOffice/OfficeReferAdd.htm?DeptID=' + infoes.Result[i].DeptId + 
                '&CaseId=' + infoes.Result[i].CaseId + '" target="_blank">我要咨询</a></td>';
            strResult += '  <td width="80" align="center"><a class="lnk" href="/AppFrontPage/OnlineOffice/OfficeReferList.htm?&CaseID=' + infoes.Result[i].CaseId + 
                '" target="_blank">查看咨询</a></td>';
            if (infoes.Result[i].IsOnline == '1')
                strResult += '    <td width="80" align="center"><a href="/AppFrontPage/OnlineOffice/OfficeApplyAdd.htm?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 += "&OfficeType=" + (MyGetQuery("OfficeType", "") == "" ? "000200030005" : MyGetQuery("OfficeType", ""));
    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="/AppFrontPage/OnlineOffice/OfficeShow.htm?CaseID='+infoes.Result[i].CaseId+'" target="_blank">';
            strResult += '  <img src="/Templates/GMS/Default/images/online01.gif" width="16" height="16" /></a>';
            strResult += '<a href="/AppFrontPage/OnlineOffice/OfficeShow.htm?CaseID='+infoes.Result[i].CaseId+'" target="_blank">';
            strResult += '  <img src="/Templates/GMS/Default/images/online02.gif" width="16" height="16" /></a>';
            strResult += '<a href="/list.aspx?KindID=11a28b0a-84d2-436c-9e37-dcd2524c0f64&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="/AppFrontPage/OnlineOffice/OfficeApplyAdd.htm?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="/AppFrontPage/OnlineOffice/OfficeReferAdd.htm?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="/AppFrontPage/OnlineOffice/OfficeShow.htm?CaseID='+infoes.Result[i].CaseId+'" target="_blank" title="'+infoes.Result[i].Name+'">';
            strResult += (i+1)+'.'+caseName+'</a> </li>';
            
            $("#"+objID).append(strResult);
        }
        
        EndWait();
    });
}

//输出办事咨询头几条
function ShowCaseReferTopBlock(objID, pageSize, intMaxTitleLength) {
    //State，状态：0未回复，1已回复，为空则获取全部
    var query = "?action=GetCaseRefer&ClientSiteKey=" + ClientSiteKey + "&pageSize=" + pageSize;
    CaseID = MyGetQuery("CaseID", "");
    query += CaseID == "" ? "" : "&CaseID=" + CaseID;
    query += "&callback=?";

    $.getJSON(AppFunctionUrlOnlineOffice + query, function(data) {
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {
            EndWait();
            $("#" + objID).append('<tr><td  align="center" colspan=3><span style="color:Red;">' + infoes.Message + '</span></td></tr>');
            return;
        }

        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].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 href="/AppFrontPage/OnlineOffice/OfficeReferShow.htm?CaseID=' + CaseID + '&CaseReferID=' + infoes.Result[i].CaseReferId +
                '" title="' + infoes.Result[i].Title + '" target="_blank">' + title + '</a></td>';
            strResult += '  <td align="center">' + (addDate.getYear() + '-' + (addDate.getMonth() + 1) + '-' + addDate.getDate()) + '</td>';
            strResult += '  <td align="center">' + state + '</td>';
            strResult += '</tr>';
            $("#" + 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 class="zxbs-td2"><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 ShowSubCaseTypeNavigation(objID, officeType, intMaxTitleLength) {
    //PID：服务导航栏目的父ID，默认指定为 000200030005；
    //GetAllChild：是否获取所有事项子分类，1是，0不是
    officeType = officeType == "" ? "000200030005" : officeType;
    $.getJSON(AppFunctionUrlOnlineOffice + "?action=GetCaseType&PID=" + officeType + "&GetAllChild=0&ClientSiteKey=" + ClientSiteKey + "&callback=?", function(data) {

        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {

            $("#" + objID).html('<li><span style="color:Red;">信息获取失败！</span></li>');
            EndWait();
            return;
        }

        var title = "";
        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 = '<li><a href="/Templates/GMS/Default/OnlineOffice_CaseList.html?OfficeType=' + infoes.Result[i].RulesId + '&Type=' + escape(infoes.Result[i].Name) + '">' + infoes.Result[i].Name + '</a></li>';
            $("#" + objID).append(strResult);
        }
    });
    EndWait();
}

//快速通道导航
function ShowCaseChannelTypeSubNavigation(objID, intMaxTitleLength) {
    $.getJSON(AppFunctionUrlOnlineOffice + "?action=GetCaseChannel&ChannelID=&IsBySiteKey=1&GetAllChild=1&ClientSiteKey=" + ClientSiteKey + "&callback=?", function(data) {
        infoes = data;
        if (!infoes.IsSuc) {

            $("#" + objID).html('<div><span style="color:Red;">' + infoes.Message + '！</span></div>');
            EndWait();
            return;
        }
        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 = ' <li><a href="/Templates/GMS/Default/OnlineOffice_CaseList.html?ChannelID=' + infoes.Result[i].CustomerId + '&type=' + escape(infoes.Result[i].Name) + '">' +
            title + '</a></li>';
            $("#" + objID).append(strResult);
        }
    });

    EndWait();
}


function ShowCaseType(objID,Pid)
{
    //PID：服务导航栏目的父ID，默认指定为 000200030005；
    //GetAllChild：是否获取所有事项子分类，1是，0不是
var xx=AppFunctionUrlOnlineOffice + "?action=GetCaseType&PID="+Pid+"&GetAllChild=0&ClientSiteKey=" + ClientSiteKey+"&callback=?";
    $.getJSON(AppFunctionUrlOnlineOffice + "?action=GetCaseType&PID="+Pid+"&GetAllChild=0&ClientSiteKey=" + ClientSiteKey+"&callback=?" , function(data) {
        
        var SeletedOfficeType=MyGetQuery('OfficeType','');
        var infoes = data;
        var strResult = "";
        if (!infoes.IsSuc) {
            $("#" + objID).append('<li>信息获取失败</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=079e6d9c-d39b-4762-b493-33f5e491ae07"+"&OfficeType="+infoes.Result[i].RulesId+"'>"+infoes.Result[i].Name+"</a></li>");
           else             
         $("#" + objID).append("<li><a href='/List.aspx?KindID=079e6d9c-d39b-4762-b493-33f5e491ae07"+"&OfficeType="+infoes.Result[i].RulesId+"'>"+infoes.Result[i].Name+"</a></li>");
        }      
    });
}
function InitDataOfficeType()
{
    ShowCaseType('ulCaseType', '0002000300050001');
    ShowCaseType('ulCaseType1', '0002000300050002');
    ShowCaseType('ulCaseType2', '0002000300050003');
    ShowCaseType('ulCaseType3', '0002000300050004');
}

function ShowCaseTypeSelect(objID)
{
    //PID：服务导航栏目的父ID，默认指定为 000200030005；
    //GetAllChild：是否获取所有事项子分类，1是，0不是
    $.getJSON(AppFunctionUrlOnlineOffice + "?action=GetCaseType&PID=000200030005&GetAllChild=0&ClientSiteKey=" + ClientSiteKey+"&callback=?" , function(data) {
        
        var SeletedOfficeType=MyGetQuery('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",MyGetQuery("Keyword",""));//关键词的设置

    ShowCaseNavigation("tableCaseNavigation", 4, 5);
    ShowCaseTypeSelect("ShowCaseTypeSelect");
    ShowCaseList('tableCaseList', 2,15)
}

function InitDataOfficeReferList()
{
    SetItemValue("Keyword",MyGetQuery("Keyword",""));//关键词的设置
    ShowCaseReferList('tableCaseReferList',2,15);
}

function ShowCase()
{
    var maxCaseAccessoriesNameLength=10;
    var CaseID=MyGetQuery("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="/AppFrontPage/OnlineOffice/OfficeReferAdd.htm?DeptID='+infoes.Result[0].DeptId+'&CaseId='+CaseID+'" target="_blank"><img src="images/b02.gif" border="0"></a>&nbsp;'+
                    '<a href="/list.aspx?KindID=97707890-404e-4d94-a694-f3798284a661&CaseId=' + CaseID + '" target="_blank"><img src="images/b01.gif" border="0"></a>&nbsp;'); 
            
        //部门名称
        var DeptName="";
        $.getJSON(AppFunctionUrlOnlineOffice+"?action=GetDeptName&DeptID=" + infoes.Result[0].DeptId, 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, 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").html(infoes.Result[0].Guide+" ");               //办事指南
        $("#Policy").html(infoes.Result[0].Policy+" ");             //相关政策
        $("#DeclareData").html(infoes.Result[0].DeclareData+" ");   //申报材料
        
        $.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=CaseAccessoriesData.Result[i].Name.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=MyGetQuery("CaseReferID","");
    var CaseID=MyGetQuery("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, 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, 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 GetCaseName(targetObjID) {
    var infoid = MyGetQuery('InfoID','');
    var infoTree = MyGetQuery('InfoTreeID','');
    $("#" + targetObjID).load(AppHelperUrl + "?action=GetCaseName&InfoID=" + infoid + "&InfoTreeID=" + infoTree+"&ClientSiteKey="+ClientSiteKey + "&callback=?"); 
}

//申请列表
function ShowCaseApplyList(objID, pageSize, linkPage)
{
    var CaseID=MyGetQuery("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++) {
            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='/AppFrontPage/OnlineOffice/OfficeApplySearch.htm';
            else
                myUrl='/AppFrontPage/OnlineOffice/OfficeApplyShow.htm?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">'+(addDate.getYear()+'-'+(addDate.getMonth()+1)+'-'+addDate.getDate())+'</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="";
            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='/AppFrontPage/OnlineOffice/OfficeApplySearch.htm';
            else
                myUrl='/AppFrontPage/OnlineOffice/OfficeApplyShow.htm?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>'+(addDate.getYear()+'-'+(addDate.getMonth()+1)+'-'+addDate.getDate())+'</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 ShowCaseApplyTopBlock(objID, pageSize) {

    var CaseID = escape(MyGetQuery("CaseID", ""));
    var query = "?action=GetCaseApply&ClientSiteKey=" + ClientSiteKey + "&page = 1" + "&pageSize = " + pageSize;
    query += CaseID == "" ? "" : ("&CaseID=" + CaseID);
    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>');
            EndWait();
            return;
        }

        var myUrl = "";
        var addDate;
        var state = "";
        for (var i = 0; i < infoes.Result.length; i++) {
            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 = '/AppFrontPage/OnlineOffice/OfficeApplySearch.htm';
            else
                myUrl = '/AppFrontPage/OnlineOffice/OfficeApplyShow.htm?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 = "<li><a href='" + myUrl + "' target='_blank'>受理编号：" + infoes.Result[i].CaseApplyId + "</a></li>";
            strResult += "<li>受理单位：" + infoes.Result[i].DeptName + "</li>";
            strResult += "<li>受理时间：" + (addDate.getYear() + '-' + (addDate.getMonth() + 1) + '-' + addDate.getDate()) + "</li>";
            strResult += "<li>办理状态： " + state + "</li>";
            strResult += " <li>&nbsp;</li>"

            $("#" + objID).append(strResult);
        }

        EndWait();
    });
}

function InitDataMainSite()
{
    ShowCaseTop("ulCaseTop", 5, 15);
}

function InitDataListOnlineOffice()
{
    ShowCaseTop("ulCaseTop", 999, 15);
}

function InitDataListOnlineOfficeApply()
{
    var linkPage = "/list.aspx?KindID=11a28b0a-84d2-436c-9e37-dcd2524c0f64";
    var CaseID=MyGetQuery("CaseID","");
    linkPage+=CaseID==""?"":("&CaseID="+CaseID)
    ShowCaseApplyList("tableCaseApplyList", 10 ,linkPage);
}

function InitDataShowCaseApplyList()
{
    ShowCaseApplyList("tableCaseApplyList",10 ,"/AppFrontPage/OnlineOffice/OfficeApplyList.htm");
}

//办事申请列表
function ShowCaseApply()
{
    var CaseApplyID = MyGetQuery('CaseApplyID','');
    var CheckKey = MyGetQuery('CheckKey','');
    var backUrl = MyGetQuery('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) {

            alert(infoes.Message);
            window.history.back(-1);

            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, 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()
{
    var linkPage="/list.aspx?KindID=8f7fb47e-db1f-44b0-825e-9f7b5958327c";
    var CaseID=MyGetQuery("CaseID","");
    linkPage+=CaseID==""?"":("&CaseID="+CaseID)
    ShowCaseReferList("tableCaseReferList", 10 ,linkPage);
}




function EndWait()
{
    try
    {
        $("#_wznWait").remove();
    }
    catch(err)
    {
    }
}

//获取事项类型名称
function GetOfficeTypeName(objID, type) {

    $("#" + objID).html("");
    $("#" + objID).append(type);
}

//办事申请查询
function SearchCaseApply(CaseApplyID, CheckKey) {
    window.location.href = "/AppFrontPage/OnlineOffice/OfficeApplyShow.htm?CaseApplyID=" + CaseApplyID + "&CheckKey=" + CheckKey;
}
