OnShow = function(bShow) {
    if(bShow){
		cb_search.text_def.Show(cb_search.GetText().length==0);
	}
}
OnInitSkin = function() {
    cb_search.text_def.Show(cb_search.GetText().length==0);
    CLOCK_PLAY.Enable(false);
    CLOCK_PLAY2.Enable(false);
    RefreshMainWnd();
    RefreshPlayInfo();
}
cb_search.OnCommand=function OnCommand(cmdObj){
	if(cmdObj.cmd.toLowerCase()=="edit"){
		if (cmdObj.code=="NOTIFY_FOCUSCHANGED"){
			if(cmdObj.focus){
				cb_search.text_def.Show(false);
			}
			else{
				cb_search.text_def.Show(cb_search.GetText().length==0);
			}
		}
	}
}
OnCommand = function(cmdObj) {
    var cmd = cmdObj.cmd.toLowerCase();
    var id = cmdObj.ctrl.GetID().toLowerCase();
    if (cmd == "cb_search") {
        if (cmdObj.code == "NOTIFY_FOCUSCHANGED") {
            if (cmdObj.focus) {
                text_search_title.Show(false);
            }
            else {
                var sztext = cb_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;
        //设置小屏模式下控件位置
        //登陆控件
        rect.SetRect(50, 17, 0, 0);
        size.SetSize(30, 18);
        btn_login.Reset(rect, size, "lt", 100);
        //登录中
        rect.SetRect(50, 17, 153, 0);
        size.SetSize(0, 18);
        text_loginuser.Reset(rect, size, "lrt", 100);
        //注册控件
        rect.SetRect(100, 17, 0, 0);
        size.SetSize(30, 18);
        btn_regist.Reset(rect, size, "lt", 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, 10);
        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_songinfo.Show(true);
        //列表窗口
        rect.SetRect(11, 53, 0, 0);
        size.SetSize(932, 506);
        WND_LIB.Reset(rect, size, "lt", 100);
        //亮图
        static_light.Show(false);
    }
    else {
        place.x = Number(place.x) + Number(place.width) - 930;
        if (Number(place.x) < 0) place.x = 0;
        place.width = 930;
        //设置大屏模式下控件位置
        //登陆控件
        rect.SetRect(62, 20, 0, 0);
        size.SetSize(25, 25);
        btn_login.Reset(rect, size, "lt", 100);
        //登录中
        rect.SetRect(62, 20, 0, 0);
        size.SetSize(80, 25);
        text_loginuser.Reset(rect, size, "lt", 100);
        //注册控件
        rect.SetRect(93, 20, 0, 0);
        size.SetSize(25, 25);
        btn_regist.Reset(rect, size, "lt", 100);
        //上一首
        rect.SetRect(31, 551, 0, 0);
        size.SetSize(35, 35);
        btn_prev.Reset(rect, size, "lt", 100);
        //下一首
        rect.SetRect(111, 551, 0, 0);
        size.SetSize(35, 35);
        btn_next.Reset(rect, size, "lt", 100);
        //播放
        rect.SetRect(71, 551, 0, 0);
        size.SetSize(35, 35);
        check_play_big.Reset(rect, size, "lt", 100);
        check_play_small.Show(false);
        check_play_big.Show(true);
        //播放时间
        rect.SetRect(696, 592, 0, 0);
        size.SetSize(35, 13);
        clock_play.Reset(rect, size, "lt", 100);
        rect.SetRect(731, 592, 0, 0);
        size.SetSize(7, 11);
        static_clock.Reset(rect, size, "lt", 100);
        rect.SetRect(738, 592, 0, 0);
        size.SetSize(35, 11);
        clock_play2.Reset(rect, size, "lt", 100);
        //播放进度
        rect.SetRect(231, 590, 0, 0);
        size.SetSize(455, 18);
        slider_play.Reset(rect, size, "lt", 100);
        //EQ
        rect.SetRect(38, 590, 0, 0);
        size.SetSize(20, 20);
        check_eq.Reset(rect, size, "lt", 100);
        //静音
        rect.SetRect(785, 569, 0, 0);
        size.SetSize(26, 26);
        check_sound.Reset(rect, size, "lt", 100);
        //音量slider_sound
        rect.SetRect(761, 594, 0, 0);
        size.SetSize(83, 15);
        slider_sound.Reset(rect, size, "lt", 100);
        //歌词
        rect.SetRect(120, 590, 0, 0);
        size.SetSize(20, 20);
        check_lrc.Reset(rect, size, "lt", 100);
        //咪咕音乐，精彩无限！
        rect.SetRect(0, 72, 15, 0);
        size.SetSize(205, 18);
        text_songinfo.Reset(rect, size, "tr", 100);
        text_songinfo.Show(false);
        //列表窗口
        rect.SetRect(10, 50, 10, 71);
        WND_LIB.Reset(rect, size, "ltrb", 100);
        rect.SetRect(231, 556, 0, 0);
        size.SetSize(290, 25);
        text_songinfo2.Reset(rect, size, "lt", 100);
        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;
