var startDate = new Date(2002, 2, 10);
var nowDate = new Date();
var imgIndex = Math.floor((nowDate-startDate)/1000); // secondly increment of imgIndex by 1

var imgs = new Array;
var urls = new Array;
var alts = new Array;
var numAds = 0;

var kingscruises  = "A leading company for Thames boat rides and events";
var watersedge    = "Riverside Property Specialists";
var rowingmuseum  = "River &amp; Rowing Museum - Home of the Wind in the Willows";
var cotswoldboats = "Boat hire on the Cotswolds Thames";

function addAdvert(img, alt)
{
    imgs[numAds] = img;
    alts[numAds++] = alt;
}

function addAdvertLink(img, alt, url)
{
    imgs[numAds] = img;
    urls[numAds] = url;
    alts[numAds++] = alt;
}

function getImg()
{
    if (imgIndex >= imgs.length)
    imgIndex -= imgs.length * Math.floor(imgIndex/imgs.length);
    document.write('<img src="' + imgs[imgIndex] + '" alt="' + alts[imgIndex] +  '" align=right border=0>');
}

function getImgNoAlign()
{
    if (imgIndex >= imgs.length)
        imgIndex -= imgs.length * Math.floor(imgIndex/imgs.length);
    document.write('<img src="' + imgs[imgIndex] + '" alt="' + alts[imgIndex] +  '" border=0>');
}

function getImgLink()
{
    if (imgIndex >= imgs.length)
        imgIndex -= imgs.length * Math.floor(imgIndex/imgs.length);
    document.write('<a href="' + urls[imgIndex] + '"><img src="' + imgs[imgIndex] + '" alt="' + alts[imgIndex] +  '" border=0></a>');
}

function getPropImgLink()
{
    if (imgIndex >= imgs.length)
        imgIndex -= imgs.length * Math.floor(imgIndex/imgs.length);
    document.write('<a target="_blank" href="' + urls[imgIndex] + '"><img src="' + imgs[imgIndex] + '" alt="' + alts[imgIndex] +  '" border=0></a>');
}

function getCaption()
{
    if (imgIndex >= imgs.length)
        imgIndex -= imgs.length * Math.floor(imgIndex/imgs.length);
    document.write('<font size="+1"><b><i>' + alts[imgIndex] + '</i></b></font>');
}

function getCaptionPlain()
{
    if (imgIndex >= imgs.length)
        imgIndex -= imgs.length * Math.floor(imgIndex/imgs.length);
    document.write(alts[imgIndex]);
}

function globalVars(){
	globComment = alts[imgIndex];
}

function getCompanyName(){
	if (imgIndex >= imgs.length){
        	imgIndex -= imgs.length * Math.floor(imgIndex/imgs.length);
	}

	switch(alts[imgIndex]){
		case kingscruises:
			var company = "King Cruises Ltd.";
			break;
	
		case watersedge:
			var company = "Waters Edge Homes";
			break;

                case rowingmuseum:
                        var company = "The River &amp; Rowing Museum";
                        break;

		case cotswoldboats:
			var company = "Cotswold Boats Hire";
			break;

		default:
			var doit = "no";
			break;
}

	if(doit != "no"){
		document.write("<font size=\"+1\"><b>This section is sponsored by " + company + "</b></font><br />");
	}
}
<!-- Sponsors Below -->

addAdvertLink("/cms/userdata/rtgads/king_cruises.jpg", kingscruises, "/cgi-bin/redirect.cgi?link=http://www.kingcruises.com");
addAdvertLink("/images/SponsCotwoldBoatHire.jpg", cotswoldboats, "/cgi-bin/redirect.cgi?link=http://www.cotswoldboat.co.uk");
addAdvertLink("/about_thames/WatersEdgeHomes.jpg", watersedge, "/cgi-bin/redirect.cgi?link=http://www.watersedgehomes.co.uk");
addAdvertLink("/about_thames/rand/rand.php", rowingmuseum, "/cgi-bin/redirect.cgi?link=http://www.rrm.co.uk");

getCompanyName();
<!-- Sponsors Above ->
