Display Message for Short Duration

This is another post in beginners series. Suppose you want to dispaly dynamic message after form submit for short duration. You want the massage to dissapper after some time.
User can have option to hide it if he wants also. How you will do it?

Here is a example script for doing so. It will display-hide the message
after certain time. Time to auto-hide the message can be fixed in JavaScript fucntion itself.
User got a hide link to hide the message if she wish. In gmail, you may have saw this
dynamic message functionality!

Style for our message, displayed after certain action - Ex. Form Submission

#short-time-msg {color:blue;background:lightblue; font-weight:bolder}

JavaScript code to Display and Hide the message

function hideAfterSomeTime(hideTime)
	// 10000 = 10 seconds. Change it
	window.setTimeout("document.getElementById('short-time-msg').style.display='none'", (hideTime)?hideTime:10000);

Message format, which can use style and JavaScript defined above:

<div id="short-time-msg">
Form submission successful.
<a href="#" onclick="hideAfterSomeTime(-1)">Hide</a>

The message here is "Form submission successful". It will
be hidden after 10 seconds of displaying the message. If user clicks on 'hide' link
then it will dissapear at the moment.
Demo page of what I mean above by - Display Message for Short Duration!