$(document).ready(function() {
	$('#menu_news').bind('mouseover', function() {
		showNews();
	}).bind('mouseout', function() {
		hideNews();
	}).bind('click', function() {
		return false;
	});
	
	$('#news_content').bind('mouseover', function() {
		clearTimeout(hideNewsTimeout);
	}).bind('mouseout', function() {
		hideNews();
	});

	$('#menu_archive').bind('mouseover', function() {
		showArchive();
	}).bind('mouseout', function() {
		hideArchive();
	}).bind('click', function() {
		return false;
	});

	$('#archive_content').bind('mouseover', function() {
		clearTimeout(hideArchiveTimeout);
	}).bind('mouseout', function() {
		hideArchive();
	});
});

var hideNewsTimeout;
function showNews() {
	clearTimeout(hideNewsTimeout);
	if (!$('#news_content').is(':visible')) {
		space = 287;

		var top = 0;
		var left = ($('body').width()-1000)/2 + 310 + 193 - 40;

		var el = $('#news_content').css({'visible':'false', 'display':'block', 'opacity':0.8});
		var height = el.height();
		el.css({'display':'none', 'visible':'true'});

		if (height < space) {
			top = space-height;
		}

		el.css({'top':top + 'px', 'left':left + 'px'});
		$('#menu_news').addClass('active');
		el.slideDown('fast');
	}
}
function hideNews() {
	hideNewsTimeout = setTimeout('doHideNews()', 500);
}
function doHideNews() {
	$('#news_content').slideUp('fast', function() {
		$('#menu_news').removeClass('active');
	});
}


var hideArchiveTimeout;
function showArchive() {
	clearTimeout(hideArchiveTimeout);
	if (!$('#archive_content').is(':visible')) {
		space = 287;

		var top = 0;
		var left = ($('body').width()-1000)/2 + 310 + 193 + 154;

		var el = $('#archive_content').css({'visible':'false', 'display':'block', 'opacity':0.8});
		var height = el.height();
		el.css({'display':'none', 'visible':'true'});

		if (height < space) {
			top = space-height;
		}

		el.css({'top':top + 'px', 'left':left + 'px'});
		$('#menu_archive').addClass('active');
		el.slideDown('fast');
	}
}
function hideArchive() {
	hideArchiveTimeout = setTimeout('doHideArchive()', 500);
}
function doHideArchive() {
	$('#archive_content').slideUp('fast', function() {
		$('#menu_archive').removeClass('active');
	});
}