function posTop() {
    return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}

function centerContent() {
        var contentHeight = (document.documentElement.clientHeight + (2 * posTop()))-125;
        var contentWidth = document.documentElement.clientWidth -42;
		if (navigator.platform == 'iPad') {
            var iContentHgt = ($(document).height()) - 125;
			var iContentWidth = ($(document).width());
            $('section').css("min-height",iContentHgt);
        } else {
            $('section').css("min-height",contentHeight);
        }
    }
	
function newPop(popupID, triggerClass) {
    var popupStatus = 0;
    var div = "#" + popupID + ".popup";
    var trigger = "a." + triggerClass;

    function loadPopup() {
        if (popupStatus == 0) {
            $("#backgroundPopup").css({ "opacity": "0.7" });
            $("#backgroundPopup").fadeIn("slow");
            $(div).fadeIn("slow");
            popupStatus = 1;
        }
    }
    function disablePopup() {
        if (popupStatus == 1) {
            $("#backgroundPopup").fadeOut("slow");
            $(div).fadeOut("slow");
            popupStatus = 0;
        }
    }
    function centerPopup() {
        var windowWidth = document.documentElement.clientWidth;
        var windowHeight = document.documentElement.clientHeight + (2 * posTop());
        var popupHeight = $(div).height();
        var popupWidth = $(div).width();
        $(div).css({ "position": "absolute", "top": windowHeight / 2 - popupHeight / 2, "left": windowWidth / 2 - popupWidth / 2 });
        $("#backgroundPopup").css({ "height": windowHeight });
    }

    $(trigger).click(function(event) {
        centerPopup();
        loadPopup();
        event.preventDefault();
    });

    $("a.close").click(function(event) {
        disablePopup();
        event.preventDefault();
    });
    $("#backgroundPopup").click(function () {
        disablePopup();
    });

    $(document).keypress(function (e) {
        if (e.keyCode == 27 && popupStatus == 1) {
            disablePopup();
        }
    });
}
