// ==PREPROCESSOR==
// @import "%fb2k_profile_path%marc2003\common7.js"
// @name "Last.fm Playcount Sync"
// @author "marc2003"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==

var p = new panel("Last.fm Playcount Sync", ["remap", "custom_background"]);
var l = new lastfm();
var ps = new playcount_sync();
var b = new buttons();

p.selection_mode = 1;

b.update = function() {
	ps.update_button();
	//the 0 and 0 here are the x/y co-ordinates. do not customise anything else. 
	b.buttons.ps = new button(0, 0, ps.size, ps.size, {normal: ps.n, hover: ps.h}, ps.func, ps.tooltip);
	//if these values need to be relative to the panel width/height, you can use p.w and p.h to retrieve the width and height respectively.
	//b.buttons.ps = new button(p.w - 32, p.h - 32, ps.size, ps.size, {normal: ps.n, hover: ps.h}, ps.func, ps.tooltip);
	window.RepaintRect(b.buttons.ps.x, b.buttons.ps.y, 32, 32);
}

if (fb.IsPlaying) on_playback_new_track();
else if (p.metadb) on_item_focus_change();
else b.update();

function on_playback_time() {
	ps.playback_time();
}

function on_size() {
	p.size();
	b.update();
}

function on_paint(gr) {
	p.draw_background(gr);
	b.draw(gr);
}

function on_metadb_changed() {
	ps.metadb_changed();
}

function on_playback_new_track() {
	ps.playback_new_track();
}

function on_playback_edited() {
	ps.playback_edited();
}

function on_mouse_move(x, y) {
	b.move(x, y);
}

function on_mouse_lbtn_up(x, y) {
	b.lbtn_up(x, y);
}