

$(document).ready(function()
{	

	$('#main-menu li').hover(
		function()
		{
			var subsize = { };
			var $submenu = $(this).addClass('hover').find('>.submenu').show();
			if($.browser.msie)
				$submenu
					.append("<iframe class='kfb-iframe'></iframe>")
						.find('.kfb-iframe').each(function(){
							var ul = $(this).prev();
							subsize = { x: ul[0].offsetWidth, y: ul[0].offsetHeight };
							$(this).css({ width: subsize.x, height: subsize.y });
						})
						.end()
					.find('>ul>li').width(subsize.x);	
		},
		function()
		{
			$(this).removeClass('hover').find('>.submenu').hide().find('.kfb-iframe').remove();
		}
	);

	// Flash player
	$.fn.flashembed && $('.flash-player').each(function(i){
 		$(this).flashembed(
          {
               src: '/inc/player.swf',
               width: 249,
               height: 158,
               wmode: 'opaque',
               allowfullscreen: 'true',
               allowscriptaccess: 'always',
               id: 'flash-player' + i,
               name: 'flash-player' + i
          },
          {file: $(this).find('a').attr('href'), searchbar: 'false', autostart: 'false', image: $(this).find('img').attr('src')}
     	);
	});
	
	$('.side-logo-menu>ul>li').bind('mouseenter',
		function()
		{
			var windowHeight = $(window).height();
			var documentHeight = $(document).height();
			var maxHeight = windowHeight > documentHeight ? $(window).height() : windowHeight + $(document).scrollTop();
			var $submenu = $(this).find('.side-submenu');
			$(this).addClass('hover');
			var top = $(this).offset().top;
			var sideMenuHeight = $submenu.outerHeight();
			if(maxHeight < top + sideMenuHeight)
			{
				$submenu.css('top', maxHeight - top - sideMenuHeight);
			}
			else $submenu.css('top', 0);
		}
	).bind('mouseleave',
		function()
		{
			$(this).removeClass('hover');
		}
	);
	
	$('#lang-menu').hover(function(){ $(this).addClass('hover'); }, function(){ $(this).removeClass('hover'); } );

	$('.top_p').cycle({
		fx: 'fade',
		pause: 1,
		speed: 1000,
		timeout: 4000
		}
	);
	$('#motive').cycle({
		fx: 'fade',
		pause: 1,
		speed: 1000,
		timeout: 4000
		}
	);

});


