Using cookies also moved all js functions to index.js