CustomLayout - how to handle window.load or document.ready?

Hello, I wish to integrate a jQuery slideshow and it seems that building the CustomLayout is the best way to do this kind of a thing. I have added jQuery script by extending default Vaadin sevlet and overriding writeAjaxPageHtmlHeader() method and created custom layout that shows up in the application correctly.

In order to show slideshow correctly, I need to invoke a slideshow library function after window has been loading completely. Apparently document ready and window load can’t be handled by the custom layout right now. This is the html file I am using from jQuery site for proof of concept.


<!DOCTYPE html>
<html>
<head>
  <style>p { color:red; }</style>
  <script src="http://code.jquery.com/jquery-1.5.js"></script>
  <script>
  $(window).load(function () {
  $("p").text("The DOM is now loaded and can be manipulated.");
  alert("Window loaded completly").
});
  </script>

</head>

<body onLoad="alert('body has been loaded.')">

  <p>Not loaded yet.</p>

</body>

</html>

Neither of the alerts are displayed when page is loaded. Same problem with $(document).ready. Are there any possible workarounds?