$(function() {
    $(".dnl_right").bind("selectstart", function() {
        return false
    });
    $(".dnl_left").bind("selectstart", function() {
        return false
    })
});
$(document).ready(function() {
    var a = 0;
    var b;
    b = $(".temaizq .pic").length;
    $(".dnl_left").click(function() {
        if (b > 4) {
            a++;
            b = $(".temaizq .pic").length;
            if (a > b - 4) {
                $(".ScrCont").stop();
                a = b - 4;
                $(".ScrCont").css("left", -a * 199)
            } else {
                if (a == 1) {
                    $(".ScrCont").animate({
                        left: -a * 199,
                    }, 700)
                } else {
                    $(".ScrCont").animate({
                        left: -a * 199,
                    }, 700)
                }
            }
        }
    });
    $(".dnl_right").click(function() {
        if (b > 4) {
            if (a == 0) {
                $(".ScrCont").stop();
                $(".ScrCont").css("left", "0px")
            } else {
                a--;
                if (a == 0) {
                    $(".ScrCont").animate({
                        left: 0,
                    }, 700)
                } else {
                    $(".ScrCont").animate({
                        left: -a * 199,
                    }, 700)
                }
            }
        }
    })
});
if ($(".zhixinlb").length) {
    if ($(".zclb_qh").length) {
        $(this).find(".zhixun_zhong").eq(0).show()
    };
    $(".zx_title li").click(function() {
        $(this).addClass("zchove").siblings().removeClass("zchove");
        $(".zclb_qh").find(".zhixun_zhong").eq($(this).index()).show().siblings().hide()
    })
};
if ($(".contest_list").length) {
    chariqi()
};
zhuangtai();
wuxingbs();

function wuxingbs() {
    var b = GetDateStr(0)[0];
    var c = Math.floor((new Date()).getTime() / 1000);
    var d = $('.temaizq .pic[data-matchtime^=' + b + ']');
    $.each(d, function(i, n) {
        var a = DateToUnix($(n).attr("data-matchtime"));
        if (a < c) {
            $(n).find(".bs_ztai span").removeClass("nobing").html("比赛中")
        }
    });
    var e = GetDateStr(-1)[0];
    var f = $('.temaizq .pic[data-matchtime^=' + e + ']');
    $.each(f, function(i, n) {
        $(n).find(".bs_ztai span").html("高清直播")
    })
};
$(document).ready(function() {
    setInterval(function() {
        zhuangtai();
        wuxingbs()
    }, 60000)
});
var domainwww = $("body").attr("data-domainwww");
var domainstatic = $("body").attr("data-domainstatic");
var zburl = domainwww + "get/";
var pagezb = 1;
var morcan = {};
if ($(".contest_list").length) {
    $(".ckmorezb").click(function() {
        if ($(".ckmorezb").html() != "没有更多数据了") {
            morcan = {};
            if ($(".ckmorezb").attr("data-sort") == "all") {
                morcan.page = pagezb;
                morcan.act = 101
            };
            if ($(".ckmorezb").attr("data-sort") == "re") {
                morcan.page = pagezb;
                morcan.act = 101;
                morcan.competid = 0
            };
            if ($(".ckmorezb").attr("data-sort") == 1) {
                morcan.page = pagezb;
                morcan.act = 101;
                morcan.competid = 0;
                morcan.cid = 1
            };
            if ($(".ckmorezb").attr("data-sort") == 2) {
                morcan.page = pagezb;
                morcan.act = 101;
                morcan.competid = 0;
                morcan.cid = 2
            };
            if ($(".ckmorezb").attr("data-sort") == 3) {
                morcan.page = pagezb;
                morcan.act = 101;
                morcan.competid = 0;
                morcan.cid = 3
            };
            if ($(".ckmorezb").attr("data-sort") == 4) {
                morcan.page = pagezb;
                morcan.act = 101;
                morcan.competid = 0;
                morcan.cid = 4
            };
            zbqhajax(morcan);
            pagezb += 1
        }
    })
};
$(".zjzb_fl li").click(function() {
    pagezb = 1;
    $(this).addClass("flhover").siblings().removeClass("flhover");
    $(".contest_list").html('');
    var a = $(this).attr("data-sort");
    $(".ckmorezb").attr("data-sort", a);
    $(".ckmorezb").html("查看更多直播");
    zbqhdata();
    zbqhajax(qhcan)
});
var qhcan = {};

function zbqhdata() {
    qhcan = {};
    if ($(".ckmorezb").attr("data-sort") == "all") {
        qhcan.act = 101
    };
    if ($(".ckmorezb").attr("data-sort") == "re") {
        qhcan.act = 101;
        qhcan.competid = 1
    };
    if ($(".ckmorezb").attr("data-sort") == 1) {
        qhcan.act = 101;
        qhcan.competid = 0;
        qhcan.cid = 1
    };
    if ($(".ckmorezb").attr("data-sort") == 2) {
        qhcan.act = 101;
        qhcan.competid = 0;
        qhcan.cid = 2
    };
    if ($(".ckmorezb").attr("data-sort") == 3) {
        qhcan.act = 101;
        qhcan.competid = 0;
        qhcan.cid = 3
    };
    if ($(".ckmorezb").attr("data-sort") == 4) {
        qhcan.act = 101;
        qhcan.competid = 0;
        qhcan.cid = 4
    }
};

function zbqhajax(f) {
    $.ajax({
        url: zburl,
        cache: false,
        type: 'post',
        async: false,
        dataType: 'json',
        data: f,
        success: function(r) {
            var b = r.data.paperList;
            var c = r.competitionArr;
            var d = r.teamArr;
            if (b != undefined && b.length) {
                $.each(b, function(i, v) {
                    var a = '';
                    a += " <li data-datetime='" + v.matchtime + "'>";
                    if (c[v.competition_id] != undefined) {
                        a += "<div class='bs_fegnlei'><cite><img src='" + domainstatic + "img/flimg_" + v.tcid + ".png'></cite><p class='bs_time_fl'><i>" + v.matchtime.substring(11, 16) + "</i><span><a href='" + domainwww + "zuqiuzhibo/" + c[v.competition_id].name_py + "'>777</a></span></p></div>"
                    } else {
                        a += "<div class='bs_fegnlei'><cite><img src='" + domainstatic + "img/flimg_" + v.tcid + ".png'></cite><p class='bs_time_fl'><i>" + v.matchtime.substring(11, 16) + "</i><span><a href='" + v.name_py + "'>" + v.name + "</a></span></p></div>"
                    }; if (v.home_id == 0) {
                        a += "<div class='bs_duiwu'><p class='bs_duiwu_bt'><a href='"  + v.id + "'>" + v.title + "</a></p></div><div class='bs_video nobegin'><a href='"  + v.id + "'><cite></cite><span>高清直播</span></a></div></li>"
                    } else {
                        if (d[v.home_id] == undefined || d[v.guest_id] == undefined) {
                            if (v.title == '') {
                                a += "<div class='bs_duiwu'><p class='bs_duiwu_bt'><a href='" + v.id + "'>-</a></p></div><div class='bs_video nobegin'><a href='"  + v.id + "'> <cite></cite><span>高清直播</span></a></div></li>"
                            } else {
                                a += "<div class='bs_duiwu'><p class='bs_duiwu_bt'><a href='"  + v.id + "'>" + v.title + "</a></p></div><div class='bs_video nobegin'><a href='"  + v.id + "'> <cite></cite><span>高清直播</span></a></div></li>"
                            }
                        } else {
                            a += "<div class='bs_duiwu'><p><a href='" + domainwww + "qiudui/" + ssfenlei(d[v.home_id].tcid) + "/" + d[v.home_id].name_py + "'><span class='zhudui'><cite>" + d[v.home_id].shot_name + "</cite></span><cite class='duibiao'><img class='tu1' src='" + d[v.home_id].picurl + "' alt='" + d[v.home_id].shot_name + "'></cite></a></p><span class='bs_vs'>vs</span><p><a href='" + domainwww + "qiudui/" + ssfenlei(d[v.guest_id].tcid) + "/" + d[v.guest_id].name_py + "'><cite class='duibiao'><img class='tu1' src='" + d[v.guest_id].picurl + "' alt='" + d[v.guest_id].shot_name + "'></cite><span class='kedui'><cite>" + d[v.guest_id].shot_name + "</cite></span></a></p></div><div class='bs_video nobegin'><a href='" + domainwww + "zuqiuzhibo/" + v.id + "'> <cite></cite><span>高清直播</span></a> </div>"
                        }
                    }
                    a += "</li>";
                    $('.contest_list').append(a)
                });
                chariqi();
                zhuangtai();
                if ($(".contest_list").find("li").length >= 30) {
                    $(".ckmorezb").show()
                } else {
                    $(".ckmorezb").hide()
                }
            };
            if (b == undefined) {
                $(".ckmorezb").html("没有更多数据了");
                if ($('.contest_list li').length == 0) {
                    $(".contest_list").html("<p class='zwxgdata' style='padding: 130px 0'><span><img src='" + domainstatic + "img/nodatalb.png'></span>'<cite>暂无数据</cite>'</p>");
                    $(".ckmorezb").hide()
                }
            }
        },
        error: function(e) {},
    })
};
$(".zhankaigjc").click(function() {
    if ($(this).find("span").html() == "展开") {
        $(this).siblings(".gjc_rlist").css("height", "auto");
        $(this).find("span").html("收起");
        $(this).find("cite").addClass("upjiantou")
    } else {
        $(this).siblings(".gjc_rlist").css("height", "187px");
        $(this).find("span").html("展开");
        $(this).find("cite").removeClass("upjiantou")
    }
});
if ($(".contest_list").find("li").length > 0) {
    moreshow()
};

function moreshow() {
    var a = $(".contest_list").find("li").length;
    if (a >= 30) {
        $(".ckmorezb").show()
    }
};
if ($(".keywordr").length > 0) {
    keywordrnav()
};

function keywordrnav() {
    var a = Math.floor(($(window).width() - 1220) / 2) - (120);
    if (a < 0) {
        $(".keywordr").css("right", "0px")
    } else {
        $(".keywordr").css("right", a / 2 + "px")
    }
};