Dear @Sophie
If you haven't already you need to look into adding Custom Javascript to Lay Theme
http://laytheme.com/documentation.html#custom-javascript
Your Code Must first go within the surrounding code.
window.laytheme.on("newpageshown", function(layoutObj, type, obj){
});
Hope this helps
Sincerely
Richard