﻿// Special Pricing Box at the top of the page
(function($) {
    $.fn.createSpecialPricingBox = function() {
        // Check cookie. If the user is a member, then hide this completely, otherwise show this as maximized
        var cookied = false;

        var isFM = $.cookies.get("IsFisherMember");
        if (isFM == '1') {
            cookied = true;
        }

        if (cookied) {
            $("#alert").hide();
        }
        else {
            // Now check for a cookie for minimization

            var minimize = $.cookies.get("FisherMinimize");

            if (minimize == "true") {
                // Hide the padding for the maximized version
                $("div.alert-padder").hide();
                $(".account-info").hide();                          // Hide first for smooth animation
                $("#btn-toggle").html("Click for Details");         // Change text for toggle link
                $("#btn-toggle").css("background", "url(/common/images/icon-maximize.gif) no-repeat right center");

                $("#maximized").hide();
                $("div.alert-ctn").addClass("alert-ctn-min").removeClass("alert-ctn");
            }
            else {
                // Hide the padding for the minimized version
                $("div.alert-padder-min").hide();
                $("#btn-toggle").css("background", "url(/common/images/icon-minimize.gif) no-repeat right center");
            }

            $("#btn-toggle").click(function() {
                // If currently maximized
                if ($("#maximized").is(":visible")) {
                    $(".account-info").hide();                      // Hide first for smooth animation
                    $("#btn-toggle").html("Click for Details");     // Change text for toggle link
                    $("#btn-toggle").css("background", "url(/common/images/icon-maximize.gif) no-repeat right center");

                    $("#maximized").slideUp();                      // Animate + hide the maximized content
                    $("div.alert-padder").slideUp();                // Animate + hide the padding for the maximized version
                    $("div.alert-padder-min").slideDown();          // Animate + show the padding for the minimized version
                    $("div.alert-ctn").addClass("alert-ctn-min").removeClass("alert-ctn");

                    // Set the cookie to keep maximized
                    var options = { hoursToLive: 24 };
                    $.cookies.set("FisherMinimize", "true", options);
                }
                // If currently minimized
                else {
                    $(".account-info").show();                      // Show first for smooth animation
                    $("#btn-toggle").html("Minimize");              // Change text for toggle link
                    $("#btn-toggle").css("background", "url(/common/images/icon-minimize.gif) no-repeat right center");

                    $("#maximized").slideDown();                    // Animate + show the maximized content
                    $("div.alert-padder").slideDown();              // Animate + show the padding for the maximized version
                    $("div.alert-padder-min").slideUp();            // Animate + hide the padding for the minimized version
                    $("div.alert-ctn-min").addClass("alert-ctn").removeClass("alert-ctn-min");

                    // Set the cookie to keep minimized
                    var options = { hoursToLive: 24 };
                    $.cookies.set("FisherMinimize", "false", options);
                }
                return false;
            });
        }
    };
})(jQuery);
