Moved javascript code to separate files