Sligthly modified JavaScript module from http://lab.jakiestfu.com/contextjs/