function tpGet(id)
{
	return document.getElementById(id);
}
function showGlassPaneByObj(obj,glassPaneId)
{
	var pos = getOffset(obj);
	var w = obj.offsetWidth;
	var h = obj.offsetHeight;
	showGlassPaneByRect(pos[0],pos[1],w,h,glassPaneId);
}
function showGlassPaneByRect(x,y,w,h,glassPaneId)
{
	if(!glassPaneId)
	{
		glassPaneId = 'tpGlassPaneDiv';
	}
	var div1 = tpGet(glassPaneId);
	div1.style.left = x;
	div1.style.top = y;
	div1.style.width = w;
	div1.style.height = h;
	div1.style.display = 'block';
}
function hideGlassPane()
{
	tpGet('tpGlassPaneDiv').style.display = 'none';
	tpGet('tpGlassPaneDiv2').style.display = 'none';
}
var showDarkGlassPaneInit = false;
function showDarkGlassPane()
{
	var div = tpGet('tpGlassPaneDarkDiv');
	var ua = navigator.userAgent.toLowerCase();
	if(!showDarkGlassPaneInit && ua.indexOf('msie') != -1)
	{
		div.parentNode.removeChild(div);
		document.body.insertBefore(div, document.body.childNodes[0]);
		div = tpGet('tpGlassPaneDarkDiv');

		div.style.position = 'absolute';
		div.style.setExpression("width", "document.body.clientWidth");
		div.style.setExpression("height", "document.body.clientHeight");
		div.style.setExpression("top", "(document.body.scrollTop) + 'px'");
		div.style.setExpression("left", "(document.body.scrollLeft) + 'px'");
		document.body.onscroll = function() {
			tpGet('tpGlassPaneDarkDiv').style.top = (document.body.scrollTop) + 'px';
			tpGet('tpGlassPaneDarkDiv').style.left = (document.body.scrollLeft) + 'px';
		}
		div.style.display = 'block';
	} else {
		div.style.height=document.body.clientHeight;
		div.style.position = 'fixed';
		div.style.display = 'block';
		document.body.onscroll = function() {
			tpGet('tpGlassPaneDarkDiv').style.top = (document.body.scrollTop) + 'px';
			tpGet('tpGlassPaneDarkDiv').style.left = (document.body.scrollLeft) + 'px';
		}
	}
	disableSelects();
	showDarkGlassPaneInit = true;
}
function hideDarkGlassPane()
{
	tpGet('tpGlassPaneDarkDiv').style.display = 'none';
	enableSelects();
}
var vodPopupInit = false;
function showPopup(id)
{
	showDarkGlassPane();
	var obj = tpGet(id);
	var ua = navigator.userAgent.toLowerCase();
	if(ua.indexOf('msie') == -1)
	{
		obj.style.position = 'fixed';
		obj.style.zIndex = 99998;
		obj.style.display = 'block';
		var w = obj.offsetWidth;
		var h = obj.offsetHeight;
		obj.style.left = parseInt((document.body.clientWidth-w)/2);
		obj.style.top = parseInt((document.body.clientHeight-h)/2);
	}
	else
	{
		if(id=='vodPopup' && !vodPopupInit)
		{
			vodPopupInit = true;
			obj.parentNode.removeChild(obj);
			document.body.insertBefore(obj, document.body.childNodes[0]);
			obj = tpGet(id);
		}
		obj.style.position = 'absolute';
		obj.style.zIndex = 99998;
		obj.style.display = 'block';
		var w = obj.offsetWidth;
		var h = obj.offsetHeight;		
		obj.style.left = parseInt((document.body.clientWidth-w)/2);
		obj.style.top = document.body.scrollTop + parseInt((document.body.clientHeight-h)/2);
	}
	try {
		var close = tpGet('tpPopupCloseButton');
		close.style.display="block";	
	} catch (e) { }
}
function hidePopup(id)
{
	hideDarkGlassPane();
	tpGet(id).style.display='none';
}
function getOffset(obj)
{
	var l=0,t=0;
	do
	{
		l += obj.offsetLeft || 0;
		t += obj.offsetTop  || 0;
		obj = obj.offsetParent;
	}
	while(obj);
	return [l,t];
}
function disableSelects()
{
	var ua = navigator.userAgent.toLowerCase();
	if(ua.indexOf('msie') != -1)
	{
		var tab = document.getElementsByTagName('select');
		for(var i=0;i<tab.length;i++)
		{
			tab[i].style.visibility = 'hidden';
		}
	}
}
function enableSelects()
{
	var ua = navigator.userAgent.toLowerCase();
	if(ua.indexOf('msie') != -1)
	{
		var tab = document.getElementsByTagName('select');
		for(var i=0;i<tab.length;i++)
		{
			tab[i].style.visibility = 'visible';
		}
	}
}