function sessionExpired()
{
	alert('ATENÇÃO!\n\nVocê precisa estar logado para acessar esta área!');
	if(window.opener == null)
		top.location.replace(URL_HTTPS + 'logout.php');
	else
	{
		window.opener.top.location.replace(URL_HTTPS + 'logout.php');
		setTimeout('self.close();', 200);
	}
}

function analizeRequest(str)
{
	// verifica se a sessão expirou
	if(str.indexOf('.NOSESSION.') == -1)
	{
		if(str.indexOf('.ERRO.') == -1)
		{
			return true;
		}
		else
		{
			arrStr = str.split('||');
			alert('ATENÇÃO!\n\n' + arrStr[1]);
			return false;
		}
	}
	else
	{
		sessionExpired();
		return false;
	}
	return false;
}

//incluir arquivos .js dinamicamente
function includeJS(arquivo,tag){
	var novo = document.createElement('script');
	novo.setAttribute('type', 'text/javascript');
	novo.setAttribute('src', arquivo);
	document.getElementsByTagName(tag)[0].appendChild(novo);
}

function windowIntSize(type)
{
	var type = (type)? type : "";
	if (document.all)
	{
		//pegando o Altura tela no IE.
		if (!document.documentElement.clientHeight)
			var height = document.body.clientHeight;                        
		else
			var height = document.documentElement.clientHeight;        
			
		//pegando a Largura tela no IE.                
		if (!document.documentElement.clientWidth)
			var width = document.body.clientWidth;                        
		else
			var width = document.documentElement.clientWidth;                        
	}
	else
	{
		//pegando a Altura tela no FF.            
			var height = window.innerHeight;
		//pegando a Largura tela no FF.            
			var width  = window.innerWidth;                
	}    

	if (type.toLowerCase()=="w")
	{
		return width;
	}
	else if (type.toLowerCase()=="h")
	{
		return height;
	}
	else
	{
		var arr = new Array(2);
		arr[0] = width;
		arr[1] = height;            
		return arr;
	}
}

function alerta(msg)
{
	var msgTitle = 'ATENÇÃO';
	try
	{
		alert(gtext(msgTitle) + '!\n\n' + gtext(msg));
	}
	catch(e)
	{
		alert(msgTitle + '!\n\n' + msg);
	}
}

function confirma(msg)
{
	var msgTitle = 'ATENÇÃO';
	try
	{
		return confirm(gtext(msgTitle) + '!\n\n' + gtext(msg));
	}
	catch(e)
	{
		return confirm(msgTitle + '!\n\n' + msg);
	}
}