$(function() {
	
	// Fancybox
	$("a.fancybox").fancybox({titleShow: true});

	
	// equalColumns (2/2)
	equalColumns();

	// MENU hover/active
	var $active = $('#topMenu li.current_page_item, #topMenu li.current_page_parent, #topMenu li.current_page_ancestor');
	$active.next().addClass('afterActive').end().prev().addClass('beforeActive');
	$('#topMenu li:first').addClass('first');
	$('#topMenu li:last').addClass('last');
	$('#topMenu li').hover(function () {
		$(this).addClass('hover');
		$(this).next().addClass('afterHover');
		$(this).prev().addClass('beforeHover');
	}, function () {
		$(this).removeClass('hover');
		$(this).next().removeClass('afterHover');
		$(this).prev().removeClass('beforeHover');
	});


	// FORMS - focus and blur
	$('input, textarea').focus(function() {
		$(this).select().parent().addClass('focus');
	});
	$('input, textarea').blur(function() {
		$(this).parent().removeClass('focus');
	});
	// FORMS - clicking on hint
	$('.hint').not('.disabled .hint').click(function() {
		$(this).parent().addClass('focus').find('input').select();
	});
	// FORMS - Empty filled fields on blur
	$('input, textarea').each(function() {
		$(this).blur(function() {
			$(this).parent().removeClass('focus');
			if ($(this).val() != "") {
				$(this).parent().addClass('filled');
			} else {
				$(this).parent().removeClass('filled');
			};
		});
	});
	// FORMS - Empty filled fields on load
	$('input, textarea').each(function() {
		if ($(this).val() != "") {
			$(this).parent().addClass('filled');
		} else {
			$(this).parent().removeClass('filled');
		};
	});
});


// equalColumns (1/2)
function equalColumns() {
	var primaryContentHeight = $('.primaryContent').height();
	var secondaryNavigationHeight = $('.secondaryNavigation').height();
	if (primaryContentHeight > secondaryNavigationHeight) {
		$('.secondaryNavigation').css({'min-height': primaryContentHeight});
	}
	if (secondaryNavigationHeight > primaryContentHeight) {
		$('.primaryContent').css({'min-height': secondaryNavigationHeight});
	}
	setTimeout("equalColumns();", 500);
	
}
