	var languageListTimeout = null;

	function showLanguageList()
	{
		var list = $('.kailisLanguageList');

		var listSize = parseInt($('.kailisLanguage').width()) + parseInt($('.kailisLanguage').css('padding-left').replace(/px/, '')) + parseInt($('.kailisLanguage').css('padding-right').replace(/px/, ''));
		$('.kailisLanguage').addClass('languageActive');
		list.width(listSize);
		list.slideDown('normal');

		list.mouseleave(function(e)
			{
				languageListTimeout = setTimeout('hideLanguageList()', 1000);
			})
			.mouseenter(function(e)
			{
				clearTimeout(languageListTimeout);
			});
	}

	function hideLanguageList()
	{
		var list = $('.kailisLanguageList');

		list.slideUp('normal', function()
			{
				$('.kailisLanguage').removeClass('languageActive');
			});
	}

$(document).ready(function()
{
	fixHeightBox();

	fixErrorBox();

	$('.kailisLanguage span').click(function(e)
		{
			if( $(e.target).hasClass('active') )
			{
				hideLanguageList();
			}
			else
			{
				showLanguageList();
			}
		});

	function fixErrorBox()
	{
		$('.element span.error').css(
		{
			position: 'relative',
			top: -18,
			marginBottom: -18
		}).click( function()
		{
			var obj = $(this);
			obj.prev().focus();
			obj.parents('.error').removeClass('error');
			obj.remove();
		});
		$('.element.textarea span.error').css(
		{
			position: 'relative',
			top: -100,
			height: 90,
			marginBottom: -90,
			backgroundColor: 'white'
		});
		$('li.error .element input, li.error .element textarea, td.error input').focus( function()
		{
			var obj = $(this);
			obj.parent().parent().removeClass('error');
			obj.parent().children('span.error').remove();
		});
	}

	function fixHeightBox()
	{
		var maxHeight = 0;

		$('div.equalHeightBox').each(function()
			{
				if( $(this).height() > maxHeight )
				{
					maxHeight = $(this).height();
				}
			});

		$('div.equalHeightBox').height(maxHeight);
		$('div.equalHeightBox.heroBox img.largeLogo').css(
			{
				bottom: 6,
				left: 6
			});
	}
});
