jQuery(document).ready(function(){
	//Set up the Carousel (jQuery jcarousel)

	jQuery('#slider-list').jcarousel({
		vertical: true,
		scroll: 1
	});

	// Additional functionality to the carousel - click to load new primary image
	var primaryImg = jQuery("#primary-image img");
	primaryImg.queue();
	jQuery("ul#slider-list li img").click(function(){
		
		var path = jQuery(this).attr("src");
		var parent = jQuery(this).attr("class").split(" ")[0];
		var fullimage = jQuery("span#image-"+parent).html()
		jQuery("#primary-image a").attr({ href: jQuery("span#url-"+parent).html() });
		jQuery("#primary-image a").attr({ title: jQuery("span#title-"+parent).html() });
		jQuery("#p-image").attr({ alt: jQuery("span#title-"+parent).html() });
		primaryImg.fadeOut("slow");
		primaryImg.queue(function() { primaryImg.attr({src: ""}); primaryImg.attr({ src: fullimage }); primaryImg.dequeue(); });
		primaryImg.fadeIn("slow");
		return false;
	});

	// Load initial image into primary image slot

	var initialpath = jQuery("ul#slider-list li img:first").attr("src");
	var initialparent = jQuery("ul#slider-list li img:first").attr("class").split(" ")[0];
	var initialfullimage = jQuery("span#image-"+initialparent).html()
	primaryImg.attr({ src: initialfullimage });
	jQuery("#primary-image a").attr({ href: jQuery("span#url-"+initialparent).html() });
	jQuery("#primary-image a").attr({ title: jQuery("span#title-"+initialparent).html() });
	jQuery("#p-image").attr({ alt: jQuery("span#title-"+initialparent).html() });
	jQuery("#nav li").hover(
		function() {
			jQuery("ul:hidden", this).slideDown(300);
		},
		function() {
			jQuery("ul", this).slideUp(100);
		}
	    );
	// Add Thickbox class to gallery
	
	jQuery("div.ngg-galleryoverview a, div.ngg-gallery-thumbnail a").addClass("thickbox");
	
	new MultiBox('thickbox', {
	});
	
	// Add last-column class to columns
	jQuery(".post-column:last").addClass ("post-column-last");
	jQuery('#past-work img').each(function() {
		jQuery(this).after(jQuery("<span class='caption' style='display:none'>"+jQuery(this).attr('alt')+"</span>"));
		
		jQuery(this).parent().mouseover(function() { 
			jQuery(this).find('.caption').stop().slideDown('fast'); 
		}); 
		jQuery(this).parent().mouseout(function() { 
			jQuery(this).find('.caption').stop().css('height', 'auto').slideUp('fast');
		}); 
	});
		jQuery('#primary-image a img').each(function() {
		jQuery(this).after(jQuery("<span class='caption caption-featured' style='display:none'>Click here to read more</span>"));
		
		jQuery(this).parent().mouseover(function() { 
			jQuery(this).find('.caption-featured').stop().slideDown('fast'); 
		}); 
		jQuery(this).parent().mouseout(function() { 
			jQuery(this).find('.caption-featured').stop().css('height', 'auto').slideUp('fast');
		}); 
	});
	
});

