﻿$(function() {
        var timer;
        var i = -1;
        var speed = 10000; //停留秒數
        var alpha = 0.7; //說明文底的透明度0~1
        var myItembox = $("#div1010 div");

        myItembox.mouseover(function() {
            for (i = 0; i < myItembox.length; i++) {
                myItembox.eq(i).css("opacity", 0.7);
            };
            var img = $(this).find("img");
            $(this).css("opacity", 1);
            var imgfile = img.attr("data");
            var imginfo = img.attr("rel");
            $('#aaa').attr('href', img.attr("title"));
            $("#showimg").attr("src", imgfile).stop();
            $("#showinfo").html(imginfo);
            i = myItembox.index($(this));

            //$("#div1010 ul li").removeClass("on"); //remove		
            //$(this).parent().addClass("on"); //add		

            return false;
        }).hover(function() {//滑入時停止輪播
            clearTimeout(timer);
        }, function() {
            timer = setTimeout(autoShow, speed);
        });

        //滑入時停止輪播
        $("#ShowBox").hover(function() {
            clearTimeout(timer);
        }, function() {
            timer = setTimeout(autoShow, speed);
        });

        //自動輪播函數
        function autoShow() {

            if (i + 1 < myItembox.length) {
                i++;
            } else {
                i = 0;
            }
            myItembox.eq(i).mouseover();
            myItembox.removeClass("on");
            myItembox.eq(i).parent().addClass("on");
            timer = setTimeout(autoShow, speed);
        }
        //啟動自動輪播
        autoShow();
});
