$(document).ready(function(){
	// voor de sorteer links
	var deSorteerWijze = $.getURLParam("sort");
	//alert (deSorteerWijze);
	if (deSorteerWijze == "az"){
		$("a#alfaSort").addClass("active");
		$("a#prijsSort").removeClass("active");
		$("a#nieuwSort").removeClass("active");
	}
	if (deSorteerWijze == "p"){
		$("a#alfaSort").removeClass("active");
		$("a#prijsSort").addClass("active");
		$("a#nieuwSort").removeClass("active");
	}
	if (deSorteerWijze == ""){
		$("a#alfaSort").removeClass("active");
		$("a#prijsSort").removeClass("active");
		$("a#nieuwSort").addClass("active");
	}
	// einde sorteer links

// start filter types //
	var deViewWijze;
	if ($.getURLParam("type") == "gal"){
		var deViewWijze = "gal";
	} else {
		var deViewWijze = "list";
	}
	//alert("deViewWijze = "+deViewWijze);
	$("#mapView").click(function(){
		//$("#hideSorteer").addClass("NOTVIS");
	  	$("div.galerijzelf").fadeOut("normal", function() {
			$("#update").click();
			$("#kaartwrap").removeClass("zwierhetweg");
			$("#kaartwrap").fadeIn("slow");
			$("#galFilterInside,#sorteeridentifier").fadeOut("slow");
			$("div#galfiltersWrap").addClass("formOpkaart");
			deViewWijze = "map";
			//alert("deViewWijze = "+deViewWijze);
		});
		return false;
	});
	// switch gal > lijst
	$("#listView").click(function(){
		//adjustLinks("list");
		//$("#hideSorteer").removeClass("NOTVIS");
		//var newCurVieuw = "list";
		//alert (newCurVieuw);
	  	$("div.galerijzelf").fadeOut("normal", function() {
			$("#kaartwrap").fadeOut("slow");
	  		$("div.galTooltipID").addClass("galTooltip_list").removeClass("DN").removeClass("galTooltip").css({opacity:1});
	  		$("div.galerijzelf").fadeIn("normal").addClass("list_view").removeClass("gal_view");
			$("div#galfiltersWrap").removeClass("formOpkaart");
			$("#galFilterInside,#sorteeridentifier").fadeIn("slow");
			deViewWijze = "list";
			//alert(deViewWijze);
			//$("div.deeskanNi").addClass("nenhoekvdFoto");
			//$("#kaartwrap").fadeOut("fast");
			//$("#kaartwrap").addClass("zwierhetweg");
		});
		return false;
	}); 
	// switch lijst > gal 
	$("#galView").click(function(){
		//adjustLinks("gal");
		//$("#hideSorteer").removeClass("NOTVIS");
		//var newCurVieuw = "gal";
	  	$("div.galerijzelf").fadeOut("normal", function() {
			$("#kaartwrap").fadeOut("slow");
	  		$("div.galTooltipID").addClass("galTooltip").addClass("DN").removeClass("galTooltip_list").css({opacity:0});
			$("div.galerijzelf").fadeIn("normal").addClass("gal_view").removeClass("list_view");
			$("div#galfiltersWrap").removeClass("formOpkaart");
			$("#galFilterInside,#sorteeridentifier").fadeIn("slow");
			deViewWijze = "gal";
			//alert("deViewWijze = "+deViewWijze);
			//$("div.deeskanNi").removeClass("nenhoekvdFoto");
			//$("#kaartwrap").fadeOut("fast");
			//$("#kaartwrap").addClass("zwierhetweg");
		});
		return false;
	}); 
	// toon-verberg
	$("div#galFilterInside a").prepend('<span class="toonofni"></span>');
	$("div#galFilterInside a span.toonofni").html("Verberg ");
	$("div#galFilterInside a.Alle span.toonofni").html("");
	$("div#galFilterInside a.totaalAantalJusteLink span.toonofni").html("");
	$("div#galFilterInside a.Alle").click(function(){
		$("div#galFilterInside a").removeClass("active");
		$(this).addClass("active");
		$("#deGal div.gallCell,#deGal div.gallCell img").removeClass("NOTVISINGAL");
		$("#deGal div.gallCell,#deGal div.gallCell img").animate({opacity:1},{duration:1000, queue:false});
		/*
		if (deViewWijze == "list"){
			$("#deGal div.gallCell").animate({width:975},{duration:1000, queue:false});
		} else {
			$("#deGal div.gallCell").animate({width:230},{duration:1000, queue:false});
		}
		*/	
		if (deViewWijze == "list"){
			$("#deGal div.gallCell").animate({width:975,height:200},{duration:1000, queue:false});
		} 
		if (deViewWijze == "gal"){
			$("#deGal div.gallCell").animate({width:230,height:220},{duration:1000, queue:false});
		}
		//$("#deGal div.gallCell").animate({width:230},{duration:1000, queue:false, complete:addVergerg});
		APP = true;
		OB = true;
		HOB = true;
		GB = true;
		AND = true;
		$("div#galFilterInside a span.toonofni").html("Verberg ");
		$("span.toonofni",this).html("");
		$("div#galFilterInside a.totaalAantalJusteLink span.toonofni").html("");
		return false;
	});
	
	
	
	var APP = true;
	var OB = true;
	var HOB = true;
	var GB = true;
	var AND = true;

		$("div#galFilterInside a.APP").click(function(){
			if (APP == true){											
				$("div#galFilterInside a.Alle").removeClass("active");
				$("div#galFilterInside a.APP").addClass("active");
				if (deViewWijze == "list"){
					$("#deGal div.APP,#deGal div.APP img").animate({opacity:0},{duration:1000, queue:false, complete:hideCell});
					$("#deGal div.APP").animate({width:0,height:0},{duration:1000, queue:false});
				}
				if (deViewWijze == "gal"){
					$("#deGal div.APP,#deGal div.APP img").animate({opacity:0},{duration:1000, queue:false, complete:hideCell});
					$("#deGal div.APP").animate({width:0,height:0},{duration:1000, queue:false});
				}
				$("span.toonofni",this).html("Toon ");
				APP = false;
			} else {
				$("div#galFilterInside a.APP").removeClass("active");
				$("#deGal div.APP").removeClass("NOTVISINGAL");
				$("#deGal div.APP,#deGal div.APP img").removeClass("NOTVISINGAL");
				$("#deGal div.APP,#deGal div.APP img").animate({opacity:1},{duration:1000, queue:false});
				if (deViewWijze == "list"){
					$("#deGal div.APP").animate({width:975,height:200},{duration:1000, queue:false});
				} 
				if (deViewWijze == "gal"){
					$("#deGal div.APP").animate({width:230,height:220},{duration:1000, queue:false});
				}
				//$("#deGal div.APP").animate({width:230},{duration:1000, queue:false});
				$("span.toonofni",this).html("Verberg ");
				APP = true;
			}
			return false;
		});
		$("div#galFilterInside a.OB").click(function(){
			if (OB == true){											
				$("div#galFilterInside a.Alle").removeClass("active");
				$("div#galFilterInside a.OB").addClass("active");
				if (deViewWijze == "list"){
					$("#deGal div.OB,#deGal div.OB img").animate({opacity:0},{duration:1000, queue:false, complete:hideCell});
					$("#deGal div.OB").animate({width:0,height:0},{duration:1000, queue:false});
				}
				if (deViewWijze == "gal"){
					$("#deGal div.OB,#deGal div.OB img").animate({opacity:0},{duration:1000, queue:false, complete:hideCell});
					$("#deGal div.OB").animate({width:0,height:0},{duration:1000, queue:false});
				}
				$("span.toonofni",this).html("Toon ");
				OB = false;
			} else {
				$("div#galFilterInside a.OB").removeClass("active");
				$("#deGal div.OB").removeClass("NOTVISINGAL");
				$("#deGal div.OB,#deGal div.OB img").removeClass("NOTVISINGAL");
				$("#deGal div.OB,#deGal div.OB img").animate({opacity:1},{duration:1000, queue:false});
				if (deViewWijze == "list"){
					$("#deGal div.OB").animate({width:975,height:200},{duration:1000, queue:false});
				} 
				if (deViewWijze == "gal"){
					$("#deGal div.OB").animate({width:230,height:220},{duration:1000, queue:false});
				}
				//$("#deGal div.OB").animate({width:230},{duration:1000, queue:false});
				$("span.toonofni",this).html("Verberg ");
				OB = true;
			}
			return false;
		});
		$("div#galFilterInside a.HOB").click(function(){
			if (HOB == true){											
				$("div#galFilterInside a.Alle").removeClass("active");
				$("div#galFilterInside a.HOB").addClass("active");
				if (deViewWijze == "list"){
					$("#deGal div.HOB,#deGal div.HOB img").animate({opacity:0},{duration:1000, queue:false, complete:hideCell});
					$("#deGal div.HOB").animate({width:0,height:0},{duration:1000, queue:false});
				}
				if (deViewWijze == "gal"){
					$("#deGal div.HOB,#deGal div.HOB img").animate({opacity:0},{duration:1000, queue:false, complete:hideCell});
					$("#deGal div.HOB").animate({width:0,height:0},{duration:1000, queue:false});
				}
				$("span.toonofni",this).html("Toon ");
				HOB = false;
			} else {
				$("div#galFilterInside a.HOB").removeClass("active");
				$("#deGal div.HOB").removeClass("NOTVISINGAL");
				$("#deGal div.HOB,#deGal div.HOB img").removeClass("NOTVISINGAL");
				$("#deGal div.HOB,#deGal div.HOB img").animate({opacity:1},{duration:1000, queue:false});
				if (deViewWijze == "list"){
					$("#deGal div.HOB").animate({width:975,height:200},{duration:1000, queue:false});
				} 
				if (deViewWijze == "gal"){
					$("#deGal div.HOB").animate({width:230,height:220},{duration:1000, queue:false});
				}
				//$("#deGal div.HOB").animate({width:230},{duration:1000, queue:false});
				$("span.toonofni",this).html("Verberg ");
				HOB = true;
			}
			return false;
		});
		$("div#galFilterInside a.GB").click(function(){
			if (GB == true){											
				$("div#galFilterInside a.Alle").removeClass("active");
				$("div#galFilterInside a.GB").addClass("active");
				if (deViewWijze == "list"){
					$("#deGal div.GB,#deGal div.GB img").animate({opacity:0},{duration:1000, queue:false, complete:hideCell});
					$("#deGal div.GB").animate({width:0,height:0},{duration:1000, queue:false});
				}
				if (deViewWijze == "gal"){
					$("#deGal div.GB,#deGal div.GB img").animate({opacity:0},{duration:1000, queue:false, complete:hideCell});
					$("#deGal div.GB").animate({width:0,height:0},{duration:1000, queue:false});
				}
				$("span.toonofni",this).html("Toon ");
				GB = false;
			} else {
				$("div#galFilterInside a.GB").removeClass("active");
				$("#deGal div.GB").removeClass("NOTVISINGAL");
				$("#deGal div.GB,#deGal div.GB img").removeClass("NOTVISINGAL");
				$("#deGal div.GB,#deGal div.GB img").animate({opacity:1},{duration:1000, queue:false});
				if (deViewWijze == "list"){
					$("#deGal div.GB").animate({width:975,height:200},{duration:1000, queue:false});
				} 
				if (deViewWijze == "gal"){
					$("#deGal div.GB").animate({width:230,height:220},{duration:1000, queue:false});
				}
				//$("#deGal div.GB").animate({width:230},{duration:1000, queue:false});
				$("span.toonofni",this).html("Verberg ");
				GB = true;
			}
			return false;
		});
 		   
	function hideCell() {
		$(this).addClass("NOTVISINGAL");	
	}
	// einde filter types //
	
	$("div.galTooltip,div.galTooltip2").animate({opacity:0},{duration:"slow", queue:false});
	//$("div.galTooltipPIDK").animate({opacity:0},{duration:"slow", queue:false});
	//$('div.galTooltip').fadeTo("fast", 0);
	$(".gallCell").mouseover(function(){
 		$('div.galTooltip, div.galTooltip2, div.galTooltipPIDK', this).removeClass("DN");
 		$('div.galTooltip, div.galTooltip2, div.galTooltipPIDK', this).animate({opacity:1},{duration:"slow", queue:false});
		//$(this).parent(".gallCell").children(".deeskanNi").removeClass("nenhoekvdFoto");
		//$(this).parent(".gallCell").children(".deeskanNi").addClass("nenhoekvdFoto-h");
		
		//$('#gegevensWrapper').animate({ height: $('#beschrijving').css('height') }, "fast");
		//$(".opacify").fadeTo(1, 0.5);
	});
	$(".gallCell").mouseout(function(){
 		//$(this).parent().removeClass("imageHoverke");
 		//$('div.galTooltip', this).addClass("DN");
 		$('div.galTooltip2,div.galTooltip, div.galTooltipPIDK', this).animate({opacity:0},{duration:"slow", queue:false});
		//$(this).parent(".gallCell").children(".deeskanNi").addClass("nenhoekvdFoto");
		//$(this).parent(".gallCell").children(".deeskanNi").removeClass("nenhoekvdFoto-h");
	});
});
