(function($) {
    if ("undefined" === typeof $) {
        throw "window.jQuery is not defined. This is required to run parallax.js";
    }

    var doParallax = function() {

        // The bubbles aren't supported in mozilla right now.
        if (!$.browser.mozilla) {
            var map = {
                // selector: speed
                ".bubbleBack": 0.05,
                ".bubbleMid": 0.025,
                ".bubbleSuperMid": 0.55,
                ".bubbleFront": 2,
                ".bubbleSuperFront": 2.5
            };
            $.each(map, function(selector, scrollingSpeed) {
                $(selector).scrollingParallax({
                    staticSpeed: scrollingSpeed,
                    loopIt: false,
                    staticScrollLimit: false
                });
            });
        }


        // Scroll the red box at the top of the page to the right or left, depending on which way you're scrolling.
        (function() {
            var box = $('#home-bkg');
            box.each(function() {
                var w = $(window),
                    trace = 0;

                w.scroll(function(e) {
                    var amount = w.scrollTop() / 2;

                    box.css({
                        backgroundPosition: [amount, 'px'].join('')
                    });
                });

            });
        }());
    };

    $(document).ready(doParallax);

}(window.jQuery));

