Moved js into functions.js
Added loading gif
Added PAG_BASE variable for specifying the URL structure