/// <reference path="jquery-1.10.2.min.js" />
var pageindex = 1;
var pagesize = 10;
var pagecount = 0;

function search_ok() {
    var title = $.trim($("#search-c").val());
    var pid = $.trim($("#J_selectSearch").attr("rel"));
    if (title == "") {
        alert("搜索词不能为空")
        return;
    }
    if (pid == "1") {
        $.post("/ajax/Overall.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": "Soft", "title": title }, function (data) {
            var d = JSON.parse(data);
            var s = "";
            for (var i = 0 ; i < d.length; i++) {
                var forso = "Search.aspx?SoftName=" + d[i].DataName + "";
                window.open(forso);
            }
            var data = eval('(' + data + ')');
            pagecount = data.pagecount;
            $(".Searchlist").html("").append(data.pagelist);
            layui.use(['laypage', 'layer'], function () {
                var nums = pagesize; //每页出现的数据量
                var laypage = layui.laypage
                , layer = layui.layer;
                laypage.render({
                    elem: 'pagerbr'
                   , count: pagecount //总页数
                   , groups: 1
                    , jump: function (obj) {
                        pageindex = obj.curr;//获取到当前页
                        $.post("/ajax/Overall.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": "Soft", "title": title }, function (data) {
                            var data = eval('(' + data + ')');
                            pagecount = data.pagecount;
                            $(".Searchlist").html("").append(data.pagelist);

                        });

                    }
                });
            });
        })
        return;
    } if (pid == "2") { 

        $.post("/ajax/Overall.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": "News", "title": title }, function (data) {
            var d = JSON.parse(data);
            var s = "";
            for (var i = 0 ; i < d.length; i++) {
                var forso = "Search.aspx?NewsName=" + d[i].NewsName + "";
                window.open(forso);
            }

            var data = eval('(' + data + ')');
            pagecount = data.pagecount;
            $(".Searchlist").html("").append(data.pagelist);
            layui.use(['laypage', 'layer'], function () {
                var nums = pagesize; //每页出现的数据量
                var laypage = layui.laypage
                , layer = layui.layer;
                laypage.render({
                    elem: 'pagerbr'
                   , count: pagecount //总页数
                   , groups: 1
                    , jump: function (obj) {
                        pageindex = obj.curr;//获取到当前页
                        $.post("/ajax/Overall.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": "News", "title": title }, function (data) {
                            var data = eval('(' + data + ')');
                            pagecount = data.pagecount;
                            $(".Searchlist").html("").append(data.pagelist);

                        });

                    }
                });
            });


        })

        return;
    }
    if (pid == "3") {

        $.post("/ajax/Overall.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": "Game", "title": title }, function (data) {
            var d = JSON.parse(data);
            var s = "";
            for (var i = 0 ; i < d.length; i++) {
                var forso = "Search.aspx?NewsName=" + d[i].NewsName + "";
                window.open(forso);
            }

            var data = eval('(' + data + ')');
            pagecount = data.pagecount;
            $(".Searchlist").html("").append(data.pagelist);
            layui.use(['laypage', 'layer'], function () {
                var nums = pagesize; //每页出现的数据量
                var laypage = layui.laypage
                , layer = layui.layer;
                laypage.render({
                    elem: 'pagerbr'
                   , count: pagecount //总页数
                   , groups: 1
                    , jump: function (obj) {
                        pageindex = obj.curr;//获取到当前页
                        $.post("/ajax/Overall.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": "Game", "title": title }, function (data) {
                            var data = eval('(' + data + ')');
                            pagecount = data.pagecount;
                            $(".Searchlist").html("").append(data.pagelist);

                        });

                    }
                });
            });


        })

        return;
    }
    if (pid == "4") {

        $.post("/ajax/Overall.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": "App", "title": title }, function (data) {
            var d = JSON.parse(data);
            var s = "";
            for (var i = 0 ; i < d.length; i++) {
                var forso = "Search.aspx?NewsName=" + d[i].NewsName + "";
                window.open(forso);
            }

            var data = eval('(' + data + ')');
            pagecount = data.pagecount;
            $(".Searchlist").html("").append(data.pagelist);
            layui.use(['laypage', 'layer'], function () {
                var nums = pagesize; //每页出现的数据量
                var laypage = layui.laypage
                , layer = layui.layer;
                laypage.render({
                    elem: 'pagerbr'
                   , count: pagecount //总页数
                   , groups: 1
                    , jump: function (obj) {
                        pageindex = obj.curr;//获取到当前页
                        $.post("/ajax/Overall.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": "App", "title": title }, function (data) {
                            var data = eval('(' + data + ')');
                            pagecount = data.pagecount;
                            $(".Searchlist").html("").append(data.pagelist);

                        });

                    }
                });
            });


        })

        return;
    }
}