Please validate your code using jshint. It has a lot of issues.