I hardly know anything about jquery, but as for th query to modify the table, I think you'd want:
Code:
$vbulletin->db->query("
UPDATE `" . TABLE_PREFIX . "session`
SET idle = '1'
WHERE dbsessionhash = {$vbulletin->session['vars']['dbsessionhash']}
");
otherwise you'll set idle in all sessions to 1. Also, you can check the value by checking $vbulletin->session['vars']['idle'] so you don't have to do a query.