var open_popup = "";

function showPopUp(type, bgtype)
{
	open_popup = type;
	
	var bg=document.getElementById(bgtype == null ? "popupbg" : bgtype);
	var popup=document.getElementById(type);
	
	var bgw = 0;
	var bgh = 0;
	if (document.body && document.body.clientWidth)
	{
		bgw = document.body.clientWidth;
		bgh = document.body.clientHeight;
	}
	var bgw2 = 0;
	var bgh2 = 0;
	if (window.innerWidth)
	{
		bgw2 = window.innerWidth;
		bgh2 = window.innerHeight;
	}
	if (document.documentElement.clientWidth)
	{
		if (bgw2 < document.documentElement.clientWidth)
			bgw2 = document.documentElement.clientWidth;
		if (bgh2 < document.documentElement.clientHeight)
			bgh2 = document.documentElement.clientHeight;
	}
	if (bgw > 0)
	{
		//if (bgw2 > bgw)
			//bgw = bgw2;
		if (bgh2 > bgh)
			bgh = bgh2;
		bg.style.width = bgw + "px";
		bg.style.height = bgh + "px";
	}
//	alert(document.body.clientWidth + " x " + document.body.clientHeight + "\n" + window.innerWidth + " x " +  window.innerHeight + "\n" + document.documentElement.clientWidth + " x " + document.documentElement.clientHeight);
	bg.style.display="block";
	popup.style.display="block";
	
	var width=GetWidth();
	var height=GetHeight();
	
	if (type == "change_pass")
	{
		popup.style.top=(getScrollXY()[1] + (height-250)/2)+"px";
		popup.style.left=(width-285)/2+"px";
	}
	else
	{
		popup.style.top=(getScrollXY()[1] + (height-436)/2)+"px";
		popup.style.left=(width-605)/2+"px";
	}
}
function closepopUp()
{
	var bg=document.getElementById("popupbg");
	var bg2=document.getElementById("popupbg2");
	var popup=document.getElementById(open_popup);
	
	bg.style.display="none";
	bg2.style.display="none";
	popup.style.display="none";
}
function GetHeight()
{
	var y = 0;
	if (self.innerHeight)
	{
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		y = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		y = document.body.clientHeight;
	}
	return y;
}
function GetWidth()
{
	var y = 0;
	if (self.innerWidth)
	{
		y = self.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		y = document.documentElement.clientWidth;
	}
	else if (document.body)
	{
		y = document.body.clientWidth;
	}
	return y;
}

function getScrollXY() {
var scrOfX = 0, scrOfY = 0;
if( typeof( window.pageYOffset ) == 'number' ) {
//Netscape compliant
scrOfY = window.pageYOffset;
scrOfX = window.pageXOffset;
} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
//DOM compliant
scrOfY = document.body.scrollTop;
scrOfX = document.body.scrollLeft;
} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
//IE6 standards compliant mode
scrOfY = document.documentElement.scrollTop;
scrOfX = document.documentElement.scrollLeft;
}
return [ scrOfX, scrOfY ];
}

