﻿var ContentPopupManager =
{
	_hideCallback: null,
	
	Init: function(hideCallback)
	{
		this._hideCallback = hideCallback;
		$("#dim").css("height", $(document).height());
		
		$("#dim").click(function(){
			ContentPopupManager.Hide();
		});
		
		$(window).bind("resize", function(){
			$("#dim").css("height", $(document).height());
		});
		
		$(document).keyup(function(e)
		{
			if (e.keyCode == 27) //esc
			{
				ContentPopupManager.Hide();
			}
		});
	},
	
	YoutubeInit: function()
	{
		if ( $.browser.msie && parseFloat($.browser.version) < 7.0 )
		{
			$(".popup-link").attr("onclick", "");
		}
		else
		{
			$(".popup-link").attr("href", "#");
		}
		
		this._hideCallback = null;
	},
	
	Show: function(html, trackingAction, trackingLabel, trackingValue)
	{
		if(trackingAction && trackingAction != "" && trackingLabel && trackingLabel != "")
			trackEvent('Popup', trackingAction, trackingLabel, trackingValue);

		$("#object").append(html);
		$("#dim").show();
		$("#msgbox").show();
	},
	
	Hide: function(ignoreCallback)
	{
		$("#object").html("");
		$("#dim").hide();
		$("#msgbox").hide();

		if(!ignoreCallback && this._hideCallback)
		{
			this._hideCallback();
		}
	},

	ShowYoutubeOverlay: function (youtubeId) {
		var html = '<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/' + youtubeId + '?fs=1&amp;color1=0x3a3a3a&amp;color2=0x999999" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed src="http://www.youtube.com/v/' + youtubeId + '?fs=1&amp;color1=0x3a3a3a&amp;color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>';
		ContentPopupManager.Show(html);
	}
}
