// for 'internal' use only, use OpenWindowCentered() instead
function _OpenWindowCentered(WinName, url, WinWidth, WinHeight, WinOptions)
{
	// validate required parameter
	if (url == null) alert("_OpenWindowCentered: missing url")

	// set default window width
	if (WinWidth == null) WinWidth = 650

	// set default window height
	if (WinHeight == null) WinHeight = 540

	if (WinOptions == null)
	{
		// set default window options
		WinOptions = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0"
	}
	
	if (WinName == null)
	{
		// default create new new, unnamed window
		WinName = "_blank"
	}
	
	// half the screen width minus half the new window width (plus 5 pixel borders).
	var WinLeft = (window.screen.width/2) - ((WinWidth/2) + 10)
	// half the screen height minus half the new window height (plus title and status bars).
	var WinTop = (window.screen.height/2) - ((WinHeight/2) + 50)
	
	// open the window
	var newwin = window.open(url, WinName, "width=" + WinWidth + ",height=" + WinHeight + ",left=" + WinLeft + ",top=" + WinTop + "," + WinOptions)

	// set the focus to it
	if (newwin) newwin.focus()
	
	return newwin
}

// create new window on the center of the screen
function OpenWindowCentered(url, WinWidth, WinHeight, WinOptions)
{
	_OpenWindowCentered('_blank', url, WinWidth, WinHeight, WinOptions)
}

function ContentEdit(url)
{
	_OpenWindowCentered('ContObj', url, 600, 370)
}

function TextEdit(url)
{
    _OpenWindowCentered('ContObj', url, 600, 100)
}

// reopen (or create) window on the center of the screen (for dialog purposes)
function OpenDialogWindow(WinName, url, scrollbars)
{
    if (scrollbars != null && scrollbars)
	{
		WinOptions = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0'
	}
	else
	{
		WinOptions = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0'
	}
	window.open(url, WinName, 'width=' + screen.width + ',height=' + screen.height + ',left='+ screen.width +',top=' + screen.height + ',' + WinOptions)
}

function OpenWindowFullScreen(url)
{
	// validate required parameter
	if (url == null) alert("OpenWindowFullScreen: missing url")

	// create unique window name based on current time
	curDate = new Date()
	WindowName = "NewWindow" + '_' + curDate.getTime()
	
	var WinWidth = window.screen.width - 10
	var WinHeight = window.screen.height - 28

	// open the window
	var newwin = window.open(url, WindowName, "height=" + WinHeight + ",width=" + WinWidth + ",left=0,top=0,screenX=0,screenY=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars,resizable=0")

	// set the focus to it
	return newwin.focus()
}

