I think in this case it might be easiest to escape from the php mode
<?
//some code
?>
<javascript here>
<javascript here>
<javascript here>
<javascript here>
<?
//more code
?>
This works fine even if it is within conditional blocks, and in case you need to insert a php variable into you javascript code, you can switch into php mode again in between.
<javascript here <echo $foo;> more javascript>