$(document).ready(function(){
	$('#lang a').click(function(){
		window.location.href = '/lang.php?lang=' + $(this).attr('href').replace(/\#/, "");;
		return false;
	});

	$('#pager li.selected a').click(function(){
		return false;
	});

	$('#content .overlay').each(function(){
		$(this).prepend('<span class="opacity" />');
	});
	$('.album.outer .inner').each(function(){
		$(this).prepend('<span class="opacity" />');
	});

	$('.opacity').css("opacity", 0.65);

	$("#content .extraInfo").hover(
		function () {
			$(this).find('.opacity').stop().animate({
				height: $(this).find('.onderschrift').height() + 42
			}, 250, function(){
				$(this).parent().find('.onderschrift').show();
			});
		},
		function () {
			$(this).find('.onderschrift').hide();
			$(this).find('.opacity').stop().animate({
				height: 30
			}, 250, function(){
			});
		}
	);

	$('#thaFolders .widgetLarge h3').each(function(){
		var h = $(this).height();
		$(this).parents('.widgetLarge').find('.opacity').css({"height": h});
//		$(this).parent('div').find('.opacity').css("height" : h);
	});

	var html = $(document).height(),
		head = $('#header').height(),
		cont = html - head;
		cont = cont + 50;

// contact form
	$('a[rel = joinAJO]').live('click', function(){
		getContactForm();
		return false;
	});

	$('.close').live('click', function(){
		closeForm();
	});
	$('.opac').live('click', function(){
		closeForm();
	});

	function getContactForm(){
		var form, formID, url, target, winH, winW;
			target	= 'body';
			url		= '/ajax/forms.php';
			formID	= 'joinForm';

		$(target).append('<div class="opac" />');
		$('.opac').css({opacity: '0.7'}).fadeIn(250);
		$(target).prepend('<span class="loadContent transparent"></span>');
		$.ajax({
				url: url,
				data: 'method=getFrom&formID=' + formID,
				success: function(results){
					$('.loadContent').remove();
					$(target).append(results);
					$(formID).hide();
				}
		});
	}

	function closeForm(){
		$('#joinForm').remove();
		$('.opac').fadeOut(250, function(){
			$(this).remove();
		});
	}
	$('#joinForm').live('submit', function(){
		ajaxHit('/ajax/join.php', '#joinForm', 'post', 'all set');
		return false;
	});

	$('.verticaal').each(function(){
		var h = $(this).parent('.stroke').height() + 10;
		$(this).css({ height: h + 'px' });
	});

	$('.trigger').live('click', function(){
		$(this).parent('li').find('.yearSub').slideToggle();
		return false;
	});

	$('.yearSub').each(function(){
		var $this = $(this);
		if( $(this).children('li').hasClass('active')) {
			$($this).addClass('show');
			$($this).parent('.year').addClass('activeli');
		}
	});


	var hash = window.location.hash;
	if(hash === '#join') {
		$('a[rel = joinAJO]').trigger('click');
	}
});
