$(document).ready(function(){
   // hide accordions if there's more then one post visible
   var lis = $(".event-list").children("li");
   if (lis.length > 1) {
       lis.find(".accordion").hide();
   }
   else {
       lis.find(".morelink").hide();
   }
   
   // expand posts
   $(".event-list .morelink, .show-arrow").click(function(e){
       $(".event-list .accordion").hide();
       $(".morelink").show();
       
       var post = $(this).closest("li");
       post.find(".morelink").hide();
       post.find(".accordion").show(); 
       
       e.preventDefault();
   });
   
   	// video gallery
	$(".event-list img").click(function(){

		var segImg = $(this).attr('src').split('_');
		var segImg2 = segImg[1].split('/');
		var fExt = segImg[2].split('.');
		var imgName = segImg[0] + "_images/" + segImg2[1] + "." + fExt[1];
		
		var imgAlt = $(this).attr('alt');
		if (imgAlt != '') {
			var imgCaption = '<div class="event-caption"><strong>In the picture:</strong> ' + $(this).attr('alt') + '</div>';
		} else {
			var imgCaption = '';
		}
		if (imgCaption != ''){
			
		}
		$(".img-zoom p").html('<img src="' + imgName  + '" />' + imgCaption);
		$(".img-zoom").show();
		imgCaption.show();
		return false;
	});
	$(".img-zoom .close").click(function(){
			var closePara = $(this);
			var videoDiv = $(this).parent().parent();
			videoDiv.hide();
	});
	
});