$ = jQuery; // give the dolla' back to jay Q!

$('.gallery a[href$=".jpg"]').attr('rel','gallery');
// Enable Lighbox on all links to jpg files.
$('a[href$=".jpg"]').lightbox();


// View More comments functionality
var comments = $('#comments-list li');
var per_page = 5;

if (comments.length>per_page) {

	// Hide them all except the latest
	comments.slice(0, comments.length - per_page).hide().addClass('hidden');

	// Insert the "view more" link
	comments.parent().before('<a id="view-older" href="#">View older items ▼<span>Showing '+per_page+' of '+comments.length+'</span></a>');

	$('#view-older').click(function(){
		comments_hidden = $('#comments-list li.hidden');
		comments_hidden.slice( comments_hidden.length - per_page , comments_hidden.length ).slideDown('slow').removeClass('hidden');
		
		nr_hidden = $('#comments-list li.hidden').length;

		if (nr_hidden) {
			$(this).find('span').html('Showing '+ (comments.length-nr_hidden) +' of '+comments.length);
		} else {
			$(this).css('cursor','default').animate({opacity: 0},500).slideUp('slow');
		}

		return false;
	});
}
