Widget code

Crap, improve it ASAP. But it does the job at least.