this plugin would allow to put your javascript just beside its html siblings in templates AND still would be generated in the <head> section of the html response.
It would be nice to be able to do as below.
{metajscode}
<!--
var themePath = '{$j_themepath}';
{literal}
jQuery(function (){
$('#jform1_category').change( function(){
if ($(this).val() == 'par') $('#jform1').submit();
});
$('#jform1_birthday').datepicker({showOn: 'both', buttonImage: themePath+'Images/calendar.gif', buttonImageOnly: true, minDate: '-60y', maxDate: '-10y', yearRange: '-60:0', firstDay: 1, defaultDate:'-10y'});
$('.datepicker_trigger').css({position:'relative',left:'-21px',top:'-1px'});
} );
-->
{/literal}
{/metajscode}
metajscode would call addJSCode of course under the hood.