BeforeSetWndPlace = function(newPlace) {

    var point = CreateDataObject();
    point.SetPoint(0, 0);
    var pvar = skin.wnd_main.check_list.ToScreenPoint(point);
    var place = skin.wnd_main.check_list.GetPlace();
    newPlace.x = Number(pvar.x) + Number(place.width) / 2;

    var rect = CreateDataObject();
    var size = CreateDataObject();

    if (skin.wnd_main.check_list.IsCheck() == false) {
        newPlace.y = Number(pvar.y);
        if (newPlace.x > 314) {
            newPlace.x = newPlace.x - 314;
        }
        if (newPlace.y > 465) {
            newPlace.y = newPlace.y - 465;
        }
        this.SetShowWndAnimationInfo("drawer,true,8,0,b,true");
        this.SetHideWndAnimationInfo("drawer,false,8,0,b,true");
    }
    else {

        newPlace.y = Number(pvar.y);
        if (newPlace.x > 314) {
            newPlace.x = newPlace.x - 314;
        }

        if (newPlace.y > 465/*177*/) {
            newPlace.y = newPlace.y - 465;
        }


        this.SetShowWndAnimationInfo("drawer,true,8,0,t,true");
        this.SetHideWndAnimationInfo("drawer,false,8,0,t,true");
    }

    return true;
}

function Number(str) {
    return str * 1;
}

OnShow = function(bShow) {
    if (bShow) {
        if (skin.wnd_main.check_lib.IsCheck() == false) {
            sound_bg.Show(true);
            sound_bg_rotate.Show(false);
        }
        else {
            eq_bsound_bgg.Show(false);
            sound_bg_rotate.Show(true);
        }
    }
}

OnCommand = function(cmdObj) {
    var cmd = cmdObj.cmd.toLowerCase();
    if (cmd == "playfavoriteslist") {
        if (cmdObj.itemId.toLowerCase() == "title" && cmdObj.type == "NOTIFY_CHILD") {
            var childCmdObj = cmdObj.data;
            var childCmd = childCmdObj.cmd.toLowerCase();
            if (childCmd == "btn_play") {
                SendMenuMsg("M_PLAY", Number(cmdObj.rowIndex) + 1);
            }
            else if (childCmd == "btn_addto") {
                SendMenuMsg("M_ADDTO", Number(cmdObj.rowIndex) + 1);
            }
            else if (childCmd == "btn_favor") {
                SendMenuMsg("M_FAVOR", Number(cmdObj.rowIndex) + 1);
            }
            else if (childCmd == "btn_down") {
                SendMenuMsg("M_DOWN", Number(cmdObj.rowIndex) + 1);
            }
        }
    }
}

function RefreshListItemInfo_title1(index,item,newState,oldState,gress,bLocfavor,textwidth) {
    var bShow=false;
	var bPlay=false;
	var bDown=true;
	if(index>=0){
		var strs=newState.split(",");
		var state=strs[0].toLowerCase();
		var songstate=strs[1].toLowerCase();
		var songtype=strs[2].toLowerCase();
		var bfavor=(bLocfavor==1);
		if(state=="in"||state=="insel"){
			bShow=true;
			if(strs.length>1&&strs[1].toLowerCase()=="error"){
				bShow=false;
			}
		}
		if (songstate=="play") {
		    bPlay=true;
		}
		if (songtype=="local") {
		    bDown=false;
		}
		item.slider_progress.SetData(gress/100);
	}
	var rect = CreateDataObject();
    var size = CreateDataObject();
    rect.SetRect(textwidth, 0, 0, 0);
    size.SetSize(24, 10);
    item.list_animation.Reset(rect, size, "lm", 1);
    item.list_animation.ShowCtrl(index>=0&&textwidth>0&&bPlay);
    item.slider_progress.Enable(false);
    item.slider_progress.ShowCtrl((gress>0||gress<100)&&(index>=0));
    if (bDown) {
        if(bLocfavor)
            rect.SetRect(0, 0, 43, 0);
        else
            rect.SetRect(0, 0, 22, 0);
        size.SetSize(20, 30);
        item.btn_addto.Reset(rect, size, "rm", 100);
    
        if(bLocfavor)
            rect.SetRect(0, 0, 64, 0);
        else
            rect.SetRect(0, 0, 43, 0);
        size.SetSize(20, 30);
        item.btn_play.Reset(rect, size, "rm", 100);
        
        if(bLocfavor)
            rect.SetRect(0, 0, 22, 0);
        else
            rect.SetRect(0, 0, 22, 0);
        size.SetSize(20, 30);
        item.btn_favor.Reset(rect, size, "rm", 100);
    }
    else{
        if(bLocfavor)
            rect.SetRect(0, 0, 22, 0);
        else
            rect.SetRect(0, 0, 1, 0);
        size.SetSize(20, 30);
        item.btn_addto.Reset(rect, size, "rm", 100);
    
        if(bLocfavor)
            rect.SetRect(0, 0, 43, 0);
        else
            rect.SetRect(0, 0, 22, 0);
        size.SetSize(20, 30);
        item.btn_play.Reset(rect, size, "rm", 100);
        
        if(bLocfavor)
            rect.SetRect(0, 0, 1, 0);
        else
            rect.SetRect(0, 0, 22, 0);
        size.SetSize(20, 30);
        item.btn_favor.Reset(rect, size, "rm", 100);
    }	
    
	item.btn_addto.ShowCtrl(bShow);
	item.btn_play.ShowCtrl(bShow);
	item.btn_favor.ShowCtrl(bShow&&bfavor);
	item.btn_down.ShowCtrl(bShow&&bDown);
}
function RefreshListItemInfo_title2(index, item, newState, oldState, gress) {
    var bShow = false;
    if (index >= 0) {
        var strs = newState.split(",");
        var state = strs[0].toLowerCase();
        if (state == "in" || state == "insel") {
            bShow = true;
            if (strs.length > 1 && strs[1].toLowerCase() == "error") {
                bShow = false;
            }
        }
    }
    item.btn_addto.ShowCtrl(bShow);
    item.btn_play.ShowCtrl(bShow);
    item.btn_favor.ShowCtrl(bShow);
    item.btn_down.ShowCtrl(bShow);
}

OnNotifyPlayListReName = function(width) {
    var rect = CreateDataObject();
    var size = CreateDataObject();
    rect.SetRect(width + 102, 10, 0, 0);
    size.SetSize(100, 18);
    text_songnumber.Reset(rect, size, "lt", 100);
}
playfavoriteslist.OnItemInfoChanged_title = RefreshListItemInfo_title1;

 