$(document).ready(function(){
	// fake idee foto click
	var dejuisteFotoTaal = $.getURLParam("lang");
	if (dejuisteFotoTaal == "nl"){
		var sluitfotoTXT = "sluit foto's";
		var toonalleTXT = "toon alle";
		var vanTXT = "van";
		var fotoTXT = "foto";
		$('body div.prev').html('vorige');
		$('body div.next').html('volgende');
	}
	if (dejuisteFotoTaal == "fr"){
		var sluitfotoTXT = "fermer les photos";
		var toonalleTXT = "montrer toutes les";
		var vanTXT = "de";
		var fotoTXT = "photo";
		$('body div.prev').html('pr&eacute;c&eacute;dent');
		$('body div.next').html('suivante');
	}
	if (dejuisteFotoTaal == "en"){
		var sluitfotoTXT = "close pictures";
		var toonalleTXT = "show all";
		var vanTXT = "of";
		var fotoTXT = "picture";
		$('body div.prev').html('previous');
		$('body div.next').html('next');
	}
	//$(".gallImageWrapper")
	$('div#fotoIdeeZelf_1').click(function() {
		$('a#fotoIdeeLink_1_1,a.fotoIdeeLink_1_1').click();
	});
	$('div#fotoIdeeZelf_2').click(function() {
		$('a#fotoIdeeLink_2_1,a.fotoIdeeLink_1_1').click();
	});
	$('div#fotoIdeeZelf_3').click(function() {
		$('a#fotoIdeeLink_3_1,a.fotoIdeeLink_1_1').click();
	});
	$('div#fotoIdeeZelf_4').click(function() {
		$('a#fotoIdeeLink_4_1,a.fotoIdeeLink_1_1').click();
	});
	$('img.kliktOpDeFoto').click(function() {
		$('a#fotoReaLink_1,a.fotoIdeeLink_1_1').click();
	});
	// einde fake idee foto click
	$('.klikFotolinkSimu').click(function() {
		//$(this).parents("div.gallCell").children("div:nth-child(3)").children("div:nth-child(1)").children("div:nth-child(3)").children("a:nth-child(1)").click();
		$(this).parents("div.gallCell").find("a.fotoLinkZelfSimu_1").click();
	});
	
	
	// voor alles
	$('div.next').click(function() {
		collection.eq(next).click();
		return false;
	});
	$('div.prev').click(function() {
		collection.eq(prev).click();
		return false;
	});

	var index;
	var tot;
	var dit;
	var parent;
	var next;
	var prev;
	var nextDet;
	var prevDet;
	var collection;
	var url;
	var denTitle;
	var denArchitekt;
	var denTekst;
	var deRef;
	// einde voor alles
	// realisaties
	$("a.toonfotoRea").click(function () {
		$("#preloader, #preloaderBG").show();
		url = $(this).attr('href');
		denTitle = $(this).attr("title");
		//denArchitekt = $(this).attr("rel");
		denTekst = $(this).attr("type");
		deRef = $(this).attr("name");

		$('img#deFotoZelf').attr('src', url);
		collection = $(this).parent("div").find("a");
		
		index = parseInt(collection.index(this));
		//var index = 0;
		tot = parseInt(collection.size())-1;
		if (collection.size() > 1){
			$('div.prev').removeClass('DN');
			$('div.next').removeClass('DN');
		} else {
			$('div.prev').addClass('DN');
			$('div.next').addClass('DN');
		}
		
		dit = $(this);
		next = index < tot ? index+1: 0;
		prev = index > 0 ? index-1: tot;
		
		
		$('div.fotoTitle').html('<div class="lijnGrijsOnder PB5 MB5 TAC"><span  class="bigTitleWit MR30">'+denTitle+'</span>ref: '+deRef+'</div><p class="TAC">'+denTekst+'</p><br />');
		$('div.fotoInfo').html(fotoTXT +' '+(index+1)+' '+ vanTXT +' '+(tot+1)+'&nbsp;&nbsp;&nbsp;&nbsp;<span class="pointer grijsLicht TisVer"><b>'+ sluitfotoTXT +'</b></span>');
		return false;
	});
	
	// ideenbank
	$("a.toonfotoIdee").click(function () {
		$("#preloader, #preloaderBG").show();	
		url = $(this).attr("href");
		denTitle = $(this).attr("title");
		denArchitekt = $(this).attr("rel");
		denTekst = $(this).attr("name");
		deideeLink = $(this).attr("rev");

		$('img#deFotoZelf').attr('src', url);
		collection = $(this).parent("div").find("a");
		index = $(this).parent("div").find("a").index(this);
		tot = parseInt(collection.size())-1;
		if (collection.size() > 1){
			$('div.prev').removeClass('DN');
			$('div.next').removeClass('DN');
		} else {
			$('div.prev').addClass('DN');
			$('div.next').addClass('DN');
		}
		
		dit = $(this);

		next = index < tot ? index+1: 0;
		prev = index > 0 ? index-1: tot;
		
		$('div.fotoTitle').html('<div class="lijnGrijsOnder PB5 MB5 TAC"><span  class="bigTitleWit MR30">'+denTitle+'</span>'+denArchitekt+'  <b><a href="'+deideeLink+'" class="ML20 rood ontopofitall">'+ toonalleTXT +' '+denTitle+'en</a></b></div><div class="ideenBody MT10 MB10">'+denTekst+'</div>');
		$('div.fotoInfo').html(fotoTXT +' '+(index+1)+' '+ vanTXT +' '+(tot+1)+'&nbsp;&nbsp;&nbsp;&nbsp;<span class="pointer grijsLicht TisVer"><b>'+ sluitfotoTXT +'</b></span>');
		return false;
	});

	$("a.toonfotoIdeeZelf").click(function () {
		$("#preloader, #preloaderBG").show();	
		url = $(this).attr("href");
		denTitle = $(this).attr("title");
		denArchitekt = $(this).attr("rel");
		denTekst = $(this).attr("type");

		$('img#deFotoZelf').attr('src', url);
		collection = $(this).parent("div").find("a");
		index = $(this).parent("div").find("a").index(this);
		tot = parseInt(collection.size())-1;
		if (collection.size() > 1){
			$('div.prev').removeClass('DN');
			$('div.next').removeClass('DN');
		} else {
			$('div.prev').addClass('DN');
			$('div.next').addClass('DN');
		}
		
		dit = $(this);
		next = index<tot ? index+1: 0;
		prev = index>0 ? index-1: tot;
		
		$('div.fotoTitle').html('<div class="lijnGrijsOnder PB5 MB5 TAC"><span  class="bigTitleWit MR30">'+denTitle+'</span>'+denArchitekt+'</div><div class="ideenBody MT10 MB10">'+denTekst+'</div>');
		$('div.fotoInfo').html(fotoTXT +' '+(index+1)+' '+ vanTXT +' '+(tot+1)+'&nbsp;&nbsp;&nbsp;&nbsp;<span class="pointer grijsLicht TisVer"><b>'+ sluitfotoTXT +'</b></span>');
		return false;
	});

	// voor detail
	$("a.toonfoto").click(function () {
		$("#preloader, #preloaderBG").show();	
		denurl = $(this).attr("href");
		fotoTitle = $(this).attr("title");

		$('img#deFotoZelf').attr('src', denurl);
		collection = $("div#slideshow div").find("a");
		//collection = $(this).parent("div").find("a");
		parent = $(this).parent("div");
		index = $("div#slideshow div").index(parent);
		tot = $("div#slideshow div").size()-1;
		dit = $(this);
		
		next = index<tot ? index+1: 0;
		prev = index>0 ? index-1: tot;

		/*$('div#nextDet').click(function() {
			$("div#slideshow div").eq(nextDet).find("a").click();
			return false;
		});
		$('div#prevDet').click(function() {
			$("div#slideshow div").eq(prevDet).find("a").click();
			return false;
		});
		*/
		$('div.fotoTitle').html('<div class="lijnGrijsOnder PB5 MB5 TAC"><span  class="bigTitleWit MR30">'+fotoTitle+'</span></div>');
		$('div.fotoInfo').html(fotoTXT +' '+(index+1)+' '+ vanTXT +' '+(tot+1)+'&nbsp;&nbsp;&nbsp;&nbsp;<span class="pointer grijsLicht TisVer"><b>'+ sluitfotoTXT +'</b></span>');
		return false;
	});
	$("a.toonfoto-buuuuuu").click(function () {
		$("#preloader, #preloaderBG").show();	
		denurl = $(this).attr("href");
		fotoTitle = $(this).attr("title");
		$('img#deFotoZelf').attr('src', denurl);
		parent = $(this).parent("div");
		index = $("div#slideshow div").index(parent);
		tot = $("div#slideshow div").size()-1;
		dit = $(this);
		
		next = index<tot ? index+1: 0;
		prev = index>0 ? index-1: tot;
		collection = $(this).parent("div").find("a");

		/*$('div#nextDet').click(function() {
			$("div#slideshow div").eq(nextDet).find("a").click();
			return false;
		});
		$('div#prevDet').click(function() {
			$("div#slideshow div").eq(prevDet).find("a").click();
			return false;
		});
		*/
		$('div.fotoTitle').html('<div class="lijnGrijsOnder PB5 MB5 TAC"><span  class="bigTitleWit MR30">'+fotoTitle+'</span></div>');
		$('div.fotoInfo').html(fotoTXT +' '+(index+1)+' '+ vanTXT +' '+(tot+1)+'&nbsp;&nbsp;&nbsp;&nbsp;<span class="pointer grijsLicht TisVer"><b>'+ sluitfotoTXT +'</b></span>');
		return false;
	});
	$("a.addDNvv").click(function () {
		$('div.prev').addClass('DN');
		$('div.next').addClass('DN');
	});
	$("a.removeDNvv").click(function () {
		$('div.prev').removeClass('DN');
		$('div.next').removeClass('DN');
	});
	// einde detail

});



