var currentPosition = 0;
var elementList;
var i = 0;

function startRotation() {
     
	 // Starting Rotation
	 //
	 
	 // alert('starting rotation');
	 
	 // Set i to Zero to ensure that we are loading the first image in the array 
	 i=0;
	 
	 rotateHeadline();
	 window.setInterval(rotateHeadline, headlineRotateTime)
	
}

function rotateHeadline() {

	// alert('i is [' + i + ']');

	if (document.getElementById("topHeadline").filters)
		document.getElementById("topHeadline").filters[1].apply();
	if (document.getElementById("headline").filters)
		document.getElementById("headline").filters[0].apply();

	var headlineText= "";
	if (headlines[i][1] != "")
		
		// Old version where we were displaying a Link
		//headlineText= "<a href='" + headlines[i][1] + "'>" + headlines[i][0] + "</a>";
		
		// New Version
		// Display a transparent graphic thats clickable over the div with the image on the background
		//headlineText= "<a href='" + headlines[i][1] + "'><img src='images/transparentgif.gif' alt='" + headlines[i][0] + "'></a>";
		headlineText= "<a href='" + headlines[i][1] + "'" + "'" + headlines[i][3] + "'" + "><img src='images/transparentgif.gif' alt='" + headlines[i][0] + "'></a>";
		
	else 
		headlineText= headlines[i][0];
		
	// Use the URL from the top headline	
	document.getElementById ("topHeadline").innerHTML = headlineText;
	document.getElementById ("headline").style.backgroundImage = "url(/headlineimages/" + headlines[i][2] + ")";
	
	
	// alert('display image [' + i + '] [' + headlines[i][2] + '] - [' + headlineText + ']');
	
	i++;
	
	if (i == headlines.length) {
		i = 0;
	}

	if (document.getElementById("topHeadline").filters)
		document.getElementById("topHeadline").filters[1].play();
	if (document.getElementById("headline").filters)
	    document.getElementById("headline").filters[0].play();
}