//搜索直播
function searchKeyMedia()
{
    var page_count = 0;
    var page_size = 0;
    var total_count = 1;
    var key = $("#key").val();
    $("#center").find("object").remove();
    $("#main_body").empty();
    $("#main_body1").empty();
    var show_type = $("#div1").css("display");
    if(show_type == "block")
    {
        $("#div1").show();
        $("#div2").hide();
    }
    else
    {
        $("#div1").hide();
        $("#div2").show();
    }
    var obj = recordFileObj;
    obj = $.parseJSON(obj);
    for(var i=0;i<obj.length;i++)
    {
        var id = obj[i].id;
        var aa = obj[i].fileName;
        bb = aa;
        bb = bb.replace("\\","/");
        var appName = obj[i].appName;
        var liveName = obj[i].liveName;
        var status = obj[i].status;
        var videoName = appName+"/"+liveName;
        var name = aa.substr(aa.lastIndexOf("/")+1,aa.length);
        var Image = name.substr(0,name.lastIndexOf("."));
        var wholePath = aa.substr(0,aa.lastIndexOf("/")+1);
        var vodPath = wholePath.substr(wholePath.indexOf("/"),wholePath.length);
        var create_time = obj[i].createDate;
        var path = aa;
        var videopath = aa.substr(aa.indexOf(":")+2,aa.length);
        var http_url = "http://"+host+":"+port+"/"+videopath;
        var videopath1 = videopath.substring(0,videopath.indexOf(videoName));
        videopath1 = videopath1.replace("/","|");
        var videopath2 = videopath.substring(videopath.indexOf(videoName),videopath.length);
        var videopath3 = videopath1 + videopath2;
        var rtmp_url = "rtmp://"+host+":"+rtmp_port+"/"+videopath3;
        var http_play_url = replace_url(http_url);
        var rtmp_play_url = replace_url(rtmp_url);
        var imagePath = "";
        var cfgFile = "http://"+host+":"+http_port+vodPath+Image+'.cfg';
        var cfgObj = "";
        var duration = "";
        var resolution = "";
        var img = "";
        var img_name = "";
        //获取视频时间
        if(sendName == videoName)
        {
            if(name.indexOf(key) != -1)
            {
                $.ajax({
                    type: "post",
                    async: false,
                    url: cfgFile,
                    success: function(data)
                    {
                        var dataArr = "["+data+"]";
                        cfgObj = $.parseJSON(dataArr);
                        for(var i=0;i<cfgObj.length ;i++)
                        {
                            duration = cfgObj[i].duration;
                            resolution = cfgObj[i].resolution;
                            img = cfgObj[i].img;
                            for(var j=0;j<img.length ;j++)
                            {
                                img_name = img[0].name;
                            }
                        }
                    },
                    error:function(cfg)
                    {

                    }
                });
                var name_cut = img_name.substr(img_name.indexOf(":")+1,img_name.length);
                imagePath = "http://"+host+":"+port+name_cut;
                if(status == 1 || status == "1" || status == 2 || status == "2" || status == 3 || status == "3" || status == 4 || status == "4"
                    || status == 6 || status == "6" || status == 7 || status == "7")
                {
                    var dom = '<div style="width: 100%;height: 21px;">';
                    dom+= '<div style="width: 380px;float:left;cursor: pointer" onclick="play(\''+http_play_url+'\')">'+name+'</div>';
                    dom+= '<div style="width: 380px;float:left;">'+duration+'</div>';
                    dom+= '<div style="width: 380px;float:left;">'+resolution+'</div>';
                    dom+= '</div>';
                    var dom1 = '<div class="AddPlayIco">';
                    dom1+= '<div style="width:135px;height:75px;"><img src="'+imagePath+'" id="image" title="'+name+'" width="200" height="85" onclick="play(\''+http_play_url+'\')" onerror=\'this.src="/images/video.jpg"\'></div>';
                    dom1+= '<div style="width:185px;height:14px;overflow: hidden;">'+name+'</div>';
                    dom1+= '<div style="color: rgb(255, 255, 255); background-color: rgb(0, 0, 0); opacity: 0.5; position: relative;left: 145px;  bottom: 30px; width: 53px;height:15px;">'+duration+'</div>';
                    dom1+= '<div class="playImage" onclick="play(\''+http_play_url+'\')"><img src="/images/img_icon.png" width="30" height="30"/></div>';
                    dom1+= '</div>';
                    if(page_size>=(total_count-1)*20 &&  page_size <(total_count-1)*20+20)
                    {
                        $("#main_body").prepend(dom);
                        $("#main_body1").prepend(dom1);
                    }
                    page_size++;
                    $("#status").html(sendName);
                }
                else if(status == 0 || status == "0")
                {
                    $("#status").html(sendName);
                }
            }
        }
    }
    page_count = Math.ceil(page_size/20);
    var page_dom = '<div class="pager Library_Page" >';
    page_dom+='<span class="Library_Page_1">'+InTotal+'<font color="red">'+page_count+'</font>&nbsp;'+Page+',<font color="red">'+page_size+'</font>'+NumberOfData+'&nbsp;&nbsp;</span>';
    page_dom+='<a href="javascript:void(0)"  onclick="gotoPage3(1)">'+HomePage+'</a>';
    if(total_count-1>0)
    {
        page_dom+='<a href="javascript:void(0)" onclick="gotoPage3('+(total_count-1)+')">'+PreviousPage+'</a>';
    }
    var page_arr = calculatePageIndex(total_count,page_count,5);
    for(var i=page_arr[0];i<=page_arr[1];i++)
    {
        if(i == total_count)
        {
            page_dom+='<a href="javascript:void(0)" style="background-color: #3EAFE0" class="Library_Page_NoPage">'+i+'</a>';
        }
        else
        {
            page_dom+='<a href="javascript:void(0)" onclick="gotoPage3('+i+')" class="Library_Page_NoPage">'+i+'</a>';
        }
    }
    if(total_count+1<=page_count)
    {
        page_dom+='<a href="javascript:void(0)" onclick="gotoPage3('+(total_count+1)+')">'+NextPage+'</a>';
    }
    page_dom+='<a href="javascript:void(0)" onclick="gotoPage3('+page_count+')">'+Shadowe+'</a>';
    page_dom+='</div>';

    $("#pager_outer").html(page_dom);
    $("#pager_outer1").html(page_dom);
    $(".AddPlayIco").each(function(){
        $(this).hover(
            function(){
                $(this).find(".playImage").show();
            },
            function(){
                $(this).find(".playImage").hide();
            });
    })
}



//直播分页
function gotoPage2(total_count)
{
    var page_count = 0;
    var page_size = 0;
    $("#main_body").empty();
    $("#main_body1").empty();
    var show_type = $("#div1").css("display");
    if(show_type == "block")
    {
        $("#div1").show();
        $("#div2").hide();
    }
    else
    {
        $("#div1").hide();
        $("#div2").show();
    }
    var obj = recordFileObj;
    obj = $.parseJSON(obj);
    for(var i=0;i<obj.length;i++)
    {
        var id = obj[i].id;
        var aa = obj[i].fileName;
        bb = aa;
        bb = bb.replace("\\","/");
        var appName = obj[i].appName;
        var liveName = obj[i].liveName;
        var status = obj[i].status;
        var videoName = appName+"/"+liveName;
        var name = aa.substr(aa.lastIndexOf("/")+1,aa.length);
        var Image = name.substr(0,name.lastIndexOf("."));
        var wholePath = aa.substr(0,aa.lastIndexOf("/")+1);
        var vodPath = wholePath.substr(wholePath.indexOf("/"),wholePath.length);
        var create_time = obj[i].createDate;
        var path = aa;
        var videopath = aa.substr(aa.indexOf(":")+2,aa.length);
        var http_url = "http://"+host+":"+port+"/"+videopath;
        var videopath1 = videopath.substring(0,videopath.indexOf(videoName));
        videopath1 = videopath1.replace("/","|");
        var videopath2 = videopath.substring(videopath.indexOf(videoName),videopath.length);
        var videopath3 = videopath1 + videopath2;
        var rtmp_url = "rtmp://"+host+":"+rtmp_port+"/"+videopath3;
        var http_play_url = replace_url(http_url);
        var rtmp_play_url = replace_url(rtmp_url);
        var imagePath = "";
        var cfgFile = "http://"+host+":"+http_port+vodPath+Image+'.cfg';
        var cfgObj = "";
        var duration = "";
        var resolution = "";
        var img = "";
        var img_name = "";
        //获取视频时间
        if(sendName == videoName)
        {
            $.ajax({
                type: "post",
                async: false,
                url: cfgFile,
                success: function(data)
                {
                    var dataArr = "["+data+"]";
                    cfgObj = $.parseJSON(dataArr);
                    for(var i=0;i<cfgObj.length ;i++)
                    {
                        duration = cfgObj[i].duration;
                        resolution = cfgObj[i].resolution;
                        img = cfgObj[i].img;
                        for(var j=0;j<img.length ;j++)
                        {
                            img_name = img[0].name;
                        }
                    }
                },
                error:function(cfg)
                {

                }
            });
            var name_cut = img_name.substr(img_name.indexOf(":")+1,img_name.length);
            imagePath = "http://"+host+":"+port+name_cut;
            if(status == 1 || status == "1" || status == 2 || status == "2" || status == 3 || status == "3" || status == 4 || status == "4"
                || status == 6 || status == "6" || status == 7 || status == "7")
            {
                var dom = '<div style="width: 100%;height: 21px;">';
                dom+= '<div style="width: 380px;float:left;cursor: pointer" onclick="play(\''+http_play_url+'\')">'+name+'</div>';
                dom+= '<div style="width: 380px;float:left;">'+duration+'</div>';
                dom+= '<div style="width: 380px;float:left;">'+resolution+'</div>';
                dom+= '</div>';
                var dom1 = '<div class="AddPlayIco">';
                dom1+= '<div style="width:135px;height:75px;"><img src="'+imagePath+'" id="image" title="'+name+'" width="200" height="85" onclick="play(\''+http_play_url+'\')" onerror=\'this.src="/images/video.jpg"\'></div>';
                dom1+= '<div style="width:185px;height:14px;overflow: hidden;">'+name+'</div>';
                dom1+= '<div style="color: rgb(255, 255, 255); background-color: rgb(0, 0, 0); opacity: 0.5; position: relative;left: 145px;  bottom: 30px; width: 53px;height:15px;">'+duration+'</div>';
                dom1+= '<div class="playImage" onclick="play(\''+http_play_url+'\')"><img src="/images/img_icon.png" width="30" height="30"/></div>';
                dom1+= '</div>';
                if(page_size>=(total_count-1)*20 &&  page_size <(total_count-1)*20+20)
                {
                    $("#main_body").prepend(dom);
                    $("#main_body1").prepend(dom1);
                }
                page_size++;
                $("#status").html(sendName);
            }
            else if(status == 0 || status == "0")
            {
                $("#status").html(sendName);
            }
        }
    }
    page_count = Math.ceil(page_size/20);
    var page_dom = '<div class="pager Library_Page" >';
    page_dom+='<span class="Library_Page_1">'+InTotal+'<font color="red">'+page_count+'</font>&nbsp;'+Page+',<font color="red">'+page_size+'</font>'+NumberOfData+'&nbsp;&nbsp;</span>';
    page_dom+='<a href="javascript:void(0)"  onclick="gotoPage2(1)">'+HomePage+'</a>';
    if(total_count-1>0)
    {
        page_dom+='<a href="javascript:void(0)" onclick="gotoPage2('+(total_count-1)+')">'+PreviousPage+'</a>';
    }
    var page_arr = calculatePageIndex(total_count,page_count,5);
    for(var i=page_arr[0];i<=page_arr[1];i++)
    {
        if(i == total_count)
        {
            page_dom+='<a href="javascript:void(0)" style="background-color: #3EAFE0" class="Library_Page_NoPage">'+i+'</a>';
        }
        else
        {
            page_dom+='<a href="javascript:void(0)" onclick="gotoPage2('+i+')" class="Library_Page_NoPage">'+i+'</a>';
        }
    }
    if(total_count+1<=page_count)
    {
        page_dom+='<a href="javascript:void(0)" onclick="gotoPage2('+(total_count+1)+')">'+NextPage+'</a>';
    }
    page_dom+='<a href="javascript:void(0)" onclick="gotoPage2('+page_count+')">'+Shadowe+'</a>';
    page_dom+='</div>';

    $("#pager_outer").html(page_dom);
    $("#pager_outer1").html(page_dom);
    $(".AddPlayIco").each(function(){
        $(this).hover(
            function(){
                $(this).find(".playImage").show();
            },
            function(){
                $(this).find(".playImage").hide();
            });
    })
}


//直播搜索分页
function gotoPage3(total_count)
{
    var page_count = 0;
    var page_size = 0;
    var key = $("#key").val();
    $("#main_body").empty();
    $("#main_body1").empty();

    var show_type = $("#div1").css("display");
    if(show_type == "block")
    {
        $("#div1").show();
        $("#div2").hide();
    }
    else
    {
        $("#div1").hide();
        $("#div2").show();
    }
    var obj = recordFileObj;
    obj = $.parseJSON(obj);
    for(var i=0;i<obj.length;i++)
    {
        var id = obj[i].id;
        var aa = obj[i].fileName;
        bb = aa;
        bb = bb.replace("\\","/");
        var appName = obj[i].appName;
        var liveName = obj[i].liveName;
        var status = obj[i].status;
        var videoName = appName+"/"+liveName;
        var name = aa.substr(aa.lastIndexOf("/")+1,aa.length);
        var Image = name.substr(0,name.lastIndexOf("."));
        var wholePath = aa.substr(0,aa.lastIndexOf("/")+1);
        var vodPath = wholePath.substr(wholePath.indexOf("/"),wholePath.length);
        var create_time = obj[i].createDate;
        var path = aa;
        var videopath = aa.substr(aa.indexOf(":")+2,aa.length);
        var http_url = "http://"+host+":"+port+"/"+videopath;
        var videopath1 = videopath.substring(0,videopath.indexOf(videoName));
        videopath1 = videopath1.replace("/","|");
        var videopath2 = videopath.substring(videopath.indexOf(videoName),videopath.length);
        var videopath3 = videopath1 + videopath2;
        var rtmp_url = "rtmp://"+host+":"+rtmp_port+"/"+videopath3;
        var http_play_url = replace_url(http_url);
        var rtmp_play_url = replace_url(rtmp_url);
        var imagePath = "";
        var cfgFile = "http://"+host+":"+http_port+vodPath+Image+'.cfg';
        var cfgObj = "";
        var duration = "";
        var resolution = "";
        var img = "";
        var img_name = "";
        //获取视频时间
        if(sendName == videoName)
        {
            if(name.indexOf(key) != -1) {
                $.ajax({
                    type: "post",
                    async: false,
                    url: cfgFile,
                    success: function(data)
                    {
                        var dataArr = "["+data+"]";
                        cfgObj = $.parseJSON(dataArr);
                        for(var i=0;i<cfgObj.length ;i++)
                        {
                            duration = cfgObj[i].duration;
                            resolution = cfgObj[i].resolution;
                            img = cfgObj[i].img;
                            for(var j=0;j<img.length ;j++)
                            {
                                img_name = img[0].name;
                            }
                        }
                    },
                    error:function(cfg)
                    {

                    }
                });
                var name_cut = img_name.substr(img_name.indexOf(":")+1,img_name.length);
                imagePath = "http://"+host+":"+port+name_cut;
                if(status == 1 || status == "1" || status == 2 || status == "2" || status == 3 || status == "3" || status == 4 || status == "4"
                    || status == 6 || status == "6" || status == 7 || status == "7")
                {
                    var dom = '<div style="width: 100%;height: 21px;">';
                    dom+= '<div style="width: 380px;float:left;cursor: pointer" onclick="play(\''+http_play_url+'\')">'+name+'</div>';
                    dom+= '<div style="width: 380px;float:left;">'+duration+'</div>';
                    dom+= '<div style="width: 380px;float:left;">'+resolution+'</div>';
                    dom+= '</div>';
                    var dom1 = '<div class="AddPlayIco">';
                    dom1+= '<div style="width:135px;height:75px;"><img src="'+imagePath+'" id="image" title="'+name+'" width="200" height="85" onclick="play(\''+http_play_url+'\')" onerror=\'this.src="/images/video.jpg"\'></div>';
                    dom1+= '<div style="width:185px;height:14px;overflow: hidden;">'+name+'</div>';
                    dom1+= '<div style="color: rgb(255, 255, 255); background-color: rgb(0, 0, 0); opacity: 0.5; position: relative;left: 145px;  bottom: 30px; width: 53px;height:15px;">'+duration+'</div>';
                    dom1+= '<div class="playImage" onclick="play(\''+http_play_url+'\')"><img src="/images/img_icon.png" width="30" height="30"/></div>';
                    dom1+= '</div>';
                    if(page_size>=(total_count-1)*20 &&  page_size <(total_count-1)*20+20)
                    {
                        $("#main_body").prepend(dom);
                        $("#main_body1").prepend(dom1);
                    }
                    page_size++;
                    $("#status").html(sendName);
                }
                else if(status == 0 || status == "0")
                {
                    $("#status").html(sendName);
                }
            }
        }
    }
    page_count = Math.ceil(page_size/20);
    var page_dom = '<div class="pager Library_Page" >';
    page_dom+='<span class="Library_Page_1">'+InTotal+'<font color="red">'+page_count+'</font>&nbsp;'+Page+',<font color="red">'+page_size+'</font>'+NumberOfData+'&nbsp;&nbsp;</span>';
    page_dom+='<a href="javascript:void(0)"  onclick="gotoPage3(1)">'+HomePage+'</a>';
    if(total_count-1>0)
    {
        page_dom+='<a href="javascript:void(0)" onclick="gotoPage3('+(total_count-1)+')">'+PreviousPage+'</a>';
    }
    var page_arr = calculatePageIndex(total_count,page_count,5);
    for(var i=page_arr[0];i<=page_arr[1];i++)
    {
        if(i == total_count)
        {
            page_dom+='<a href="javascript:void(0)" style="background-color: #3EAFE0" class="Library_Page_NoPage">'+i+'</a>';
        }
        else
        {
            page_dom+='<a href="javascript:void(0)" onclick="gotoPage3('+i+')" class="Library_Page_NoPage">'+i+'</a>';
        }
    }
    if(total_count+1<=page_count)
    {
        page_dom+='<a href="javascript:void(0)" onclick="gotoPage3('+(total_count+1)+')">'+NextPage+'</a>';
    }
    page_dom+='<a href="javascript:void(0)" onclick="gotoPage3('+page_count+')">'+Shadowe+'</a>';
    page_dom+='</div>';

    $("#pager_outer").html(page_dom);
    $("#pager_outer1").html(page_dom);
    $(".AddPlayIco").each(function(){
        $(this).hover(
            function(){
                $(this).find(".playImage").show();
            },
            function(){
                $(this).find(".playImage").hide();
            });
    })
}