/* Gets the window position for IE and Firefox, at least */
function windowLeft() {return typeof window.screenLeft != 'undefined' ? window.screenLeft : typeof window.screenX != 'undefined' ?  window.screenX : 0;} 
function windowTop() {return typeof window.screenTop != 'undefined' ? window.screenTop : typeof window.screenY != 'undefined' ?  window.screenY : 0;} 

function popUp(url, width, height, menubar, name, top, left) 
{
	var strName;
	if(!top)
	{
		if(height)
		{
			top = (screen.height / 2 - height / 2);
			if(document.body.offsetHeight == height)
			{
			    top += 50;
			    if(Math.abs(windowTop() - top) < 50)
			    {
			        top += 50;
			    }
			}
		}
		else
			top = 50;
	}
	if(!left)
	{
		if(width)
		{
			left = (screen.width / 2 - width / 2);
			if(document.body.offsetWidth == width)
			{
			    left += 50;
			    if(Math.abs(windowLeft() - left) < 50)
			    {
			        left += 50;
			    }
			}
		}
		else
			left = 100;
	}
	if(name) strName = name; else strName = "popup"
	if (menubar) {
	    var newWindow = window.open(url, strName, 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,left=' + left + ',top=' + top + ',width=' + width + ',height=' + height);
	    newWindow.focus();
	}
	else {
	    var newWindow = window.open(url, strName, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,left=' + left + ',top=' + top + ',width=' + width + ',height=' + height);
	    newWindow.focus();
	}
}

function popUpDrilldown(url,name, width, height)
{
	if (width == null)
		width = 800;
	if (height == null)
		height = 600;
	popUp(url, width, height, false, name);
}

function popUpConfirmation(url,name)
{
	popUp(url, 360, 240, false, name);
}

function popUpLookup(url,hiddenName)
{
	var retVal = false;
	var returnId = "";
	returnId = window.showModalDialog(url,'','dialogHeight:400px;dialogWidth:500px');
	if(returnId != "" && returnId != undefined)
	{
		var hiddenField = document.getElementById(hiddenName);
		hiddenField.value = returnId;
		retVal = true;
	}
	return(retVal);
}
