function item($t, $d) {
	this.title = $t;
	this.description = $d;
	this.show = function () {
		this.title.add(this.description).stop(true, true).fadeIn();
	}
	this.hide = function () {
		this.title.add(this.description).hide();
	}
}
if($)
{
	$(document).ready(function () {
		var items = Array();
		$("#whatsNewCont > H2").each(function (i, o) {
			var $h2 = $(this);
			var $details = $h2.nextUntil("H2");
			var it = new item($h2, $details);
			it.hide();
			items.push(it);
		});
		if (items.length == 0)
			return;
		items[0].show();
		if (items.length == 1)
			return;
		var count = 0;
		var $nav = $("<div></div>").attr("id", "whatsNewNav");
		var $upLink = $("<a></a>").css({ cursor: "pointer" });
		$upLink.append("<img src='/images/homepage/whatsNewArrow-up.png' width='13' height='9' alt='previous' />");
		$nav.append($upLink);
		var $text = $("<p></p>").text("01");
		$nav.append($text)
		var $downLink = $("<a></a>").css({ cursor: "pointer" });
		$downLink.append("<img src='/images/homepage/whatsNewArrow-down.png' width='13' height='9' alt='next' />");
		$nav.append($downLink);
		function showItem(i) {
			if (i < 0)
				i = 0;
			if (i >= items.length)
				i = i % items.length;
			if (i > 8)
				$text.text(i + 1);
			else
				$text.text("0" + (i + 1));
			for (var a = 0; a < items.length; a++) {
				if (a == i)
					items[a].show();
				else
					items[a].hide();
			}
		}
		function showNext() {
			count = (++count) % items.length;
			showItem(count);
		}
		function showPrevious() {
			count = --count;
			if (count < 0)
				count = items.length - 1;
			showItem(count);
		}
		setInterval(showNext, 5000);
		$upLink.click(function () { showPrevious(); return false; });
		$downLink.click(function () { showNext(); return false; });
		$("#whatsNew").append($nav);
	});
}
