var newsItems; var currentItem = 0;
$(document).ready(init);
$(window).resize(setRollovers);

function init() {
	// Set up the rollovers
	setRollovers();

	// Set up the news ticker
	newsItems = $("table#news div");
	$(newsItems[currentItem]).show();
	setInterval(animateNews, 7000);
}

function setRollovers() {
	$("table#main td:has(a)").each(function(){
		var offset = $(this).offset();
		$(this).children("a").each(function(){
			var id = this.pathname.replace(/\//g, "");
			if ($.browser.msie) {
				offset.left -= 2;
				offset.top -= 2;
			}
			$("div#"+id).css({
				left: offset.left,
				top: offset.top
			}).bind("mouseleave", function(){
				$(this).fadeOut("fast");
			}).click(function(){
				top.location = "/" + id;
			});
		});
	}).bind("mouseenter", function(){
		var child = $(this).children("a")[0];
		var id = child.pathname.replace(/\//g, "");
		$("div#"+id).fadeIn("fast");
	});
}

function animateNews() {
	$(newsItems[currentItem++]).fadeOut("normal", function(){
		$(newsItems[currentItem]).fadeIn();
	});
	if (currentItem == newsItems.length) { currentItem = 0; }
}