jQuery(document).ready(function($) {
	// Top menu
	$('#top_menu td').each(function(){
		var $this = $(this);
		var $this_ul = $this.find('ul');
		if ($this_ul.length)
		{
			var $this_sibling = $this.find('.top_menu_elem');
			$this_sibling.addClass('has_children');
			if ($this_sibling[0].tagName == 'SPAN' && !$this_ul.hasClass('selected') && $this_ul.hasClass('g-dn'))
			{
				$this.hover(
					function(){
						$this_ul.show();
						$this_ul.css('z-index', 2);
						$this_sibling.css('z-index', 3);
						$this_sibling.addClass('selected');
					},
					function(){
						$this_ul.hide();
						$this_sibling.removeClass('selected');
					}
				);
			}
		}
	});

	//Content notes
	$('.content_note').each(function(){
		var $this = $(this);
		if ($this.height() > 70)
		{
			$this.css('padding-bottom', '50px');
			current_height = $this.height();
			$this.append('<div class="overflow"></div>');
			$this.height(80);
			$this.find('div.overflow').toggle(
				function(){
					$this.stop().animate({height: current_height + 'px'});
					this.style.backgroundPosition = 'bottom';
				},
				function(){
					$this.stop().animate({height: 70 + 'px'});
					this.style.backgroundPosition = 'top';
				}
			);
		}
	});
});
