JQUI - including code

JQUI - including code

I've written a dialog script:

  1. <script>
  2. //Init

  3. $( ".ramka" ).dialog({ autoOpen: false,  
  4. closeText: "zamknij",
  5. hide: 'fade',
  6. show: 'fade',
  7. modal: true,
  8. resizable: false
  9.  });

  10. //Closing window on click

  11. $('body').on('click','.ui-widget-overlay', function() {
  12.     $('.ui-dialog').filter(function () {
  13.     return $(this).css("display") === "block";
  14.     }).find('.ui-dialog-content').dialog('close');
  15. });

  16. //Closing dialog on click
  17. $( ".ramka" ).click(function() {$( this ).dialog( "close" );
  18. });

  19. function widthHeight(szerokosc,wysokosc) {$( ".ramka" ).dialog( "option", "height", wysokosc );
  20.    $( ".ramka" ).dialog( "option", "width", szerokosc );
  21. };
  22. </script>
And I want to put it into a .js file and include it on my sites. Sadly, I don't really have access to the <HEAD> section, because the site is powered by a lousy CMS. When I have this code on a page, the dialog works perfectly (ofcourse I have a div and an opening function in there) but when I put this in a .js file (without the <script> tags) and include in on the site by <script src=""></script> my div isn't hidden and the dialog doesn't work. How do I properly make this code into a library? Or maybe it's just Java isn't like PHP include and I have to put it all in a function and execute it (which I don't think coz including JQuery and JQUI works fine)?