var news = {};

$(document).ready(function() {
	var _prev = null;

	// Search autocomplete
	if($.autocomplete) {
		$("INPUT[autocomplete=news]").autocomplete({
			url: "/news/autocomplete",
			cacheLength: 50,
			delay: 250,
			minChars: 4,
			matchContains: true
		});
	}

	// Script for compact-dynamic
	$("table.news .links A:first").each(function() {
		_prev = $(this).addClass("current");
	});

	$("table.news .links A").bind("mouseover", function(evt) {
		var e = $(evt.target);
		var n = news[e.attr("news-item")];
		if(!n) return;

		if(_prev) _prev.removeClass("current");
		_prev = e.addClass("current");

		var nt = e.parents("table").find(".teaser");
		nt.children("h2").html(n.title);
		nt.children("h3").html(n.date);
		nt.find("p").html(n.teaser);
	});
});

