Remove that php_js variable crap and refactor function