$(function() {
	$("#info-popup").hide().each(function() {
		function openCard(href) {
			if ($("#info-popup").is(":not(:visible)")) {
				$("<div id='overlay'></div>")
					.css({ opacity: 0 }).appendTo("body").show()
					.fadeTo("fast", 0.5, function() {
						$("#info-popup").css({top: centerVert(683)}).show()
					})
					.click(closePopup)
			}
		}
		
		function closePopup() {
			$("#info-popup").hide()
			$("#overlay").fadeOut("fast", function() {
				$(this).remove();
			})
			return false
		}
		
		$(this).find("a.close").click(closePopup)
		$(this).find("a.close2").click(closePopup)
		
		$(".info-content").css({ position: "absolute", top: 0, left: 0 })
		
		$("#upcoming-menu a").click(function() {
			openCard($(this).attr("href"));
			return false
		})
		
	
		$("#info-menu a").click(function() {
			openCard($(this).attr("href"));
			return false
		})
	})
})

function centerVert(h) {
	var wh = (window.innerHeight ?
		window.innerHeight : document.documentElement.clientHeight)
	var p = (wh - h < 0) ? 0 : wh - h;
	var s = (window.scrollY ? 
		window.scrollY : document.documentElement.scrollTop)
	return (s + (p / 2));
}

function open(href) {
			if ($("#info-popup").is(":not(:visible)")) {
				$("<div id='overlay'></div>")
					.css({ opacity: 0 }).appendTo("body").show()
					.fadeTo("fast", 0.5, function() {
						$("#info-popup").css({top: centerVert(683)}).show()
					})
					.click(closePopup)
			}
		}
