		var popupWidth, popupHeight, originalDocumentWidth;
		
		function showPopup(title, flashUrl, width, height)
		{
			var elSource = document.getElementById('popupSource');
			var el = document.getElementById('popupMask');
			var elContent = document.getElementById('popupContent');
		
			// Store input dimensions
			popupWidth = width;
			popupHeight = height;
			originalDocumentWidth = document.documentElement.scrollWidth;
			
			// Copy source html into elContent
			elContent.innerHTML = elSource.innerHTML.split("<!--@Title-->").join(title);
			
			// Load SWF
			if(flashUrl.indexOf('swf') > 0)
			{
				var so = new SWFObject(flashUrl + "?rndm=" + Math.round(1000*Math.random()), "flvplayer", width, height, "8", "#FFFFFF");
				so.addParam("wmode","transparent");
				so.write("swfFlvPlayer");
			}
			else
			{
				var so = new SWFObject("/Files/System/JOM/Js/Player.swf?rndm=" + Math.round(1000*Math.random()), "flvplayer", width, height, "8", "#FFFFFF");
				so.addParam("wmode","transparent");
				so.addParam("salign","tl");
				so.addVariable("skinName","/Files/System/JOM/Js/SteelExternalAll.swf");
				so.addVariable("streamHeight","288");
				so.addVariable("streamName",flashUrl);
				so.write("swfFlvPlayer");
			}
			
			// Set dimensions
			setPopupDimensions(el, elContent);
			
			// Set visibility
			el.style.display = '';
			elContent.style.display = '';
			
			// Detect resizes
			window.onresize = setPopupDimensions;
			window.onscroll = setPopupDimensions;
		}
		
		function setPopupDimensions(el, elContent, width, height)
		{	
			var elSource = document.getElementById('popupSource');
			var el = document.getElementById('popupMask');
			var elContent = document.getElementById('popupContent');
			
			// Get stored dimensions
			
			width = popupWidth;
			height = popupHeight;
			
			// The SWF needs some extra margins
			width = width + 12;
			height = height + 2;
			
			// Get scroll position
			var scrollY = document.documentElement.scrollTop;
			var scrollX = document.documentElement.scrollLeft;
			
			// Get document dimensions
			var documentHeight = document.body.clientHeight > document.documentElement.clientHeight ? document.body.clientHeight : document.documentElement.clientHeight;
			var documentWidth = originalDocumentWidth < document.documentElement.scrollWidth ? originalDocumentWidth : document.documentElement.scrollWidth;
			
			// Get browser dimensions
			if(self.innerHeight)
				var innerHeight = self.innerHeight;
			else
				var innerHeight = document.body.clientHeight;
				
			var innerWidth = document.body.clientWidth < document.body.clientWidth ? document.body.clientWidth : document.body.clientWidth;
			
			if(documentWidth < innerWidth)
				documentWidth = innerWidth;
			
			// Set dimensions of background mask
			el.style.width = documentWidth + 'px';
			el.style.height = documentHeight + 'px';
			el.style.top = 0;
			el.style.left = 0;
			
			// Set dimensions of content
			elContent.style.width = width + 'px';
			elContent.style.height = height + 'px';
			elContent.style.top = (scrollY + innerHeight / 2 - height / 2 - 48 / 2) + 'px';
			elContent.style.left = (scrollX + innerWidth / 2 - width / 2) + 'px';
			//alert(elContent.style.top + "//" + elContent.style.left);
			//alert("width:"+width+"\nheight:"+height+"\nscrollY:"+scrollY+"\nscrollX:"+scrollX+"\ndocumentWidth:"+documentWidth+"\ndocumentHeight:"+documentHeight+"\ninnerWidth:"+innerWidth+"\ninnerHeight:"+innerHeight);
		}
		
		function cancelPopup()
		{
			// Hide view
			document.getElementById('popupMask').style.display = 'none';
			document.getElementById('popupContent').style.display = 'none';
			document.getElementById('swfFlvPlayer').innerHTML = '';
			
			// Don't handle resizes
			window.onresize = null;
			window.onscroll = null;
		}