// Flash font replacement
// Must run before $(document).ready();
// var preussische = { src : 'swf/preussische.swf' };
// sIFR.activate(preussische);
// sIFR.replace(preussische, {
// 	selector: '.sifr',
// 	defaultKerning: true,
// 	forceWidth: true,
// 	wmode: 'transparent',
// 	css: '.sIFR-root { letter-spacing: -1; background-color: transparent; color: #000000; }'
// });
// sIFR.replace(preussische, {
// 	selector: '.sifr-centered',
// 	defaultKerning: true,
// 	forceWidth: true,
// 	wmode: 'transparent',
// 	css: '.sIFR-root { letter-spacing: -1; background-color: transparent; color: #000000; text-align:center }'
// });


$(document).ready(function() {
	// Scrolling functionality
	$.localScroll({
		target:'#slide-container',
		axis:'x',
		hash:'false',
		onBefore: function() {
			players = $('.player').each(function(obj) {
				$f(obj).pause();
			});
		}
	});
	
	// Nav menu functions
	$('.nav-text').hide(); // all nav text should be hidden by default
	$('.menu-wrapper').hide(); // menus hidden by default
	$('#dialog').hide(); // dialog hidden by default
	// Add menu appear/disappear to click event
	$('.menu-button').click(function() {
		var menuId = $(this).attr('id');
		var menuLoc = menuId.split('-')[0];
		var menu = $('#'+ menuLoc + '-menu');
		// $('.menu-wrapper').hide();
		if (menu.css('display') == 'none')
		{
			$('.menu-wrapper').not(menuId).fadeOut('fast');
			menu.fadeIn('normal');
			$('.player').each(function(obj) {
				$f(obj).pause();
				$f(obj).hide();
			});
			$('.prev,.next').hide();
		}
		else {
			var menusHidden = true;
			menu.fadeOut('fast', function() {
				$('.menu-wrapper').each(function() {
					if ( $(this).css('display') != 'none') menusHidden = false;
				});
				if (menusHidden) $('.prev,.next').show();
			});
			$('.player').each(function(obj) {
				$f(obj).show();
			});
		}
	});
	// $('#menu').mouseleave(function() {
	// 	$('ul#menu-list li').stop();
	// 	$('ul#menu-list li').fadeTo("fast", 0.5);
	// }); 
	// When we leave menu area, stop fading those boxes
	$('.menu').mouseleave(function() {
		$('ul.menu-list li').stop();
		$('ul.menu-list li').fadeTo("fast", 1);
	});
	$('ul.menu-list li').mouseover(function() {
		$(this).stop();
		var theli = $(this);
		$(this).fadeTo("fast", 1);
		var theinfPos = theli.position();
		var left = theinfPos.left + 3;
		var top = theinfPos.top + 3;
		var theinfo = $(this).find('.nav-text');
		$(theinfo).css('position', 'absolute');
		$(theinfo).css('left', left);
		$(theinfo).css('top', top);
		$(theinfo).show();
		$('ul.menu-list li').not(this).stop();
		$('ul.menu-list li div.nav-text').not(theinfo).hide();
		$('ul.menu-list li').not(this).fadeTo("slow", 0.5);
	});
	$('ul.menu-list li').mouseleave(function() {
		var theinfo = $(this).find('.nav-text');
		$(theinfo).hide();
	});
	$('ul.menu-list li a').click(function() {
		$('.menu-wrapper').hide();
	});
});