$(document).ready(function() {
	setSidebarHeight();
	
	$("#side-panel .search input[type=text]").bind("focus", function() {
		try {
			_gaq.push(['_trackEvent', 'Zoeken', 'Klik in inputfield']);
		} catch(e) {
		}
	});
	
	$("div#logos-navigation img").each(function(){
		$(this).mouseover(function(){
			if ($(this).parent().is("a")) {
				$(this).parent().next().css("display", "block");
				$(this).parent().next().css("left", $(this).position().left + $(this).width());
				$(this).parent().next().css("top", $(this).position().top - 15);
			} else {
				$(this).next().css("display", "block");
				$(this).next().css("left", $(this).position().left + $(this).width());
				$(this).next().css("top", $(this).position().top - 15);
			}
		});
		
		$(this).mouseout(function(){
			if ($(this).parent().is("a")) {
				$(this).parent().next().css("display", "none");
			} else {
				$(this).next().css("display", "none");
			}
		});
		
		if ($(this).parent().is("a")) {
			$(this).parent().click(function(){
				$(this).next().css("display", "none");
				window.open(this.href);
				return false;
			});
		}
	});
});

function setSidebarHeight()
{
	if ($("#side-panel").height() < $("#main-panel").height())
	{
		$("#side-panel").height($("#main-panel").height() + 'px');
	}
	
	// Fix for slow loading images without width/height, or opening/closing
	// items that adjust the main content height
	window.setTimeout(setSidebarHeight, 150);
}
