Class(function(extend, using, self){


//    <!--<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>-->
//        <!--<script type="text/javascript" src="js/plugin/switchtab.js"></script>-->
//        <!--<script type="text/javascript" src="js/plugin/jquery-ui.min.js"></script>-->
//        <!--<script type="text/javascript" src="js/city-change.js"></script>-->
//        <!--<script type="text/javascript" src="js/common.js"></script>-->
//        <!--<script type="text/javascript" src="js/user.js"></script>-->
    extend("pages/page");
    using("lib/jquery.min.js");
    using("plugin/switchtab")
    var cityPlugin = null;
    using("plugin/jquery-ui.min")
    var data = null;

    self.user_ref = null;
    self.on_change = 0;
    // 用户点击确定按钮的时候如果传入参数 0 则不做处理 1 则做处理
    self.img_path = "";
    self.room_id = 0;
    self.user_indentity = 0;
    self.location = null;
    self.initPage = function () {
        set_input_style();
        /* 初始化选择默认页面li */
        var that = this;
        var default_index = this.user_ref.get_show_index();
        select_default_li(default_index);
        var video_flag = this.user_ref.is_display_video_set();
        video_show(video_flag); //是否显示视频
        that.log_trace(userinfo, "User initPage  start");
        that.log_trace(userinfo, "User bindMyUserInfo  start");
        /* 绑定用户信息 */
        this.bindMyUserInfo();
        that.log_trace(userinfo, "User bindMyUserInfo  end");
        that.log_trace(userinfo, "User bindSystemInfo  start");
        /* 绑定系统设置信息 */
        this.bindSystemInfo();

        that.log_trace(userinfo, "User bindSystemInfo  end");
        that.log_trace(userinfo, "User bindAudioInfo  start");
        /* 绑定语音设置 */
        this.bindAudioInfo();

        that.log_trace(userinfo, "User bindAudioInfo  end");
        that.log_trace(userinfo, "User bindVideoInfo  start");
        /* 绑定视频设置 */
        this.bindVideoInfo();

        that.log_trace(userinfo, "User bindVideoInfo  end");
        that.log_trace(userinfo, "User bindAudioVideoInfo  start");
        /* 绑定语音、视频初始值 */
        this.bindAudioVideoInfo();

        that.log_trace(userinfo, "User bindAudioVideoInfo  end");
        that.log_trace(userinfo, "User initMyRoomInfo  start");
        /* 初始化我的房间信息 */
        that.initMyRoomInfo();

        that.log_trace(userinfo, "User initMyRoomInfo  end");
        that.log_trace(userinfo, "User bindMyRoomInfo  start");
        /* 绑定我的房间信息 */
        that.bindMyRoomInfo(1, 0);
        that.log_trace(userinfo, "User bindMyRoomInfo  end");
        that.log_trace(userinfo, "User contextMenu newsBar  start");
        $(".set-btn-box li").SwitchTab({  // $('.newsBar a') 点击元素
            showObj: '.set-content',        // 需显示的内容（必填项）
            mouseEvent: 'click',    // 鼠标事件设定，默认：click
            currentClass: 'active',     //当前tab class
            showEffect: "show",     // 默认show（无效果），fade（渐隐渐现）,slide（窗帘效果）
            active: function (target) {
                var index = parseInt(target.attr("index"));
                switch (index) {
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                        that.user_ref.showVideoWnd(false, -1);
                        break;
                    case 5:
                        that.user_ref.set_video_hwnd(document.getElementById("object-vedio").getHwnd());
                        that.user_ref.showVideoWnd(true, $("select[name='c-select-video']").val());
                        break;
                }
            }
        });

        that.log_trace(userinfo, "User contextMenu newsBar  end");
        /**
         * 左键菜单
         */
        that.log_trace(userinfo, "User left contextMenu  start");
        date_sx();
        that.log_trace(userinfo, "User left contextMenu  end");
        that.log_trace(userinfo, "User initPage  end");

    }
    // 绑定Year信息
    self.bindYearInfo = function (_y) {
        var years = [];
        var d = new Date();
        var now_year = d.getFullYear();
        if (_y < 1954) {
            for (var i = _y; i <= now_year; i++) {
                years.push("<option value=\"" + i + "\">" + i + "</option>");
            }
        } else {
            for (var i = now_year - 60; i <= now_year; i++) {
                years.push("<option value=\"" + i + "\">" + i + "</option>");
            }
        }
        var c = $("select[name='c-select-year']");
        c.empty().append(years.join(""));
        c.find("option[value='" + _y + "']").prop("selected", true);
    }
    // 绑定Month信息 */
    self.bindMonthInfo = function (_m) {
        var month = [];
        for (var i = 1; i <= 12; i++) {
            month.push("<option value=\"" + i + "\">" + i + "</option>");
        }
        var c = $("select[name='c-select-month']");
        c.empty().append(month.join(""));
        c.find("option[value='" + _m + "']").prop("selected", true);
    }
    /* 绑定Day信息 */
    self.bindDayInfo = function (_y, _m, _d) {
        var days = [];
        var month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
        if ((_y % 4 == 0 && _y % 100 != 0) || (_y != 0 && _y % 400 == 0)) {
            month_days[1] = 29;
        }
        else {
            month_days[1] = 28;
        }
        for (var i = 1; i <= month_days[parseInt(_m) - 1]; i++) {
            days.push("<option value=\"" + i + "\">" + i + "</option>");
        }
        var c = $("select[name='c-select-day']");
        c.empty().append(days.join(""));
        c.find("option[value='" + _d + "']").prop("selected", true);
    }
    /* 绑定用户信息 */
    self.bindMyUserInfo = function () {
        var info = this.user_ref.get_user_info();
        var that = this;


        add_default_img(); //通过性别增加默认头像
        if (info) {
            that.img_path = info.szImgExt;
            $(".head-box img:first").attr("src", "file:///" + info.szImgExt + "?t=" + Math.random());
            var u = $(".user-info");
            u.find(".user-name").text(info.wszUserName);
            //u.find(".user-nick-name").val(info.wszNickName);
            u.find(".user-nick-name").text(info.wszNickName);
            u.find(".user-credit").text(parseInt(info.uExperience / 60));
            u.find(".mark").val(info.sign);
            u.find(".popularity").text(info.popularity);
            // 魅力值
            $('#td-charm').text(Math.round(info.charm));

            // 勋章(数组)
            this.addAward(info.award, info.awardtips);

            if (info.location.length <= 0) {
                u.find(".selInput").text("");
                country_id = 1;
                data.country = "";
                data.city = "";
                data.area = "";
            } else {
                u.find(".selInput").text(info.location);
            }
            var location = info.location.split(" ");
            if (location.length) {
                if (location.length == 3) {
                    data.country = location[0];
                    data.city = location[1];
                    data.area = location[2];
                } else if (location.length == 2) {
                    data.city = location[0];
                    data.area = location[1];
                } else {
                    data.city = location[0];
                    data.area = location[0];
                }

            }

            var level = parseInt(Math.sqrt(info.uExperience / 60));
            var level_class = " span:first";
            that.change_class_by_level(level, level_class);
            u.find(".Integral span:first strong").text(level);
            u.find("select[name='c-select-sex']").find("option[value='" + info.bUserSex + "']").prop("selected", true);
            var birthDay = new Date(info.szBirthDate.replace("00:00:00", "").replace(" ", ""));
            if (isNaN(birthDay.getFullYear())) {
                var d = new Date();
                var year = d.getFullYear();
                this.bindYearInfo(year - 60);
                this.bindMonthInfo(1);
                this.bindDayInfo(year, 1, 1);
            } else {
                this.bindYearInfo(birthDay.getFullYear());
                this.bindMonthInfo(birthDay.getMonth() + 1);
                this.bindDayInfo(birthDay.getFullYear(), parseInt(birthDay.getMonth()) + 1, birthDay.getDate());
            }
            //var user_age = info.uAge;
            var user_age = 0;
            if (user_age == 0) {
                var year = birthDay.getFullYear();
                var d = new Date();
                var now_year = d.getFullYear();
                user_age = now_year - year;
            }
            if (isNaN(user_age)) {
                user_age = 0;
            }
            u.find(".c-age").text(user_age);
        }
    }
    self.addAward = function(arr, tips){
        var $td = $('#td-award').html('');
        var i = 0;
        var len = arr.length;
        for(i = 0; i < len; i++){
            $td.append($('<img>').attr('src', 'file:///'+arr[i]).attr('title', tips[i]));
        }
    }
    /* 绑定系统设置 */
    self.bindSystemInfo = function () {
        var info = this.user_ref.get_system_set_info();
        if (info.autoRun) {
            $("input[class='c-open-auto-checkbox']").prop("checked", true);
        }
        if (info.autoLogin) {
            $("input[class='c-open-auto-login-checkbox']").prop("checked", true);
        }
        if (info.closeMode) {
            $("input[name='prog-status'][value='" + 1 + "']").prop("checked", true);
        } else {
            $("input[name='prog-status'][value='" + 0 + "']").prop("checked", true);
        }
    }
    /* 绑定语音设置 */
    self.bindAudioInfo = function () {
        var mic_infos = Array();
        var mic_info = this.user_ref.get_mico_device_list();
        if (mic_info) {
            for (var i = 0; i < mic_info.length; i++) {
                //mic_infos.push("<option value=\"" + mic_info[i] + "\">" + mic_info[i] + "</option>");
                mic_infos.push("<option value=\"" + i + "\">" + mic_info[i] + "</option>");
            }
        }
        $("select[name='c-select-mic']").append(mic_infos.join(""));

        var spk_infos = Array();
        var spk_info = this.user_ref.get_speak_device_list();
        if (spk_info) {
            for (var i = 0; i < spk_info.length; i++) {
                //spk_infos.push("<option value=\"" + spk_info[i] + "\">" + spk_info[i] + "</option>");
                spk_infos.push("<option value=\"" + i + "\">" + spk_info[i] + "</option>");
            }
        }
        $("select[name='c-select-spk']").append(spk_infos.join(""));
    }
    /* 绑定视频设置 */
    self.bindVideoInfo = function () {
        var infos = Array();
        var info = this.user_ref.get_vedio_device_list();
        if (info) {
            for (var i = 0; i < info.length; i++) {
                //infos.push("<option value=\"" + info[i] + "\">" + info[i] + "</option>");
                infos.push("<option value=\"" + i + "\">" + info[i] + "</option>");
            }
        }
        if (infos.length > 0) {
            $("select[name='c-select-video']").empty().append(infos.join(""));
        }
    }
    /* 绑定语音、视频设置 */
    self.bindAudioVideoInfo = function () {
        var that = this;
        var info = this.user_ref.get_audio_video_info();
        if (info) {
            $("select[name='c-select-mic']").find("option[value='" + info.micoIndex + "']").prop("selected", true);
            $("select[name='c-select-spk']").find("option[value='" + info.speakIndex + "']").prop("selected", true);
            $("select[name='c-select-video']").find("option[value='" + info.videoIndex + "']").prop("selected", true);
            //设置麦克风扬声器初始值
            var _rb1 = $('#input-range-mic');
            var _fv1 = $("#fv");
            $("#fv").text(info.micoVolume);
            $("#fv1").text(info.speakVolume);
            _rb1.slider({
                range: "min",
                value: info.micoVolume,
                min: 0,
                max: 100,
                slide: function (event, ui) {
                    _fv1.show();
                    _fv1.css({
                        'left': event.pageX
                    });
                    _fv1.text(ui.value);
                    /* 麦克风div */
                    that.user_ref.on_change_mic_vol(ui.value);
                }
            });
            _rb1.mousedown(function (e) {
                _fv1.css({
                    'top': e.pageY - 20
                });
            });
            var _rb2 = $('#input-range-speaker');
            var _fv2 = $("#fv1");
            _rb2.slider({
                range: "min",
                value: info.speakVolume,
                min: 0,
                max: 100,
                slide: function (event, ui) {
                    _fv2.show();
                    _fv2.css({
                        'left': event.pageX
                    });
                    _fv2.text(ui.value);
                    /* 扬声器div */
                    that.user_ref.on_change_spk_vol(ui.value);
                }
            });
            _rb2.mousedown(function (e) {
                _fv2.css({
                    'top': e.pageY - 20
                });
            });
            $('body').mouseup(function () {
                _fv1.fadeOut();
                _fv2.fadeOut();
            });
        }
    } /* 设置应用的状态 */
    self.settingApply = function (apply_status) {
        if (apply_status) {
            $(".c-btn-apply").removeAttr("disabled").removeClass("disabled");
            this.on_change = 1;
        } else {
            $(".c-btn-apply").attr("disabled", "disabled").addClass("disabled");
            this.on_change = 0;
        }
    }

    self.total_count = 0;
    self.page_size = 0;
    self.page_index = 0;
    self.page_count = 0;
    self.page_index_sort_key = 0;
    self.initMyRoomInfo = function () {
        this.total_count = this.user_ref.get_myroom_count();
        if (this.total_count % 6 == 0) {
            this.page_count = parseInt(this.total_count / 6);
        }
        else {
            this.page_count = parseInt(this.total_count / 6) + 1;
        }
    }
    self.getMyRoomInfo = function (index) {
        return this.user_ref.get_myroominfo_by_index(index);
    }
    // 绑定房间信息
    self.bindMyRoomInfo = function (page_index, sort_key) {
        var items = Array();
        items.push('<tr class="c-room-info c-room-list-{roomid}">');
        items.push('<td><div title="{title}">{name}</div></td>');
        items.push('<td>{roomid}</td>');
        items.push('<td><img src="static/images/role/{image}" alt="" /></td>');
        items.push('<td class="c-room-info-opt" indentity="{indentity}" roomid="{roomid}"><span class="down-arrow-ico"></span></td>');
        items.push('</tr>');
        var infos = Array();


        if (sort_key == 0) {
            this.page_index_sort_key = 0;
            for (var i = (page_index - 1) * 6; i < page_index * 6; i++) {
                if (i < this.total_count) {
                    var text = items.join("");
                    var info = this.getMyRoomInfo(i);
                    var title = info.zonename;
                    infos.push(text.replace(/\{title\}/g, title.replace(/\"/g, "\'")).replace(/\{name\}/g, this.encodeHTML(info.zonename)).replace(/\{roomid\}/g, info.zoneid).replace(/\{image\}/g, info.idtimage).replace(/\{indentity\}/g, info.indentity));
                }
            }
        }

        if (sort_key == 1) {
            this.page_index_sort_key = 1;
            var start_count = this.total_count - (page_index - 1) * 6 - 1;
            var end_count = this.total_count - page_index * 6 - 1;
            if (end_count < 0) {
                end_count = 0;
            }
            for (var i = start_count; i >= end_count; i--) {
                var text = items.join("");
                var info = this.getMyRoomInfo(i);
                infos.push(text.replace(/\{name\}/g, this.encodeHTML(info.zonename)).replace(/\{roomid\}/g, info.zoneid).replace(/\{image\}/g, info.idtimage).replace(/\{indentity\}/g, info.indentity));
            }
        }

        this.page_index = page_index;
        $(".user-list tbody").remove();
        $(".user-list colgroup").after("<tbody>" + infos.join("") + "</tbody>");
    }

    self.initEvent = function(){
        var that = this;

        /*点击按钮*/
        $(document).delegate(".set-box .btn .left", "click", function (e) {
            that.user_ref.btn_alter_image_click();
        });

        /*点击名片*/
        $(document).delegate(".set-box .btn .right", "click", function (e) {
            that.user_ref.btn_alter_card_click();
        });


        /*点击头像*/
        $(document).delegate(".set-box .head-box img:first", "click", function (e) {
            that.user_ref.btn_alter_image_click();
        });

        $(document).delegate(".c-room-info", "click", function (e) {
            $(".c-room-info").each(function () {
                $(this).removeClass("active");
            });
            $(this).addClass("active");
        });


        $(document).delegate(".c-room-info-opt", "click", function (e) {
            e.stopPropagation();
            var menu = $('.user-context-menu-item');
            that.room_id = $(this).attr("roomid");
            that.user_indentity = $(this).attr("indentity");
            var curUserInfo = that.user_ref.get_user_info();

            if (curUserInfo.zoneid == that.room_id){
                menu.find("a:eq(0)").hide();
            } else
                menu.find("a:eq(0)").show();

            if (that.user_indentity < 16) {
                menu.find('a:eq(4)').show();
            } else {
                menu.find('a:eq(4)').hide();
            }
            if (that.user_ref.is_collected_room(that.room_id)) {
                if (menu.length > 0) {
                    menu.find('a:eq(2)').hide();
                    menu.find('a:eq(3)').show();
                }
            }
            else {
                if (menu.length > 0) {
                    menu.find('a:eq(2)').show();
                    menu.find('a:eq(3)').hide();
                }
            }
            var menu_top = $(this).offset().top + 17;
            var $win = $(window);
            var bottom = $win.height();
            var height = menu.height();
            if (menu_top + height > bottom) {
                menu_top -= height;
                menu.css({top: menu_top, left: 386}).show();
            } else {
                menu.css({top: menu_top, left: 386}).show();
            }
        }).delegate('.c-room-info-opt', 'mouseleave', function () {
            that.tipid && clearTimeout(that.tipid), that.tipid = setTimeout(function () {
                $('.user-context-menu-item').hide();
            }, 200);
        }).delegate('.user-context-menu-item', 'mouseenter', function () {
            that.tipid && clearTimeout(that.tipid);
        }).delegate('.user-context-menu-item', 'mouseleave', function () {
            $('.user-context-menu-item').hide();
        });

        $(document).delegate(".user-context-menu-item a", "click", function () {
            var key = $(this).attr("item");
            switch (key) {
                case "join":
                    that.user_ref.enter_room(that.room_id);
                    break;
                case "view":
                    that.user_ref.view_room(that.room_id);
                    break;
                case "add":
                    that.user_ref.collect_room(that.room_id);
                    $('.user-context-menu-item').hide();
                    break;
                case "cancel":
                    that.user_ref.uncollect_room(that.room_id);
                    $('.user-context-menu-item').hide();
                    break;
                case "exit":
                    that.user_ref.release_member_room(that.room_id, that.user_indentity);
                    $('.user-context-menu-item').hide();
                    break;
            }
        });

        $(document).delegate(".c-room-info", "dblclick", function () {
            var roomid = $(this).find(".c-room-info-opt").attr("roomid");
            that.user_ref.enter_room(roomid);
        });


        /* 更新性别时更新应用按钮状态 */
        $(document).delegate("select[name='c-select-sex']", "change", function () {
            that.settingApply(true);
        });


        /* 更新昵称时更新应用按钮状态 */
        $(document).delegate(".user-nick-name", "input", function () {
            that.settingApply(true);
        });

        /* 更新签名时更新应用按钮状态 */
        $(document).delegate(".mark", "input", function () {
            that.settingApply(true);
        });


        /* 更新签名时更新应用按钮状态 */
        $(document).delegate(".mark", "input", function () {
            that.settingApply(true);
        });


        /* 更改年份时初始化天数、且更新应用按钮状态 */
        $(document).delegate("select[name='c-select-year']", "change", function () {
            var year = parseInt($(this).val());
            that.bindDayInfo(year, $(this).next().val(), 1);
            $("tr .c-age").text(new Date().getFullYear() - year);
            that.settingApply(true);
        });

        /* 更改月份时初始化天数、且更新应用按钮状态 */
        $(document).delegate("select[name='c-select-month']", "change", function () {
            var year = parseInt($(this).prev().val());
            that.bindDayInfo(year, $(this).val(), 1);
            $("tr .c-age").text(new Date().getFullYear() - year);
            date_sx();
            that.settingApply(true);
        });

        /* 更改天数时更新应用按钮状态 */
        $(document).delegate("select[name='c-select-day']", "change", function () {
            date_sx();
            that.settingApply(true);
        });

        /* 变更 开机自启动 状态时 更新应用按钮状态 */
        $(document).delegate("input[class='c-open-auto-checkbox']", "change", function () {
            that.settingApply(true);
        });

        /* 变更 开机自登陆 状态时 更新应用按钮状态 */
        $(document).delegate("input[class='c-open-auto-login-checkbox']", "change", function () {
            that.settingApply(true);
        });

        /* 变更 主面板 状态时 更新应用按钮状态 */
        $(document).delegate("input[name='prog-status']", "change", function () {
            that.settingApply(true);
        });
        /*
         * 点击label，相邻兄弟节点checked改变状态
         */
        $(document).delegate(".c-many-check", "click", function () {
            that.settingApply(true);
            var flag = $(this).prev().is(":checked");
            if (flag == true) {
                $(this).prev().prop('checked', false);
            } else {
                $(this).prev().prop('checked', true);
            }
        });

        /* 点击label，相邻兄弟节点checked改变状态
         */
        $(document).delegate(".c-one-check", "click", function () {
            that.settingApply(true);
            $(this).prev().prop('checked', true);
        });

        /* 上一页 */
        $(document).delegate(".paging-box a:eq(0)", "click", function () {
            if (that.page_index <= 1) {
                return;
            }
            var sort_key = that.page_index_sort_key;
            switch (sort_key) {
                case 0:
                    that.bindMyRoomInfo(--that.page_index, 0);
                    break;
                case 1:
                    that.bindMyRoomInfo(--that.page_index, 1);
                    break;
            }
        });

        /* 下一页 */
        $(document).delegate(".paging-box a:eq(1)", "click", function () {
            if (that.page_index == that.page_count) {
                return;
            }
            var sort_key = that.page_index_sort_key;
            switch (sort_key) {
                case 0:
                    that.bindMyRoomInfo(++that.page_index, 0);
                    break;
                case 1:
                    that.bindMyRoomInfo(++that.page_index, 1);
                    break;
            }
        });

        /* 试麦 */
        $(document).delegate(".c-test-mic", "click", function () {
            var micoVolume = that.toInt($('#input-range-mic').slider("option", "value"));
            var speakVolume = that.toInt($('#input-range-speaker').slider("option", "value"));
            that.user_ref.on_change_mic_vol(micoVolume);
            that.user_ref.on_change_spk_vol(speakVolume);
            that.user_ref.btn_check_audio_click();
        });

        $(document).delegate(".c-btn-confirm", "click", function () {
            that.user_ref.btn_ok_click(that.on_change);
        });

        $(document).delegate(".c-btn-cancel", "click", function () {
            that.user_ref.btn_cancel_click();
        });

        $(document).delegate(".c-btn-apply", "click", function (event) {
            event.stopPropagation();
            that.settingApply(false);
            var reg = /\/[0-9]{1,}\./g;
            var img_srv = $(".head-box img:first").attr("src");
            var img_path = that.img_path;
            var m = img_path.match(reg);
            if (img_srv.indexOf(m) < 0) {
                var use_sex = $("select[name='c-select-sex']  option:selected").val();
                change_default_img(use_sex);
            }
            that.user_ref.btn_apply_click();

        });

        /*视频设备切换*/
        $(document).delegate("select[name='c-select-video']", "change", function () {
            var value = $(this).val();
            that.user_ref.showVideoWnd(true, value);
        });


        /*麦克风驱动程序切换*/
        $(document).delegate("select[name='c-select-mic']", "change", function () {
            that.settingApply(true);
        });

        /*扬声器驱动程序切换*/
        $(document).delegate("select[name='c-select-spk']", "change", function () {
            that.settingApply(true);
        });

        /* 我的房间身份排序切换*/
        $(document).delegate(".c-down-arrow-ico", "click", function () {
            $(".user-list-box .c-room-info").remove();
            $("span[rol='c-arrow-ico']").addClass("c-up-arrow-ico").addClass("up-arrow-ico").removeClass("down-arrow-ico").removeClass("c-down-arrow-ico");
            that.initMyRoomInfo();
            /* 绑定我的房间信息 */
            that.bindMyRoomInfo(1, 1);
        });

        /* 我的房间身份排序切换*/
        $(document).delegate(".c-up-arrow-ico", "click", function () {
            $(".user-list-box .c-room-info").remove();
            $("span[rol='c-arrow-ico']").addClass("c-down-arrow-ico").removeClass("c-up-arrow-ico").removeClass("up-arrow-ico").addClass("down-arrow-ico");
            that.initMyRoomInfo();
            /* 绑定我的房间信息 */
            that.bindMyRoomInfo(1, 0);
        });

        /*点击下拉出按键模式菜单按钮*/
        $(document).delegate("#input-range-mic span:first", "mousemove", function () {
            var _rb = $("#fv");
            _rb.css({'top': event.pageY - 20});
            _rb.css('left', event.pageX);
            _rb.show();
        });

        /*点击下拉出按键模式菜单按钮*/
        $(document).delegate("#input-range-mic span:first", "mouseout", function () {
            var _rb = $("#fv");
            _rb.hide();
        });

        /*鼠标移动显示麦克风的tip*/
        $(document).delegate("#input-range-speaker span:first", "mousemove", function () {
            var _rb = $("#fv1");
            _rb.css({'top': event.pageY - 20});
            _rb.css('left', event.pageX);
            _rb.show();
        });

        /*鼠标移开隐藏麦克风的tip*/
        $(document).delegate("#input-range-speaker span:first", "mouseout", function () {
            var _rb = $("#fv1");
            _rb.hide();
        });
    }

    self.func(function(curData){
        var that = this;

        cityPlugin = using("plugin/city-change").New(that)
        data = cityPlugin.getData()
        /*设置下拉框样式*/
        that.addCall("set_input_style", function() {
            var _webkitHack = false;
            var _cwh = $('.hover-show-select');
            _cwh.mouseover(function () {
                _webkitHack = false;
                $('.hover-show-select').removeClass('hover');
                $(this).addClass('hover');
            });
            _cwh.mouseout(function () {
                if (_webkitHack) {
                    _webkitHack = false;
                } else {
                    $(this).removeClass('hover');
                }
            });
            _cwh.click(function () {
                if (_webkitHack) {
                    $(this).removeClass('hover');
                } else {
                    _webkitHack = true;
                }
            });
        });

        /* 提交用户个人信息 */
        that.addCall("send_user_info", function() {
            var sex = $("select[name='c-select-sex']").val();
            var year = $("select[name='c-select-year']").val();
            var month = $("select[name='c-select-month']").val();
            var day = $("select[name='c-select-day']").val();
            var u = $(".user-info");
            var signin = "";
            signin = u.find(".mark").val();
            var location = u.find(".selInput").text();
            //var wszNickName = u.find(".user-nick-name").val();
            var wszNickName = u.find(".user-nick-name").text();
            if (month < 10) {
                month = "0" + month;
            }
            if (day < 10) {
                day = "0" + day;
            }
            var text = "{ \"sign\":\"" + signin + "\",\"location\":\"" + location + "\",\"wszNickName\":\"" + wszNickName + "\",\"szBirthDate\":\"" + year + "-" + month + "-" + day + " 00:00:00\",\"bUserSex\":" + sex + "}";
            return that.formatData(text);
        });

        /* 提交音频设置信息 */
        that.addCall("send_audio_audio_info", function() {
            var currentMicoName = $("select[name='c-select-mic'] option:selected").text();
            var currentSpeakName = $("select[name='c-select-spk'] option:selected").text();
            var currentVideoName = $("select[name='c-select-video'] option:selected").text();
            var micoVolume = that.toInt($('#input-range-mic').slider("option", "value"));
            var speakVolume = that.toInt($('#input-range-speaker').slider("option", "value"));
            var micoIndex = that.toInt($("select[name='c-select-mic'] option:selected").val());
            var speakIndex = that.toInt($("select[name='c-select-spk'] option:selected").val());
            var videoIndex = that.toInt($("select[name='c-select-video'] option:selected").val());
            var str1 = "{ \"currentMicoName\":\"" + currentMicoName + "\",\"currentSpeakName\":\"" + currentSpeakName + "\",\"currentVideoName\":\"" + currentVideoName;
            var str2 = "\", \"micoVolume\":" + micoVolume + ",\"speakVolume\":" + speakVolume + ",\"micoIndex\":" + micoIndex + ",\"speakIndex\":" + speakIndex + ",\"videoIndex\":" + videoIndex + " }";
            var text = str1 + str2;
            return that.formatData(text);
        });
        /* 提交系统信息 */
        that.addCall("send_system_info", function() {
            var autoRun = 0;
            if ($("input[class='c-open-auto-checkbox']").is(":checked")) {
                autoRun = 1;
            }

            var autoLogin = 0;
            if ($("input[class='c-open-auto-login-checkbox']").is(":checked")) {
                autoLogin = 1;
            }

            var closeMode = $("input[name='prog-status']:checked").val();

            var text = "{ \"autoRun\":" + autoRun + ",\"autoLogin\":" + autoLogin + ",\"closeMode\":" + closeMode + " }";
            return that.formatData(text);
        });

        /* 加载发生错误添加默认头像 */
        that.addCall("add_default_img", function() {
            var info = that.user_ref.get_user_info();
            var use_status = info.bUserSex;
            if (use_status == 1) {
                $(".head-box img:first").attr({src: "static/images/hall/pic.png"});
            }
            else {
                $(".head-box img:first").attr({src: "static/images/hall/female.png"});
            }
        });
        /*默认头像性别改变 */
        that.addCall("change_default_img", function(flag) {
            if (flag == 1) {
                $(".head-box img:first").attr({src: "static/images/hall/pic.png"});
            }
            else {
                $(".head-box img:first").attr({src: "static/images/hall/female.png"});
            }
        });


        /* 个人头像修改成功刷新个人头像 */
        that.addCall("on_refresh_userimage", function(imgPath) {
            $(".head-box img:first").attr("src", "file:///" + imgPath + "?t=" + Math.random());
        });

        /* loading-mask 控制*/
        that.addCall("on_show_loading", function(bshow) {
            if (bshow == true) {
                $(".loading-mask").show();
            } else {
                $(".loading-mask").hide();
            }
        });

        /* 初始化选择默认页面li */
        that.addCall("select_default_li", function(index) {
            if (index != 0) {
                index_default = index + 1;
                $(".set-btn-box ul li:eq(0)").removeClass("active");
                $(".set-btn-box ul li:eq(" + index + ")").addClass("active");
                $("div[index='1']").css('display', 'none');
                $("div[index=" + index_default + "]").css('display', 'block');
            }
        });

        /*是否显示视频*/
        that.addCall("video_show", function(flag) {
            if (flag == true) {
                $(".set-btn-box ul li:eq(4)").css('display', 'block');
            }
        });

        /* 退出房间更新对应我的房间列表 (异步回调)*/
        that.addCall("on_delete_myroom", function(zoneid) {
            var zoneid = $(".c-room-list-" + zoneid);
            zoneid.remove();
        });


        that.addCall("date_sx", function() {
            var m = parseInt($("select[name='c-select-month']").val());
            var d = parseInt($("select[name='c-select-day']").val());
            var result = '';
            var XZDict = '摩羯宝瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手';
            var Zone = [1222, 122, 222, 321, 421, 522, 622, 722, 822, 922, 1022, 1122, 1222];
            if ((100 * m + d) >= Zone[0] || (100 * m + d) < Zone[1])
                var i = 0;
            else
                for (var i = 1; i < 12; i++) {
                    if ((100 * m + d) >= Zone[i] && (100 * m + d) < Zone[i + 1])
                        break;
                }
            result = XZDict.substring(2 * i, 2 * i + 2) + '座';
            $(".constellation").text(result);
        })

        that.addCall("update_audio_dev", function(mic, speaker) {
            $('#select-mic').val(mic);
            $('#select-speaker').val(speaker);
        });


        that.user_ref = curData;//userinfo;

        that.sup().constructor(curData);

        that.initPage();
        that.initEvent();
    })

})