Auto save form when focus is lost

i use this java script to save on a specific time to save the content of a form.

function sc_form_onload()
{
setInterval(function(){
nm_atualiza (‘alterar’);
}, 300000);
}

the annoying part is that it saves even when a customer is typing.

other thing is that this script only works when the page is open. aka when a user is doing something else, the script does nothing and when a user comes back on the page, all his work is lost because scriptcase kicked the user out of the system.

beside the fact that this “security feature” of scriptcase is terrible and i find that the logout and autosave function should be updatet (or do i miss something?)

is there a solution for the problem that when a user loses focus on the page, the autosave kicks in?