function createJingPop()
{
	var sample = document.getElementById('container').getElementsByTagName('*');
	var jingPop = new Array;
	var jingClick = new Array;
	for (var i = 0; i < sample.length; i++)
	{
		if (sample[i].className == 'media jingPopClass')
		{
			jingPop.push(sample[i]);
		}
	}
	
	for (i = 0; i < jingPop.length; i++)
	{
		jingPop[i].removeChild(jingPop[i].getElementsByTagName('script')[0]);
		jingPop[i].content = jingPop[i].innerHTML;
		
		// create replacement
		jingClick[i] = document.createElement('div');
		jingClick[i].className = 'jing';
		jingPop[i].parentNode.replaceChild(jingClick[i], jingPop[i]);
	}
	
	for (i = 0; i < jingClick.length; i++)
	{
		jingClick[i].iter = i;
		jingClick[i].onclick = function()
		{
			jwMediaPopJing(jingPop[this.iter]);
		}
	}
}

function jwMediaPopJing(obj)
{
	var tmp = obj.content.split(/thumb=/i);
	tmp = tmp[1].split(/"|'/);
	var flashVars = 'thumb=' + tmp[0];
	tmp = flashVars.split(/width=/i);
	tmp = tmp[1].split('&');
	var width = tmp[0];
	tmp = flashVars.split(/height=/i);
	var height = tmp[1];
	
	// create background
	if (!document.getElementById('jingBoxBg'))
	{
		var bg = document.createElement('div');
		bg.id = 'jingBoxBg';
		bg.style.width = document.documentElement.clientWidth + 'px';
		if (document.documentElement.scrollHeight < document.documentElement.clientHeight)
		{
			bg.style.height = document.documentElement.clientHeight + 'px'
		}
		else
		{
			bg.style.height = document.documentElement.scrollHeight + 'px';
		}
		bg.style.position = 'absolute';
		bg.style.top = 0;
		bg.style.left = 0;
		bg.style.zIndex = 15;
		bg.style.opacity = .6;
		bg.style.filter = 'alpha(opacity=60)';
		bg.style.background = '#000';
		document.body.appendChild(bg);
		
		// fix Firefox 2 Mac bug
		if (navigator.platform.match(/Mac/))
		{
			if (navigator.userAgent.match(/Firefox\/2/))
			{
				bg.style.opacity = '';
				bg.style.background = 'transparent';
			}
		}
	}
	
	// create scroll variable
	var scroll = window.pageYOffset || document.documentElement.scrollTop;
	
	// create panel
	var panel = document.createElement('div');
	panel.style.width = width + 'px';
	panel.style.height = parseInt(height) + 22 + 'px';
	panel.style.padding = '10px 10px 0';
	panel.style.position = 'absolute';
	panel.style.left = (document.documentElement.clientWidth - width - 20) / 2  + 'px';
	panel.style.top = (document.documentElement.clientHeight - height - 32) / 2  + scroll + 'px';
	if (parseInt(panel.style.top) < 0)
	{
		panel.style.top = 0;
	}
	panel.style.zIndex = 150;
	panel.style.background = '#fff';
	
	
	obj.className = '';
	obj.style.width = width + 'px';
	obj.style.height = height + 'px';
	obj.style.background = "url('/themes/mscCommon1/images/loading.gif') no-repeat center #fff";
	panel.appendChild(obj)
	
	// create close
	var close = document.createElement('div');
	close.style.height = '19px'
	close.style.paddingTop = '3px';
	close.style.paddingRight = '2px';
	close.style.cursor = 'pointer';
	close.style.textAlign = 'right';
	close.style.fontWeight = 'bold';
	close.style.background = '#fff';
	close.innerHTML = 'Close';
	close.onmouseover = function()
	{
		close.style.color = '#c00';
	}
	close.onmouseout = function()
	{
		close.style.color = '#000';
	}
	close.onclick = function()
	{
		// drop panel from document
		document.body.removeChild(this.parentNode);
		document.body.removeChild(bg);
		
		// allow more pops
		obj.onclick = function()
		{
			jwMediaPopJing(this);
		}
	}
	panel.appendChild(close);
	
	// insert panel into document
	document.body.appendChild(panel);
	
	// prevent more pops
	obj.onclick = null;
}

var loadEvent = window.onload;
if (typeof loadEvent != 'function')
{
	window.onload = function()
	{
		createJingPop();
	};
}
else
{
	window.onload = function()
	{
		loadEvent();
		createJingPop();
	};
}