$(document).ready(function(){
	
	//set some variables
	efforts_listing = $(".efforts_listing ul li a");
	image_holder = $("div.images")
	
	$("div.efforts_listing ul li a").click(function(e){
		e.preventDefault();
		$(".efforts_listing ul li a.selected").removeClass()
		$(this).addClass('selected')
		$("div.images").html('')
		var href=$(this).attr("href")
		$.get(href, function(data){
		 	image_holder.html(data)
		
			// add carousel
			// create an array to store the id's of the inside carousel navigation
			var carousel_nav_id=[];

			$('div.carousel_nav a').each(function(){
				var control = $(this)
				// attach an on click event to each item in the carousel navigation to toggle the selected classes
				control.click(function(e){
					e.preventDefault();
					$('a.picture-selected').removeClass();
						control.addClass('picture-selected');
					})
					control_id = control.attr('id')
					// store the id of each span for use by the carousel plugin
					carousel_nav_id.push("#"+control_id);
				})// end each

				var myCarousel = $('div.carousel');
				// add a carousel
				if(carousel_nav_id.length > 1) {
					myCarousel.jCarouselLite({
				        btnGo: carousel_nav_id,
						visible: 1
					});
				} else {
					$('div.carousel_nav').hide(); 
				   
				} // end if
			
		
		
		
		 
		 /*	if($("div.details").text().length > 10) $('img.work').hoverIntent({
				sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
				interval: 100,   // number = milliseconds of polling interval
				over: function(){$(".details").slideDown('slow')},  // function = onMouseOver callback (required)
				timeout: 0,   // number = milliseconds delay before onMouseOut function call
				out: function(){$(".details").slideUp('slow')}    // function = onMouseOut callback (required)
		 	});	
		 	 */
		});
	});

	$("div.efforts_listing ul li a:first").click();

});
