$(document).ready(function() {
	initMenu();
	processLeftMenu();
	processNewsList();
});
$(window).load(function() {
	setColumnHeights();
});

function setColumnHeights()
{
	var l = $("#leftColumn");
	var c = $("#centerColumn");
	var r = $("#rightColumn");
	var h = Math.max(
		l.outerHeight(),
		Math.max(
			c.outerHeight(),
			r.outerHeight()
		)
	);
	
	//alert(h);
	
	l.height(h - (l.outerHeight() - l.innerHeight()));
	c.height(h - (c.outerHeight() - c.innerHeight()));
	r.height(h - (r.outerHeight() - r.innerHeight()));
}

function initMenu()
{
	$("#topMenu li a").each(function() {
		var t = $(this);
		var menuItem = t.attr("name");
		var title = t.text();
		var isActive = t.hasClass("active");
		var active = isActive ? "on" : "";
		var img = $('<img src="images/menu/' + menuItem + active + '.png" alt="' + title + '" />');
		if(!isActive) {
			img.hover(
				function() {
					$(this).attr("src", "images/menu/" + menuItem +"on.png");
				},
				function() {
					$(this).attr("src", "images/menu/" + menuItem +".png");
				});
		}
		t.html(img);
	});
}

function processLeftMenu()
{
	$("div.leftMenu a").each(function() {
									  $(this).html("<b>&bull;</b> " + $(this).html());
									  });
}
function processNewsList()
{
	$("#leftColumn div.newsList div.newsItem").each(function() {
		var u = $(this).find("div.head a");
		$(this).click(function() {
						 location.href = u.attr("href");
						 });
		$(this).attr("title", u.text());
	});
}
