/**
 *  大厅首页
 */

$.registerNameSpace("cga.apps.major.room");
$.cga.apps.major.room = {
    
};

$(function() {
    //打开改建设置
    $("[attr='open_key_setting']").click(function() {
        var game_id = $(this).attr('game_id');
        $.cga.client.client.openKeySetting(game_id);
    });


    //打开游戏设置
    /*$("[attr='open_game_setting']").click(function() {
        var game_id = $(this).attr('game_id');
        $.cga.client.client.openGameSetting(game_id);
    });*/

    //开始游戏
    $("[attr='start_game']").click(function() {
        var game_id = $(this).attr('game_id'); 
        $.cga.client.client.startGame(game_id);
    });

    //打开战报
    $("[attr='open_battle']").click(function() {
        //未登录
        if(!$.cga.client.client.checkClientLogin()) {
            $.cga.client.client.openLoginWindow();
            return;
        }
        var game_id = $(this).attr('game_id');
        var title = $(this).attr('win_title');
        var url = $.cga.config.SITE_URL+'/history?game_id=' + game_id;
        var width = 894;
        var height = 598;
        $.cga.client.client.openWindowUrl(width,height,title,url,'',1);
    });

    $("[attr='open_battle_center']").click(function() {
        var url = $(this).attr('url');
        window.top.$.cga.apps.major.main.changeIframeSrc(3,url);
    });

    //打开最新战报
    $("[attr='open_new_battle']").click(function() {
        //未登录
        if(!$.cga.client.client.checkClientLogin()) {
            $.cga.client.client.openLoginWindow();
            return;
        }
        var user_id = $(this).attr('user_id');
        var game_id = $(this).attr('game_id');
        var title = $(this).attr('win_title');
      
        var url = $.cga.config.SITE_URL+'/battle/NewBattle?game_id=' + game_id+'&user_id='+user_id;
       
        var width = 894;
        var height = 598;
        $.cga.client.client.openWindowUrl(width,height,title,url,'',1);
    });


    //切换状态
    $("#ul_main_game li").hover(function(){
        $(this).addClass("active");
    },function(){
        $(this).removeClass("active");
    });


});
