function Number(str){
	return str*1;
}
OnCommand=function(cmdObj){
	var cmd=cmdObj.cmd.toLowerCase();
	if(cmd=="list_favorites"){
		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);
}
function RefreshListItemInfo_title3(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.slider_progress.SetData(gress/100);
	}
	item.slider_progress.Enable(false);
	item.slider_progress.ShowCtrl((gress>0||gress<100)&&(index>=0));
	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, 8, 0, 0);
    size.SetSize(100, 18);
    text_songnumber.Reset(rect, size, "lt", 100);
}
LIST_FAVORITES.OnItemInfoChanged_title=RefreshListItemInfo_title1;
LIST_LOCALSONG.OnItemInfoChanged_title=RefreshListItemInfo_title2;
LIST_DOWNLOAD.OnItemInfoChanged_title=RefreshListItemInfo_title3;