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

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

    //打开历史战报
    $("[attr='open_battle']").click(function() {
        var game_id = $(this).attr('game_id');
        var user_id = $(this).attr('user_id');
        var title = $(this).attr('title');
        var url = $.cga.config.SITE_URL + '/history?game_id='+game_id+"&user_id="+user_id;
        $.cga.client.client.openWindowUrl(894,598,title,url,'',1);
    });

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

    //打开视频url
    $("[attr='open_video_url']").click(function() {
        var url = $(this).attr('url');
        var linkmode = $(this).attr('linkmode');
        if(linkmode == 1)
        	window.open(url);
        else
        	$.cga.client.client.setMainGameUrl(1,url);
    });

    $("#gametype option[value=\""+$("#hidValue").val()+"\"]").attr("selected",true);
});
