
var viewer = null;

function doWindow(name,url,width,height,sbars)
{
	window.open(url, name, 'width=' + width + ',height=' + height + ',' + getPosition(width, height) + ',resizable=no,scrollbars=' + ((sbars) ? 'yes': 'no') + ',status=1');
	
	return false;
}

function closeWindow(refresh)
{
	if(refresh && window.opener.refreshPage != null)
		window.opener.refreshPage();
	
	window.close();
}

function getPosition(width, height)
{
	var winTop 		= (screen.height - height) / 2;
	var	winLeft 	= (screen.width - width) / 2;
	
	return "screenX=" + winLeft + ",left=" + winLeft + ",screenY=" + winTop + ",top=" + winTop;
}

function refreshPage()
{
	window.location.reload();
}

function doViewer(url,width,height)
{
	if(viewer != null)
		viewer.close();
	
	viewer = window.open(url, "viewer", 'width=' + width + ',height=' + height + ',' + getPosition(width, height) + ',resizable=yes,scrollbars=auto,status=0');
	
	return false;
}

function doPageTask(task)
{
	if(window[task] != null)
		return window[task]();
	
	return true;
}
