

InitializeTimer();

var timerID = null;
var timerRunning = false;
var delay = 30000;

function InitializeTimer()
{
    //StartTheTimer();	//start he countdown
    showBanner();	//show first banner
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID);
    timerRunning = false;
}


function StartTheTimer()
{
  StopTheClock();	//temp stop the counter
  showBanner();	//do the action
  timerID = self.setTimeout("StartTheTimer()", delay);	//restart the counter
  timeRunning = true;	//flag as running
}


// Image rotator
function showBanner()
{
	var strHTML = "";
	var strBanner = "";
	var strURL = "";
	var objBanner = document.getElementById("tdBanner");
	if (objBanner != null)
	{
		var p = theImages.length;
		var whichImage = Math.round(Math.random()*(p-1));
		strBanner = "media/content/" + theImages[whichImage];
		if (strBanner.indexOf("|") > 0)
		{
			var arrBanner = new String(strBanner).split("|");
			strBanner = arrBanner[0];
			strURL = arrBanner[1];
		}
		if (strBanner.indexOf(".swf") > 0)
		{
			if (strURL != "")
				strBanner += "?url=" + strURL;
			//flash file
			strHTML = "<div style='z-index:-1'>" + 
				"<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'" +
				" codebase='https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0'" +
				" width='625' height='112' VIEWASTEXT>" + 
				" <param name=wmode value='transparent'>" +
				" <param name='movie' value='" + strBanner + 
				"' />" +
				" <param name='quality' value='high'/>" +
				" <embed src='" + strBanner + "'" + " wmode='transparent'" +
				" quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'" +
				" width='625' height='110'></embed>" +
				"</object></div>";
		}
		else
		{
			//otherwise assume image
			if (strURL != "")
			{
				strHTML = "<a href='" + strURL + "'>" +
				"<img src='" + strBanner + "' border=0> </a>";
			}
			else
			{
				strHTML = "<img src='" + strBanner + "' border=0>";
			}
		}
		objBanner.innerHTML = strHTML;
	}
}