function createAd(url, image)
{
	this.url = url;
	this.img = image;
	this.write = echoAds;
}

function echoAds()
{
	var str = '';
	str += '<div style="display: block; height: 189px; background-image: url(images/ads/' + this.img + '); cursor: pointer" onclick="window.parent.location=\'' + this.url + '\'">';
		str += '<ul id="key">';
			str += '<li><a href="1" onclick="rotate(0); return false;">1</a></li>';
			str += '<li><a href="2" onclick="rotate(1); return false;">2</a></li>';
			str += '<li><a href="3" onclick="rotate(2); return false;">3</a></li>';
			str += '<li><a href="4" onclick="rotate(3); return false;">4</a></li>';
		str += '</ul>';
	str += '</div>';
	return str;
}

var nIndex = 0;
var timerID = null;
var numSel = null;
function rotate(numSel)
{
	var len = adArray.length;

	if (numSel != null)
	{
		nIndex = numSel;
	}
	
	if(nIndex >= len)
	{
		nIndex = 0;
	}
	
	document.getElementById('latestnews').innerHTML = adArray[nIndex];
	nIndex++;
	timerID = setTimeout('rotate()',3000);
}

function pauseAds()
{
	if (timerID != null)
	{
		clearTimeout(timerID);
		timerID = null;
	}
}

function playAds()
{
	if (timerID == null)
	{
		timerID = setTimeout('rotate()', 3000);
	}
}