I'll give you a few tips to start with, but I could write the whole script if you want.
Use a cookie to store the current date. Use setInterval to update a function which counts down from that date. You should probabaly store the date in milliseconds since it's easier to read a bunch of numbers from the cookie and convert them back to a date. (I think there's a build in method for the conversion)
If the visitor leaves you want the counter to continue form the stored date. So the first thing the script should do is to check the cookie file to see if there's a date in there.