Fixing js error see http://stackoverflow.com/questions/6992723/uncaught-typeerror-property-of-object-object-domwindow-is-not-a-function