var sicretId1 = '\'webmailpopup1\''; //used in home/2009/popups.jsp
var sicretId2 = '\'webmailpopup2\''; //used in home/2009/popups.jsp
var sicretId3 = '\'webmailpopup3\''; //used in home/2009/popups.jsp

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 showDarkGlassPaneInit2 = false;
function showDarkGlassPane2(id)
{
	var div = tpGet('tpGlassPaneDarkDiv');
	var ua = navigator.userAgent.toLowerCase();
	if(!showDarkGlassPaneInit2 && 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() {
			//console.log(tpGet('tpGlassPaneDarkDiv').style.top,document.body.scrollTop);
			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';
		if (ua.indexOf('msie') != -1) {
		document.body.onscroll = function() {
		//console.log(tpGet('tpGlassPaneDarkDiv').style.top,document.body.scrollTop);
			tpGet('tpGlassPaneDarkDiv').style.top = (document.body.scrollTop) + 'px';
			tpGet('tpGlassPaneDarkDiv').style.left = (document.body.scrollLeft) + 'px';
		}
		}
	}
	disableSelectsOut(id);
	showDarkGlassPaneInit2 = true;
}
var vodPopupInit = false;
function showPopup(id)
{
	showDarkGlassPane2(id);
	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';
}
var tpLastPopupId = null;
var tpLastPopupId2 = null;
function showPopup2(id,noClose)
{
	tpLastPopupId = id;
	tpLastPopupId2 = 'mfPopupCloseButton';
	showDarkGlassPane2(id);
	var obj = tpGet(id);
	obj.parentNode.removeChild(obj);
	document.body.insertBefore(obj, document.body.childNodes[0]);
	obj = tpGet(id);
	if (noClose!=true) {
	try {
		var close = tpGet('mfPopupCloseButton');
		close.parentNode.removeChild(close);
		document.body.insertBefore(close, obj);
		close = tpGet('mfPopupCloseButton');
	} catch (e) { 
		try {
			var close = tpGet('tpPopupCloseButton');
			close.parentNode.removeChild(close);
			document.body.insertBefore(close, obj);
			close = tpGet('tpPopupCloseButton');
		} catch (e) {}
	}
	}
	var ua = navigator.userAgent.toLowerCase();
	var l=0;
	var t=0;
	if(ua.indexOf('msie') == -1)
	{
		if (noClose!=true) { close.style.position = 'fixed'; }
		obj.style.position = 'fixed';
		obj.style.zIndex = 99998;/*998;*/
		obj.style.display = 'block';
		var w = obj.offsetWidth;
		var h = obj.offsetHeight;
		l = parseInt((document.body.clientWidth-w)/2);
		t = parseInt((document.body.clientHeight-h)/2);
	}
	else
	{
		if (noClose!=true) { close.style.position = 'absolute'; }
		obj.style.position = 'absolute';
		obj.style.zIndex = 99998/*998;*/
		obj.style.display = 'block';
		var w = obj.offsetWidth;
		var h = obj.offsetHeight;		
		l = parseInt((document.body.clientWidth-w)/2);
		t = document.body.scrollTop + parseInt((document.body.clientHeight-h)/2);
	}
	if (l<13) l=15; if (t<13) t=15; 
	obj.style.left = l+'px';
	obj.style.top = t+'px';
	if (!noClose) {
		close.style.left = l-13;
		close.style.top = t-13;
		close.style.display='block';
		//setTimeout('tpGet(\'mfPopupCloseButton\').getElementsByTagName(\'a\')[0].focus()',100);
	}
}
function hidePopup2(id,fun)
{
	hideDarkGlassPane();
	if(id) tpGet(id).style.display='none';
	if(tpLastPopupId && document.getElementById(tpLastPopupId)){
		if(tpLastPopupId!=null) tpGet(tpLastPopupId).style.display='none';
	}
	if(tpLastPopupId2 && document.getElementById(tpLastPopupId2) ){	
		if(tpLastPopupId2!=null) tpGet(tpLastPopupId2).style.display='none';
	}
	tpLastPopupId = null; tpLastPopupId2 = null;
	try {
		tpGet('mfPopupCloseButton').style.display='none';
	} catch (e) { }
	try {
		tpGet('tpPopupCloseButton').style.display='none';
	} catch (e) { }
	try {
		return fun();
	} catch (e) { }
}
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 disableSelectsOut(id)
{
	disableSelects();
	var ua = navigator.userAgent.toLowerCase();
	//if(ua.indexOf('msie') != -1)
	//{
		var div = document.getElementById(id);
		if (div != null) {
		var tab = div.getElementsByTagName('select');
		for(var i=0;i<tab.length;i++)
		{
			tab[i].style.visibility = 'visible';
		}
		}
	//}
}
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';
		}
	}
}
