幻灯片切换JS

        <script>
                var arr =   new Array();
                <!--{eval $i=0;}-->
                <!--{loop $slideshow $value}-->
                        <!--{eval $article_url = fetch_article_url($value);}-->
                        arr[$i]  =   new Array('/data/attachment/$value[pic]','$value[title]','$value[summary]','$value[ymd]','$value[from]','$article_url');
                        <!--{eval $i++;}-->
                <!--{/loop}-->      
 
                change_current(0);
                var num     =   arr.length-1;
                var timer   =   setInterval("clock()",3000);
 
                $("#focus").mouseover(function (){clearInterval(timer);});
                $("#focus").mouseout(function (){timer=setInterval("clock()",3000);});
 
                $("#rightarrow_btn").click(function (){clearInterval(timer);clock();return false;});
                $("#leftarrow_btn").click(function (){clearInterval(timer);backstep();return false;});
                function clock()
                {
                    var current_id  =   parseInt($("#current_id").val());
                    var next_id     =   current_id>=num ? 0 : current_id+1;
                    change_current(next_id);
                }
                function backstep()
                {
                    var current_id  =   parseInt($("#current_id").val());
                    var next_id     =   current_id==0 ? num : current_id-1;
                    change_current(next_id);
                }
                function change_current(id)
                {
                    small_img_change(id);
                    large_img_change(id);
                    $("#current_id").val(id);
                }
 
                function small_img_change(i)
                {
                    for(var y=0;y<=num;y++)
                    {
                       if(i==y)
                       {
                        $('#slideshow_small_'+y).removeClass().addClass("active");
                       }
                       else
                       {
                        $('#slideshow_small_'+y).removeClass();
                       }
                    }
                }
                function large_img_change(i)
                {
                    $('#slideshow_large_img').attr('src',arr[i][0]);
                    $("#slideshow_title").html(arr[i][1]);
                    $("#slideshow_summary").html(arr[i][2]);
                    $("#slideshow_publishtime").html(arr[i][3]);
                    $("#slideshow_source").html(arr[i][4]);
                    //link
 
                }
                function clear_and_change(id)
                {
                   clearInterval(timer);
                   change_current(id); 
                   return false;
                }
 
            </script>

Related posts: