well the reason for your error is because you are opening a <?php tag within another php tag.. also.. you should never echo a php function . i would say how you can fix that so you don't get parse errors, but your bigger problem is that you are trying to execute php from within javascript.
php executes server-side .. before the javascript can execute. this is because javascript executes on the client's machine after the page has been parsed by php.
i don't think it's possible to execute php within javascript . someone correct me if i am wrong plz.
-mike