/* Joint Medias - J Gallery */

//declare variables
var tpanels, id, num, thumbs, num_pages;

//when document is ready
$(document).ready(function() {	
	
	//get number of albums
	num_pages = $('.panels-content').size();
	
	//if only one page of galleries, then hide controls
	if (num_pages == 1) { $('.album-ctrl').hide(); }
	
   //each time a album is clicked
   $('.albums li').click(function() {
	
	  //get id of each album
      id = $(this).attr('id');	  
	  //strip first character of album id
      num = id.substr(1);	  
	  //set id of thumbnail div
      thumbs = '#t' + num; 
	  //set panels id
	  tpanels = 'tpp' + num; 
	  
	  //hide album list
      $('.albums').fadeOut(400); 
	  
	  //show the thumbnail holder 
	  $('.thumb-holder').fadeIn(400);
	  //fade in thumbnails
      $(thumbs).fadeIn(400); 
 

	$(".thumbs a").fancybox({overlayColor: '#000', overlayOpacity: 0.7});

	  //return false link	  
	  return false; 
	  
	  
	}); //end albums li click
	
			   
});	 //end doc ready


//function to reset gallery - hides thumbnails and shows albums
function jReset() {

   //show albums
   $('.albums').fadeIn(400);
   
   //hide thumbnails
   $(thumbs).fadeOut(400);   
   $('.thumb-holder').fadeOut(400);
   
   //return false link
   return false;
   
}

