ported from the wonderful cowtab extension, source available here

the cowtab portions of this web page are subject to the MIT license, you can view it here

the rest was made by me, rungus