//jQuery.ui.coulisse.min 
/*
 LuvDaSun Coulisse - v0.8 - 2011-03-01
 http://coulisse.luvdasun.com/

 Copyright 2010-2011 "Elmer Bulthuis" <elmerbulthuis@gmail.com>
 Dual licensed under the MIT and GPL licenses.
*/
(function () {
    var W = this;
    this.lds = this.lds || {};
    var D = function (d, a) {
            if (!a) return d;
            var h = typeof a;
            switch (h) {
            case "function":
                return a.apply(d);
            case "string":
            case "number":
                h = d[a];
                switch (typeof h) {
                case "function":
                    return h();
                default:
                    return h
                }
            case "object":
                switch (a.constructor) {
                case Array:
                    return a.length == 0 ? d : D(D(d, a[0]), a.slice(1));
                default:
                    throw "unknown object is not supported as a getter";
                }
            default:
                throw h + " is not supported as a getter";
            }
        },
        H = function (d, a, h) {
            if ("addEventListener" in d) d.addEventListener(a, h, false);
            else if ("attachEvent" in d) d.attachEvent("on" + a, h);
            else throw "" + a + " event could not be bound";
        },
        I = function (d, a, h) {
            if ("removeEventListener" in d) d.removeEventListener(a, h, false);
            else if ("detachEvent" in d) d.detachEvent("on" + a, h);
            else throw "" + a + " event could not be unbound";
        },
        X = 0,
        E = {},
        Y = function (d, a, h, f, p, r) {
            var m = ++X,
                s = a - d,
                i = (new Date).getTime(),
                q = function () {
                    var o = (new Date).getTime() - i;
                    if (o < p) {
                        o = f(d, a, s, o, p);
                        h(o, false);
                        E[m] = window.setTimeout(q, r)
                    } else {
                        delete E[m];
                        h(a, true)
                    }
                };
            q();
            return m
        },
        N = function (d, a, h, f) {
            var p = d.canvas.width,
                r = d.canvas.height,
                m = a.width,
                s = a.height;
            f = f || p;
            for (var i = 0; i < f; i++) {
                var q = Math.floor(m * i / f),
                    o = Math.floor(p * i / f),
                    w = h * r * (f - i - 1) / (f - 1);
                d.drawImage(a, q, 0, Math.ceil(m * (i + 1) / f) - q, s, o, w / 2, Math.ceil(p * (i + 1) / f) - o, r - w)
            }
        },
        O = function (d, a, h, f) {
            var p = d.canvas.width,
                r = d.canvas.height,
                m = a.width,
                s = a.height;
            f = f || p;
            for (var i = 0; i < f; i++) {
                var q = Math.floor(m * i / f),
                    o = Math.floor(p * i / f),
                    w = h * r * i / (f - 1);
                d.drawImage(a, q, 0, Math.ceil(m * (i + 1) / f) - q, s, o, w / 2, Math.ceil(p * (i + 1) / f) - o, r - w)
            }
        };
    this.lds.Coulisse = function (d, a) {
        var h = this,
            f = a.duration || 800,
            p = a.interval || 20,
            r = a.sliceCount || 10,
            m = a.area || 0.5,
            s = a.pinch || 0.4,
            i = a.scale || 0.4,
            q = a.activeSize || 800,
            o = a.inactiveSize || 400,
            w = a.onActivateIndex || null,
            P = a.onIndexChange || null,
            Q = a.onIndexChanging || null,
            R = a.onIndexChanged || null,
            Z = a.imageSrcGetter || null,
            $ = a.linkHrefGetter || null,
            t = [],
            ba = function (e, k, l) {
                var b = this,
                    v = null,
                    g = document.createElement("img"),
                    C = l ? document.createElement("a") : null,
                    F = "HTMLCanvasElement" in W ? document.createElement("canvas") : null,
                    u = F ? F.getContext("2d") : null,
                    S = false,
                    j = F || g,
                    z = C || j,
                    n = z.style,
                    T = function (c) {
                        if (x != e) {
                            w && w({
                                index: e
                            }) === false || h.setIndex(e);
                            "preventDefault" in c && c.preventDefault();
                            return false
                        }
                    },
                    U = function () {
                        var c = Math.sqrt(g.width * g.width + g.height * g.height);
                        b.activePanelWidth = g.width * q / c;
                        b.activePanelHeight = g.height * q / c;
                        b.inactivePanelWidth = i * g.width * o / c;
                        b.inactivePanelHeight = g.height * o / c;
                        b.deltaWidth = b.activePanelWidth - b.inactivePanelWidth;
                        b.deltaHeight = b.activePanelHeight - b.inactivePanelHeight;
                        C && C.appendChild(j);
                        d.appendChild(z);
                        S = true;
                        J(true)
                    };
                this.drawPanel = function (c) {
                    var K = true;
                    if (!S) return K;
                    var A = true,
                        B = e - y,
                        aa = c.panelCount - Math.abs(Math.round(B));
                    if (B < 0) {
                        if (B > -1) {
                            var L = t[e + 1];
                            j.width = b.inactivePanelWidth + b.deltaWidth * c.realIndexModInv;
                            j.height = b.inactivePanelHeight + b.deltaHeight * c.realIndexModInv;
                            u && O(u, g, s * c.realIndexMod, r);
                            c.panelLeft = (d.offsetWidth - b.activePanelWidth) / 2;
                            c.panelLeft -= b.inactivePanelWidth * m * c.realIndexMod;
                            c.panelLeft -= (L.activePanelWidth - b.activePanelWidth) / 2 * c.realIndexMod
                        } else {
                            if (v > -1) {
                                j.width = b.inactivePanelWidth;
                                j.height = b.inactivePanelHeight;
                                u && O(u, g, s)
                            }
                            A = c.panelLeft >= 0 - j.width;
                            c.panelLeft -= j.width * m
                        }
                        if (A) {
                            n.left = c.panelLeft + "px";
                            n.right = ""
                        }
                    } else if (B > 0) {
                        if (B < 1) {
                            L = t[e - 1];
                            j.width = b.inactivePanelWidth + b.deltaWidth * c.realIndexMod;
                            j.height = b.inactivePanelHeight + b.deltaHeight * c.realIndexMod;
                            u && N(u, g, s * c.realIndexModInv, r);
                            c.panelRight = (d.offsetWidth - b.activePanelWidth) / 2;
                            c.panelRight -= b.inactivePanelWidth * m * c.realIndexModInv;
                            c.panelRight -= (L.activePanelWidth - b.activePanelWidth) / 2 * c.realIndexModInv
                        } else {
                            if (v < 1) {
                                j.width = b.inactivePanelWidth;
                                j.height = b.inactivePanelHeight;
                                u && N(u, g, s)
                            }
                            A = c.panelRight >= 0 - j.width;
                            c.panelRight -= j.width * m
                        }
                        if (A) {
                            n.left = "";
                            n.right = c.panelRight + "px"
                        }
                    } else {
                        j.width = b.activePanelWidth;
                        j.height = b.activePanelHeight;
                        u && u.drawImage(g, 0, 0, g.width, g.height, 0, 0, j.width, j.height);
                        c.panelLeft = (d.offsetWidth - b.activePanelWidth) / 2;
                        c.panelRight = (d.offsetWidth - b.activePanelWidth) / 2;
                        if (A) {
                            n.left = c.panelLeft + "px";
                            n.right = c.panelRight + "px"
                        }
                    }
                    if (A) {
                        n.zIndex = aa;
                        n.top = n.bottom = (d.offsetHeight - j.height) / 2 + "px";
                        n.display = "block"
                    } else {
                        K = n.display != "none";
                        n.display = "none"
                    }
                    v = B;
                    return K
                };
                this.destruct = function () {
                    I(z, "click", T);
                    I(g, "load", U);
                    d.removeChild(z);
                    delete z;
                    delete g;
                    delete F
                };
                H(z, "click", T);
                H(g, "load", U);
                n.display = "none";
                n.position = "absolute";
                if (C) C.href = l;
                g.src = k
            },
            J = function (e) {
                var k = t.length;
                if (k) {
                    k = {
                        panelLeft: null,
                        panelRight: null,
                        panelCount: k,
                        realIndexInt: parseInt(y),
                        realIndexMod: y % 1,
                        realIndexModInv: 1 - y % 1
                    };
                    for (var l = k.realIndexInt; l >= 0; l--) {
                        var b = t[l];
                        if (b) if (!b.drawPanel(k) && !e) break
                    }
                    for (l = k.realIndexInt + 1; l < k.panelCount; l++) if (b = t[l]) if (!b.drawPanel(k) && !e) break
                }
            },
            V = function () {
                J(true)
            },
            ca = function (e, k) {
                var l = Math.round(e);
                if (x != l) {
                    x = l;
                    Q && Q({
                        index: x
                    })
                }
                if (y != e) {
                    y = e;
                    J(false)
                }
                k && M()
            },
            da = a.animationCalculate ||
        function (e, k, l, b, v) {
            return e + l * Math.sin(Math.PI * b / v / 2)
        }, G, M = function () {
            if (G) {
                var e = G;
                window.clearTimeout(E[e]);
                delete E[e];
                G = null;
                R && R({
                    index: x
                })
            }
        }, x = a.index || 0, y = x;
        this.setIndex = function (e) {
            M();
            e = Math.round(e);
            P && P({
                index: e
            });
            G = Y(y, e, ca, da, f, p)
        };
        this.getIndex = function () {
            return x
        };
        this.destruct = function () {
            M();
            I(window, "resize", V);
            for (var e = t.pop(); e; e = t.pop()) {
                e.destruct();
                delete e
            }
        };
        this.addImages = function (e) {
            for (var k = 0, l = e.length; k < l; k++) {
                var b = e[k],
                    v = D(b, Z),
                    g = a.linkHrefGetter ? D(b, $) : null;
                b = t.length;
                v = new ba(b, v, g);
                t[b] = v
            }
        };
        this.countImages = function () {
            return t.length
        };
        a.images && this.addImages(a.images);
        H(window, "resize", V);
        delete a
    }
})();

/*
 jQuery-ui wrapper for LuvDaSun Coulisse - v0.2 - 2011-03-01
 http://coulisse.luvdasun.com/

 Copyright 2010-2011 "Elmer Bulthuis" <elmerbulthuis@gmail.com>
 Dual licensed under the MIT and GPL licenses.
*/
typeof jQuery != "undefined" && typeof jQuery.ui != "undefined" &&
function (b) {
    b.widget("lds.coulisse", {
        widgetEventPrefix: "coulisse",
        options: {
            duration: null,
            area: 0.5,
            pinch: 0.5,
            scale: 0.5,
            sliceCount: 20,
            activeSize: 800,
            inactiveSize: 400,
            index: 0
        },
        _coulisse: null,
        _create: function () {
            var c = this,
                a = this.options;
            this._coulisse = new lds.Coulisse(this.element[0], {
                duration: b.fx.off ? 0 : typeof a.duration == "number" ? a.duration : a.duration in b.fx.speeds ? b.fx.speeds[a.duration] : b.fx.speeds._default,
                interval: b.fx.interval,
                sliceCount: a.sliceCount,
                area: a.area,
                pinch: a.pinch,
                scale: a.scale,
                activeSize: a.activeSize,
                inactiveSize: a.inactiveSize,
                images: a.images,
                imageSrcGetter: a.imageSrcGetter,
                linkHrefGetter: a.linkHrefGetter,
                index: a.index,
                onActivateIndex: function (d) {
                    return c._trigger("activateIndex", null, d)
                },
                onIndexChange: function (d) {
                    return c._trigger("indexChange", null, d)
                },
                onIndexChanging: function (d) {
                    return c._trigger("indexChanging", null, d)
                },
                onIndexChanged: function (d) {
                    return c._trigger("indexChanged", null, d)
                },
                animationCalculate: null
            });
            this.element.addClass("lds-coulisse");
            b.Widget.prototype._create.apply(this, arguments)
        },
        destroy: function () {
            this.element.removeClass("lds-coulisse");
            this._coulisse.destruct();
            delete this._coulisse;
            b.Widget.prototype.destroy.apply(this, arguments)
        },
        _setOption: function (c, a) {
            switch (c) {
            case "index":
                this._coulisse.setIndex(a);
                break;
            case "images":
                this._coulisse.addImages(a)
            }
        },
        _getOption: function (c) {
            switch (c) {
            case "index":
                return this._coulisse.getIndex();
            case "images":
                return this._coulisse.countImages();
            default:
                return null
            }
        }
    })
}(jQuery);
