$(document).ready(function() {

	/* This is basic - uses default settings */
	
	$("a#single_image").fancybox();
	$("a.iframe").fancybox();
	
	/* Using custom settings */
	
	$("a#inline").fancybox({
		'hideOnContentClick': true
	});

	/* Apply fancybox to multiple items */
	
	$("a.group").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});
	
	
	//Fotoalbum
	$("div.fotoalbum-cat").mouseover(function(){
		$(this).addClass("fotoalbum-cat-hover");		
		$(this).find("img").addClass("fotoalbum-cat-img-hover");
	});

	$("div.fotoalbum-cat").mouseout(function(){
		$(this).removeClass("fotoalbum-cat-hover");
		$(this).find("img").removeClass("fotoalbum-cat-img-hover");
	});
	
	$("div.fotoalbum-img-box").mouseover(function(){		
		$(this).find("img").addClass("fotoalbum-cat-img-hover");
	});

	$("div.fotoalbum-img-box").mouseout(function(){
		$(this).find("img").removeClass("fotoalbum-cat-img-hover");
	});
	
	$("div.fotoalbum-cat").click(function(){
		var mapid = $(this).attr("id");
		window.location.replace("fotos.php?map="+mapid);
	});
	
	
	
	$('.login-link').click(function(){
		$("#top_login").trigger('click');
	});
	
	//LOGIN
	$("#top_login").live('mouseenter', function(){
		$(this).find("p").css("color", "#971A1E");
		
		//Iemand is ingelogd, menu groter maken voor extra opties
		if($(this).find("p").html().indexOf("uitloggen") >1){
			//$(this).css("height", "80px");
			
			if($(this).has('#change-password').length == 0){
				$(this).append('<div id="change-password"><a href="login.php?action=changepasswrd">Wijzig wachtwoord</a></div>');
				$(this).addClass("top_login-hover");
			}
		}
	});
	
	$("#top_login").live('mouseleave', function(){
		$(this).find('#change-password').remove();
		$(this).find("p").css("color", "black");
		$(this).removeClass("top_login-hover");
	});
	
	$("#top_login").mouseout(function(){
		$(this).find("p").css("color", "black");
	});
	
	$("#top_login").click(function(event){
		if(event.target.nodeName != "A"){
			var page_redirect = $(this).find("p").attr("class");
			var page = "login.php";
			
			if($(this).find("p").html().indexOf("uitloggen") >1){
				page = "login2.php?action=logout&page="+page_redirect;
			} else {
				page = "login2.php?page="+page_redirect;
			}
			
			$.fancybox({
				'width': 500,
				'height': 400,
				'scrolling' :false,
				'autoScale' :false,
				'href' : page
			});
		}
	});
	
	
	$(".tr-uitslagenlist").mouseover(function(){
		$(this).addClass("trmouseover");
	});
	
	$(".tr-uitslagenlist").mouseout(function(){
		$(this).removeClass("trmouseover");
	});
	
	$(".tr-uitslagenlist").click(function(){
		var id = $(this).attr("id");
		
		window.location = "uitslag.php?id="+id;
	});
});


