<hi:common_aliohheader runat="server" />
<div class="panel panel-default list-sort-panel" style="margin-bottom: 0; border-radius: 0;
    position: relative;">
    <div id="collapseOne" class="panel-collapse collapse">
        <div class="panel-body">
            <div class="goods-list-bar">
                <div class="input-group form-search">
                    <input type="text" class="form-control search-query" id="txtKeywords" style="height: 30px;
                        border-color: #F6BB42;">
                    <span class="input-group-btn">
                        <button type="submit" onclick="searchs()" class="btn btn-warning btn-sm" data-type="last">
                            搜索
                        </button>
                    </span>
                </div>
            </div>
        </div>
    </div>
</div>
<p class="text-center list-empty hide" id="empty">
    没有找到相关文章
</p>
<div class="pbox" id="articlelistContainer">
    <div id="category" class="listtitle">【<a href="ArticleCategory.aspx">文章分类</a>】&nbsp;&nbsp;&gt;&nbsp;&nbsp;<a href="#" id="category_link">文章搜索</a></div>
    <div class="articlelist clearfix" id="articlelist">
        <ul>
            <hi:AliOHTemplatedRepeater id="rptArticles" templatefile="/Tags/skin-Common_Articles.ascx"
                                       runat="server" />
        </ul>
    </div>
    <div id="pager">
    </div>
</div>
< value="" runat="server" clientidmode="static" id="txtTotal" />
< value="" runat="server" clientidmode="static" id="txtCategoryName" />
< value="" runat="server" clientidmode="static" id="txtCategoryId" />
<hi:common_aliohfooter runat="server" />
<script src="/Utility/common.js" type="text/javascript"></script>
<script src="/Utility/pager.js" type="text/javascript"></script>
<script type="text/javascript">


    $(function () {
        var categoryId = parseInt($("#txtCategoryId").val());
        if (isNaN(categoryId)) categoryId = 0;
        var categoryName = $("#txtCategoryName").val();
        if (categoryId == 0) categoryName = "文章搜索";
        $("#category_link").html(categoryName);
        $("#category_link").attr("href", "Articles.aspx?categoryId=" + categoryId);
        if ($('#articlelist ul li').length == 0) {

            $('#articlelistContainer').addClass('hide');
            $('#empty').removeClass('hide');
        }

        var sort = getParam('sort');
        var order = getParam('order');
        if (sort && order) {
            debugger;
            var selectedLink = $('.sort a[name="' + sort + '"]');
            if (order == 'desc')
                selectedLink.find('div').addClass('down');
            else
                selectedLink.find('div').addClass('up');
        }

        var sortLink = $('.sort a[href="#"]');
        var categoryId = getParam('categoryId');

        var keyWords = getParam('keyWord');
        if (keyWords)
            $("#txtKeywords").val(keyWords);


        $.each(sortLink, function (i, link) {
            link = $(link);
            url = '/wapshop/Articles.aspx?categoryId=' + categoryId + '&keyWord=' + escape(keyWords);
            if (i > 0) {//第一个为默认面，不设置排序
                url += '&sort=' + link.attr('name');
                if (link.find('div.up').length > 0)
                    url += '&order=desc';
                else
                    url += '&order=asc';
            }
            link.attr('href', url);
        });

        vshopPager('pager', $('#txtTotal').val(), 1, 20);

    });
    function searchs() {

        var key = $("#txtKeywords").val();
        var categoryId = getParam('categoryId');
        var url = "/wapshop/Articles.aspx?categoryId=" + categoryId + "&keyWord=" + escape(key);

        window.location.href = url;
    }


</script>
