Expanding javascript before sending it

Hi,

I had a simple javascript function directly in the rhtml with a rails
helper in it.
Before the page was sent to the client the rails help was of course
expanded.

Moving it into a separated .js file, the rails code is, once again of
course, no more expanded.

function save(id) {
var el = document.getElementById(‘s’+id);
el.src = “<%= theme_image_path(‘loading.gif’)%>”
new Ajax.Request(’/task/save/’+id, {asynchronous:true,
evalScripts:true,
onComplete:function(request){eval(request.responseText)},
parameters:Form.serialize(‘tr’+id)});
return false;
}

<%= theme_image_path(‘loading.gif’)%> is not more expanded into pure
html once it is in a .js file.

Is there a way to generate the code before sending the js file to the
client ?
Or is there another way of doing rails code into js ?

Thanks for your help,
Mickael.