// JavaScript Document
$(document).ready(function($) {

	$("#lang").children().children().children().mouseover(function() { 
		$(this).attr('src', $(this).attr('src').replace('1.gif', '2.gif'));
	}).mouseout(function() { 
		$(this).attr('src', $(this).attr('src').replace('2.gif', '1.gif'));
	});
	
	$("a[rel^='prettyPhoto']").prettyPhoto();
	
	$("#disciplines a").click(function () { 
										
		$(this).blur();
		
		$("#disciplines a").removeClass('discipline_active');
		$(this).addClass('discipline_active');
		
		$.get("/ajax.php", { cmd: 'geefSessies', discipline_id: $(this).attr('rel'), lang: $("body").attr('class') }, function(data) { 
			$.temp = data;
			$("#sessies").fadeOut(200, function() { 
				$(this).html($.temp).fadeIn(200);
				delete($.temp);
			});
		});
		return false; 
	});
	
	$("#disciplines_right li a:not([class=right_discipline_active])").next().hide();
	
	$("#disciplines_right li a[rel='discipline']").click(function() { 
												
		$(this).addClass('right_discipline_active').next().slideDown(300);
												
		$(this).parent().siblings('li').each(function() { 
			$(this).children('a').removeClass('right_discipline_active').next().slideUp(300);
		});
		
		return false;
		
	});
	
	$("div#header img:first").css('display', 'block').attr('rel', 'active');
	
	if ($("div#header img").length > 1)
		setInterval(doHeader, 10000);
	
});

function doHeader () {
	
	var elm = $("div#header img:[rel=active]");
	
	elm.attr('rel', '').fadeOut(600);
	if (elm.next().length == 0)
		elm.siblings('img:first').fadeIn(600).attr('rel', 'active');
	else
		elm.next().fadeIn(600).attr('rel', 'active');
	
}