Change picture according to the system time

Hi friends,
My client ask for script in the website, which will help to change 2 two images according to the system time.

Example:
6 am - 6pm : the website should show day.jpg
6pm-6-am : the website show show night.jpg

So i asked my friend to script it for me and he did it:

<script language="JavaScript">

//var hour;

function setImage()
{
now = new Date();

hour = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();

var tag = "";

if (hour >= 18 || hour <= 5) {
//hour = hour - 12;
tag = "PM";
}

else {
tag = "AM";
}

imgAM = new Image();
imgAM.src = "am.jpg";
imgPM = new Image();
imgPM.src = "pm.jpg";

i = eval("img" + tag + ".src");

document.getElementById("img").src = i;

//alert(hour);
        
}

window.onload=setImage;
</script>

**

Body
**

<body onload="setImage();">

<img border=0 name="img" id="img">
</body>

The only problem is that now the client dont want a image file but he want a swf file to do the same function. Now me and my friend doesnt know to code it. What can we do to modify this code to support swf file. Please help.