自己写的轮播图,为什么点上一页的按钮就能点一下,还不报错。求大神简答

// JavaScript Document
$(document).ready(function() {

//执行幻灯片
slideShow();

});

function slideShow() {

//将所有图像的value设置为0
$('#gallery a').val("0");

//获取第一个图像并显示它
$('#gallery a:first').val("1");

//设置标题背景半透明
$('#gallery .caption').css({opacity: 0.0});

//调整文字宽度根据图像宽度
$('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});

//从rel属性获得第一个图像字幕显示
$('#gallery .content').html($('#gallery a:first').find('img').attr('rel'));
$('#gallery .caption').animate({height: '500px',opacity: 0.0},100).animate({height: '500px',opacity: 0.7},1000);
$('#gallery .caption .tit img').animate({left: '-900px'},100).animate({left: '0px'},1000);

//运行幻灯片,6秒
//timer=setInterval('gallery()',4000);
//首页点击
$('#first_page').click(function(){
    gallery();  
});

}

function gallery() {
$('#gallery .content').html("");
//判断第一张图片
var current = ($('#gallery a.show')? $('#gallery a.show') : $('#gallery a:first'));

//获取下一个图像,如果它达到的幻灯片结束,旋转它回到第一图像
var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));

//获取下一个图像标题
var caption = next.find('img').attr('rel');

//设置下一个图像的淡入效果
next.addClass('show')
.animate({value: 1}, 1000);

//隐藏当前图像
current.animate({value: 0}, 1000)
.removeClass('show');

//加入动画
animation()

//显示的内容
$('#gallery .content').html(caption);

//点击右键
$('.right').click(function(){
    //clearInterval(timer);
    gallery();
    //timer=setInterval('gallery()',4000);
});

//点击左键
$('.left').click(function(){
    $('#gallery .content').html("");
    //clearInterval(timer);
    //判断当前图片
    var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:lest'));

    //获取上一个图像,如果它达到的幻灯片第一个,旋转它回到最后一个
    var prev = ((current.prev().length) ? ((current.prev().hasClass('caption'))? $('#gallery a:lest') :current.prev()) : $('#gallery a:lest')); 

    //获取上一个图像标题
    var caption = prev.find('img').attr('rel');

    //设置上一个图像的淡入效果
    prev.addClass('show')
    .animate({value: 1}, 1000);

    //隐藏当前图像
    current.animate({value: 0}, 1000)
    .removeClass('show');

    //加入动画
    animation()

    //显示的内容
    $('#gallery .content').html(caption);
    //timer=setInterval('gallery()',4000);
});

//末页点击
$('#last_page').click(function(){
    window.location.reload();   
});

}

function animation(){

if($('a:nth-child(1)').val()==1||$('a:nth-child(5)').val()==1||$('a:nth-child(9)').val()==1||$('a:nth-child(13)').val()==1){

    $('#gallery .caption')
    .animate({height: '500px',opacity: 0.0},100)
    .animate({height: '500px',opacity: 0.7},1000);

}else{

    $('#gallery .caption')
    .animate({height: '75px',opacity: 0.0},100 )
    .animate({height: '75px',opacity: 0.7},1000);

}   

}

HTML页面的代码能否也贴上?我可以调调看