var stopPage =
{
    show: function (subscription) {
        if ($("#backgroundOverlayTemp").length == 0) {

            var stopPage = $("#stopPageOverlay");
            var centerx = ($(document).width() - stopPage.width()) / 2;
            var centery = ($(document)[0].body.offsetHeight - stopPage.height()) / 2;
            stopPage.css('left', centerx);
            stopPage.css('top', centery);
            var bgOverlay = $("#backgroundOverlay").clone(true);
            bgOverlay.css('position', 'absolute');
            bgOverlay.width($(document).width());
            bgOverlay.height($(document).height());
            bgOverlay.css('top', '0');
            bgOverlay.css('left', '0');
            bgOverlay.attr("id", "backgroundOverlayTemp");
            bgOverlay.appendTo('body');
            //$("#container").prepend($("#stopPageOverlay"));
            $(bgOverlay).children().append($("#stopPageOverlay"));

        }

        $("#backgroundOverlayTemp").height($("#container").outerHeight()).show();
        scroll(0, 0);
        var subscriptionOverlay = this.GetSubscriptionOverlay(subscription);

        $("#stopPageOverlay").empty().html($(subscriptionOverlay).html());
        $("#stopPageOverlay").fadeIn();

        var allVisibleInputs = $("select:visible");
        var count = $(allVisibleInputs).length;
        $(allVisibleInputs).each(function () {
            $(this).attr("ThisWasVisible", "true");
            $(this).hide();
        });
        return false;
    }
    ,
    hide: function () {

        $("#stopPageOverlay").fadeOut(function () { $("#backgroundOverlayTemp").hide(); });
        $("[ThisWasVisible=true]").show();
        return false;
    },
    GetSubscriptionOverlay: function (subscription) {
        if (subscription) {
            var subscriptions = subscription.split(',');
            for (var i = 0; i < subscriptions.length; i++) {
                if (subscriptions[i].match("(AP15)")) {
                    return "#stopPageOverlayAP15";
                }
                if (subscriptions[i].match("(APA)")) {
                    return "#stopPageOverlayAPA";
                }
            }
        }
        return "#stopPageOverlayAPAP15";
    }
};
