$(document).ready(function() {

	/* Draggable logo BEG */
	$('#fe_logo').draggable({
		appendTo: 'body',
		containment: 'body',
		helper: 'original',
		zIndex: 9999,
		stop: function() {
			$(this).animate({
				'top': '0px',
				'right': '0px'
			}, 1000, 'easeOutElastic');
		}
	});
	/* Draggable logo END */

	$('#fe_header_overlay').css({
		'opacity': 0.85
	});


	/* Menu BEG */

	// Active menu items
/*	$('a.menu_item').css({
		'backgroundImage': $('a.menu_item').hasClass('menu_item_active') ? $('a.menu_item').css('backgroundImage').replace(/.png/g, '_hover.png') : $('a.menu_item').css('backgroundImage')
	});
*/

	$('.menu_item_wrapper a').each(function() {

		if ($(this).hasClass('menu_item_sub_active')) {
			$(this).parents('.menu_item_wrapper', this).css({
				'top': '5px',
				'height': '27px'
			});
		}
	});

	// Hover
	$('.menu_item_wrapper').mouseover(function() {
		$(this).stop().animate({
			'height': '400px'
		});
		var background = $('a.menu_item', this).css('backgroundImage');

		if (!$(this).children('a.menu_item_sub').hasClass('menu_item_sub_active')) {
			$('.menu_item', this).css({
				'backgroundImage': background.replace(/.png/g, '_hover.png')
			});

			$('.menu_item', this).stop().animate({
				'top': ($('.menu_item', this).hasClass('menu_item_active')) ? '0px' : '5px',
				'height': ($('.menu_item', this).hasClass('menu_item_active')) ? '32px' : '27px'
			});
		}
	});

	$('.menu_item_wrapper').mouseout(function() {
		if (!$(this).children('a.menu_item_sub').hasClass('menu_item_sub_active')) {
			$(this).stop().animate({
				'height': '32px'
			});
			var background = $('a.menu_item', this).css('backgroundImage');

			$('.menu_item', this).stop().css({
				'backgroundImage': background.replace(/_hover.png/g, '.png')
			}).animate({
					'top': $('.menu_item', this).hasClass('menu_item_active') ? '5px' : '0px',
				'height': $('.menu_item', this).hasClass('menu_item_active') ? '27px' : '32px'
			});
		} else {
			$(this).stop().animate({
				'height': '27px'
			});
		}
	});

	// Click (optimized for Ipad
	$('.menu_item_wrapper').click(function() {
		$(this).trigger('mousover');
	});

	/* Menu END */


	/* Recommendation BEG */
	$("#fe_recommend").click(function () {
		$("#recommendation_container").animate({
			'top': '-420px',
			'height' : '380px'
		}, 700);
	});

	$("#hide_recommendation").click(function () {
		$("#recommendation_container").animate({
			'top': '0px',
			'height' : '0px'
		}, 700);
	});

	var recommendation_message = '';
	$('#recommendation_message').keyup(function(ekey) {
		$('#recommendation_msg_count').text(100 - $(this).val().length);
		if (recommendation_message.length >= 100 && ekey.which != 8 && ekey.which != 46) {
			$(this).val(recommendation_message);
		} else {
			recommendation_message = $(this).val();
		}
	});


	$("#send_recommendation").click(function () {
		$('<input>')
			.css('display', 'none')
			.attr({
				name: 'recommendation_sent',
				value: 'sent_true'
			})
			.appendTo('#form_recommendation')
		;

		$('#form_recommendation').attr({
			'method': 'post'
		}).submit();
	});
	/* Recommendation END */

});


/* IE 6 message */
function checkIE6() {
	if ($.browser.msie && parseInt($.browser.version, 10) < 7) {
		$("#ie6error").css({
			'display': 'block'
		});
		$('#currentBrowserVersion').text($.browser.version);

		$("#ie6error div").click(function () {
			$("#ie6error").css({
				'display': 'none'
			});
		});
	}
}
/* IE 6 message END */

function getMovieObjOfId(movieName) {

	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	var flObj = (isIE) ? window[movieName] : document[movieName];

	return flObj;
}





