How to unflag all messages when a users visits the Message page? I am using the Message module in combination with the Flag module in order to build a simple notifications system for my site. 

More specifically I have created a page in Views showing all (new) messages for the current user. The page is accessible through a menu link (called "Messages") in the front page. I have also created a message flag so users can flag/unflag there messages as new/old ones.

But instead of forcing the user to manually flag/unflag his messages, I would like all messages to automatically be unflagged (i.e. become old) when the user visits the messages page (or a certain context in general).  

Any hints on how to achieve this?
This sounds like a job for Javascript

Flags has an option to allow the link to use AJAX. So I would dig into the Javascript that the flags modules uses and then create your own script that walks over and triggers each link when the page is loaded.