Sitewide Header/Footer Modifications


I am using CometChat on my Wordpress MU/BuddyPress site. The chat software works great and is totally integrated with our Buddypress system (avatars show up correctly, video chat works, etc). So far I have integrated the chat software into the main theme by editing the theme files to include it, and I have got it working in the admin dashboard by creating some custom functions that I placed in mu-plugins. Now, I want to make a plugin that will edit both the headers and footers of every theme installed so that the chat software will show up correctly as long as a user is logged into the site. I need to add a link <script> link to jQuery in each themes <head> section, and I need to add the javascript to the footer on each theme, or at least right before </body>.

Does anyone know how to accomplish this? I'm not exactly sure what I can do in order to make sure it is compatible with each theme. Obviously, each theme I am using should have both a header.php and footer.php as they are standard. I am using WPMU Dev's Fams 133 pack for themes as well as a few other themes I have picked up here and there.