$(document).ready(function(){
gallery();    
});

gallery = function() {
var current = 1;
var total = $('#photos b').length;
$('#photos b').hide();
$('#pic1').fadeIn('slow');
$('#number').html('1 of ' + total );
setHeight(1)

$('#first').click(function(){
var prev  = 1;
if (current != 1) {
$('#pic' + current).fadeOut('slow');
setHeight(prev)
$('#pic' + prev).fadeIn('slow');
current = 1;
$('#number').html(current + ' of ' + total)
}
return false;
});

$('#previous').click(function(){
var prev  = current - 1;
if (prev < 1) prev = 1;
if (current != 1) {
$('#pic' + current).fadeOut('slow');
$('#pic' + prev).fadeIn('slow');
current = prev;
setHeight(current)
$('#number').html(current + ' of ' + total)
}
return false;
});

$('#next').click(function(){
var next = current + 1;
if (next > total) next = total;
if (current != total) {
$('#pic' + current).fadeOut('slow');
$('#pic' + next).fadeIn('slow');
current = next;
setHeight(current)
$('#number').html(current + ' of ' + total)
}
return false;
});

$('#last').click(function(){
var next  = total;
if (current != total) {
$('#pic' + current).fadeOut('slow');
$('#pic' + next).fadeIn('slow');
current = total;
setHeight(current)
$('#number').html(current + ' of ' + total)
}
return false;
});

function setHeight(current) {}}
