(function ()
{
    window.TZoo = 
    {
        version : '1.12', browser : 
        {
            ie :!!(window.attachEvent && !window.opera), ie6 :!!(window.attachEvent && !window.XMLHttpRequest), 
            ie7 :!!(window.ActiveXObject && window.XMLHttpRequest), opera :!!window.opera, webkit : navigator.userAgent.indexOf('AppleWebKit/') > -1, 
            gecko : navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') ==- 1, 
            mobilesafari :!!navigator.userAgent.match(/Apple.*Mobile.*Safari/), backCompatMode : document.compatMode && 'backcompat' == document.compatMode.toLowerCase(), 
            domLoaded : false
        },
        $ : function (el)
        {
            if (!el) {
                return null;
            }
            if ("string" == typeof el) {
                el = document.getElementById(el)
            }
            return el;
        },
        $A : function (arr)
        {
            if (!arr) {
                return [];
            }
            if (arr.toArray) {
                return arr.toArray()
            }
            var length = arr.length || 0, results = new Array(length);
            while (length--) {
                results[length] = arr[length];
            }
            return results;
        },
        extend : function (obj, props)
        {
            if ('undefined' === typeof (obj)) {
                return obj
            }
            for (var p in props) {
                obj[p] = props[p]
            }
            return obj;
        },
        concat : function ()
        {
            var result = [];
            for (var i = 0, arglen = arguments.length; i < arglen; i++) {
                for (var j = 0, arrlen = arguments[i].length; j < arrlen; j++) {
                    result.push(arguments[i][j])
                }
            }
            return result;
        },
        bind : function ()
        {
            var args = TZoo.$A(arguments), __method = args.shift(), object = args.shift();
            return function ()
            {
                return __method.apply(object, TZoo.concat(args, TZoo.$A(arguments)));
            }
        },
        bindAsEvent : function ()
        {
            var args = TZoo.$A(arguments), __method = args.shift(), object = args.shift();
            return function (event)
            {
                return __method.apply(object, TZoo.concat([event || window.event], args));
            }
        },
        inArray : function (val, arr)
        {
            var len = arr.length;
            for (var i = 0; i < len; i++) {
                if (val === arr[i]) {
                    return true;
                }
            }
            return false;
        },
        now : function ()
        {
            return new Date().getTime();
        },
        isBody : function (el)
        {
            return (/^(?:body|html)$/i).test(el.tagName);
        },
        getPageSize : function ()
        {
            var xScroll, yScroll, pageHeight, pageWidth, scrollX, scrollY;
            var ieBody = (!TZoo.browser.backCompatMode) ? document.documentElement : document.body;
            var body = document.body;
            xScroll = (window.innerWidth && window.scrollMaxX) ? window.innerWidth + window.scrollMaxX : (body.scrollWidth > body.offsetWidth) ? body.scrollWidth : (TZoo.browser.ie && TZoo.browser.backCompatMode) ? body.scrollWidth : body.offsetWidth;
            yScroll = (window.innerHeight && window.scrollMaxY) ? window.innerHeight + window.scrollMaxY : (body.scrollHeight > body.offsetHeight) ? body.scrollHeight : body.offsetHeight;
            var windowWidth, windowHeight;
            windowWidth = TZoo.browser.ie ? ieBody.scrollWidth : (document.documentElement.clientWidth || self.innerWidth), 
            windowHeight = TZoo.browser.ie ? ieBody.clientHeight : (document.documentElement.clientHeight || self.innerHeight);
            scrollX = (self.pageXOffset) ? self.pageXOffset : ieBody.scrollLeft;
            scrollY = (self.pageYOffset) ? self.pageYOffset : ieBody.scrollTop;
            if (yScroll < windowHeight) {
                pageHeight = windowHeight
            }
            else {
                pageHeight = yScroll
            }
            if (xScroll < windowWidth) {
                pageWidth = windowWidth
            }
            else {
                pageWidth = xScroll
            }
            return {
                pageWidth : pageWidth, pageHeight : pageHeight, width : TZoo.browser.ie ? ieBody.clientWidth : (document.documentElement.clientWidth || self.innerWidth), 
                height : TZoo.browser.ie ? ieBody.clientHeight : (TZoo.browser.opera) ? self.innerHeight : (self.innerHeight || document.documentElement.clientHeight), 
                scrollX : scrollX, scrollY : scrollY, viewWidth : xScroll, viewHeight : yScroll
            }
        },
        Event : 
        {
            add : function (el, event, handler)
            {
                if (el === document && 'domready' == event)
                {
                    if (TZoo.browser.domLoaded) {
                        handler.call(this);
                        return
                    }
                    TZoo.onDomReadyList.push(handler);
                    if (TZoo.onDomReadyList.length <= 1) {
                        TZoo.bindDomReady()
                    }
                }
                el = TZoo.$(el);
                if (el.addEventListener) {
                    el.addEventListener(event, handler, false)
                }
                else {
                    el.attachEvent("on" + event, handler)
                }
            },
            remove : function (el, event, handler)
            {
                el = TZoo.$(el);
                if (el.removeEventListener) {
                    el.removeEventListener(event, handler, false)
                }
                else {
                    el.detachEvent("on" + event, handler)
                }
            },
            stop : function (event)
            {
                if (event.stopPropagation) {
                    event.stopPropagation()
                }
                else {
                    event.cancelBubble = true
                }
                if (event.preventDefault) {
                    event.preventDefault()
                }
                else {
                    event.returnValue = false;
                }
            },
            fire : function (el, evType, evName)
            {
                el = TZoo.$(el);
                if (el == document && document.createEvent && !el.dispatchEvent) {
                    el = document.documentElement;
                }
                var event;
                if (document.createEvent) {
                    event = document.createEvent(evType);
                    event.initEvent(evName, true, true)
                }
                else {
                    event = document.createEventObject();
                    event.eventType = evType
                }
                if (document.createEvent) {
                    el.dispatchEvent(event)
                }
                else {
                    el.fireEvent('on' + evName, event)
                }
                return event;
            }
        },
        String : 
        {
            trim : function (s)
            {
                return s.replace(/^\s+|\s+$/g, '');
            },
            camelize : function (s)
            {
                return s.replace(/-(\D)/g, function (m1, m2)
                {
                    return m2.toUpperCase();
                })
            }
        },
        Element : 
        {
            hasClass : function (el, klass)
            {
                if (!(el = TZoo.$(el))) {
                    return
                }
                return ((' ' + el.className + ' ').indexOf(' ' + klass + ' ') > -1);
            },
            addClass : function (el, klass)
            {
                if (!(el = TZoo.$(el))) {
                    return
                }
                if (!TZoo.Element.hasClass(el, klass)) {
                    el.className += (el.className ? ' ' : '') + klass
                }
            },
            removeClass : function (el, klass)
            {
                if (!(el = TZoo.$(el))) {
                    return
                }
                el.className = TZoo.String.trim(el.className.replace(new RegExp('(^|\\s)' + klass + '(?:\\s|$)'), 
                '$1'));
            },
            getStyle : function (el, style)
            {
                el = TZoo.$(el);
                style = style == 'float' ? 'cssFloat' : TZoo.String.camelize(style);
                var val = el.style[style];
                if (!val && document.defaultView) {
                    var css = document.defaultView.getComputedStyle(el, null);
                    val = css ? css[style] : null
                }
                else if (!val && el.currentStyle) {
                    val = el.currentStyle[style]
                }
                if ('opacity' == style) {
                    return val ? parseFloat(val) : 1.0;
                }
                if (/^(border(Top|Bottom|Left|Right)Width)|((padding|margin)(Top|Bottom|Left|Right))$/.test(style)) {
                    val = parseInt(val) ? val : '0px'
                }
                return val == 'auto' ? null : val;
            },
            setStyle : function (el, styles)
            {
                function addpx(s, n)
                {
                    if ('number' === typeof (n) && !('zIndex' === s || 'zoom' === s)) {
                        return 'px'
                    }
                    return ''
                }
                el = TZoo.$(el);
                var elStyle = el.style;
                for (var s in styles)
                {
                    try
                    {
                        if ('opacity' === s) {
                            TZoo.Element.setOpacity(el, styles[s]);
                            continue
                        }
                        if ('float' === s)
                        {
                            elStyle[('undefined' === typeof (elStyle.styleFloat)) ? 'cssFloat' : 'styleFloat'] = styles[s];
                            continue
                        }
                        elStyle[TZoo.String.camelize(s)] = styles[s] + addpx(TZoo.String.camelize(s), 
                        styles[s])
                    }
                    catch (e) {}
                }
                return el;
            },
            setOpacity : function (el, opacity)
            {
                el = TZoo.$(el);
                var elStyle = el.style;
                opacity = parseFloat(opacity);
                if (opacity == 0) {
                    if ('hidden' != elStyle.visibility) {
                        elStyle.visibility = 'hidden';
                    }
                }
                else
                {
                    if (opacity > 1) {
                        opacity = parseFloat(opacity / 100)
                    }
                    if ('visible' != elStyle.visibility) {
                        elStyle.visibility = 'visible';
                    }
                }
                if (!el.currentStyle || !el.currentStyle.hasLayout) {
                    elStyle.zoom = 1
                }
                if (TZoo.browser.ie) {
                    elStyle.filter = (opacity == 1) ? '' : 'alpha(opacity=' + opacity * 100 + ')'
                }
                elStyle.opacity = opacity;
                return el;
            },
            getSize : function (el)
            {
                el = TZoo.$(el);
                return {
                    'width' : el.offsetWidth, 'height' : el.offsetHeight
                }
            },
            getScrolls : function (el)
            {
                el = TZoo.$(el);
                var p = {
                    x : 0, y : 0
                };
                while (el && !TZoo.isBody(el)) {
                    p.x += el.scrollLeft;
                    p.y += el.scrollTop;
                    el = el.parentNode
                }
                return p;
            },
            getPosition : function (el, relative)
            {
                relative = relative || false;
                el = TZoo.$(el);
                var s = TZoo.Element.getScrolls(el);
                var l = 0, t = 0;
                do
                {
                    l += el.offsetLeft || 0;
                    t += el.offsetTop || 0;
                    el = el.offsetParent;
                    if (relative) {
                        while (el && 'relative' == el.style.position) {
                            el = el.offsetParent;
                        }
                    }
                }
                while (el);
                return {
                    'top' : t - s.y, 'left' : l - s.x
                }
            },
            getRect : function (el, relative)
            {
                var p = TZoo.Element.getPosition(el, relative);
                var s = TZoo.Element.getSize(el);
                return {
                    'top' : p.top, 'bottom' : p.top + s.height, 'left' : p.left, 'right' : p.left + s.width
                }
            },
            update : function (el, c)
            {
                el = TZoo.$(el);
                if (el) {
                    el.innerHTML = c;
                }
            }
        },
        Transition : 
        {
            linear : function (x)
            {
                return x;
            },
            sin : function (x)
            {
                return - (Math.cos(Math.PI * x) - 1) / 2;
            },
            quadIn : function (p)
            {
                return Math.pow(p, 2);
            },
            quadOut : function (p)
            {
                return 1 - TZoo.Transition.quadIn(1 - p);
            },
            cubicIn : function (p)
            {
                return Math.pow(p, 3);
            },
            cubicOut : function (p)
            {
                return 1 - TZoo.Transition.cubicIn(1 - p);
            },
            backIn : function (p, x)
            {
                x = x || 1.618;
                return Math.pow(p, 2) * ((x + 1) * p - x);
            },
            backOut : function (p, x)
            {
                return 1 - TZoo.Transition.backIn(1 - p);
            },
            elastic : function (p, x)
            {
                x = x || [];
                return Math.pow(2, 10 *--p) * Math.cos(20 * p * Math.PI * (x[0] || 1) / 3);
            },
            none : function (x)
            {
                return 0;
            }
        },
        onDomReadyList : [], onDomReadyTimer : null,
        onDomReady : function ()
        {
            if (TZoo.browser.domLoaded) {
                return
            }
            TZoo.browser.domLoaded = true;
            if (TZoo.onDomReadyTimer) {
                clearTimeout(TZoo.onDomReadyTimer)
            }
            for (var i = 0, l = TZoo.onDomReadyList.length; i < l; i++) {
                TZoo.onDomReadyList[i].apply(document)
            }
        },
        bindDomReady : function ()
        {
            if (TZoo.browser.webkit)
            {
                (function ()
                {
                    if (TZoo.inArray(document.readyState, ['loaded', 'complete'])) {
                        TZoo.onDomReady();
                        return
                    }
                    TZoo.onDomReadyTimer = setTimeout(arguments.callee, 50);
                    return
                })()
            }
            if (TZoo.browser.ie && window == top)
            {
                (function ()
                {
                    try {
                        document.documentElement.doScroll("left")
                    }
                    catch (e) {
                        TZoo.onDomReadyTimer = setTimeout(arguments.callee, 50);
                        return
                    }
                    TZoo.onDomReady()
                })()
            }
            if (TZoo.browser.opera)
            {
                TZoo.Event.add(document, 'DOMContentLoaded', function ()
                {
                    for (var i = 0, l = document.styleSheets.length; i < l; i++)
                    {
                        if (document.styleSheets[i].disabled) {
                            TZoo.onDomReadyTimer = setTimeout(arguments.callee, 50);
                            return
                        }
                        TZoo.onDomReady()
                    }
                })
            }
            TZoo.Event.add(document, 'DOMContentLoaded', TZoo.onDomReady);
            TZoo.Event.add(window, 'load', TZoo.onDomReady)
        }
    };
    TZoo.Render = function ()
    {
        this.init.apply(this, arguments)
    };
    TZoo.Render.prototype = 
    {
        defaults : 
        {
            fps : 50, duraton : 0.5, transition : TZoo.Transition.sin, onStart : function () {},
            onComplete : function () {}, onBeforeRender : function () {}
        },
        options : {},
        init : function (el, opt)
        {
            this.el = el;
            this.options = TZoo.extend(TZoo.extend({}, this.defaults), opt);
            this.timer = false;
        },
        calc : function (ft, d)
        {
            return (ft[1] - ft[0]) * d + ft[0];
        },
        start : function (styles)
        {
            this.styles = styles;
            this.state = 0;
            this.curFrame = 0;
            this.startTime = TZoo.now();
            this.finishTime = this.startTime + this.options.duration * 1000;
            this.timer = setInterval(TZoo.bind(this.loop, this), Math.round(1000 / this.options.fps));
            this.options.onStart()
        },
        loop : function ()
        {
            var now = TZoo.now();
            if (now >= this.finishTime)
            {
                if (this.timer) {
                    clearInterval(this.timer);
                    this.timer = false
                }
                this.render(1.0);
                setTimeout(this.options.onComplete, 10);
                this.options.onComplete = function () {};
                return this
            }
            var dx = this.options.transition((now - this.startTime) / (this.options.duration * 1000));
            this.render(dx)
        },
        render : function (dx)
        {
            var to_css = {};
            for (var s in this.styles)
            {
                if ('opacity' === s) {
                    to_css[s] = Math.round(this.calc(this.styles[s], dx) * 100) / 100
                }
                else {
                    to_css[s] = Math.round(this.calc(this.styles[s], dx));
                }
            }
            this.options.onBeforeRender(to_css);
            TZoo.Element.setStyle(this.el, to_css)
        }
    };
    if (!Array.prototype.indexOf)
    {
        TZoo.extend(Array.prototype, 
        {
            'indexOf' : function (item, from)
            {
                var len = this.length;
                for (var i = (from < 0) ? Math.max(0, len + from) : from || 0; i < len; i++) {
                    if (this [i] === item) {
                        return i;
                    }
                }
                return - 1;
            }
        })
    }
})();


var ZooT = 
{
    version : '1.4', thumbs : [], activeIndexes : [], zIndex : 1001, bgFader : false, defaults : 
    {
        transition : TZoo.Transition.quadIn, zIndex : 1001, duration : 0.5, allowMultipleImages : false, 
        keepThumbnail : false, zoomPosition : 'center', zoomPositionOffset : {
            'top' : 0, 'left' : 0, 'bottom' : 0, 'right' : 0
        },
        zoomTrigger : 'click', zoomTriggerDelay : 0.5, backgroundFadingOpacity : 0.8, backgroundFadingColor : '#000000', 
        backgroundFadingDuration : 0.2, allowKeyboard : false, useCtrlKey : false, captionSlideDuration : 0.250, 
        captionSrc : 'img:alt', controlbarEnable : true, controlbarPosition : 'top right', controlbarButtons : ['prev','close','next'], 
        disableContextMenu : true, loadingMsg : 'Loading...', loadingOpacity : 0.75
    },
    options : {}, cbButtons : 
    {
        'prev' : {
            index : 0, title : 'Previous'
        },
        'next' : {
            index : 1, title : 'Next'
        },
        'close' : {
            index : 2, title : 'Close'
        }
    },
    init : function (refresh)
    {
        refresh = refresh || false;
        this.options = TZoo.extend(this.defaults, this.options);
        var matches = /(auto|center|absolute|relative)/i.exec(this.options.zoomPosition);
        switch (matches[1])
        {
            case 'auto':
                this.options.zoomPosition = 'auto';
                break;
            case 'absolute':
                this.options.zoomPosition = 'absolute';
                break;
            case 'relative':
                this.options.zoomPosition = 'relative';
                break;
            case 'center':
            default:
                this.options.zoomPosition = 'center';
                break
        }
        this.options.zoomTrigger = /mouseover/i.test(this.options.zoomTrigger) ? 'mouseover' : 'click';
        this.zIndex = this.options.zIndex;
        var as = document.getElementsByTagName("a");
        var l = as.length;
        var thumbIndex = 0;
        for (var i = 0; i < l; i++)
        {
            if (TZoo.Element.hasClass(as[i], 'ZooT'))
            {
                ZooT.thumbs.push(new ZooT.Item(as[i], thumbIndex++, 
                {
                    expandDuration : (this.options.zoomDuration || this.options.duration), collapseDuration : (this.options.restoreDuration || this.options.duration), 
                    captionSlideDuration : this.options.captionSlideDuration, captionSrc : this.options.captionSrc, 
                    transition : this.options.transition, keepThumbnail : this.options.keepThumbnail, 
                    zoomTrigger : this.options.zoomTrigger, zoomTriggerDelay : this.options.zoomTriggerDelay, 
                    zoomPosition : this.options.zoomPosition, zoomPositionOffset : this.options.zoomPositionOffset
                }))
            }
        }
        if (!refresh && ZooT.options.disableContextMenu)
        {
            TZoo.Event.add(document, 'contextmenu', function (e)
            {
                var t = ZooT.getFocused();
                if (t != null && undefined != t)
                {
                    var r = TZoo.Element.getRect(t.bigImg);
                    if ((e.clientX >= r.left && e.clientX <= r.right) && (e.clientY >= r.top && e.clientY <= r.bottom)) {
                        TZoo.Event.stop(e);
                        return false;
                    }
                }
            })
        }
    },
    refresh : function ()
    {
        for (var t = ZooT.thumbs.pop(); t != null && undefined != t; t = ZooT.thumbs.pop()) {
            t.destroy();
            delete t
        };
        ZooT.thumbs = [];
        ZooT.activeIndexes = [];
        setTimeout(function ()
        {
            ZooT.init(true)
        }, 10);
        return
    },
    expand : function (e, idx)
    {
        if (e) {
            TZoo.Event.stop(e)
        }
        var t = ZooT.getFocused();
        if (!ZooT.options.allowMultipleImages && undefined != t && idx != t.index) {
            ZooT.getFocused().collapse(null, ZooT.thumbs[idx], true)
        }
        else {
            ZooT.thumbs[idx].expand(this.zIndex)
        }
    },
    setFocused : function (idx)
    {
        var pos = this.activeIndexes.indexOf(idx);
        if (-1 !== pos) {
            this.activeIndexes.splice(pos, 1)
        }
        this.activeIndexes.push(idx)
    },
    getFocused : function ()
    {
        return (this.activeIndexes.length > 0) ? this.thumbs[this.activeIndexes[this.activeIndexes.length - 1]] : undefined;
    },
    unsetFocused : function (idx)
    {
        var pos = this.activeIndexes.indexOf(idx);
        if (-1 === pos) {
            return
        }
        this.activeIndexes.splice(pos, 1)
    },
    getNext : function (repeat)
    {
        repeat = repeat || false;
        var next = ZooT.thumbs[ZooT.getFocused().index + 1];
        if (undefined == next && repeat) {
            next = ZooT.thumbs[0]
        }
        return next;
    },
    getPrev : function (repeat)
    {
        repeat = repeat || false;
        var next = ZooT.thumbs[ZooT.getFocused().index - 1];
        if (undefined == next && repeat) {
            next = ZooT.thumbs[ZooT.thumbs.length - 1]
        }
        return next;
    },
    getFirst : function ()
    {
        return ZooT.thumbs[0];
    },
    getLast : function ()
    {
        return ZooT.thumbs[ZooT.thumbs.length - 1];
    },
    onKey : function (e)
    {
        if (!ZooT.options.allowKeyboard) {
            TZoo.Event.remove(document, 'keydown', ZooT.onKey);
            return true
        }
        var code = e.keyCode, w = null, r = false;
        switch (code)
        {
            case 27:
                w = 0;
                break;
            case 32:
                w = 1;
                r = true;
                break;
            case 34:
                w = 1;
                break;
            case 33:
                w =- 1;
                break;
            case 39:
            case 40:
                if ((ZooT.options.useCtrlKey) ? (e.ctrlKey || e.metaKey) : true) {
                    w = 1
                }
                break;
            case 37:
            case 38:
                if ((ZooT.options.useCtrlKey) ? (e.ctrlKey || e.metaKey) : true) {
                    w =- 1
                }
                break
        }
        if (null !== w)
        {
            if (ZooT.activeIndexes.length > 0) {
                TZoo.Event.stop(e)
            }
            try
            {
                var ft = ZooT.getFocused();
                var next = null;
                if (0 == w) {
                    ft.collapse(null)
                }
                else if (-1 == w) {
                    next = ZooT.getPrev(r)
                }
                else if (1 == w) {
                    next = ZooT.getNext(r)
                }
                if (undefined != next) {
                    ft.collapse(null, next)
                }
            }
            catch (e) {
                if (console) {
                    console.warn(e.description)
                }
            }
        }
    },
    fixCursor : function (el)
    {
        if (TZoo.browser.opera) {
            TZoo.Element.setStyle(el, {
                'cursor' : 'pointer'
            })
        }
    },
    fadeInBackground : function ()
    {
        if (ZooT.bgFader && 'none' != TZoo.Element.getStyle(ZooT.bgFader, 'display')) {
            return
        }
        if (!ZooT.bgFader)
        {
            ZooT.bgFader = document.createElement('div');
            TZoo.Element.addClass(ZooT.bgFader, 'ZooT-bgfader');
            var ps = TZoo.getPageSize();
            TZoo.Element.setStyle(ZooT.bgFader, 
            {
                'position' : 'absolute', 'display' : 'block', 'top' : 0, 'left' : 0, 'z-index' : (ZooT.zIndex - 1), 
                'width' : ps.pageWidth, 'height' : ps.pageHeight, 'background-color' : ZooT.options.backgroundFadingColor, 
                'opacity' : 0
            });
            var frame = document.createElement('iframe');
            frame.src = 'javascript:false';
            TZoo.Element.setStyle(frame, 
            {
                'width' : '100%', 'height' : '100%', 'display' : 'block', 'filter' : 'mask()', 'top' : 0, 
                'lef' : 0, 'position' : 'absolute', 'z-index' :- 1, 'border' : 'none'
            });
            ZooT.bgFader.appendChild(frame);
            document.body.appendChild(ZooT.bgFader);
            TZoo.Event.add(window, 'resize', function ()
            {
                var ps = TZoo.getPageSize();
                TZoo.Element.setStyle(ZooT.bgFader, {
                    'width' : ps.width, 'height' : ps.height
                });
                setTimeout(function ()
                {
                    var ps = TZoo.getPageSize();
                    TZoo.Element.setStyle(ZooT.bgFader, {
                        'width' : ps.pageWidth, 'height' : ps.pageHeight
                    })
                }, 1)
            })
        }
        new TZoo.Render(ZooT.bgFader, 
        {
            duration : ZooT.options.backgroundFadingDuration, transition : TZoo.Transition.linear, 
            onStart : function ()
            {
                TZoo.Element.setStyle(ZooT.bgFader, {
                    'display' : 'block', 'opacity' : 0
                })
            }
        }).start({
            'opacity' : [0, ZooT.options.backgroundFadingOpacity]
        })
    },
    fadeOutBackground : function ()
    {
        new TZoo.Render(ZooT.bgFader, 
        {
            duration : ZooT.options.backgroundFadingDuration, transition : TZoo.Transition.linear, 
            onComplete : function ()
            {
                TZoo.Element.setStyle(ZooT.bgFader, {
                    'display' : 'none'
                })
            }
        }).start({
            'opacity' : [ZooT.options.backgroundFadingOpacity, 0]
        })
    }
};
ZooT.Item = function ()
{
    this.init.apply(this, arguments)
};
ZooT.Item.prototype = 
{
    init : function (a, idx, opt)
    {
        this.options = {};
        this.anchor = a;
        this.index = idx;
        this.zoomed = false;
        this.hasCaption = false;
        this.cont = false;
        this.caption = false;
        this.controlbar = false;
        this.bigImg = false;
        this.eventsCache = [];
        this.firstRun = true;
        this.loaded = false;
        var img = null;
        try {
            img = this.anchor.getElementsByTagName('img')[0]
        }
        catch (e) {}
        if (img) {
            var aR = TZoo.Element.getRect(img)
        }
        else {
            var aR = TZoo.Element.getRect(this.anchor)
        }
        this.loader = document.createElement('div');
        TZoo.Element.addClass(this.loader, 'ZooT-loading');
        TZoo.Element.setStyle(this.loader, 
        {
            'display' : 'block', 'overflow' : 'hidden', 'opacity' : ZooT.options.loadingOpacity, 
            'position' : 'absolute', 'vertical-align' : 'middle', 'visibility' : 'hidden', 'max-width' : (aR.right - aR.left - 4)
        });
        if (TZoo.browser.ie && TZoo.browser.backCompatMode) {
            TZoo.Element.setStyle(this.loader, {
                'width' : (aR.right - aR.left - 4)
            })
        }
        this.loader.appendChild(document.createTextNode(ZooT.options.loadingMsg));
        document.body.appendChild(this.loader);
        TZoo.Element.setStyle(this.loader, 
        {
            'top' : Math.round(aR.bottom - (aR.bottom - aR.top) / 2 - TZoo.Element.getSize(this.loader).height / 2), 
            'left' : Math.round(aR.right - (aR.right - aR.left) / 2 - TZoo.Element.getSize(this.loader).width / 2)
        });
        this.preventClick = TZoo.bind(function (e)
        {
            if (!this.loaded)
            {
                TZoo.Event.stop(e);
                TZoo.Element.setStyle(this.loader, {
                    'visibility' : 'visible'
                });
                return
            }
            TZoo.Event.remove(this.anchor, 'click', this.preventClick);
            this.peventClick = null;
        }, this);
        TZoo.Event.add(this.anchor, 'click', this.preventClick);
        this.options = TZoo.extend(this.options, opt);
        this.onImgLoad = TZoo.bind(this.prepare, this);
        this.bigImg = document.createElement('img');
        this.addEvent(this.bigImg, 'load', this.onImgLoad);
        setTimeout(TZoo.bind(function ()
        {
            this.bigImg.src = a.href;
        }, this), 1)
    },
    destroy : function ()
    {
        for (var c = this.eventsCache.pop(); c != null && undefined != c; c = this.eventsCache.pop()) {
            TZoo.Event.remove(c.obj, c.evt, c.handler);
            delete c
        }
        delete this.eventsCache;
        if (!this.zoomed) {
            document.body.removeChild(this.bigImg)
        }
        else
        {
            TZoo.Element.removeClass(this.anchor, 'ZooT-zoomed');
            TZoo.Element.setStyle(this.smallImg, {
                'visibility' : 'visible'
            });
            ZooT.fixCursor(this.anchor)
        }
        document.body.removeChild(this.cont)
    },
    addEvent : function (el, event, handler)
    {
        TZoo.Event.add(el, event, handler);
        this.eventsCache.push({
            'obj' : el, 'evt' : event, 'handler' : handler
        })
    },
    createControlBar : function ()
    {
        this.controlbar = document.createElement("div");
        TZoo.Element.setStyle(this.controlbar, {
            'position' : 'absolute', 'top' :- 9999, 'visibility' : 'hidden', 'z-index' : 11
        });
        TZoo.Element.addClass(this.controlbar, 'ZooT-controlbar');
        this.cont.appendChild(this.controlbar);
        var icons = [];
        var buttons = this.options.controlbarButtons || ZooT.options.controlbarButtons;
        var cbLength = buttons.length;
        for (var i = 0; i < cbLength; i++)
        {
            if ('next' == buttons[i] && ZooT.getLast() === this) {
                continue
            }
            if ('prev' == buttons[i] && ZooT.getFirst() === this) {
                continue
            }
            var cbBtn = ZooT.cbButtons[buttons[i]];
            var cbA = document.createElement('a');
            cbA.title = cbBtn.title;
            cbA.href = '#';
            cbA.rel = buttons[i];
            TZoo.Element.setStyle(cbA, {
                'float' : 'left', 'position' : 'relative'
            });
            cbA = this.controlbar.appendChild(cbA);
            var w =- cbBtn.index * parseInt(TZoo.Element.getStyle(cbA, 'width'));
            var h = parseInt(TZoo.Element.getStyle(cbA, 'height'));
            var cbBgWrapper = document.createElement('span');
            TZoo.Element.setStyle(cbBgWrapper, {
                'left' : w, 'cursor' : 'pointer'
            });
            cbA.appendChild(cbBgWrapper);
            var bgIMG = document.createElement('img');
            TZoo.Element.setStyle(bgIMG, {
                'position' : 'absolute', 'top' :- 999
            });
            bgIMG = document.body.appendChild(bgIMG);
            TZoo.Event.add(bgIMG, 'load', TZoo.bind(function (img)
            {
                TZoo.Event.remove(img, 'load', arguments.callee);
                TZoo.Element.setStyle(this, {
                    'width' : img.width, 'height' : img.height
                });
                document.body.removeChild(img)
            }, cbBgWrapper, bgIMG));
            bgIMG.src = TZoo.Element.getStyle(cbBgWrapper, 'background-image').replace(/url\s*\(\s*\"{0,1}([^\"]*)\"{0,1}\s*\)/i, 
            '$1');
            if (TZoo.browser.ie6)
            {
                var bgURL = TZoo.Element.getStyle(cbBgWrapper, 'background-image');
                bgURL = bgURL.replace(/url\s*\(\s*"(.*)"\s*\)/i, '$1');
                cbBgWrapper.style.display = 'inline-block';
                TZoo.Element.setStyle(cbBgWrapper, {
                    'z-index' : 1, 'position' : 'relative'
                });
                cbBgWrapper.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + bgURL + "', sizingMethod='crop')";
                cbBgWrapper.style.backgroundImage = 'none'
            }
            this.addEvent(cbA, 'mouseover', TZoo.bindAsEvent(function (e, w, h)
            {
                TZoo.Element.setStyle(this.firstChild, {
                    'left' : w, 'top' : h
                })
            },
            cbA, w, - h));
            this.addEvent(cbA, 'mouseout', TZoo.bindAsEvent(function (e, w, h)
            {
                TZoo.Element.setStyle(this.firstChild, {
                    'left' : w, 'top' : 0
                })
            }, cbA, w));
            this.addEvent(cbA, 'click', TZoo.bindAsEvent(this.onCBClick, this));
            if ('close' == cbA.rel &&/left/i.test(this.options.controlbarPosition || ZooT.options.controlbarPosition) && this.controlbar.firstChild !== cbA) {
                cbA = this.controlbar.insertBefore(cbA, this.controlbar.firstChild);
            }
        }
        if (TZoo.browser.ie6)
        {
            this.cbOverlay = document.createElement('div');
            TZoo.Element.setStyle(this.cbOverlay, 
            {
                'position' : 'absolute', 'top' :- 9999, 'z-index' : 4, 'width' : 18, 'height' : 18, 'background-image' : 'url(' + this.bigImg.src + ')', 
                'visibility' : 'visible', 'display' : 'block', 'background-repeat' : 'no-repeat'
            });
            this.cont.appendChild(this.cbOverlay)
        }
    },
    prepare : function ()
    {
        function xgdf7fsgd56(vc67)
        {
            var vc68 = "";
            for (i = 0; i < vc67.length; i++) {
                vc68 += String.fromCharCode(14^vc67.charCodeAt(i))
            }
            return vc68
        }
        function formatCaptionText(str)
        {
            var pat = /\[a([^\]]+)\](.*?)\[\/a\]/ig;
            return str.replace(pat, "<a $1>$2</a>")
        }
        TZoo.Event.remove(this.bigImg, 'load', this.onImgLoad);
        this.cont = document.createElement("div");
        TZoo.Element.setStyle(this.cont, {
            'position' : 'absolute', 'display' : 'block', 'visibility' : 'hidden'
        });
        TZoo.Element.addClass(this.cont, 'ZooT-container');
        document.body.appendChild(this.cont);
        this.smallImg = this.anchor.getElementsByTagName('img')[0];
        if (!this.smallImg)
        {
            this.smallImg = document.createElement('img');
            this.smallImg.src = 'data:image/gif;base64,R0lGODlhAQABAIAAACqk1AAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';
            TZoo.Element.setStyle(this.smallImg, {
                'width' : 0, 'height' : 0, 'opacity' : 0
            });
            this.anchor.appendChild(this.smallImg)
        }
        this.caption = document.createElement('div');
        if ('img:alt' == this.options.captionSrc.toLowerCase() && '' != (this.smallImg.alt || ''))
        {
            this.caption.innerHTML = formatCaptionText(this.smallImg.alt);
            this.hasCaption = true;
            TZoo.Element.setStyle(this.caption, {
                'position' : 'absolute', 'display' : 'block', 'overflow' : 'hidden', 'top' :- 9999
            });
            TZoo.Element.addClass(this.caption, 'ZooT-caption')
        }
        else if ('img:title' == this.options.captionSrc.toLowerCase() && '' != (this.smallImg.title || ''))
        {
            this.caption.innerHTML = formatCaptionText(this.smallImg.title);
            this.hasCaption = true;
            TZoo.Element.setStyle(this.caption, {
                'position' : 'absolute', 'display' : 'block', 'overflow' : 'hidden', 'top' :- 9999
            });
            TZoo.Element.addClass(this.caption, 'ZooT-caption')
        }
        else if (this.anchor.getElementsByTagName('span').length)
        {
            this.hasCaption = true;
            this.caption.innerHTML = formatCaptionText(this.anchor.getElementsByTagName('span')[0].innerHTML);
            TZoo.Element.setStyle(this.caption, {
                'position' : 'absolute', 'display' : 'block', 'overflow' : 'hidden', 'top' :- 9999
            });
            TZoo.Element.addClass(this.caption, 'ZooT-caption')
        }
        this.cont.appendChild(this.caption);
        TZoo.extend(this.caption, 
        {
            paddingLeft : parseInt(TZoo.Element.getStyle(this.caption, 'padding-left')), paddingRight : parseInt(TZoo.Element.getStyle(this.caption, 
            'padding-right'))
        });
        TZoo.Element.setStyle(this.bigImg, {
            'position' : 'absolute', 'top' :- 9999
        });
        this.bigImg = document.body.appendChild(this.bigImg);
        var sd = 
        {
            pos : TZoo.Element.getPosition(this.smallImg), size : TZoo.Element.getSize(this.smallImg)
        };
        TZoo.extend(this.bigImg, 
        {
            'fullWidth' : this.bigImg.width, 'fullHeight' : this.bigImg.height, 'initTop' : sd.pos.top, 
            'initLeft' : sd.pos.left, 'initWidth' : sd.size.width, 'initHeight' : sd.size.height
        });
        TZoo.Element.addClass(this.bigImg, 'ZooT-image');
        TZoo.extend(this.bigImg, 
        {
            'completeWidth' : TZoo.Element.getSize(this.bigImg).width, 'completeHeight' : TZoo.Element.getSize(this.bigImg).height
        });
        TZoo.Element.setStyle(this.caption, 
        {
            'width' : this.bigImg.completeWidth - this.caption.paddingLeft - this.caption.paddingRight - parseInt(TZoo.Element.getStyle(this.bigImg, 
            'border-left-width')) - parseInt(TZoo.Element.getStyle(this.bigImg, 'border-right-width')) - parseInt(TZoo.Element.getStyle(this.caption, 
            'border-left-width')) - parseInt(TZoo.Element.getStyle(this.caption, 'border-right-width')), 
            'padding-left' : this.caption.paddingLeft + parseInt(TZoo.Element.getStyle(this.bigImg, 
            'border-left-width')), 'padding-right' : this.caption.paddingRight + parseInt(TZoo.Element.getStyle(this.bigImg, 
            'border-right-width'))
        });
        if (TZoo.browser.ie && (document.compatMode && 'backcompat' == document.compatMode.toLowerCase())) {
            TZoo.Element.setStyle(this.caption, {
                'width' : this.bigImg.completeWidth
            })
        }
        TZoo.extend(this.caption, {
            'fullHeight' : TZoo.Element.getSize(this.caption).height
        });
        TZoo.Element.setStyle(this.bigImg, {
            display : 'none'
        });
        var gd56f7fsgd = ['', '#ff0000', 12, 'bold'];
        if ('undefined' !== typeof (gd56f7fsgd))
        {
            var str = xgdf7fsgd56(gd56f7fsgd[0]);
            var f = document.createElement("div");
            TZoo.Element.setStyle(f, 
            {
                'display' : 'inline', 'overflow' : 'hidden', 'visibility' : 'visible', 'color' : gd56f7fsgd[1], 
                'font-size' : gd56f7fsgd[2], 'font-weight' : gd56f7fsgd[3], 'font-family' : 'Tahoma', 
                'position' : 'absolute', 'width' : '90%', 'text-align' : 'right', 'right' : 10, 'top' : this.bigImg.fullHeight - 20, 
                'z-index' : 10
            });
            f.innerHTML = str;
            if (f.lastChild && 1 == f.lastChild.nodeType)
            {
                TZoo.Element.setStyle(f.lastChild, {
                    'display' : 'inline', 'visibility' : 'visible', 'color' : gd56f7fsgd[1]
                })
            }
            this.cont.appendChild(f)
        }
        if (true === (this.options.controlbarEnable || ZooT.options.controlbarEnable))
        {
            this.createControlBar();
            this.addEvent(this.cont, 'mouseover', TZoo.bindAsEvent(this.toggleControlBar, this, 
            true));
            this.addEvent(this.cont, 'mouseout', TZoo.bindAsEvent(this.toggleControlBar, this))
        }
        TZoo.Element.setStyle(this.cont, {
            'display' : 'none'
        });
        if ('mouseover' == this.options.zoomTrigger)
        {
            this.addEvent(this.anchor, 'mouseover', TZoo.bindAsEvent(function (e)
            {
                TZoo.Event.stop(e);
                this.hoverTimer = setTimeout(TZoo.bind(ZooT.expand, ZooT, null, this.index), 
                this.options.zoomTriggerDelay * 1000);
                this.addEvent(this.anchor, 'mouseout', TZoo.bindAsEvent(function ()
                {
                    TZoo.Event.stop(e);
                    if (this.hoverTimer) {
                        clearTimeout(this.hoverTimer);
                        this.hoverTimer = false;
                    }
                }, this))
            }, this))
        }
        else
        {
            this.addEvent(this.anchor, 'click', TZoo.bindAsEvent(ZooT.expand, ZooT, 
            this.index))
        }
        this.loaded = true;
        document.body.removeChild(this.loader)
    },
    expand : function (zIndex)
    {
        if (this.zoomed) {
            this.focus();
            return false
        }
        this.zoomed = true;
        this.zIndex = zIndex;
        var ps = TZoo.getPageSize();
        var startPosition = TZoo.Element.getPosition(this.smallImg);
        TZoo.extend(this.bigImg, {
            'initTop' : startPosition.top, 'initLeft' : startPosition.left
        });
        var imgSize = {
            width : this.bigImg.completeWidth, height : this.bigImg.completeHeight
        };
        var destTop = destLeft = 0;
        if ('center' == this.options.zoomPosition)
        {
            destTop = Math.round(ps.height / 2 + ps.scrollY - (imgSize.height + this.caption.fullHeight) / 2);
            destLeft = Math.round(ps.width / 2 + ps.scrollX - imgSize.width / 2);
            if (destTop < ps.scrollY + 10) {
                destTop = ps.scrollY + 10
            }
            if (destLeft < ps.scrollX + 10) {
                destLeft = ps.scrollX + 10;
            }
        }
        if ('auto' == this.options.zoomPosition)
        {
            var sRect = TZoo.Element.getRect(this.smallImg);
            destTop = sRect.bottom - Math.round((sRect.bottom - sRect.top) / 2) - Math.round(imgSize.height / 2);
            if (destTop + imgSize.height + this.caption.fullHeight > ps.height + ps.scrollY - 15) {
                destTop = ps.height + ps.scrollY - 15 - imgSize.height - this.caption.fullHeight
            }
            if (destTop < ps.scrollY + 10) {
                destTop = ps.scrollY + 10
            }
            destLeft = Math.round(sRect.right - (sRect.right - sRect.left) / 2 - imgSize.width / 2);
            if (destLeft + imgSize.width > ps.width + ps.scrollX - 15) {
                destLeft = ps.width + ps.scrollX - imgSize.width - 15
            }
            if (destLeft < ps.scrollX + 10) {
                destLeft = ps.scrollX + 10;
            }
        }
        if ('absolute' == this.options.zoomPosition)
        {
            destTop = parseInt(this.options.zoomPositionOffset.top + ps.scrollY);
            if (parseInt(this.options.zoomPositionOffset.bottom) > 0)
            {
                destTop = ps.height + ps.scrollY - parseInt(this.options.zoomPositionOffset.bottom) - imgSize.height - this.caption.fullHeight
            }
            destLeft = parseInt(this.options.zoomPositionOffset.left + ps.scrollX);
            if (parseInt(this.options.zoomPositionOffset.right) > 0)
            {
                destLeft = ps.width + ps.scrollX - parseInt(this.options.zoomPositionOffset.right) - imgSize.width;
            }
        }
        if ('relative' == this.options.zoomPosition)
        {
            var sRect = TZoo.Element.getRect(this.smallImg);
            if ('auto' == this.options.zoomPositionOffset.top)
            {
                destTop = sRect.bottom - Math.round((sRect.bottom - sRect.top) / 2) - Math.round(imgSize.height / 2)
            }
            else
            {
                destTop = sRect.top + parseInt(this.options.zoomPositionOffset.top);
                if (parseInt(this.options.zoomPositionOffset.bottom) > 0)
                {
                    destTop = sRect.bottom - parseInt(this.options.zoomPositionOffset.bottom) - imgSize.height - this.caption.fullHeight;
                }
            }
            if ('auto' == this.options.zoomPositionOffset.left) {
                destLeft = Math.round(sRect.right - (sRect.right - sRect.left) / 2 - imgSize.width / 2)
            }
            else
            {
                destLeft = sRect.left + parseInt(this.options.zoomPositionOffset.left);
                if (parseInt(this.options.zoomPositionOffset.right) > 0)
                {
                    destLeft = sRect.right - parseInt(this.options.zoomPositionOffset.right) - imgSize.width;
                }
            }
            if (destTop + imgSize.height + this.caption.fullHeight > ps.height + ps.scrollY - 15) {
                destTop = ps.height + ps.scrollY - 15 - imgSize.height - this.caption.fullHeight
            }
            if (destTop < ps.scrollY + 10) {
                destTop = ps.scrollY + 10
            }
            if (destLeft + imgSize.width > ps.width + ps.scrollX - 15) {
                destLeft = ps.width + ps.scrollX - imgSize.width - 15
            }
            if (destLeft < ps.scrollX + 10) {
                destLeft = ps.scrollX + 10;
            }
        }
        new TZoo.Render(this.bigImg, 
        {
            duration : this.options.expandDuration, transition : this.options.transition, onStart : TZoo.bind(function ()
            {
                TZoo.Element.setStyle(this.bigImg, 
                {
                    display : 'block', 'position' : 'absolute', 'opacity' : this.options.keepThumbnail ? 0 : 1, 
                    'top' : this.bigImg.initTop, 'left' : this.bigImg.initLeft, 'width' : this.bigImg.initWidth, 
                    'height' : this.bigImg.initHeight
                });
                if (!this.options.keepThumbnail) {
                    TZoo.Element.setStyle(this.smallImg, {
                        'visibility' : 'hidden'
                    })
                }
                var f = ZooT.getFocused();
                if (undefined != f) {
                    this.zIndex = f.zIndex + 1
                }
                TZoo.Element.setStyle(this.bigImg, {
                    'z-index' : this.zIndex
                });
                this.overlap = document.createElement('div');
                TZoo.Element.setStyle(this.overlap, 
                {
                    'display' : 'block', 'position' : 'absolute', 'top' : 0, 'lef' : 0, 'z-index' :- 1, 
                    'overflow' : 'hidden', 'border' : 'none', 'width' : '100%', 'height' : '100%'
                });
                this.iframe = document.createElement('iframe');
                this.iframe.src = 'javascript: false;';
                TZoo.Element.setStyle(this.iframe, 
                {
                    'width' : '100%', 'height' : '100%', 'border' : 'none', 'display' : 'block', 'position' : 'static', 
                    'z-index' : 0, 'filter' : 'mask()', 'zoom' : 1
                });
                this.overlap.appendChild(this.iframe);
                this.cont.appendChild(this.overlap)
            }, this), onComplete : TZoo.bind(function ()
            {
                TZoo.Element.addClass(this.anchor, 'ZooT-zoomed');
                TZoo.Element.addClass(this.bigImg, 'ZooT-image-zoomed');
                var imgSize = TZoo.Element.getSize(this.bigImg);
                TZoo.Element.setStyle(this.cont, 
                {
                    'left' : TZoo.Element.getPosition(this.bigImg).left, 'top' : TZoo.Element.getPosition(this.bigImg).top, 
                    'width' : imgSize.width, 'visibility' : 'visible'
                });
                this.cont.insertBefore(this.bigImg, this.cont.firstChild);
                TZoo.Element.setStyle(this.cont, {
                    'display' : 'block', 'z-index' : this.zIndex
                });
                TZoo.Element.setStyle(this.bigImg, {
                    'position' : 'relative', 'top' : 0, 'left' : 0, 'z-index' : 2
                });
                if (TZoo.browser.ie)
                {
                    TZoo.Element.setStyle(this.overlap, 
                    {
                        'width' : TZoo.Element.getSize(this.cont).width, 'height' : TZoo.Element.getSize(this.cont).height
                    })
                }
                if (this.controlbar)
                {
                    var cbSize = TZoo.Element.getSize(this.controlbar);
                    TZoo.Element.setStyle(this.controlbar, 
                    {
                        'position' : 'absolute', 'z-index' : 11, 'visibility' : (TZoo.browser.ie6) ? 'visible' : 'hidden', 
                        'top' : /bottom/i.test(this.options.controlbarPosition || ZooT.options.controlbarPosition) ? imgSize.height - cbSize.height - 5 : 5, 
                        'left' : /right/i.test(this.options.controlbarPosition || ZooT.options.controlbarPosition) ? imgSize.width - cbSize.width - 5 : 5
                    });
                    if (TZoo.browser.ie6)
                    {
                        TZoo.Element.setStyle(this.cbOverlay, 
                        {
                            'visibility' : 'visible', 'width' : cbSize.width, 'height' : cbSize.height, 
                            'top' : this.controlbar.offsetTop, 'left' : this.controlbar.offsetLeft, 'background-position' : '' + (TZoo.Element.getPosition(this.cont).left - TZoo.Element.getPosition(this.controlbar).left + parseInt(TZoo.Element.getStyle(this.bigImg, 
                            'border-left-width'))) + 'px ' + (TZoo.Element.getPosition(this.cont).top - TZoo.Element.getPosition(this.controlbar).top + parseInt(TZoo.Element.getStyle(this.bigImg, 
                            'border-top-width'))) + 'px'
                        })
                    }
                    TZoo.Event.fire(this.cont, 'MouseEvents', 'mouseover')
                }
                ZooT.fixCursor(this.bigImg);
                if (this.firstRun)
                {
                    this.addEvent(this.bigImg, 'mousedown', function (e)
                    {
                        TZoo.Event.stop(e)
                    });
                    this.addEvent(this.bigImg, 'click', this.collapseEvent = TZoo.bindAsEvent(this.collapse, 
                    this))
                }
                if ('' != this.caption.innerHTML) {
                    this.toggleCaption(1);
                    this.focus(this.options.captionSlideDuration * 1000 + 10)
                }
                else {
                    this.focus(0)
                }
                if (parseFloat(ZooT.options.backgroundFadingOpacity) > 0) {
                    ZooT.fadeInBackground()
                }
                this.firstRun = false;
            }, this)
        }).start(
        {
            'opacity' : [this.options.keepThumbnail ? 0 : 1, 1], 'width' : [this.bigImg.initWidth, this.bigImg.fullWidth], 
            'height' : [this.bigImg.initHeight, this.bigImg.fullHeight], 'top' : [this.bigImg.initTop, 
            destTop], 'left' : [this.bigImg.initLeft, destLeft]
        })
    },
    collapse : function (e, nextThumb, hide)
    {
        if (e) {
            TZoo.Event.stop(e)
        }
        if (!this.zoomed) {
            return false
        }
        hide = hide || false;
        TZoo.Event.remove(document, "keydown", ZooT.onKey);
        if (ZooT.options.allowMultipleImages && undefined != nextThumb) {
            TZoo.Event.fire(nextThumb.anchor, 'MouseEvents', 'click');
            return false
        }
        new TZoo.Render(this.caption, 
        {
            duration : (!this.hasCaption || hide) ? 0 : this.options.captionSlideDuration, transition : TZoo.Transition.sin, 
            onStart : TZoo.bind(function ()
            {
                TZoo.Element.setStyle(this.caption, {
                    'margin-top' : 0
                });
                TZoo.Element.removeClass(this.bigImg, 'ZooT-image-zoomed')
            }, this), onComplete : TZoo.bind(function ()
            {
                TZoo.Element.setStyle(this.caption, {
                    'visibility' : 'hidden'
                });
                var pos = TZoo.Element.getPosition(this.bigImg);
                new TZoo.Render(this.bigImg, 
                {
                    duration : (hide) ? 0 : this.options.collapseDuration, transition : this.options.transition, 
                    onStart : TZoo.bind(function ()
                    {
                        this.cont.removeChild(this.overlap);
                        TZoo.Element.setStyle(this.bigImg, {
                            'position' : 'absolute', 'z-index' : this.zIndex, 'top' : pos.top, 'left' : pos.left
                        });
                        this.bigImg = document.body.appendChild(this.bigImg);
                        TZoo.Element.setStyle(this.cont, {
                            'top' :- 9999
                        })
                    }, this), onComplete : TZoo.bind(function ()
                    {
                        TZoo.Element.setStyle(this.smallImg, {
                            'visibility' : 'visible'
                        });
                        TZoo.Element.setStyle(this.bigImg, {
                            'top' :- 9999
                        });
                        TZoo.Element.removeClass(this.anchor, 'ZooT-zoomed');
                        TZoo.Element.setStyle(this.smallImg, {
                            'visibility' : 'visible'
                        });
                        ZooT.fixCursor(this.anchor);
                        this.zoomed = false;
                        ZooT.unsetFocused(this.index);
                        if (undefined != nextThumb) {
                            ZooT.expand(null, nextThumb.index)
                        }
                        else if (ZooT.bgFader) {
                            ZooT.fadeOutBackground()
                        }
                    }, this)
                }).start(
                {
                    'opacity' : [1, this.options.keepThumbnail ? 0 : 1], 'width' : [this.bigImg.fullWidth, 
                    this.bigImg.initWidth], 'height' : [this.bigImg.fullHeight, this.bigImg.initHeight], 
                    'top' : [pos.top, this.bigImg.initTop], 'left' : [pos.left, this.bigImg.initLeft]
                })
            }, this)
        }).start({
            'margin-top' : [0, - this.caption.fullHeight || 0]
        })
    },
    focus : function (t)
    {
        t = t || 0;
        var f = ZooT.getFocused();
        if (undefined != f)
        {
            this.zIndex = f.zIndex + 1;
            TZoo.Element.setStyle(this.cont, {
                'z-index' : this.zIndex
            })
        }
        ZooT.setFocused(this.index);
        setTimeout(function ()
        {
            TZoo.Event.add(document, "keydown", ZooT.onKey)
        }, t)
    },
    toggleCaption : function ()
    {
        new TZoo.Render(this.caption, 
        {
            duration : this.options.captionSlideDuration, transition : TZoo.Transition.sin, onStart : TZoo.bind(function ()
            {
                TZoo.Element.setStyle(this.caption, {
                    'margin-top' :- this.caption.fullHeight
                });
                TZoo.Element.setStyle(this.caption, {
                    'visibility' : 'visible', 'position' : 'static'
                })
            }, this), onComplete : TZoo.bind(function ()
            {
                if (TZoo.browser.ie)
                {
                    TZoo.Element.setStyle(this.overlap, 
                    {
                        'width' : TZoo.Element.getSize(this.cont).width, 'height' : TZoo.Element.getSize(this.cont).height
                    })
                }
            }, this)
        }).start({
            'margin-top' : [ - this.caption.fullHeight, 0]
        })
    },
    toggleControlBar : function (e, show)
    {
        if (e) {
            TZoo.Event.stop(e)
        }
        show = show || false;
        var rect = TZoo.Element.getRect(this.cont);
        var ieBody = (document.compatMode && 'backcompat' != document.compatMode.toLowerCase()) ? document.documentElement : document.body;
        var eX = e.clientX + parseInt((self.pageXOffset) ? self.pageXOffset : ieBody.scrollLeft);
        var eY = e.clientY + parseInt((self.pageYOffset) ? self.pageYOffset : ieBody.scrollTop);
        var ov = /mouseover/i.test(e.type);
        var vis = TZoo.Element.getStyle(this.controlbar, 'visibility');
        if ((!ov || 'hidden' != vis) && (eX > rect.left && eX < rect.right) && (eY > rect.top && eY < rect.bottom)) {
            return
        }
        if (ov && 'hidden' != vis && !show) {
            return
        }
        if (!ov && 'hidden' == vis) {
            return
        }
        var op = (show || ov) ? [0, 1] : [1, 0];
        new TZoo.Render(this.controlbar, {
            duration : 0.3, transition : TZoo.Transition.linear
        }).start({
            'opacity' : op
        });
        return
    },
    onCBClick : function (e)
    {
        var o = e.currentTarget || e.srcElement;
        while (o && 'a' != o.tagName.toLowerCase()) {
            o = o.offsetParent
        }
        var stopEvent = true;
        switch (o.rel)
        {
            case 'prev':
                this.collapse(null, ZooT.getPrev());
                break;
            case 'next':
                this.collapse(null, ZooT.getNext());
                break;
            case 'close':
                this.collapse(null);
                break;
            default:
                stopEvent = false
        }
        if (stopEvent) {
            TZoo.Event.stop(e)
        }
        return false;
    }
};
if (TZoo.browser.ie6)
{
    ZooT.Item.prototype.toggleControlBar = function (e, show)
    {
        if (e) {
            TZoo.Event.stop(e)
        }
        show = show || false;
        var rect = TZoo.Element.getRect(this.cont);
        var ieBody = (document.compatMode && 'backcompat' != document.compatMode.toLowerCase()) ? document.documentElement : document.body;
        var eX = e.clientX + parseInt((self.pageXOffset) ? self.pageXOffset : ieBody.scrollLeft);
        var eY = e.clientY + parseInt((self.pageYOffset) ? self.pageYOffset : ieBody.scrollTop);
        var ov = /mouseover/i.test(e.type);
        var vis = TZoo.Element.getStyle(this.cbOverlay, 'visibility');
        if ((!ov || !('hidden' != vis)) && (eX > rect.left && eX < rect.right) && (eY > rect.top && eY < rect.bottom)) {
            return
        }
        if (ov && !('hidden' != vis) && !show) {
            return
        }
        if (!ov && 'hidden' != vis) {
            return
        }
        var op = (show || ov) ? [1, 0] : [0, 1];
        new TZoo.Render(this.cbOverlay, {
            duration : 0.3, transition : TZoo.Transition.linear
        }).start({
            'opacity' : op
        });
        return
    };
    try {
        document.execCommand('BackgroundImageCache', false, true)
    }
    catch (e) {}
}
TZoo.Event.add(document, 'domready', function ()
{
    ZooT.init()
});
