$(function() {
	// floorplans
	if($("#hiddenfloorplan div").length > 0) {
		$("#hiddenfloorplan").append('<div class="floorplanlinks"></div>');
		$("#hiddenfloorplan img").each(function(index) {
			var thisLink = '<a href="' + $(this).attr("src") + '" data-src="' + $(this).attr("src") + '">' + $(this).attr("src") + '</a>';
			$(".floorplanlinks").append(thisLink);
		});
		$('.floorplanlinks').lightGallery({
			selector: 'a',
			download: false,
			counter: false
		});
		$(".floorplantoggle").click(function(e) {
			e.preventDefault();
			$("#hiddenfloorplan a").trigger("click");
		});
	} else {
		$("#floorplanlinkwrap").hide();
	}

	// epc
	if($("#hiddenepc .propertyimage").length > 0) {
		$("#hiddenepc").append('<div class="epclinks"></div>');
		$("#hiddenepc img").each(function(index) {
			var thisLink = '<a href="' + $(this).attr("src") + '" data-src="' + $(this).attr("src") + '">' + $(this).attr("src") + '</a>';
			$(".epclinks").append(thisLink);
		});
		$('.epclinks').lightGallery({
			selector: 'a',
			download: false,
			counter: false
		});
		$(".epctoggle").click(function(e) {
			e.preventDefault();
			$("#hiddenepc a").trigger("click");
		});
	} else {
		$("#epclinkwrap").hide();
	}

	// Google maps
	$('#maplinkwrap a').lightGallery({
		selector: 'this',
		iframeMaxWidth: '95%',
		download: false
	});
	// streetview needs closable:false to prevent accidental closes from releasing the mouse after dragging the map
	$('#streetviewlinkwrap a').lightGallery({
		selector: 'this',
		iframeMaxWidth: '95%',
		download: false,
		closable: false
	});

	$('#vtourlinkwrap a').lightGallery({
		selector: 'this',
		iframeMaxWidth: '95%',
		download: false
	});

});