rewrote the whole thing as a jQuery plugin. much cleaner