<%@ Page Language="c#" Inherits="Web.User.AuditingNews" CodeBehind="AuditingNews.aspx.cs" %>

<%@ Register Src="~/Module/pageNavi.ascx" TagPrefix="uc1" TagName="pageNavi" %>
<%@ Register Src="~/User/AuditingNav.ascx" TagPrefix="uc1" TagName="AuditingNav" %>

<!DOCTYPE html>
<!--[if lt IE 9]><html class="lte-ie8"><![endif]-->
<!--[if gt IE 8]><!-->
<html>
<!--<![endif]-->
<head>
    <title>待审信息列表</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!--#include file = "../Css/head.htm" -->
</head>
<body>
    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="list-func-box func-box">
                    <form id="Form1" method="post" runat="server">
                    <uc1:AuditingNav runat="server" id="AuditingNav" />
                            <%--<ul class="inbox-tabs nav nav-tabs tab-size-bigger tab-space-1" id="inbox-tabs">
                                <!-- #section:pages/inbox.compose-btn -->

                                <li class="dropdown active">
                                    <a class="dropdown-toggle" href="#" data-toggle="dropdown">
                                        <i class="pink ace-icon fa fa-tags bigger-130"></i>


                                        <span class="bigger-110">待审信息
														
                                    <i class="ace-icon fa fa-caret-down"></i>
                                            <span class="badge badge-danger" id="addred" runat="server"><%= add %></span>
                                        </span>

                                    </a>

                                    <ul class="dropdown-menu dropdown-light-blue dropdown-125">
                                        <li id="none" runat="server" visible="False">
                                            <a href="AuditingNews.aspx" data-toggle="tab">
                                                <span>没有需要审核的内容</span>
                                            </a>
                                        </li>

                                        <li id="newsHyper" runat="server" visible="False" class="active">
                                            <a href="AuditingNews.aspx" data-toggle="tab">
                                                <span class="mail-tag badge badge-info"></span>
                                                <span>新闻待审</span>
                                                <span class="badge badge-danger"><%= newsCount %></span>
                                            </a>
                                        </li>

                                        <li id="reviewHyper" runat="server" visible="False">
                                            <a href="AuditingReviews.aspx" data-toggle="tab">
                                                <span class="mail-tag badge badge-info"></span>
                                                <span>评论待审</span>
                                                <span class="badge badge-danger"><%= reviewsCount %></span>
                                            </a>
                                        </li>

                                        <li id="messageHyper" runat="server" visible="False">
                                            <a href="AuditingMessageBoard.aspx" data-toggle="tab">
                                                <span class="mail-tag badge badge-info"></span>
                                                <span>留言待审</span>
                                                <span class="badge badge-danger"><%= messageCount %></span>
                                            </a>
                                        </li>

                                        <li id="hyLink" runat="server" visible="False">
                                            <a href="AuditingLink.aspx" data-toggle="tab">
                                                <span class="mail-tag badge badge-info"></span>
                                                <span>链接待审</span>
                                                <span class="badge badge-danger"><%= linkCount %></span>
                                            </a>
                                        </li>

                                        <li id="hyLinkGang" runat="server" visible="False">
                                            <a href="AuditingLinkGang.aspx" data-toggle="tab">
                                                <span class="mail-tag badge badge-info"></span>
                                                <span>链接组待审</span>
                                                <span class="badge badge-danger"><%= linkGangCount %></span>
                                            </a>
                                        </li>

                                        <li id="hyPeople" runat="server" visible="False">
                                            <a href="AuditingPeople.aspx" data-toggle="tab">
                                                <span class="mail-tag badge badge-info"></span>
                                                <span>人事物信息待审</span>
                                                <span class="badge badge-danger"><%= peopleCount %></span>
                                            </a>
                                        </li>

                                        <li id="hyBoard" runat="server" visible="False">
                                            <a href="AuditingBoard.aspx" data-toggle="tab">
                                                <span class="mail-tag badge badge-info"></span>
                                                <span>公告待审</span>
                                                <span class="badge badge-danger"><%= boardCount %></span>
                                            </a>
                                        </li>
                                    </ul>
                                </li>
                                <!-- /.dropdown -->
                                <li>
                                    <a href="infoSearch.aspx" data-toggle="tab" data-target="write">
                                        <i class="pink ace-icon fa fa-envelope bigger-130"></i>
                                        <span class="bigger-110">我的发布</span>
                                    </a>
                                </li>
                                <!-- /.li-new-mail -->

                                <!-- /section:pages/inbox.compose-btn -->
                                <li>
                                    <a href="myDraft.aspx" data-toggle="tab" data-target="inbox">
                                        <i class="blue ace-icon fa fa-inbox bigger-130"></i>
                                        <span class="bigger-110">我的草稿</span>
                                    </a>
                                </li>

                                <li>
                                    <a href="search.aspx" data-toggle="tab" data-target="sent">
                                        <i class="orange ace-icon fa fa-location-arrow bigger-130"></i>
                                        <span class="bigger-110">站内搜索</span>
                                    </a>
                                </li>
                            </ul>--%>
                        <div class="bd tab-content">
                            <div class="page-header clearfix">
                                <div class="pull-left col-xs-6">
                                    <asp:Button ID="btnSave" runat="server" class="btn btn-sm btn-primary" Text="保 存" OnClick="btn_Click"></asp:Button>
                                    &nbsp;&nbsp;
                        <asp:Button ID="btnPass" runat="server" class="btn btn-sm btn-primary" Text="通 过" OnClick="btn_Click" />
                                    &nbsp;&nbsp;
                        <asp:Button ID="btnNopass" runat="server" class="btn btn-sm btn-primary" Text="不通过" OnClick="btn_Click" />
                                    &nbsp;<asp:Label ID="lbTip" runat="server" ForeColor="Red" Text=""></asp:Label>
                                    <asp:HiddenField ID="MoveTargetBigClassID" runat="server" />
                                    <asp:HiddenField ID="MoveTargetMenuID" runat="server" />
                                    <asp:HiddenField ID="MoveObjectId" runat="server" />
                                    <asp:Button ID="btnMoveSave" runat="server" Text="MoveSave" OnClick="MoveSaveButton_Click" UseSubmitBehavior="False" Style="display: none"></asp:Button>
                                    &nbsp;&nbsp;
                                </div>
                            </div>
                            <div>
                                <!--[if lte IE 7]><div style="zoom:1"><![endif]-->
                                <asp:HiddenField ID="hfidstr" runat="server" />
                                <asp:HiddenField ID="hftitlestr" runat="server" />
                                <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" class="table table-striped table-bordered table-hover table-sorting" 
                                    OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound" EmptyDataText="暂无内容..." OnSorting="GridView1_Sorting">
                                    <Columns>
                                        <asp:TemplateField HeaderStyle-CssClass="title text-center" ItemStyle-CssClass="text-center" ItemStyle-Width="36px">
                                            <HeaderTemplate>
                                                <asp:CheckBox ID="cbAll" Text=" " runat="server" onclick="GridSelectAll('GridView1',this.checked)" />
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <asp:CheckBox ID="cbthis" runat="server" Text=" "></asp:CheckBox>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="pkId" HeaderText="ID号" HeaderStyle-CssClass="hidden" ItemStyle-CssClass="hidden" FooterStyle-CssClass="hidden"></asp:BoundField>
                                        <asp:TemplateField HeaderText="标题"  SortExpression="intactTitle"  >
                                            <ItemTemplate>
                                                 <asp:Label ID="V" Visible="false" runat="server" Text="[过期]" ForeColor="Red"></asp:Label>
                                                <asp:Label ID="D" Visible="false" runat="server" Text="[抄]" ForeColor="Red"></asp:Label>
                                                <asp:Label ID="L" Visible="false" runat="server" Text="[链]" ForeColor="Red"></asp:Label>
                                                <span data-placement="right" data-rel="popover" data-content="<%# Eval( "intactTitle") %>" data-trigger="hover">
                                                    <asp:HyperLink ID="intactTitle" runat="server" Text='<%# Eval( "intactTitle") %>' Target="_blank" NavigateUrl='<%# Eval( "pkId", "../newsInfo.aspx?pkId={0}") %>'>
                                                    </asp:HyperLink>
                                                </span>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="所属栏目" SortExpression="menuName" >
                                            <ItemTemplate>
                                                <asp:Label ID="menuLabel" runat="server" Text='<%# Eval("menuName") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="发布人" SortExpression="fullName" >
                                            <ItemTemplate>
                                                <span data-placement="right" data-rel="popover" data-content="<%# "发布IP："+Eval( "updateIp") %>" data-trigger="hover"><%#Eval( "fullName") %></span>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="发布时间"  ItemStyle-Width="100px" SortExpression="updateTime" >
                                            <ItemTemplate>
                                                <span data-placement="right" data-rel="popover" data-content="<%# Eval("updateTime") %>" data-trigger="hover">
                                                    <asp:Label ID="lbtime" runat="server" Text='<%# Eval( "updateTime", "{0:yyyy-M-d}") %>'></asp:Label></span>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="今日推荐"  Visible="false">
                                            <ItemTemplate>
                                                <asp:DropDownList ID="isRecommand" runat="server" SelectedValue='<%# Eval( "isRecommand") %>'>
                                                    <asp:ListItem Value="0" Selected="True">否</asp:ListItem>
                                                    <asp:ListItem Value="1">推荐</asp:ListItem>
                                                </asp:DropDownList>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="click" HeaderText="点击量"  ItemStyle-Width="60px" SortExpression="click" ></asp:BoundField>
                                        <asp:TemplateField HeaderText="固顶"  SortExpression="isTop">
                                            <ItemTemplate>
                                                <asp:DropDownList ID="isTop" runat="server" SelectedValue='<%# Eval( "isTop") %>'>
                                                    <asp:ListItem Value="0" Selected="True">取消</asp:ListItem>
                                                    <asp:ListItem Value="1">固顶</asp:ListItem>
                                                </asp:DropDownList>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="显示等级"  SortExpression="gradeId">
                                            <ItemTemplate>
                                                <asp:DropDownList ID="gradeDrop" runat="server" DataValueField="pkId" DataTextField="name" SelectedValue='<%# Eval("gradeId") %>'
                                                    DataSource="<%# dt_grade %>">
                                                </asp:DropDownList>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="浏览权限" SortExpression="gate" >
                                            <ItemTemplate>
                                                <asp:DropDownList ID="gate" runat="server" SelectedValue='<%# Eval( "gate") %>'>
                                                    <asp:ListItem Value="0" Selected="True">无限制</asp:ListItem>
                                                    <asp:ListItem Value="1">仅内网可见</asp:ListItem>
                                                    <asp:ListItem Value="2">仅登录可见</asp:ListItem>
                                                    <asp:ListItem Value="3">内网或登录可见</asp:ListItem>
                                                </asp:DropDownList>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="管理" ItemStyle-Width="120px">
                                            <ItemTemplate>
                                                <div class="action-buttons">
                                                    <asp:LinkButton ID="edit"  runat="server" CommandArgument='<%#Eval("pkId") +"&"+Eval("Code")+"&"+Eval("bigClassId")+"&"+Eval("menuId")+"&"+Eval("isDuplicated")+"&"+Eval("duplicatedPkId") %>' CommandName="edit" data-toggle="tooltip" data-placement="bottom" title="编辑"><i class="ace-icon fa fa-pencil bigger-120 blue" ></i></asp:LinkButton>
                                                    <%--<asp:LinkButton ID="edit1" CssClass="FBox3" runat="server" data-toggle="tooltip" data-placement="bottom" title="对不起，您没有权限编辑" Visible="false" Enabled="false"><i class="ace-icon fa fa-pencil bigger-120 grey"></i></asp:LinkButton>--%>
                                                    <asp:LinkButton ID="lbmove" Visible="false" runat="server" data-toggle="tooltip" data-placement="bottom" title="移动"><i class="ace-icon fa fa-exchange bigger-120 pink" ></i></asp:LinkButton>
                                                    <asp:LinkButton ID="lbmove1" runat="server" CssClass="FBox3" data-toggle="tooltip" data-placement="bottom" title="对不起，您没有权限移动" Visible="false" Enabled="false"><i class="ace-icon fa fa-exchange bigger-120 grey" ></i></asp:LinkButton>
                                                    <asp:LinkButton ID="del" Visible="false" runat="server" CommandArgument='<%#Eval("pkId") %>' CommandName="del" data-toggle="tooltip" data-placement="bottom" title="删除"><i class="ace-icon fa fa-trash bigger-120 red" ></i></asp:LinkButton>
                                                    <asp:LinkButton ID="del1" runat="server" CssClass="FBox3" data-toggle="tooltip" data-placement="bottom" title="对不起，您没有权限删除" Visible="false" Enabled="false"><i class="ace-icon fa fa-trash-o bigger-120 grey" ></i></asp:LinkButton>
                                                    <a href='manageReview.aspx?newsId=<%# Eval( "pkId")%>' target="_blank" data-toggle="tooltip" data-placement="bottom" title="评论"><i class="ace-icon fa fa-edit bigger-120 blue"></i></a>
                                                </div>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField Visible="False" DataField="grade" HeaderText="等级" ></asp:BoundField>
                                        <asp:BoundField Visible="False" DataField="useListTitle" HeaderText="useListTitle"></asp:BoundField>
                                        <asp:BoundField Visible="False" DataField="listTitle" HeaderText="listTitle"></asp:BoundField>
                                        <asp:BoundField Visible="False" DataField="Code" HeaderText="TemplateCode"></asp:BoundField>
                                        <asp:BoundField Visible="False" DataField="bigClassId" HeaderText="bigClassId"></asp:BoundField>
                                        <asp:BoundField Visible="False" DataField="sourceMenuId" HeaderText="menuId"></asp:BoundField>
                                        <asp:BoundField Visible="False" DataField="isDuplicated" HeaderText="isDuplicated"></asp:BoundField>
                                        <asp:BoundField Visible="False" DataField="duplicatedPkId" HeaderText="duplicatedPkId"></asp:BoundField>
                                    </Columns>
                                </asp:GridView>
                                <div class="grid-pager">
                                <uc1:pageNavi runat="server" id="pageNavi" dataCtlName="GridView1" />
                            </div>
                                <%--<div id="isnull" runat="server" visible="false" style="text-align: center;">
                                    <p class="no-record">暂无内容！</p>
                                </div>--%>
                                <!--[if lte IE 7]></div><![endif]-->
                            </div>
                            <!--/function-bd-->
                        </div>
                        <%--<div class="ft">
                            <div class="pagination">
                                <asp:Label ID="showPage" runat="server"></asp:Label>
                            </div>
                        </div>--%>
                    </form>
                </div>
                <!--/bd-->

            </div>
        </div>
    </div>
    <!--#include file = "../Css/foot.htm" -->
      <script language="javascript" type="text/javascript">
  
          //防止用户恶意保存
          jQuery(function ($) {
              $("#btnSave").click(function () {
                  //return confirm("您确定要保存列表吗？");
                  return GridSelectCheck('GridView1', true);
              });

              $("#btnPass").click(function () {

                  if (GridSelectCheck('GridView1', true)) {
                      //加载load特效（防止在生成静态页阶段重复点击按钮） 不显示弹出层的关闭按钮，按ESC来关闭弹出层
                      $.fancybox({
                          'type': 'image',
                          'width': 50,
                          'height': 50,
                          'hideOnOverlayClick': false,
                          'padding': '0',
                          'scrolling': 'no',
                          'enableEscapeButton': 'true',
                          'showCloseButton': false,
                          'href': '../images/resfile/loading.gif'
                      });
                      return true;
                  }
                  else {
                      return false;
                  }
              });
              $("#btnNopass").click(function () {

                  if (GridSelectCheck('GridView1', true)) {
                      //加载load特效（防止在生成静态页阶段重复点击按钮） 不显示弹出层的关闭按钮，按ESC来关闭弹出层
                      $.fancybox({
                          'type': 'image',
                          'width': 50,
                          'height': 50,
                          'hideOnOverlayClick': false,
                          'padding': '0',
                          'scrolling': 'no',
                          'enableEscapeButton': 'true',
                          'showCloseButton': false,
                          'href': '../images/resfile/loading.gif'
                      });
                      return true;
                  }
                  else {
                      return false;
                  }
              });

              //设置“待审信息”的样式为选中效果。
              document.getElementById("auditingNews").className = "active";
              
          });

          //单个移动
          function MoveSave(menuID, oid) {
              //改用弹出层，因为201409发布的最新ghome开始不支持showModalDialog()
              $.fancybox({
                  'type': 'iframe',
                  'width': 400,
                  'height': 350,
                  'hideOnOverlayClick': false,
                  'href': 'MoveSaveForSingle.aspx?menuID=' + menuID + '&oid=' + oid
              });
              //showModalDialog("MoveSaveForSingle.aspx?menuID=" + menuID + "&oid=" + oid, window, "dialogWidth:420px; dialogHeight:350px; status:0");
          }

          function CallMoveSubmit() {
              $("#btnMoveSave").click();
          }

          //选中背景特效
          //$(function () {
          //    $('.text-center input').click(function () {
          //        $(this).parents('tr').toggleClass('active');
          //    })
          //    $('.title.text-center input').click(function () {

          //        if ($('.list-table tr:first').hasClass('active')) {
          //            $('.list-table tr').addClass('active');
          //        } else {
          //            $('.list-table tr').removeClass('active');
          //        }
          //    })
          //    $('.table select').change(function () {
          //        //背景选中
          //        if ($(this).parents('tr').hasClass('active')) {

          //        } else {
          //            $(this).parents('tr').toggleClass('active');
          //        }

          //        //复选框选中
          //        var checkbox = $(this).parents("tr").find("input");
          //        for (var i = 0; i < checkbox.length; i++) {
          //            if (checkbox[i].type == 'checkbox') {
          //                checkbox[i].checked = true;
          //            }
          //        }
          //    })
          //})
    </script>
    <script type="text/javascript">
        jQuery(function ($) {
            $('#AuditingNav_newsHyper').addClass('active');

            //handling tabs and loading/displaying relevant messages and forms
            //not needed if using the alternative view, as described in docs
            $('#inbox-tabs a[data-toggle="tab"]').on('show.bs.tab', function (e) {
                var currentTab = $(e.target).data('target');
                if (currentTab == 'write') {
                    Inbox.show_form();
                }
                else if (currentTab == 'inbox') {
                    Inbox.show_list();
                }
            })



            //basic initializations
            $('.message-list .message-item input[type=checkbox]').removeAttr('checked');
            $('.message-list').on('click', '.message-item input[type=checkbox]', function () {
                $(this).closest('.message-item').toggleClass('selected');
                if (this.checked) Inbox.display_bar(1);//display action toolbar when a message is selected
                else {
                    Inbox.display_bar($('.message-list input[type=checkbox]:checked').length);
                    //determine number of selected messages and display/hide action toolbar accordingly
                }
            });


            //check/uncheck all messages
            $('#id-toggle-all').removeAttr('checked').on('click', function () {
                if (this.checked) {
                    Inbox.select_all();
                } else Inbox.select_none();
            });

            //select all
            $('#id-select-message-all').on('click', function (e) {
                e.preventDefault();
                Inbox.select_all();
            });

            //select none
            $('#id-select-message-none').on('click', function (e) {
                e.preventDefault();
                Inbox.select_none();
            });

            //select read
            $('#id-select-message-read').on('click', function (e) {
                e.preventDefault();
                Inbox.select_read();
            });

            //select unread
            $('#id-select-message-unread').on('click', function (e) {
                e.preventDefault();
                Inbox.select_unread();
            });

            /////////

            //display first message in a new area
            $('.message-list .message-item:eq(0) .text').on('click', function () {
                //show the loading icon
                $('.message-container').append('<div class="message-loading-overlay"><i class="fa-spin ace-icon fa fa-spinner orange2 bigger-160"></i></div>');

                $('.message-inline-open').removeClass('message-inline-open').find('.message-content').remove();

                var message_list = $(this).closest('.message-list');

                $('#inbox-tabs a[href="#inbox"]').parent().removeClass('active');
                //some waiting
                setTimeout(function () {

                    //hide everything that is after .message-list (which is either .message-content or .message-form)
                    message_list.next().addClass('hide');
                    $('.message-container').find('.message-loading-overlay').remove();

                    //close and remove the inline opened message if any!

                    //hide all navbars
                    $('.message-navbar').addClass('hide');
                    //now show the navbar for single message item
                    $('#id-message-item-navbar').removeClass('hide');

                    //hide all footers
                    $('.message-footer').addClass('hide');
                    //now show the alternative footer
                    $('.message-footer-style2').removeClass('hide');


                    //move .message-content next to .message-list and hide .message-list
                    $('.message-content').removeClass('hide').insertAfter(message_list.addClass('hide'));

                    //add scrollbars to .message-body
                    $('.message-content .message-body').ace_scroll({
                        size: 150,
                        mouseWheelLock: true,
                        styleClass: 'scroll-visible'
                    });

                }, 500 + parseInt(Math.random() * 500));
            });


            //display second message right inside the message list
            $('.message-list .message-item:eq(1) .text').on('click', function () {
                var message = $(this).closest('.message-item');

                //if message is open, then close it
                if (message.hasClass('message-inline-open')) {
                    message.removeClass('message-inline-open').find('.message-content').remove();
                    return;
                }

                $('.message-container').append('<div class="message-loading-overlay"><i class="fa-spin ace-icon fa fa-spinner orange2 bigger-160"></i></div>');
                setTimeout(function () {
                    $('.message-container').find('.message-loading-overlay').remove();
                    message
                        .addClass('message-inline-open')
                        .append('<div class="message-content" />')
                    var content = message.find('.message-content:last').html($('#id-message-content').html());

                    //remove scrollbar elements
                    content.find('.scroll-track').remove();
                    content.find('.scroll-content').children().unwrap();

                    content.find('.message-body').ace_scroll({
                        size: 150,
                        mouseWheelLock: true,
                        styleClass: 'scroll-visible'
                    });

                }, 500 + parseInt(Math.random() * 500));

            });



            //back to message list
            $('.btn-back-message-list').on('click', function (e) {

                e.preventDefault();
                $('#inbox-tabs a[href="#inbox"]').tab('show');
            });



            //hide message list and display new message form
            /**
            $('.btn-new-mail').on('click', function(e){
                e.preventDefault();
                Inbox.show_form();
            });
            */




            var Inbox = {
                //displays a toolbar according to the number of selected messages
                display_bar: function (count) {
                    if (count == 0) {
                        $('#id-toggle-all').removeAttr('checked');
                        $('#id-message-list-navbar .message-toolbar').addClass('hide');
                        $('#id-message-list-navbar .message-infobar').removeClass('hide');
                    }
                    else {
                        $('#id-message-list-navbar .message-infobar').addClass('hide');
                        $('#id-message-list-navbar .message-toolbar').removeClass('hide');
                    }
                }
                ,
                select_all: function () {
                    var count = 0;
                    $('.message-item input[type=checkbox]').each(function () {
                        this.checked = true;
                        $(this).closest('.message-item').addClass('selected');
                        count++;
                    });

                    $('#id-toggle-all').get(0).checked = true;

                    Inbox.display_bar(count);
                }
                ,
                select_none: function () {
                    $('.message-item input[type=checkbox]').removeAttr('checked').closest('.message-item').removeClass('selected');
                    $('#id-toggle-all').get(0).checked = false;

                    Inbox.display_bar(0);
                }
                ,
                select_read: function () {
                    $('.message-unread input[type=checkbox]').removeAttr('checked').closest('.message-item').removeClass('selected');

                    var count = 0;
                    $('.message-item:not(.message-unread) input[type=checkbox]').each(function () {
                        this.checked = true;
                        $(this).closest('.message-item').addClass('selected');
                        count++;
                    });
                    Inbox.display_bar(count);
                }
                ,
                select_unread: function () {
                    $('.message-item:not(.message-unread) input[type=checkbox]').removeAttr('checked').closest('.message-item').removeClass('selected');

                    var count = 0;
                    $('.message-unread input[type=checkbox]').each(function () {
                        this.checked = true;
                        $(this).closest('.message-item').addClass('selected');
                        count++;
                    });

                    Inbox.display_bar(count);
                }
            }

            //show message list (back from writing mail or reading a message)
            Inbox.show_list = function () {
                $('.message-navbar').addClass('hide');
                $('#id-message-list-navbar').removeClass('hide');

                $('.message-footer').addClass('hide');
                $('.message-footer:not(.message-footer-style2)').removeClass('hide');

                $('.message-list').removeClass('hide').next().addClass('hide');
                //hide the message item / new message window and go back to list
            }

            //show write mail form
            Inbox.show_form = function () {
                if ($('.message-form').is(':visible')) return;
                if (!form_initialized) {
                    initialize_form();
                }


                var message = $('.message-list');
                $('.message-container').append('<div class="message-loading-overlay"><i class="fa-spin ace-icon fa fa-spinner orange2 bigger-160"></i></div>');

                setTimeout(function () {
                    message.next().addClass('hide');

                    $('.message-container').find('.message-loading-overlay').remove();

                    $('.message-list').addClass('hide');
                    $('.message-footer').addClass('hide');
                    $('.message-form').removeClass('hide').insertAfter('.message-list');

                    $('.message-navbar').addClass('hide');
                    $('#id-message-new-navbar').removeClass('hide');


                    //reset form??
                    $('.message-form .wysiwyg-editor').empty();

                    $('.message-form .ace-file-input').closest('.file-input-container:not(:first-child)').remove();
                    $('.message-form input[type=file]').ace_file_input('reset_input');

                    $('.message-form').get(0).reset();

                }, 300 + parseInt(Math.random() * 300));
            }




            var form_initialized = false;
            function initialize_form() {
                if (form_initialized) return;
                form_initialized = true;

                //intialize wysiwyg editor
                $('.message-form .wysiwyg-editor').ace_wysiwyg({
                    toolbar:
                    [
                        'bold',
                        'italic',
                        'strikethrough',
                        'underline',
                        null,
                        'justifyleft',
                        'justifycenter',
                        'justifyright',
                        null,
                        'createLink',
                        'unlink',
                        null,
                        'undo',
                        'redo'
                    ]
                }).prev().addClass('wysiwyg-style1');



                //file input
                $('.message-form input[type=file]').ace_file_input()
                .closest('.ace-file-input')
                .addClass('width-90 inline')
                .wrap('<div class="form-group file-input-container"><div class="col-sm-7"></div></div>');

                //Add Attachment
                //the button to add a new file input
                $('#id-add-attachment')
                .on('click', function () {
                    var file = $('<input type="file" name="attachment[]" />').appendTo('#form-attachments');
                    file.ace_file_input();

                    file.closest('.ace-file-input')
                    .addClass('width-90 inline')
                    .wrap('<div class="form-group file-input-container"><div class="col-sm-7"></div></div>')
                    .parent().append('<div class="action-buttons pull-right col-xs-1">\
							<a href="#" data-action="delete" class="middle">\
								<i class="ace-icon fa fa-trash-o red bigger-130 middle"></i>\
							</a>\
						</div>')
                    .find('a[data-action=delete]').on('click', function (e) {
                        //the button that removes the newly inserted file input
                        e.preventDefault();
                        $(this).closest('.file-input-container').hide(300, function () { $(this).remove() });
                    });
                });
            }//initialize_form

            //turn the recipient field into a tag input field!
            /**	
            var tag_input = $('#form-field-recipient');
            try { 
                tag_input.tag({placeholder:tag_input.attr('placeholder')});
            } catch(e) {}
        
        
            //and add form reset functionality
            $('#id-message-form').on('reset', function(){
                $('.message-form .message-body').empty();
                
                $('.message-form .ace-file-input:not(:first-child)').remove();
                $('.message-form input[type=file]').ace_file_input('reset_input_ui');
        
                var val = tag_input.data('value');
                tag_input.parent().find('.tag').remove();
                $(val.split(',')).each(function(k,v){
                    tag_input.before('<span class="tag">'+v+'<button class="close" type="button">&times;</button></span>');
                });
            });
            */

        });
    </script>
</body>
</html>
