﻿/// <reference path="http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.1-vsdoc.js" />

if (typeof Stayfree === 'undefined') Stayfree = {};

Stayfree.Content = (function ($) {
    // Extended overlay settings
    var overlay = {
        manager: null,
        maxHeight: 500,
        heightPadding: 50,
        content: null,
        container: null
    };


    var animateHeight = function (newHeight) {
        jQuery(overlay.content).notIe(6).animate({
            height: (newHeight + overlay.heightPadding)
        }, 300);
        jQuery(overlay.container).notIe(6).animate({
            top: "+=" + (jQuery(overlay.content).height() - (newHeight + overlay.heightPadding)) / 2
        }, 300);
    };

    var setHeight = function (bodyHeight) {
        if (bodyHeight < overlay.maxHeight) {
            animateHeight(bodyHeight);
        } else {
            animateHeight(overlay.maxHeight);
        }
    };


    return {
        init: function () {
            // This sets up the overlay popup things.  You can access certain methods
            // through the overlayManager, like .close() and .open(url).
            overlay.manager = jdiacono.web.overlay({
                container: '#mainOverlay',
                content: '.content',
                links: 'a.overlay',
                spawnWindowByDefault: true,
                lightBoxing: true,
				rememberPreviousState: false
            });

            overlay.content = overlay.manager.content;
            overlay.container = overlay.manager.container;
        },
        getOverlayManager: function () {
            return overlay.manager;
        },
        setOverlayHeight: setHeight
    };
})(jQuery);

Stayfree.Overlay = (function ($) {
    return {
        load: function () {
            var windowHeight = $('body').height();

            window.parent.Stayfree.Content.setOverlayHeight(windowHeight);
        }
    };
})(jQuery);

Stayfree.Under13 = (function ($) {

    // private variables
    var redirect = function () {
        window.parent.location = "/";
    };

    return {
        init: function () {
            setTimeout(redirect, 10000);
        },
        redirect: redirect
    };
})(jQuery);
