Why not `Joomla` namespace?
```JS
var Joomla = ( Joomla || {} );
Joomla.addCloakedMailto = function(id){
    // ...
}
```

and later
```PHP
<script type="text/javascript">Joomla.addCloakedMailto("' . $id . '");</script>
```