Testing connections

Hi, is it possible to test a users internet connection using javascript?
Here’s the situation, I have an html page which has a form in it. I want to hide the form if the user is not connected to the internet, so that a user can’t try and submit the form and finish up with a ‘Page cannot be displayed’ message.

The reason being is that the project is to go on a CD, so it rules out any server side scripting.

I thought i may be possible to swap the content in, a little like swfObject does this flash.

Anyone any ideas?