suresh, I must tell you that i'm no Javascript Master, I've only trying to lear for some time by now.
What I should do, is to set to javascript functions, at page load. One function that "logs out" the current user by, lets say, redirecting it to a logout.php. You may settimeout(); for this function in 5 minutes.
Then, you may set another function, that opens a "confirm" window that asks the user to continue or not. If the user press NO, redirect it to logout.php.
If the user Presses "yes", then you must reset the time out for the first function, to another 5 minutes.
Please, excuse my english, its noy my mother language (as you may noticed).