Here is a bit of code that will help.
this page consists of a counter that counts down from 5 to 0 then closes the window. There is some code that resets the counter if you move the mouse (you will probably want to remove this, but i though i'd leave it in to show you what can be done).
HTH
Rhys
<html>
<head>
<title>Untitled</title>
</head>
<body onLoad="fnStartInterval()" onmousemove="setkk()">
<form name=jj>
<input type=text name=kk value=5 size=4 >
</form>
<script language="JavaScript" type="text/javascript">
<!--
function setkk()
{
document.jj.kk.setAttribute("value","5"

}
function fnStartInterval(){
window.setInterval("countdown()",1000)
}
function countdown()
{
if (document.jj.kk.value>0)
{
document.jj.kk.setAttribute("value", document.jj.kk.value -1)}
else
{gogogo()}
}
function gogogo()
{
window.close()
}
-->
</script>
</body>
</html>