Image

HELP! Image based on the day's date?

What the most efficient way to insert an image based on the day's date?

For example, on Monday April 18, 2005 it would generate:
[img src="http://www.domain.com/images/20050418.jpg"]


I ended up doing this ...
[SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"]
[!--
var today = new Date();
var Year = takeYear(today);
var Month = leadingZero(today.getMonth()+1);
var Day = leadingZero(today.getDate());
function takeYear(theDate)
{
x = theDate.getYear();
var y = x % 100;
y += (y < 38) ? 2000 : 1900;
return y;
}
function leadingZero(nr)
{
if (nr < 10) nr = "0" + nr;
return nr;
}
document.write ('[img src="http://www.domain.com/images/' + Year + Month + Day + '.jpg"]');
// --]
[/SCRIPT]

But I still need a hand writing code to check to see that the image exists before inserting it, and if not continuing to subract a day from the date until it found an image.

Anyone have any idea how I could do this?