function posX(obj)
{
	if (obj.offsetParent == null)
		return 0;
	else
		return posX(obj.offsetParent) + obj.offsetLeft;
}

function posY(obj)
{
	if (obj.offsetParent == null)
		return 0;
	else
		return posY(obj.offsetParent) + obj.offsetTop;
}

function openWindow(url,name,width,height,obj)
{
	var left = posX(obj) + window.screenLeft - document.body.scrollLeft;
	var top = posY(obj) + window.screenTop - document.body.scrollTop;

	if (!window.hWnds)
		window.hWnds = new Array();
	
	var bDone = false;
	if (window.hWnds["name"])
	{
		try
		{
			var hWnd = window.hWnds["name"];
			hWnd.moveTo(left,top);
			if (hWnd.document.location.href.indexOf(url)<0)
			{
				hWnd.document.location = url;
				hWnd.resizeTo(width + 10,height + 46); //??? but it works
			}
			hWnd.focus();
			bDone = true;
		}
		catch (e) {}
	}
	
	if (!bDone)
	{
		var hWnd = window.open(url,name,'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
		window.hWnds["name"] = hWnd;
	}
}

function openScrollableWindow(url,name,width,height,obj)
{
	var left = posX(obj) + window.screenLeft - document.body.scrollLeft;
	var top = posY(obj) + window.screenTop - document.body.scrollTop;

	if (!window.hWnds)
		window.hWnds = new Array();
	
	var bDone = false;
	if (window.hWnds["name"])
	{
		try
		{
			var hWnd = window.hWnds["name"];
			hWnd.moveTo(left,top);
			if (hWnd.document.location.href.indexOf(url)<0)
			{
				hWnd.document.location = url;
				hWnd.resizeTo(width + 10,height + 46); //??? but it works
			}
			hWnd.focus();
			bDone = true;
		}
		catch (e) {}
	}
	
	if (!bDone)
	{
		var hWnd = window.open(url,name,'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',scrollbars=yes');
		window.hWnds["name"] = hWnd;
	}
}