Noob's questions about using jQuery in php

Noob's questions about using jQuery in php

Let me start by saying I'm brand new to java / jQuery world so please bear with me if I say something really stupid. In fact this is the very first thing I've ever written so it might be horrible @ best.  This will be a bit lengthy but I want to try to be as clear as I can so I don't waste anyone's time.

What I'm doing: using jQuery to manipulate class elements within my Joomla! template that don't seem to conform well to just a .css solution.  Like...
  • figuring out proper margin-top for the .nav when the .navbar-brand has a non-fixed size.
  • Creating proper margin-top to offset header size when using .navbar-fixed.
  • vertically positioning ( top middle bottom ) within the header the navbar based on users choice.  etc....
What my questions are:
  • Am I doing things the most efficient way possible?
  • Will I gain performance / lose by putting the code in a separate file?
  • To enhance maintainability can I simply extract the entire php / jQuery logic section and put it in another .php file and do a "include_once" ?  
  • Any tips, advice, guidance you'd care to give?
My ultimate goal is: Fast, well written, flexible code.

Code used:
You can see a site where I'm using the template as a test bed,  Hallhome.us This site changes a bit right now while I use it to test out the template in a real life situation.
The section of code that I've tested and seems to work well is below...
just after <head> I have...
  1. <style type="text/css">
  2.       body header.main-header {visibility: hidden;}
  3. </style>
Then just before closing body I have ...
  1. <script type="text/javascript">
  2. jQuery(document).ready(function() {
  3. jQuery('.tooltip').tooltip({
  4. html: true
  5. });
  6. });</script>
  7. <script type="text/javascript">
  8. jQuery(document).ready(function() {
  9. jQuery("div#mm-sidebar").mmenu({
  10. <?php if ($mmenucolor) : ?>
  11. classes: "<?php echo $mmenucolor; ?>",
  12. <?php endif; ?>
  13. offCanvas: {
  14. position : "<?php echo $mmenuslide; ?>",
  15. zposition: "<?php echo $mmenueffect; ?>"
  16. },
  17. header: {
  18. title: "<?php echo $mmenutitle; ?>",
  19. add: <?php echo $mmenuheader; ?>,
  20. update: "<?php echo $mmenuheader; ?>"
  21. }
  22. });
  23. });</script>
  24. <?php if ($topnavbar && $topnavbaraffix == 2): ?>
  25. <script type="text/javascript">
  26. jQuery(document).ready(function(){
  27. jQuery('#menu').scrollupbar();
  28. });</script>
  29. <?php endif; ?>

  30. <!-- insert navbar style -->
  31. <?php if ($navbarStyle): ?>
  32. <script type="text/javascript">
  33. jQuery(document).ready(function(){
  34. jQuery("nav#menu ul.col-centered.jqnavbarStyle").removeClass("jqnavbarStyle").addClass("<?php echo $navbarStyle; ?>");
  35. });</script>
  36. <?php endif; ?>
  37. <!-- center menu vertically -->
  38. <!-- menu is @ top so set margin to zero -->
  39. <?php if ($topnavbar && $mainmenuVAlignment == "top") :
  40. ?>
  41. <style> header.main-header ul.nav.menu{ margin-top: 0px; }</style>
  42. <script type="text/javascript">
  43. jQuery(window).load(function(){
  44. jQuery('header.main-header').css({'min-height':  jQuery('nav#menu .row').outerHeight(true) });
  45. });</script>

  46. <!-- is it set to vertical center ? -->
  47. <?php elseif ($topnavbar && $mainmenuVAlignment == "middle") : ?>
  48. <script type="text/javascript">
  49. jQuery(window).load(function(){
  50. jQuery('header.main-header').css({'min-height':  jQuery('nav#menu .row').outerHeight(true) });
  51. jQuery('header.main-header ul.nav.menu').css({'margin-top':  parseInt( ( parseInt(jQuery('nav#menu .row').outerHeight(true) ) - parseInt( jQuery('header.main-header ul.nav.menu').outerHeight(true) +5 ) ) / 2 ) });
  52. });</script>
  53. <!-- must be bottom -->
  54. <?php elseif ($topnavbar && $mainmenuVAlignment == "bottom") : ?>
  55. <script type="text/javascript">
  56. jQuery(window).load(function(){
  57. jQuery('header.main-header').css({'min-height':  jQuery('nav#menu .row').outerHeight(true) });
  58. jQuery('header.main-header ul.nav.menu').css({'margin-top':  jQuery('header.main-header .row').outerHeight() - jQuery('header.main-header ul.nav.menu').outerHeight() });
  59. });
  60. </script> 
  61. <?php endif; ?>
  62. <!-- limit width of navbar to available space for single row -->
  63. <?php if ($topnavbar) : ?>
  64. <script type="text/javascript">
  65. jQuery(window).load(function(){
  66. jQuery('header.main-header ul.nav.menu').css({'max-width':  ( jQuery('.container').width() - jQuery('header.main-header a.navbar-brand').innerWidth() - jQuery('header.main-header .search .row').width() ) });
  67. });</script>
  68. <?php endif; ?>
  69. <script type="text/javascript">
  70. jQuery(window).load(function(){
  71. jQuery("body header.main-header").css("visibility","visible");
  72. });
  73. </script>
I'm using .load because .ready was causing the header to move AFTER the page had loaded.
65-71 exist because the row does not use col- for sizing so its value must be computed dynamically afaik.
If you've read this far I want to thank you for caring enough to stick with me.  I anxiously & nervously await your reply(s).