
var IDS_WIDTH_OFFSET = 30;
var IDS_HEIGHT_OFFSET = 30;
var CONSOLE_WIDTH = 200;

// ---- [Public] Open a new window and focus it
function BSC_openWindowOnFocus(strURL, strWinTarget, strWinFeatures) 
{
	var pWindow = window.top.open(strURL, strWinTarget, strWinFeatures);
	if (pWindow)
		pWindow.focus();
}

// ---- [Public] Return default window size 
function BSC_UseDefaultSizing(pWindow)
{
	var	lWidth = BSC_getWindowWidth(pWindow) - CONSOLE_WIDTH;
	var lHeight = BSC_getWindowHeight(pWindow);
	var strFeature;
	var lLeft;
	var lTop;

	if (BSC_isIE())
	{
		// IE case
		lTop = pWindow.screenTop + IDS_HEIGHT_OFFSET;
		lLeft = pWindow.screenLeft + IDS_WIDTH_OFFSET;
		
		strFeature = "left=" + lLeft + ",top=" + lTop + ",width=" + lWidth + ",height=" + lHeight + ",resizable,scrollbars,toolbar=yes,menubar=yes,status=yes";
	}
	else
	{
		// Netscape case	
		lTop = pWindow.screenY + IDS_HEIGHT_OFFSET;
		lLeft = pWindow.screenX + IDS_WIDTH_OFFSET;
		strFeature = "screenX=" + lLeft + ",screenY=" + lTop + ",outerWidth=" + lWidth + ",outerHeight=" + lHeight + ",resizable,scrollbars,status=yes";
	}

	return strFeature;
}

// ---- [Private] get the window width
function BSC_getWindowWidth(pWin)
{
	if (BSC_isIE()) 
	{
		return pWin.document.body.clientWidth;
	} 
	else if (BSC_isNetscape()) 
	{
		return pWin.outerWidth;
	}
}

// ---- [Private] get the window height
function BSC_getWindowHeight(pWin)
{
	if (BSC_isIE()) 
	{
		var bodyClientHeight = pWin.document.body.clientHeight;
		if( bodyClientHeight > pWin.screen.availHeight )
		{
			bodyClientHeight = pWin.screen.availHeight;
		}
		return bodyClientHeight;
	} 
	else if (BSC_isNetscape()) 
	{
		return pWin.outerHeight;
	}
}

// Checks if browser is IE
function BSC_isIE() {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return true;
	} else {
		return false;
	}
}

// Checks if browser is Netscape
function BSC_isNetscape() {
	if (navigator.appName.indexOf("Netscape") != -1) {
		return true;
	} else {
		return false;
	}
}

