Class(function(extend, using, self){
    extend("pages/page");
    using("lib/jquery.min.js");

    self.create_group_ref = null;

    self.initEvent = function(){
        var that = this;
        // 应用按钮
        $(document).delegate(".btn-box button:eq(0)", "click", function () {
            var password_content = $(".c-password-val").val();
            var groupname = $(".c-group-name").val();
            if(groupname.length <= 0){
                $("#table1 tr:eq(0) td:eq(2)").text("房间名称不为空");
                return;
            }
            that.create_group_ref.btn_creategroup_click(password_content);
        });

        // 设置密码
        $(document).delegate("input[name='c-set-password']", "click", function () {
            if($(this).is(':checked')) {
                $(".c-password-val").removeAttr('disabled');
            } else {
                $(".c-password-val").attr('disabled','disabled');
            }
        });

        // radio
        $('#roomTypeList li').click(function() {
            return false;
            $('#roomTypeList input').removeAttr('checked');
            $(this).children('input').attr('checked', 'true');
        });

        //resize the roomtype list
        $('.scrollList').css('width', $('#roomTypeList li').length * 170);

        //left scroll
        $('div.pre').click(function() {
            if($('.scrollList').offset().left < 20) {
                $('.scrollList').animate({left: '+=150px'});
            }
        });

        //right scroll
        $('div.next').click(function() {
            if($('.scrollList').offset().left > -($('#roomTypeList li').length-4) * 170 + 20) {
                $('.scrollList').animate({left: '-=150px'});
            }
        });
    }

    self.func(function(curData){
        var that = this;
        that.sup().constructor(curData);
        that.addCall("send_group_info", function(){
            var groupname = that.encodeHTML($(".c-group-name").val());
            var password_content = $(".c-password-val").val();
            var b_set_password = 0;
            if($("input[name='c-set-password']").is(":checked")) {
                b_set_password = 1;
            }
            var group_type = that.toInt($("input[name='type-model']:checked").val());
            var text = "{ \"groupname\":\"" + groupname + "\",\"password_content\":\"" + password_content + "\",\"b_set_password\":" + b_set_password +  ",\"group_type\":" + group_type + "}";
            return that.formatData(text);
        });

        that.create_group_ref = curData;
        that.initEvent();
    });
});

//Audio.CreateSubRoom = Audio.CreateSubRoom || {create_group_ref:null};
//
//function send_group_info() {
//    var groupname = Audio.encodeHTML($(".c-group-name").val());
//    var password_content = $(".c-password-val").val();
//    var b_set_password = 0;
//    if($("input[name='c-set-password']").is(":checked")) {
//        b_set_password = 1;
//    }
//    var group_type = Audio.toInt($("input[name='type-model']:checked").val());
//    var text = "{ \"groupname\":\"" + groupname + "\",\"password_content\":\"" + password_content + "\",\"b_set_password\":" + b_set_password +  ",\"group_type\":" + group_type + "}";
//    return Audio.formatData(text);
//}

//(function () {
//
//    /* 应用按钮*/
//    $(document).delegate(".btn-box button:eq(0)", "click", function () {
//        var password_content = $(".c-password-val").val();
//        var groupname = $(".c-group-name").val();
//        if(groupname.length <= 0){
//            $("#table1 tr:eq(0) td:eq(2)").text("房间名称不为空");
//            return;
//        }
//         Audio.CreateSubRoom.create_group_ref.btn_creategroup_click(password_content);
//    });
//
//     /* 设置密码*/
//    $(document).delegate("input[name='c-set-password']", "click", function () {
//        if($(this).is(':checked')) {
//            $(".c-password-val").removeAttr('disabled');
//        } else {
//             $(".c-password-val").attr('disabled','disabled');
//        }
//    });
//
//
//})();

//window.onload = function () {Audio.CreateSubRoom.create_group_ref = creategroup;}