$(document).ready(function() {
	registerMainMenu();
	registerContent();
	$(window).load(registerContent);
	registerFancybox();
	registerLogin();
});

function registerMainMenu()
{
	var mm=$('#mainMenu');
	$('ul.mainMenuSub',mm).parent('li').hover(null,function() { $(this).children('ul').hide(); }).children('a').hover(function() { $(this).siblings('ul').show(); });
	$('ul li').hover(function() { $(this).addClass('hover'); },function() { $(this).removeClass('hover'); });
}

function registerContent()
{
	$('.imagetext_content').each(function() {
		$(this).height('auto');
		var compareHeight=$('.imagetext_content_text',this).outerHeight();
		if($(this).height()<compareHeight)
		{
			$(this).height(compareHeight);
		}
	});
}

function registerFancybox()
{
	$('a.content-image-zoom').fancybox({
		'overlayOpacity':0.6,
		'overlayColor':'#000000',
		'titleShow':false,
		'padding':15
	});
	
	$('a.content-video-zoom').fancybox({
		'overlayOpacity':0.6,
		'overlayColor':'#000000',
		'titleShow':false,
		'padding':15,
		'type':'swf',
		'width':640,
		'height':392,
		'swf':{
			'wmode':'transparent',
			'allowfullscreen':true,
			'width':640,
			'height':392,
			'flashvars':'abouttext=Flash player&skin=/video/modieus/modieus.xml&autostart=true'
		},
		'autoScale':false
	});
}

function registerLogin()
{
	$('.openLogin').click(function() {
		var cont=$(this).siblings('.loginContainer');
		if(cont.is(':animated')) return false;
		else if(cont.is(':hidden')) { cont.slideDown(); return false; }
		$('#loginForm').submit();
	});
	$('div.loginError').parents('.loginContainer').show();
}
