Javascript + rails

Hi,

I have the following code for a google map event:

@map.event_init(@map,:click,"function(overlay,point)
   {
     if (overlay)
     {
       map.removeOverlay(overlay);
       document.getElementById(\"latitude\").value=null;
       document.getElementById(\"longitude\").value=null;
     }
     else
     {
       map.addOverlay(new GMarker(point));
       document.getElementById(\"latitude\").value=point.y;
       document.getElementById(\"longitude\").value=point.x;
     }
   }")

As you can see, the action is written in JS.
How can I call a ruby action from that code, so I can handle events
properly?

Thanks,
hugo