/*<RMJSDep>BrowserUtils</RMJSDep>*/
//Fecha a janela aberta
function CloseWindowOpener()
{
	if (IsWindowOpenerValid())
		window.close();
}

//Verifica se o window.opener é valido
function IsWindowOpenerValid()
{
	if ((window.opener!=null) && 
		(!window.opener.closed))
		return true;
	else
		return false;
}

function OpenWindow(Url, WindowName, WindowFeatures)
{
	WindowFeatures = SetWindowFeaturesHeight(WindowFeatures);
	return window.open(Url,WindowName,WindowFeatures);
}

/********************************************************
Funcao criada para adicionar 20px no Height da janela do NS
já que a janela aberta pelo window.open do NS é menor que 
do IE
O parametro AddNSHeight recebe um valor booleano
********************************************************/
function SetWindowFeaturesHeight(pWindowFeatures)
{
	var result;
	result = pWindowFeatures.toUpperCase();
	
	if (isNS())
	{
		var HeightConst = "HEIGHT";
		var StartPos;
		var EndPos;
		var HeightValue;
		
		StartPos = result.indexOf(HeightConst);

		if (StartPos!=-1)
		{
			EndPos = result.indexOf(",", StartPos);
			if (EndPos!=-1)
			{
				HeightValue = result.substring(StartPos + 7, EndPos);
				result = result.substring(0,StartPos) + result.substr(EndPos + 1);
			}
			else
			{
				HeightValue = result.substring(StartPos + 7);
				result = result.substr(0,StartPos);
			}
					
			HeightValue = parseInt(HeightValue) + 20;

			while((result.length>0) &&
				  (result.substr(result.length-1)==" "))
					result = result.substring(0,result.length-1);
			
			if ((result.length>0) &&
				(result.substr(result.length-1)!=","))
				result = result + ",";
			
			result = result + HeightConst + "=" + HeightValue + "PX,";
		}
	}

	return result;
}
