http://pastebin.mozilla.org/2054677