With your script, you are clearly trying to use jQuery to target a specific <div> and <img>. In the sequence of how this page would load in a browser, having the script in the <head> means the <body> hasn't even begun to load yet when you're trying to attach the event handlers.
You should move at least the two jQuery commands (if not all of the JS you currently have in the <head>) to the bottom of the page (before the </body> closing tag). e.g. where you are calling the mboxCreate() function
If you're still having issues with this, can you post a link to the web page where you're having issues? If it's not public (e.g. intranet site), then please attach the full code of the page in question as a text attachment to your next reply. It's far more effective to debug code in context.