$(document).ready(function(){
/*	
	// rollover images: initial state
	$('.rolloverimg').each(function(index) {
		imgsrc = $(this).attr('src');
		$(this).attr('src', imgsrc.replace('.png','-bw.png'));
	});
	
	// rollover images: on hover
	$('.rolloverimg').hover(
		function() {
			imgsrc = $(this).attr('src');
			$(this).attr('src', imgsrc.replace('-bw.png','.png'));
		}, function() {
			imgsrc = $(this).attr('src');
			$(this).attr('src', imgsrc.replace('.png','-bw.png'));
		}
	);
*/
	// dropdown menus
	// http://tympanus.net/codrops/2010/11/25/overlay-effect-menu/   
	// http://tympanus.net/Tutorials/OverlayEffectMenu/ 
	$(function() {
		var $oe_menu		= $('#mainmenu');
		var $oe_menu_items	= $oe_menu.children('li');
	
		$oe_menu_items.bind('mouseenter',function(){
			var $this = $(this);
			if ($this.children('div').length) {
				$this.addClass('slided selected');
			}
			$oe_menu_items.not('.slided').children('div').hide(); // for menu items that do not have a submenu
			$this.children('div').css('z-index','9999').stop(true,true).slideDown(200,function(){
				$oe_menu_items.not('.slided').children('div').hide();
				$this.removeClass('slided');
			});
		}).bind('mouseleave',function(){
			var $this = $(this);
			$this.removeClass('selected').children('div').css('z-index','1');
		});
	
		$oe_menu.bind('mouseenter',function(){
			var $this = $(this);
			$this.addClass('hovered');
		}).bind('mouseleave',function(){
			var $this = $(this);
			$this.removeClass('hovered');
			$oe_menu_items.children('div').hide();
		})
	});
	
	$(function() {
		var $oe_menu		= $('#languages_bar');
		var $oe_menu_items	= $oe_menu.children('li');
	
		$oe_menu_items.bind('mouseenter',function(){
			var $this = $(this);
			if ($this.children('div').length) {
				$this.addClass('slided selected');
			}
			$oe_menu_items.not('.slided').children('div').hide(); // for menu items that do not have a submenu
			$this.children('div').css('z-index','9999').stop(true,true).slideDown(200,function(){
				$oe_menu_items.not('.slided').children('div').hide();
				$this.removeClass('slided');
			});
		}).bind('mouseleave',function(){
			var $this = $(this);
			$this.removeClass('selected').children('div').css('z-index','1');
		});
	
		$oe_menu.bind('mouseenter',function(){
			var $this = $(this);
			$this.addClass('hovered');
		}).bind('mouseleave',function(){
			var $this = $(this);
			$this.removeClass('hovered');
			$oe_menu_items.children('div').hide();
		})
	});
	
});

