function initOverlay() {
	$("a[rel='form'], a[rel='rules']")
	.click(
		function(event) {
			event.preventDefault();
			var thisButton = this;
			$("#overlay").css({'opacity' : '0.9'}).fadeIn("normal").queue(function () {
				var objectSelector = '.popDiv.' + $(thisButton).attr('rel');
				var object = $(objectSelector);
				
				var objectHeight = object.height();
				var windowHeight = getWindowHeight();
				if (windowHeight > objectHeight)
				{
					var marginTop = (Math.round(object.height()/2) * -1) + "px";
					object.css({'top':'50%','margin-top':marginTop});
				}
				else
				{
					object.css({'top':'0px','margin-top':'0px'});
				}
				
				object.fadeIn("normal");
				$(this).dequeue();
			});
		}
	);
	function detectMacXFF2() {
		var userAgent = navigator.userAgent.toLowerCase();
		if (/firefox[\/\s](\d+\.\d+)/.test(userAgent)) {
			var ffversion = new Number(RegExp.$1);
			if (ffversion < 3 && userAgent.indexOf('mac') != -1) {
				return true;
			}
		}
	}
	$("a[rel='killer_insert']")
	.click(
		function(event) {
			event.preventDefault();
			var thisButton = this;
			
			var ff2 = detectMacXFF2();
			if (ff2)
			{
				$("#overlay").show();
				
				/*var checkSlideshow = $('#slideshow');
				if (checkSlideshow != null)
				{
					slideshowAutoplay(false);
				}*/
				if ($('#slideshow'))
				{
					$('#slideshow').css('display','none');
				}
				if ($('.BrightcoveExperience'))
				{
					$('.BrightcoveExperience').css('display','none');
				}
				var objectSelector = '.popDiv.' + $(thisButton).attr('rel');
				var object = $(objectSelector);
				
				var objectHeight = object.height();
				var windowHeight = getWindowHeight();
				if (windowHeight > objectHeight)
				{
					var marginTop = (Math.round(object.height()/2) * -1) + "px";
					object.css({'top':'50%','margin-top':marginTop});
				}
				else
				{
					object.css({'top':'0px','margin-top':'0px'});
				}
				
				object.show();
			}
			else
			{
				$("#overlay").css({'opacity' : '0.9'}).fadeIn("normal").queue(function () {
					var objectSelector = '.popDiv.' + $(thisButton).attr('rel');
					var object = $(objectSelector);
					
					var objectHeight = object.height();
					var windowHeight = getWindowHeight();
					if (windowHeight > objectHeight)
					{
						var marginTop = (Math.round(object.height()/2) * -1) + "px";
						object.css({'top':'50%','margin-top':marginTop});
					}
					else
					{
						object.css({'top':'0px','margin-top':'0px'});
					}
					
					object.show();
					$(this).dequeue();
				});
			}
		}
	);
	$("#overlay, a[rel='closePopDiv']")
	.click(
		function(event) {
			event.preventDefault();
			
			var ff2 = detectMacXFF2();
			if (ff2)
			{
				if ($('#slideshow'))
				{
					$('#slideshow').css('display','');
				}
				if ($('.BrightcoveExperience'))
				{
					$('.BrightcoveExperience').css('display','');
				}
				$(".popDiv:visible").hide();
				$("#overlay").fadeOut("normal");
			}
			else
			{
				$(".popDiv:visible").fadeOut("normal").queue(function () {
					$("#overlay").fadeOut("normal");
					$(this).dequeue();
				});
			}
		}
	);
	function getWindowHeight() {
	  var myWidth = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	  }
	  return myHeight;
	  //window.alert( 'Width = ' + myWidth );
	  //window.alert( 'Height = ' + myHeight );
	};
}
