$(document).ready(function () {
	// главное меню {
	var _levels = new Array ();
	_levels[1] = null;
	_levels[2] = null;
	_levels[3] = null;
	$('span.mmenu').each( function () {
		if ($(this).css('display')=='block') {
			_levels[parseInt($(this).attr('_level'))] = $(this).attr('_id');
		}
	});
	/*
	$('a.mmenu').mousemove( function() { 
		var _flag = false;;
		$(this).parent().find('span.mmenu').each(function() {
			if (!_flag) {
				var _span = $(this);
				var _level = $(_span).attr('_level');
				var _id = $(_span).attr('_id');
				if (_levels[parseInt(_level)] != _id) {
					$(_span).slideDown("slow");
					_levels[parseInt(_level)] = _id;
					hideOther(parseInt(_level));
				}
				_flag = true;
			}
		});
	});
	*/
	function hideOther(_level) {
		$('span.mmenu').each(function() {
			if ($(this).css('display') != 'none') {
				if (parseInt($(this).attr('_level')) == _level) {
					if (_levels[parseInt($(this).attr('_level'))] != undefined) {
						if ($(this).attr('_id') != _levels[parseInt($(this).attr('_level'))]) {
							$(this).slideUp("slow");
						}
					}
				}
			}
		});
	}
	// }
	
	// Блоки новостей {
	var _bnews_timer = null;
	
	refreshBNews();
	// }
});

	function hideBNews(_div) {
		$('div.bnews').each(function() {
			if ($(this).css('display') != 'none' && $(this).get(0)!=_div) $(this).hide();
		});
	}

	function refreshBNews() {
		$('a.bnews').each(function() {
			$(this).mouseover(function() {
				_div = $(this).parent().find('div.bnews');
				if (_div != undefined) {
					var coords = findPos($(this).get(0));
					$(_div).css('left', coords[0]+10);
					$(_div).css('top', coords[1]+25);
					$(_div).show(); //fadeIn("slow"); // slideDown("slow");
					hideBNews($(_div).get(0));
				}
			});
			$(this).mouseout(function() {
				_div = $(this).parent().find('div.bnews');
				if (_div != undefined) {
					$(_div).hide(); //slideUp("slow");
				}
			});
		});
	};


