I suggest change that first line to this:
$(document).ready(function () {
instead of:
$(window).load(function () {
also if you upgrade to the new version of mojoPortal we have a new Custom Javascript module that you can add to a page like any feature and it has a setting for the location of the script. It can support external scripts with an url or inline blocks of script as well.
Hope that helps,
Joe