(function () {

    var G = this,
        W,
        D,
        E;

    if (
        ('object' != typeof G)
        || ('undefined' == typeof G.window)
        || !(
            (W = G.window)
            && 'undefined' != typeof W.setTimeout
            && 'undefined' != typeof W.clearTimeout
        )
        || !(
            (D = W.document)
            && ('undefined' != typeof D.body)
            && ('undefined' != typeof D.createElement)
            && ('undefined' != typeof D.documentElement)
            && ('undefined' != typeof D.getElementById)
        )
        || !(
            (E = D.createElement('DIV'))
            && ('undefined' != typeof E.appendChild)
            && ('string'    == typeof E.className)
            && ('undefined' != typeof E.getElementsByTagName)
            && ('undefined' != typeof E.parentNode)
            && ('undefined' != typeof E.removeChild)
            && ('undefined' != typeof E.style)
        )
    ) {
        return false;
    }

    var root = D.documentElement,
        root_class = 'js';
    if (root.className) {
        root.className = [root.className, ' ', root_class].join('');
    } else {
        root.className = root_class;
    }

    var opacity = ('string' == typeof E.style.opacity)
        ? function (el, z) {
            el.style.opacity = (z / 100);
        }
        : (('string' == typeof E.style.filter)
            ? function (el, z) {
                el.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity = ' + z + ')';
            }
            : null
        );

    var BLURB,
        BODY,
        IMG,
        JACKET,
        LAYER;

    function init() {
        BODY   = D.body;
        JACKET = D.getElementById('jacket');
        IMG    = JACKET.getElementsByTagName('IMG')[0];
        BLURB  = D.getElementById('blurb');
        BLURB.style.visibility = 'visible';
        LAYER  = overlay('#fff');
        slide();
    }

    function elasticOut(t, b, c, d, a, p) {
        var s;
        if (t == 0) {
            return b;
        }
        if ((t /= d) == 1) {
            return b + c;
        }
        if (!p) {
            p = d * .3;
        }
        if (!a || a < Math.abs(c)) {
            a = c;
            s = p / 4;
        } else {
            s = p / (2 * Math.PI) * Math.asin(c / a);
        }
        return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
    }

    function getFrames(start, end, step, unit, easing) {
        var frames = [],
            range = (end - start),
            len = Math.floor(range / step) + 1,
            i = 0,
            j = 0,
            t;
        !unit && (unit = '');
        for (; i < len; i++) {
            t = Math.round(easing(i, start, range, len)) + unit;
            if (!j || (t != frames[j - 1])) {
                frames[j++] = t;
            }
        }
        return frames;
    }

    function overlay(color) {
        BLURB.style.position = 'relative';
        var div = D.createElement('DIV'),
            style = div.style;
        style.position = 'absolute';
        style.top  = '-4px';
        style.left = '-4px';
        style.width  = (BLURB.offsetWidth + 8) + 'px';
        style.height = (BLURB.offsetHeight + 8) + 'px';
        style.backgroundColor = color;
        BLURB.appendChild(div);
        return div;
    }

    function slide() {
        var style = JACKET.style,
            start,
            end;
        style.display = 'block';
        start = -JACKET.offsetWidth,
        end = (BODY.scrollWidth - (JACKET.offsetWidth + 20));
        style.right = 'auto';
        style.left = start + 'px';
        W.setTimeout(
            function () {
                move(start, end);
            }, 2000
        );
    }

    function move(start, end) {
        var style = JACKET.style,
            frames = getFrames(start, end, 5, 'px', elasticOut),
            l = frames.length,
            i = 0;
        var t = W.setInterval(
            function () {
                if (i < l) {
                    style.left = frames[i];
                    i++;
                } else {
                    style.right = style.left = '';
                    W.clearInterval(t);
                    if (opacity) {
                        W.setTimeout(
                            function () {
                                show();
                            }, 500
                        );
                    } else {
                        LAYER.parentNode.removeChild(LAYER);
                    }
                }
            }, 10
        );
    }

    function show(o) {
        o = o || 100;
        W.setTimeout(
            function () {
                o -= 20;
                if (o > 0) {
                    opacity(LAYER, o);
                    show(o);
                } else {
                    LAYER.parentNode.removeChild(LAYER);
                }
            }, 50
        );
    }

    window.onload = init;

    E = null;

    return true;

})();
