to save yourself duplicating the same code, create a new function and then call that from the button. add this at the start of your panel... edit: it needs to go just after the line that begins var li = new list(...
li.lastfm_change_mode = function (m)
this.lastfm_mode = m;
window.SetProperty("2k3.lastfm_mode", this.lastfm_mode); //store the value so it's remembered on panel reload/foobar restart
this.artist = ""; //the panel won't update if the artist doesn't change so i just clear it
p.item_focus_change(); //this calls the function that refreshes the panel - don't repaint because it's already done for you
}
then when you create your buttons...
//1st
b.buttons.similar = new button(x,y,w,h,image,function() { li.lastfm_change_mode(0); }, tooltip);
//2nd
b.buttons.tag = new button(x,y,w,h,image,function() { li.lastfm_change_mode(1); }, tooltip);
//etc