﻿//$(document).ready(function() {

//    var height = $(window).height();
//    $("#block").css("top", height);
//    $("#block").show();
//    $("#block").animate({
//        top: height - 100


//    }, 1500);

//    // Using multiple unit types within one animation.
//    $("#go").click(function() {
//        var height = $(window).height();
//        $("#block").animate({

//            top: height
//        }, 1500, function() { $("#block").hide() });
//    });
//});

jQuery(document).ready(function() {
var wrapper = jQuery(".popUpWrapper");
var popup = jQuery(".popup", wrapper);
var minContent = jQuery(".minPopupContent", popup);
var fullContent = jQuery(".fullPopupContent", popup);

    // Set the height of the page-sized wrapper
var windowHeight = jQuery(window).height() + 1;
    wrapper.css("height", windowHeight);

    // Set the height of the popup (calculated from content) and
    // then slide the popup in (adjusting the 'left' so it's on screen).
    var popupHeight = jQuery(".popup .popupInner").outerHeight(true);

    popup.css("left", 0);

    var min = jQuery.cookie('CP_ContractPopup_Hidden') == 'true';

    fullContent.hide();
    minContent.hide();

    if (min) {
        minContent.slideDown();
        fullContent.hide();
    }
    else {
        minContent.hide();
        fullContent.slideDown("slow");
    }

    // When you click any of the 'read contract' links, mark the cookie as hidden
    jQuery(".popup a").click(function() {
    jQuery.cookie('CP_ContractPopup_Hidden', 'true');
    });

    // When you click close, hide the popup and mark the cookie
    jQuery(".closeButton", fullContent).bind("click", { wrapper: wrapper, popup: popup, minContent: minContent, fullContent: fullContent }, hideContractPopup);

    // When you click open, show the full popup and mark the cookie
    jQuery(".openButton", minContent).bind("click", { wrapper: wrapper, popup: popup, minContent: minContent, fullContent: fullContent }, showContractPopup);

    // For IE6, move page-sized wrapper down as you scroll and
    // resize the wrapper too
    jQuery(window).scroll(function() {
    var wrapper = jQuery(".popUpWrapper");
        var top = jQuery(window).scrollTop();
        var maxTop = jQuery(document).height() - wrapper.outerHeight(true);

        if (top > maxTop) {
            top = maxTop;
        }

        wrapper.css("top", top);
    });

    jQuery(window).resize(function() {
    jQuery(".popUpWrapper").css("height", jQuery(window).height());
    });

    if (jQuery.browser.safari) {
        // Need to get safari to update layout
        wrapper.css("height", windowHeight - 1);
    }
});

function hideContractPopup(event) {
    jQuery.cookie('CP_ContractPopup_Hidden', 'true');

    event.data.minContent.slideDown();
    event.data.fullContent.slideUp();
}

function showContractPopup(event) {
    jQuery.cookie('CP_ContractPopup_Hidden', 'false');

    event.data.minContent.slideUp();
    event.data.fullContent.slideDown();
}
