You are using smarty, right? Please always specify what are you using!!!
The main idea of templates (and PHP itself) is that produce palin HTML to browser. So you can't access any PHP staff from javascript. But if you need to pass some variable to js function you can do this:
---->
Here is HTML code
<script language="javascript">
alert('{$ThisIsPHPVariable}');
</script>
Here is HTML code
<----