/**
 * 活动页面
 */

$.registerNameSpace("cga.apps.match.index");
$.cga.apps.match.index = {

    ROLL_WIDTH : 112,

    rollMatch : function() {
        var _this = this;
        var obj = $("#ul_match");
        var index = parseInt(obj.attr('index')) || 1;
        var show_len = 3;
        var li_len = obj.find('li').length;
        $("#match_left_btn").click(function() {
            if(index == 1) return;
            index--;
            obj.animate({'marginLeft' : '+='+_this.ROLL_WIDTH+'px'},300);
            obj.attr('index' , index)
        });

        $("#match_right_btn").click(function() {
            if(li_len == show_len) return;
            if(index+show_len > li_len) return;
            index++;
            obj.animate({'marginLeft' : '-='+_this.ROLL_WIDTH+'px'},300);
            obj.attr('index' , index)
        });

    }

};


$(function() {
    $.cga.apps.match.index.rollMatch();

    //赛事,报名点击
    $("[attr='reg_match']").click(function() {
        var url = $(this).attr('url');
        if(!url.length || !url) return;
        if(url.indexOf('http://') == -1) url = 'http://'+url;
        $.cga.client.client.setMainPageIndex(2); //设置到赛事按钮
        $.cga.client.client.setMainUrl(url); //设置连接
    });

    $("[attr='open_login_window']").click(function() {
        $.cga.client.client.openLoginWindow();
        return;
    });
});
