OnShow = function(bShow) {
    if (bShow) {
        var sztext = edit_search.GetText();
        if (sztext.length != 0) {
            text_search_title.Show(false);
            //edit_search.SetFocus();
            //edit_search.SetSel(0,-1);
        }
        else {
            text_search_title.Show(true);
        }
    }
}
OnInitSkin = function() {
    var sztext = edit_search.GetText();
    if (sztext.length != 0) {
        text_search_title.Show(false);
    }
    else {
        text_search_title.Show(true);
    }
    CLOCK_PLAY.Enable(false);
    CLOCK_PLAY2.Enable(false);
    RefreshMainWnd();
    RefreshPlayInfo();
}

OnCommand = function(cmdObj) {
    var cmd = cmdObj.cmd.toLowerCase();
    var id = cmdObj.ctrl.GetID().toLowerCase();
    if (cmd == "edit_search") {
        if (cmdObj.code == "NOTIFY_FOCUSCHANGED") {
            if (cmdObj.focus) {
                text_search_title.Show(false);
            }
            else {
                var sztext = edit_search.GetText();
                if (sztext.length != 0) {
                    text_search_title.Show(false);
                }
                else {
                    text_search_title.Show(true);
                }
            }
        }
    }
    else if (id == "check_lib") {
		if (!check_lib.IsCheck()){
			RefreshMainWnd();
		}
    }
}
PreOnCommand = function(cmdObj) {
    var cmd = cmdObj.cmd.toLowerCase();
    var id = cmdObj.ctrl.GetID().toLowerCase();
	if (id == "check_lib") {
		if (check_lib.IsCheck()){
			RefreshMainWnd();
		}
    }
}
function Number(str) {
    return str * 1;
}

function RefreshMainWnd() {
    var place = GetWndPlace();
    var rect = CreateDataObject();
    var size = CreateDataObject();
    //small width: 303, big width: 935
    if (check_lib.IsCheck() == false) {
        place.x = Number(place.x) + Number(place.width) - 323;
        if (Number(place.x) < 0) place.x = 0;
        place.width = 323;
        //设置小屏模式下控件位置
        //登陆控件
        <!--begin_namespace:_SOFTVER_MIGU,_SOFTVER_MDA-->
        rect.SetRect(98, 17, 0, 0);
        size.SetSize(30, 18);
        btn_login.Reset(rect, size, "lt", 100);
        //登录中
        rect.SetRect(98, 17, 146, 0);
        size.SetSize(0, 18);
        text_loginuser.Reset(rect, size, "lrt", 100);
        //上一首
        rect.SetRect(14, 175, 0, 0);
        size.SetSize(29, 29);
        btn_prev.Reset(rect, size, "lt", 100);
        //下一首
        rect.SetRect(98, 175, 0, 0);
        size.SetSize(29, 29);
        btn_next.Reset(rect, size, "lt", 100);
        //播放
        rect.SetRect(44, 169, 0, 0);
        size.SetSize(53, 39);
        check_play_small.Reset(rect, size, "lt", 100);
        check_play_small.Show(true);
        check_play_big.Show(false);
        //播放时间
        rect.SetRect(229, 86, 0, 0);
        size.SetSize(35, 13);
        clock_play.Reset(rect, size, "lt", 100);
        rect.SetRect(264, 86, 0, 0);
        size.SetSize(7, 11);
        static_clock.Reset(rect, size, "lt", 100);
        rect.SetRect(271, 86, 0, 0);
        size.SetSize(35, 11);
        clock_play2.Reset(rect, size, "lt", 100);
        //播放进度
        rect.SetRect(11, 155, 11, 0);
        size.SetSize(0, 10);
        slider_play.Reset(rect, size, "lrt", 100);
        //EQ
        rect.SetRect(236, 174, 0, 0);
        size.SetSize(35, 29);
        check_eq.Reset(rect, size, "lt", 100);
        //静音
        rect.SetRect(127, 177, 0, 0);
        size.SetSize(26, 26);
        check_sound.Reset(rect, size, "lt", 100);
        //音量slider_sound
        rect.SetRect(154, 182, 0, 0);
        size.SetSize(80, 15);
        slider_sound.Reset(rect, size, "lt", 100);
        //歌词
        rect.SetRect(269, 174, 0, 0);
        size.SetSize(44, 29);
        check_lrc.Reset(rect, size, "lt", 100);
        //咪咕音乐，精彩无限！
        rect.SetRect(0, 82, 98, 0);
        size.SetSize(122, 18);
        text_songinfo.Reset(rect, size, "tr", 100);
        text_songinfo2.Show(false);
        //列表窗口
        rect.SetRect(0, 220, 14, 17);
        size.SetSize(294, 0);
        WND_LIST.Reset(rect, size, "rtb", 100);
        <!--end_namespace-->
        <!--begin_namespace:_SOFTVER_FETION-->
        rect.SetRect(120, 17, 0, 0);
        size.SetSize(30, 18);
        btn_login.Reset(rect, size, "lt", 100);
        //登录中
        rect.SetRect(120, 17, 146, 0);
        size.SetSize(0, 18);
        text_loginuser.Reset(rect, size, "lrt", 100);
        //上一首
        rect.SetRect(14, 146, 0, 0);
        size.SetSize(29, 29);
        btn_prev.Reset(rect, size, "lt", 100);
        //下一首
        rect.SetRect(98, 146, 0, 0);
        size.SetSize(29, 29);
        btn_next.Reset(rect, size, "lt", 100);
        //播放
        rect.SetRect(44, 140, 0, 0);
        size.SetSize(53, 39);
        check_play_small.Reset(rect, size, "lt", 100);
        check_play_small.Show(true);
        check_play_big.Show(false);
        //播放时间
        rect.SetRect(229, 57, 0, 0);
        size.SetSize(35, 13);
        clock_play.Reset(rect, size, "lt", 100);
        rect.SetRect(264, 57, 0, 0);
        size.SetSize(7, 11);
        static_clock.Reset(rect, size, "lt", 100);
        rect.SetRect(271, 57, 0, 0);
        size.SetSize(35, 11);
        clock_play2.Reset(rect, size, "lt", 100);
        //播放进度
        rect.SetRect(11, 126, 11, 0);
        size.SetSize(0, 10);
        slider_play.Reset(rect, size, "lrt", 100);
        //EQ
        rect.SetRect(236, 145, 0, 0);
        size.SetSize(35, 29);
        check_eq.Reset(rect, size, "lt", 100);
        //静音
        rect.SetRect(127, 148, 0, 0);
        size.SetSize(26, 26);
        check_sound.Reset(rect, size, "lt", 100);
        //音量slider_sound
        rect.SetRect(154, 153, 0, 0);
        size.SetSize(80, 15);
        slider_sound.Reset(rect, size, "lt", 100);
        //歌词
        rect.SetRect(269, 145, 0, 0);
        size.SetSize(44, 29);
        check_lrc.Reset(rect, size, "lt", 100);
        //咪咕音乐，精彩无限！
        rect.SetRect(0, 53, 98, 0);
        size.SetSize(122, 18);
        text_songinfo.Reset(rect, size, "tr", 100);
        text_songinfo2.Show(false);
        //列表窗口
        rect.SetRect(0, 191, 14, 17);
        size.SetSize(294, 0);
        WND_LIST.Reset(rect, size, "rtb", 100);
        <!--end_namespace-->
        //亮图
        static_light.Show(false);
    }
    else {
        place.x = Number(place.x) + Number(place.width) - 955;
        if (Number(place.x) < 0) place.x = 0;
        place.width = 955;
        //设置大屏模式下控件位置
        //登陆控件
        rect.SetRect(0, 17, 272, 0);
        size.SetSize(30, 18);
        btn_login.Reset(rect, size, "rt", 100);
        //登录中
        rect.SetRect(653, 17, 146, 0);
        size.SetSize(0, 18);
        text_loginuser.Reset(rect, size, "ltr", 100);
        //上一首
        rect.SetRect(352, 584, 0, 0);
        size.SetSize(29, 29);
        btn_prev.Reset(rect, size, "lt", 100);
        //下一首
        rect.SetRect(480, 584, 0, 0);
        size.SetSize(29, 29);
        btn_next.Reset(rect, size, "lt", 100);
        //播放
        rect.SetRect(394, 577, 0, 0);
        size.SetSize(73, 39);
        check_play_big.Reset(rect, size, "lt", 100);
        check_play_small.Show(false);
        check_play_big.Show(true);
        //播放时间
        rect.SetRect(731, 593, 0, 0);
        size.SetSize(35, 13);
        clock_play.Reset(rect, size, "lt", 100);
        rect.SetRect(766, 593, 0, 0);
        size.SetSize(7, 11);
        static_clock.Reset(rect, size, "lt", 100);
        rect.SetRect(773, 593, 0, 0);
        size.SetSize(35, 11);
        clock_play2.Reset(rect, size, "lt", 100);
        //播放进度
        rect.SetRect(13, 562, 13, 0);
        size.SetSize(0, 10);
        slider_play.Reset(rect, size, "lrt", 100);
        //EQ
        rect.SetRect(850, 583, 0, 0);
        size.SetSize(35, 29);
        check_eq.Reset(rect, size, "lt", 100);
        //静音
        rect.SetRect(534, 586, 0, 0);
        size.SetSize(26, 26);
        check_sound.Reset(rect, size, "lt", 100);
        //音量slider_sound
        rect.SetRect(561, 591, 0, 0);
        size.SetSize(83, 15);
        slider_sound.Reset(rect, size, "lt", 100);
        //歌词
        rect.SetRect(882, 583, 0, 0);
        size.SetSize(44, 29);
        check_lrc.Reset(rect, size, "lt", 100);
        <!--begin_namespace:_SOFTVER_MIGU,_SOFTVER_MDA-->
        //咪咕音乐，精彩无限！
        rect.SetRect(0, 82, 15, 0);
        size.SetSize(205, 18);
        text_songinfo.Reset(rect, size, "tr", 100);
        //列表窗口
        rect.SetRect(0, 157, 14, 83);
        size.SetSize(294, 0);
        WND_LIST.Reset(rect, size, "brt", 100);
        <!--end_namespace-->
        <!--begin_namespace:_SOFTVER_FETION-->
        rect.SetRect(0, 53, 15, 0);
        size.SetSize(205, 18);
        text_songinfo.Reset(rect, size, "tr", 100);
        rect.SetRect(0, 128, 14, 83);
        size.SetSize(294, 0);
        WND_LIST.Reset(rect, size, "brt", 100);
        <!--end_namespace-->
        text_songinfo2.Show(true);
        //亮图
        static_light.Show(true);
    }
    SetWndPlace(place);
}

function RefreshPlayInfo() {
    var bShowFlash = false;
    var song = skin.GetPlayingSong();
    if (song) {
        if (song.state == "PLAY" && song.dataState == "COMMON") {
            bShowFlash = true;
            CLOCK_PLAY2.SetData(song.length, song.length);
        }
    }
    slider_play.btn.flash_playing.Show(bShowFlash);
}

function RefreshClockPos() {
    var song = skin.GetPlayingSong();
    if (song) {
        CLOCK_PLAY.SetData(song.pos, song.pos);
    }
}

skin.OnNotifyPlaySongChanged = RefreshPlayInfo;
skin.OnNotifyPlayStateChanged = RefreshPlayInfo;
skin.OnNotifyPlayPosChanged = RefreshClockPos;
