var slideShow = function() {
    var bxs, bxe, fxs, fxe, yStart, yEnd, thumbList, imageDiv, ie, st, ss, ft, fs, xp, yp, ci, t, thumbValuesArray, thumbnailCount;
    thumbList = document.getElementById(thumbid);
    imageDiv = document.getElementById(imgid);
    thumbListItems = thumbList.getElementsByTagName('li');
    ie = document.all ? true : false;
    st = 3; ss = 3; ft = 10; fs = 5; xp, yp = 0;
    return {
        init: function() {
            document.onmousemove = this.pos;
            window.onresize = function() {
                setTimeout("slideShow.lim()", 500)
            };
            yStart = this.toppos(thumbList);
            yEnd = yStart + thumbList.offsetHeight;
            len = thumbListItems.length;
            thumbValuesArray = [];

            for (i = 0; i < len; i++) {
                var id = thumbListItems[i].value;
                thumbValuesArray[i] = id;
                thumbListItems[i].onclick = new Function("slideShow.getimg('" + id + "')");
                if (i == 0) {
                    this.getimg(id)
                }
            }
            thumbnailCount = thumbValuesArray.length;
        },

        scroll: function(direction) {
            clearInterval(thumbList.timer);

            var l;
            if (direction == -1)
                l = 0;
            else
                l = (thumbListItems[thumbnailCount - 1].offsetLeft - (thumbList.parentNode.offsetWidth - thumbListItems[thumbnailCount - 1].offsetWidth) + 10)

            thumbList.timer = setInterval(function() { slideShow.mv(direction, l) }, st);

        },

        mv: function(d, l) {
            thumbList.style.left = thumbList.style.left || '0px';
            var left = thumbList.style.left.replace('px', '');
            if (d == 1) {
                if (l - Math.abs(left) <= ss) {
                    this.cncl(thumbList.id);
                    //thumbList.style.left='-'+l+'px';
                } else { thumbList.style.left = left - ss + 'px' }
            } else {
                if (Math.abs(left) - l <= ss) {
                    this.cncl(thumbList.id);
                    thumbList.style.left = l + 'px';
                } else {
                    thumbList.style.left = parseInt(left) + ss + 'px'
                }
            }
        },

        cncl: function() { clearTimeout(thumbList.timer) },

        getimg: function(id) {



            var text;

            if (id == 1) { text = caption1; }
            if (id == 2) { text = caption2; }
            if (id == 3) { text = caption3; }
            if (id == 4) { text = caption4; }
            if (id == 5) { text = caption5; }
            if (id == 6) { text = caption6; }
            if (id == 7) { text = caption7; }
            if (id == 8) { text = caption8; }
            if (id == 9) { text = caption9; }
            if (id == 10) { text = caption10; }
            if (id == 11) { text = caption11; }
            if (id == 12) { text = caption12; }
            if (id == 13) { text = caption13; }
            if (id == 14) { text = caption14; }
            if (id == 15) { text = caption15; }
            if (id == 16) { text = caption16; }
            if (id == 17) { text = caption17; }
            if (id == 18) { text = caption18; }
            if (id == 19) { text = caption19; }
            if (id == 20) { text = caption20; }

            var textControl;
            textControl = document.getElementById('photoText');

            if (textControl.innerText) {
                textControl.innerText = text;
            }
            else {
                document.getElementById('photoText').textContent = text;
            }

            if (auto) { clearTimeout(imageDiv.timer) }
            if (ci != null) {
                var ts, tsl, x;
                ts = imageDiv.getElementsByTagName('img'); tsl = ts.length; x = 0;
                for (x; x < tsl; x++) {
                    if (ci.id != id) { var o = ts[x]; clearInterval(o.timer); o.timer = setInterval(function() { slideShow.fdout(o) }, fs) }
                }
            }

            if (!document.getElementById(id)) {
                var i = document.createElement('img');
                imageDiv.appendChild(i);
                i.id = id; i.av = 0; i.style.opacity = 0;
                i.style.filter = 'alpha(opacity=0)';
                var realDir = imgdir.replace("a**b!!!@@#", "http://");
                var readDir2 = realDir.replace("dotcom", ".com");
                i.src = imgdir + '/' + id + imgext + imgsuffix;
            } else {
                i = document.getElementById(id); clearInterval(i.timer);
            }
            i.timer = setInterval(function() { slideShow.fdin(i) }, fs);
        },

        nav: function(d) {
            var c = 0;
            for (key in thumbValuesArray) { if (thumbValuesArray[key] == ci.id) { c = key } }
            if (thumbValuesArray[parseInt(c) + d]) {
                this.getimg(thumbValuesArray[parseInt(c) + d]);
            } else {
                if (d == 1) {
                    this.getimg(thumbValuesArray[0]);
                } else { this.getimg(thumbValuesArray[thumbnailCount - 1]) }
            }
        },

        auto: function() { imageDiv.timer = setInterval(function() { slideShow.nav(1) }, autodelay * 1000) },
        fdin: function(i) {
            if (i.complete) { i.av = i.av + fs; i.style.opacity = i.av / 100; i.style.filter = 'alpha(opacity=' + i.av + ')' }
            if (i.av >= 100) { if (auto) { this.auto() }; clearInterval(i.timer); ci = i }
        },

        fdout: function(i) {
            i.av = i.av - fs; i.style.opacity = i.av / 100;
            i.style.filter = 'alpha(opacity=' + i.av + ')';
            if (i.av <= 0) { clearInterval(i.timer); if (i.parentNode) { i.parentNode.removeChild(i) } }
        },

        lim: function() {
            var taw, taa, len; taw = thumbList.parentNode.offsetWidth; taa = taw / 4;
            bxs = slideShow.leftpos(thumbList); bxe = bxs + taa; fxe = bxs + taw; fxs = fxe - taa;
        },

        pos: function(e) {
            xp = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
            yp = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
            if (xp > bxs && xp < bxe && yp > yStart && yp < yEnd) {
                slideShow.scroll(-1);
            } else if (xp > fxs && xp < fxe && yp > yStart && yp < yEnd) {
                slideShow.scroll(1);
            } else { slideShow.cncl() }
        },

        leftpos: function(t) {
            var l = 0;
            if (t.offsetParent) {
                while (1) { l += t.offsetLeft; if (!t.offsetParent) { break }; t = t.offsetParent }
            } else if (t.x) { l += t.x }
            return l;
        },

        toppos: function(t) {
            var p = 0;
            if (t.offsetParent) {
                while (1) { p += t.offsetTop; if (!t.offsetParent) { break }; t = t.offsetParent }
            } else if (t.y) { p += t.y }
            return p;
        }
    };
} ();

window.onload=function(){slideShow.init(); slideShow.lim()};