/**
SlideItMoo v1.1 - Image slider
(c) 2007-2009 Constantin Boiangiu <http://www.php-help.ro>
MIT-style license.
	
Changes from version 1.0
- added continuous navigation
- changed the navigation from Fx.Scroll to Fx.Morph
- added new parameters: itemsSelector: pass the CSS class for divs
- itemWidth: for elements with margin/padding pass their width including margin/padding
	
Updates ( August 4'th 2009 )
- added new parameter 'elemsSlide'. When this is set to a value lower that the actual number of elements in HTML, it will slide at once that number of elements when navigation clicked. Default: null
- added onChange event that returns the index of the current element
**/


/*
SlideItMoo v1.0 - Image slider
(c) 2007-2008 Constantin Boiangiu <http://www.php-help.ro>
MIT-style license.
*/
var SlideItMoo = new Class({

    initialize: function(options) {
        this.options = $extend({
            itemsVisible: 5,
            showControls: 1,
            autoSlide: 0,
            transition: Fx.Transitions.linear,
            currentElement: 0,
            thumbsContainer: 'SlideItMoo_items',
            elementScrolled: 'SlideItMoo_inner',
            overallContainer: 'SlideItMoo_outer'
        }, options || {});
        if (document.getElementById('SlideItMoo_items') == null)
            return;
        this.images = $(this.options.thumbsContainer).getElements('a');
        // assumes that all thumbnails have the same width
        this.image_size = this.images[0].getSize();

        // resizes the container div's according to the number of itemsVisible thumbnails
        this.setContainersSize();

        this.myFx = new Fx.Scroll(this.options.elementScrolled, { transition: this.options.transition });
        // adds the forward-backward buttons
        if (this.images.length > this.options.itemsVisible) {
            this.fwd = this.addControlers('addfwd');
            this.bkwd = this.addControlers('addbkwd');
            this.forward();
            this.backward();
            /* if autoSlide is not set, scoll on mouse wheel */
            if (!this.options.autoSlide) {
                $(this.options.thumbsContainer).addEvent('mousewheel', function(ev) {
                    new Event(ev).stop();
                    ev.wheel < 0 ? this.fwd.fireEvent('click') : this.bkwd.fireEvent('click');
                } .bind(this));
            }
            else {
                this.startIt = function() { this.fwd.fireEvent('click') } .bind(this);
                this.autoSlide = this.startIt.periodical(this.options.autoSlide, this);
                this.images.addEvents({
                    'mouseover': function() {
                        $clear(this.autoSlide);
                    } .bind(this),
                    'mouseout': function() {
                        this.autoSlide = this.startIt.periodical(this.options.autoSlide, this);
                    } .bind(this)
                })
            }
        };

        // if there's a specific default thumbnail to start with, slide to it
        if (this.options.currentElement !== 0) {
            this.options.currentElement -= 1;
            this.slide(1);
        }
    },

    setContainersSize: function() {
        $(this.options.overallContainer).set({
            styles: {
                'width': 920
            }
        });
        $(this.options.elementScrolled).set({
            styles: {
                'width': 825
            }
        });
    },

    forward: function() {
        this.fwd.addEvent('click', function() {
            this.slide(1);
        } .bind(this));
    },

    backward: function() {
        this.bkwd.addEvent('click', function() {
            this.slide(-1);
        } .bind(this))
    },

    addControlers: function(cssClass) {
        element = new Element('div', {
            'class': cssClass,
            styles: {
                'display': this.options.showControls ? '' : 'none'
            }
        }).injectInside($(this.options.overallContainer));
        return element;
    },

    slide: function(step) {
        /* if autoslice is on, when end is reached, go back to begining */
        if (this.options.autoSlide && this.options.currentElement >= this.images.length - this.options.itemsVisible) {
            this.options.currentElement = -1;
        }

        if ((this.options.currentElement < this.images.length - this.options.itemsVisible && step > 0) || (step < 0 && this.options.currentElement !== 0)) {
            this.myFx.cancel();
            this.options.currentElement += step;
            this.myFx.toElement(this.images[this.options.currentElement]);
        }
    }
})

window.addEvent('domready', function() {


    /* thumbnails example , div containers */
    new SlideItMoo({ itemsVisible: 5, // the number of thumbnails that are visible
        currentElement: 0, // the current element. starts from 0. If you want to start the display with a specific thumbnail, change this
        thumbsContainer: 'SlideItMoo_items',
        elementScrolled: 'SlideItMoo_inner',
        overallContainer: 'SlideItMoo_outer'
    });


});
/*
Slimbox v1.65 - The ultimate lightweight Lightbox clone
(c) 2007-2008 Christophe Beyls <http://www.digitalia.be>
MIT-style license.
*/
var Slimbox; (function() { var g = 0, f, l, b, s, t, o, e, m, j = new Image(), k = new Image(), x, A, p, h, w, z, i, y, c; window.addEvent("domready", function() { $(document.body).adopt($$([x = new Element("div", { id: "lbOverlay" }).addEvent("click", n), A = new Element("div", { id: "lbCenter" }), z = new Element("div", { id: "lbBottomContainer" })]).setStyle("display", "none")); p = new Element("div", { id: "lbImage" }).injectInside(A).adopt(h = new Element("a", { id: "lbPrevLink", href: "#" }).addEvent("click", d), w = new Element("a", { id: "lbNextLink", href: "#" }).addEvent("click", r)); i = new Element("div", { id: "lbBottom" }).injectInside(z).adopt(new Element("a", { id: "lbCloseLink", href: "#" }).addEvent("click", n), y = new Element("div", { id: "lbCaption" }), c = new Element("div", { id: "lbNumber" }), new Element("div", { styles: { clear: "both"} })); e = { overlay: new Fx.Tween(x, { property: "opacity", duration: 500 }).set(0), image: new Fx.Tween(p, { property: "opacity", duration: 500, onComplete: a }), bottom: new Fx.Tween(i, { property: "margin-top", duration: 400 })} }); Slimbox = { open: function(E, D, C) { f = $extend({ loop: false, overlayOpacity: 0.8, resizeDuration: 400, resizeTransition: false, initialWidth: 250, initialHeight: 250, animateCaption: true, showCounter: true, counterText: "Image {x} of {y}" }, C || {}); if (typeof E == "string") { E = [[E, D]]; D = 0 } l = E; f.loop = f.loop && (l.length > 1); B(); q(true); o = window.getScrollTop() + (window.getHeight() / 15); e.resize = new Fx.Morph(A, $extend({ duration: f.resizeDuration, onComplete: a }, f.resizeTransition ? { transition: f.resizeTransition} : {})); A.setStyles({ top: o, width: f.initialWidth, height: f.initialHeight, marginLeft: -(f.initialWidth / 2), display: "" }); e.overlay.start(f.overlayOpacity); g = 1; return u(D) } }; Element.implement({ slimbox: function(C, D) { $$(this).slimbox(C, D); return this } }); Elements.implement({ slimbox: function(C, F, E) { F = F || function(G) { return [G.href, G.title] }; E = E || function() { return true }; var D = this; D.removeEvents("click").addEvent("click", function() { var G = D.filter(E, this); return Slimbox.open(G.map(F), G.indexOf(this), C) }); return D } }); function B() { x.setStyles({ top: window.getScrollTop(), height: window.getHeight() }) } function q(C) { ["object", Browser.Engine.trident ? "select" : "embed"].forEach(function(E) { Array.forEach(document.getElementsByTagName(E), function(F) { if (C) { F._slimbox = F.style.visibility } F.style.visibility = C ? "hidden" : F._slimbox }) }); x.style.display = C ? "" : "none"; var D = C ? "addEvent" : "removeEvent"; window[D]("scroll", B)[D]("resize", B); document[D]("keydown", v) } function v(C) { switch (C.code) { case 27: case 88: case 67: n(); break; case 37: case 80: d(); break; case 39: case 78: r() } return false } function d() { return u(s) } function r() { return u(t) } function u(C) { if ((g == 1) && (C >= 0)) { g = 2; b = C; s = ((b || !f.loop) ? b : l.length) - 1; t = b + 1; if (t == l.length) { t = f.loop ? 0 : -1 } $$(h, w, p, z).setStyle("display", "none"); e.bottom.cancel().set(0); e.image.set(0); A.className = "lbLoading"; m = new Image(); m.onload = a; m.src = l[C][0] } return false } function a() { switch (g++) { case 2: A.className = ""; p.setStyles({ backgroundImage: "url(" + l[b][0] + ")", display: "" }); $$(p, i).setStyle("width", m.width); $$(p, h, w).setStyle("height", m.height); y.set("html", l[b][1] || ""); c.set("html", (f.showCounter && (l.length > 1)) ? f.counterText.replace(/{x}/, b + 1).replace(/{y}/, l.length) : ""); if (s >= 0) { j.src = l[s][0] } if (t >= 0) { k.src = l[t][0] } if (A.clientHeight != p.offsetHeight) { e.resize.start({ height: p.offsetHeight }); break } g++; case 3: if (A.clientWidth != p.offsetWidth) { e.resize.start({ width: p.offsetWidth, marginLeft: -p.offsetWidth / 2 }); break } g++; case 4: z.setStyles({ top: o + A.clientHeight, marginLeft: A.style.marginLeft, visibility: "hidden", display: "" }); e.image.start(1); break; case 5: if (s >= 0) { h.style.display = "" } if (t >= 0) { w.style.display = "" } if (f.animateCaption) { e.bottom.set(-i.offsetHeight).start(0) } z.style.visibility = ""; g = 1 } } function n() { if (g) { g = 0; m.onload = $empty; for (var C in e) { e[C].cancel() } $$(A, z).setStyle("display", "none"); e.overlay.chain(q).start(0) } return false } })();

// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
Slimbox.scanPage = function() {
    var links = $$("a").filter(function(el) {
        return el.rel && el.rel.test(/^lightbox/i);
    });
    $$(links).slimbox({/* Put custom options here */
}, null, function(el) {
    return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
});
};

window.addEvent("domready", Slimbox.scanPage);
