// Filename: popup.js
// Project : Javascript Library
//
// Description:
// Support for window pop-ups. Pop-ups are fully supported in v4 browsers and up with
// the majority of support in v3 browsers and up.
//
// Revision History:
// 11FEB2001 - MJT - Initial development.
// 12MAY2002 - MJT - Aded POPUP_OpenGet

// POPUP_Open
// Open a pop-up window and set the focus to it (if possible).
// strURL: url to open in the window
// strName: the name of the window
// strProperties: the properties of the new window
// returns: nothing
function POPUP_Open( strURL, strName, strProperties )
{
	// create the new pop-up window
	var nw = window.open( strURL, strName, strProperties );
	// if there is support for setting the focus - set the focus to the new window
	if ( window.focus )
	{
		nw.focus( );
	}
}

// POPUP_OpenGet
// Open a pop-up window and set the focus to it (if possible).
// strURL: url to open in the window
// strName: the name of the window
// strProperties: the properties of the new window
// returns: the new window
function POPUP_OpenGet( strURL, strName, strProperties )
{
	// create the new pop-up window
	var nw = window.open( strURL, strName, strProperties );
	// if there is support for setting the focus - set the focus to the new window
	if ( window.focus )
	{
		nw.focus( );
	}
}

// POPUP_OpenAt
// Opens a pop-up at a specific position with specified size.
// strURL: url to open in the pop-up
// strName: name of the window
// lngLeft, lngTop: position of the window (4+ only to work)
// lngWidth, lngHeight: size of the window
// returns: nothing
function POPUP_OpenAt( strURL, strName, lngLeft, lngTop, lngWidth, lngHeight )
{
	var strProperties = 'height=' & lngHeight & ',width=' & lngWidth & ',top=' & lngTop & ',left=' & lngLeft;
	POPUP_Open( strURL, strName, strProperties );
}

// POPUP_MakeProperties
// Create a properties string for a pop-up window from the component settings.
// lngLeft, lngTop: optional - used only if > 0
// lngWidth, lngHeight: required for all pop-ups
// blnDirectories, blnLocation, blnMenubar, blnResizable, blnScrollbars, blnStatus, blnToolbar:
//		optional pieces of the window that are specified with a true/false.
// returns: the property string for creating the window.
function POPUP_MakeProperties( lngLeft, lngTop, lngWidth, lngHeight, blnDirectories, blnLocation, 
	blnMenubar, blnResizable, blnScrollbars, blnStatus, blnToolbar )
{
	var strProperties;
	
	strProperties = 'width=' + lngWidth + ',height=' + lngHeight
	if ( lngLeft > 0 )
		strProperties += ( ',left=' + lngLeft );
	if ( lngTop > 0 )
		strProperties += ( ',top=' + lngTop );
	strProperties += (',directories=' + ((blnDirectories) ? 'yes': 'no'));
	strProperties += (',location=' + ((blnLocation) ? 'yes': 'no'));
	strProperties += (',menubar=' + ((blnMenubar) ? 'yes': 'no'));
	strProperties += (',resizable=' + ((blnResizable) ? 'yes': 'no'));
	strProperties += (',scrollbars=' + ((blnScrollbars) ? 'yes': 'no'));
	strProperties += (',status=' + ((blnStatus) ? 'yes': 'no'));
	strProperties += (',toolbar=' + ((blnToolbar) ? 'yes': 'no'));
	
	return strProperties;
}

// POPUP_OpenFullScreen
// Opens a full screen pop-up at the origin
// strURL: url to open in the pop-up
// strName: name of the window
// strProperties: other properties for the window
// returns: nothing
function POPUP_OpenFullScreen( strURL, strName, strProperties )
{
	var lngHeight, lngWidth;
	if ( window.screen )
	{
		lngWidth = window.screen.availWidth * 0.9;
		lngHeight = window.screen.availHeight * 0.9;
	}
	else
	{
		lngWidth = 770;
		lngHeight = 500;
	}
	strProperties = 'height=' + lngHeight +  ',width=' + lngWidth + ',top=1,left=1,' + strProperties;
	POPUP_Open( strURL, strName, strProperties );
}

