$(document).ready(function() {

	//hide last post divider
	var count = 0;
	$(".post").each(function() {
		count++;
	});	

	if (count < 7) {
		$(".post:last").css("background", "none");
		$(".post:last").css("margin", "0");
	}	

});

/**
 * Gallery
 */
(function($) {
	
	$.fn.gallery = function() {
		
		var $this = $(this);
		
		return this.each(function() {
			
			$("#wrapper").css("width", "980px");
			$("#footer").css("width", "955px");
			$("#mainnav-wrapper").hide();
			$("#flyers").hide();
			
			$(".big-img").hide();
			$(".desc").hide();
			
			var image_wrapper = $('<div id="gallery-image-wrapper"></div>').insertAfter(".ngg-galleryoverview");
			
			var default_image = $this.find(".ngg-thumbnail:first .big-img").clone().appendTo(image_wrapper);
			
			var default_desc = $this.find(".ngg-thumbnail:first .desc").clone().appendTo(image_wrapper);
			
			var image_height = default_image.height();
			
			var image_wrapper_height = image_height + 25;
	
			image_wrapper.css("height", image_wrapper_height);
			
			default_image.fadeIn("slow");
			default_desc.show();
			
			var thumb = $this.find(".ngg-thumbnail .thumb");
			
			thumb.click(function() {
				
				var $thumb = $(this);
				
				image_wrapper.find(".big-img").fadeOut("slow");
				image_wrapper.find(".desc").hide();
				
				var new_image = $thumb.parent().find(".big-img");
				var new_desc = $thumb.parent().find(".desc");
				
				var cloned_image = new_image.clone().appendTo(image_wrapper);
				var cloned_desc = new_desc.clone().appendTo(image_wrapper);
				
				var image_height = cloned_image.height();
				
				var image_wrapper_height = image_height + 25;
		
				image_wrapper.css("height", image_wrapper_height);
				
				cloned_image.fadeIn("slow");
				cloned_desc.show();
			});
		});
	}
}) (jQuery);

