var brwsr = navigator.appName
if (brwsr=="Netscape") brwsr = "ns"
else if (brwsr=="Microsoft Internet Explorer") brwsr = "ie"

function abrirPagina(cUrl)
	{
	objLogado = document.getElementById('Logado');
	if(objLogado.value == 'false'){
		alert('Você precisa logar antes de acessar os serviços.'); document.forms[0].txtUsuario.focus(); return false;}
	document.location.href = cUrl;}

function abrirSistema(cUrl)
{
	if(document.all.Logado.value == 'false')
	{
		alert('Você precisa logar antes de acessar os serviços.'); 
		document.forms[0].txtUsuario.focus(); 
		return false;
	}
	if(brwsr=="ie")	window.open(cUrl + '?brwsr=ie','','fullscreen=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
	if(brwsr=="ns")	abreJanela(cUrl + '?brwsr=ns');
}

function abreJanela(url)
{
	/*
	objLogado = document.getElementById('Logado');
	if(objLogado.value == 'false'){
		alert('Você precisa logar antes de acessar os serviços.'); document.forms[0].txtUsuario.focus(); return false;}
	*/
	if (screen)
	{
	  sHeight = screen.availHeight
	  sWidth = screen.availWidth
	  wHeight = 1     //new window height
	  wWidth = 1      //new window width
	  wLeft = 0  //left position
	  wTop = 0 //top position
	  if(newWindow)
	  {
		newWindow.close();
		newWindow = null;
	  }
	  newWindow = window.open(url,"","left=" + wLeft + ",top=" + wTop + ",width=" + wWidth + ",height=" + wHeight + ",scrollbars=yes, menubar=yes")
	  newWindow.resizeTo(sWidth, sHeight);
	}
}

var newWindow;

function abreJanelaCentro(url, nHeight, nWidth, cAdicional){
	if(screen){
		sHeight = screen.height
		sWidth = screen.width
		wHeight = nHeight    //new window height
		wWidth = nWidth     //new window width
		wLeft = (sWidth - wWidth) / 2  //left position
		wTop = (sHeight - wHeight) / 2 //top position
		if(newWindow){
			newWindow.close();
			newWindow = null;}
		newWindow = window.open(url,"","left=" + wLeft + ",top=" + wTop + ",width=" + wWidth + ",height=" + wHeight +  cAdicional)}}
		
function VerificaNumerico(checkStr,valInteger)
{
	var allValid = true;
	if(valInteger)
		var checkOK = "0123456789"
	else
		var checkOK = "0123456789.,";
	var decPoints = 0;
	var allNum = "";
	for (k = 0; k < checkStr.length; k++)
	{
		ch = checkStr.charAt(k);
		for (j = 0; j < checkOK.length; j++)
			 if (ch == checkOK.charAt(j))
				 break;
		 if (j == checkOK.length)
		  {
			  allValid = false;
			  break;
			}
		allNum += ch;
	}
	return (allValid);
}

function verificaQuantidadeCaracteres(objetoVerificar, MaximoCaracteres)
{
	if(objetoVerificar.value.length > MaximoCaracteres)
	{
		alert("Máximo de caracteres perimitidos: " + MaximoCaracteres)
		objetoVerificar.value = objetoVerificar.value.substr(0, MaximoCaracteres);
	}
}
