It seems you don't fully grasp the difference between client-side and server-side code.
1) You execute a JavaScript function within a Sever-side method. The former is processed at the client, the latter on the server. You can use methods such as ClientScriptManager.RegisterClientScriptBlock to inject JavaScript into the page but it will only execute AFTER the server-side event has been handled and the page rendered to the client again. JavaScript have timers,
setInterval[
^] or
setTimeout[
^]
2) You can use a hidden element to store this value so it can be updated on the server (must use runat='server') and accessible from JavaScript.