$(document).ready(function() {

	var $submenuActive = false;

	$('#fe_topmenu').hover(function() {
		$submenuActive = true;
		$('#top_submenu').animate({
			'height': '318px'
		});
	}, function() {
		$submenuActive = false;
		window.setTimeout(function() {
			$('#top_submenu').stop();

			if (!$submenuActive) {
				$('#top_submenu').animate({
					'height': '1px'
				});
			}
		}, 300);
	});

	$('#top_submenu').hover(function() {
		$submenuActive = true;
	}, function() {
		$submenuActive = false;
		$('#fe_topmenu').trigger('mouseout');
	});

	$('#top_submenu ul li a').hover(function() {
		$(this).stop(true).animate({
			'paddingLeft': '40px'
		});
		$('span.info', this).stop().animate({
			'color': '#000000'
		});

		var thpos = $(this).position();
		var papos = $('#top_submenu_scroller').position();

		$('#top_menu_pointer').animate({
			'left': (thpos.left + 15 + papos.left * -1) + 'px',
			'top': (thpos.top + 9) + 'px'
		});
	}, function() {
		$(this).stop(true).animate({
			'paddingLeft': '30px'
		});
		$('span.info', this).stop().animate({
			'color': '#606060'
		});

		$('#top_menu_pointer').stop();
	});

	$('#fe_topmenu a').mouseover(function() {
		var menId = $(this).attr('id').replace(/topmenu/, '');

		$('#top_submenu_scroller').stop();
		$('#top_submenu_scroller').animate({
			'left': (-905 * (menId - 1)) + 'px'
		});
	});

	$('#home_hover_layer').hover(function() {
		$('#home_hover_img').animate({
			'width': '49px',
			'left': '5px'
		});
	}, function() {
		$('#home_hover_img').animate({
			'width': '0px',
			'left': '54px'
		});
	});


	$('#recommendation_toggler').click(function(e) {
		e.preventDefault();
		$('#recommendation_container').css({
			'opacity': 0,
			'display': 'block'
		}).animate({
			'opacity': 0.9
		}, 1000);
	});

	$('#send_recommendation').click(function() {
		$('<form />')
			.appendTo('#recommendation_subcontainer')
			.append($('#recommendation_subcontainer>input,#recommendation_subcontainer>textarea'))
			.append('<input type="hidden" name="recommendation_sent" value="sent_true" />')
			.attr({
				'method': 'post'
			})
			.submit()
		;
	}).hover(function() {
		$('div', this).stop().animate({
			'top': '0px'
		}, false, 'easeInQuad');
	}, function() {
		$('div', this).stop().animate({
			'top': '-72px'
		}, 2000, 'easeOutQuint');
	});

	$('#hide_recommendation').click(function() {
		$('#recommendation_container').animate({
			'opacity': 0
		}, 1000, false, function() {
			$(this).css('display', 'none');
		});
	});


	if ($('.fe_contentwrapper').height() < $('#sub_menu_holder').height() + 356) {
		$('.fe_contentwrapper').animate({
			'height': ($('#sub_menu_holder').height() + 380) + 'px'
		});
	}

});



