$(document).ready(function () {
    /* Transition Slideshow */
    var setControls = function (c, n, options, f) {
        $("#slideshow_controls li a").removeClass("selected");
        $($("#slideshow_controls").children()[(options.slideCount - 1) - options.currSlide]).children(":first").addClass("selected");
    };
    $("#slideshow").cycle({
        speed: 1000,
        timeout: 6000,
        after: setControls
    });
    /* Unhide Controls */
    $("#slideshow_controls").removeClass("hide");
    /* Add Events */
    $("#slideshow_controls").children().each(function () {
        $(this).first().click(function () {
            // Due to the float right the list is reversed.
            var slideCount = $("#slideshow_controls").children().length,
                slideIndex = slideCount - $(this).index() - 1;
            $("#slideshow").cycle(slideIndex);
            $("#slideshow").cycle("pause");
            // So it doesn't lag on the after callback
            setControls(null, null, { currSlide: slideIndex + 1, slideCount: slideCount + 1 }, null);
            // Stop event
            return false;
        });
    });
    if ($.cookie("merger") == null) {
        tt.overlay({
            width: 400,
            height: 380,
            shadeClose: false,
            content: function () {
                $("#overlay_close").css({ "z-index": 9999 });
                var title = "Announcing our merger!";
                $(this.container).empty();
                $(this.container).addClass("merger");

                $(this.container).append('<div class="title">' + title + '<a href="" id="overlay_x">X</a></div>');

                $(this.container).append('<p>On 12/8/2011, Triton-Tek agreed to be acquired by Maven Wave Partners.  Though our name is changing, Triton-Tek will continue to develop leading internet, mobile, and collaborative solutions for our clients.  By joining the Maven Wave platform, we will be better able to serve clients from the formation of a business idea through technology delivery both on premise and in the cloud.</p>');

                $(this.container).append('<p><a href="http://www.prweb.com/releases/MavenWave/TritonTek/prweb9000865.htm">Please read the Press Release</a></p>'); //More details can be found here
                $(this.container).append('<p style="padding:0 10px;"><a href="http://www.mavenwave.com/" target="_blank">Learn more about Maven Wave</a></p>');
                $(this.container).append('<p style="padding:0 10px;"><a href="http://triton-tek.com/" id="learn_more">Learn more about Triton-Tek</a></p>');

                $("#learn_more").click(function () {
                    $.cookie("merger", "closed");
                    tt.removeOverlay();
                    return false;
                });

                $("#overlay_x").click(function () {
                    $.cookie("merger", "closed");
                    tt.removeOverlay();
                    return false;
                });
            }
        });
    }
});
