var type = '';	//Variavel global para identificar o Bowser
definirBrowser();
//detecta o browser do Cliente
function definirBrowser() {
	if (navigator.userAgent.indexOf('Opera')!=-1 && document.getElementById) type='MO';		//Opera
	else if (document.all) type='IE';														//Internet Explorer e.g. IE4 upwards
	else if (document.layers) type='N4';													//Netscape Communicator 4
	else if (!document.all && document.getElementById) type='MO';							//Mozila e.g. Netscape 6 upwards
	if (type == '' || type == 'N4') location.href = 'atualizarBrowser.htm';
}

//IMPRIMIR A PAGINA CORRENTE DO BROWSER
function imprimirPagina() {
    window.print()
}


//FUNÇÕES PARA MANIPULAR DIVS
//ALTERAR POSIÇÃO, CONTEUDO, ABRIR E FECHAR
function alterarLarguraDiv(Div, largura, unidade) {
	var obj;
	if (type=="IE") 				obj = document.all[Div];
	if (type=="MO" || type=="OP")	obj = document.getElementById(Div);
	obj.style.width = largura+unidade;
}

function alterarAlturaDiv(Div, altura, unidade) {
	var obj;
	if (type=="IE") 				obj = document.all[Div];
	if (type=="MO" || type=="OP")	obj = document.getElementById(Div);
	obj.style.height = altura+unidade;
}

//ALTERAR O CONTEÚDO DO DIV
//Div: NOME DO DIV
//str: NOVO TEXTO A SER INCLUÍDO NO DIV
function escreverDiv(Div, str) {
	document.getElementById(Div).innerHTML = str;
}

//REMOVER O CONTEÚDO DO DIV
//Div: NOME DO DIV
function removerConteudoDiv(Div) {
	document.getElementById(Div).innerHTML = '';
}

//MOSTRA OU ESCONDE O DIV
//Div: NOME DO DIV
/**
 * Função utilizada no ambiente administrativo do portal EPSJV	
 */
function abrirfecharDiv(Div) {
	var obj;
	if (type=="IE") 				obj = document.all[Div];
	if (type=="MO" || type=="OP")	obj = document.getElementById(Div);
	if (obj.style.display == 'none')
		obj.style.display = '';
	else
		obj.style.display = 'none';
}

/**
 * Função utilizada na view do portal EPSJV	
 */
function abrirFecharDiv(Div) {
	var obj;
	if (type=="IE") 				obj = document.all[Div];
	if (type=="MO" || type=="OP")	obj = document.getElementById(Div);
	if (obj.style.display == 'none')
		obj.style.display = '';
	else
		obj.style.display = 'none';
}

//ESCONDE O DIV
//Div: NOME DO DIV
function fecharDiv(Div) {
	var obj;
	if (type=="IE") 				obj = document.all[Div];
	if (type=="MO" || type=="OP")	obj = document.getElementById(Div);
	obj.style.display = 'none';
}

//MOSTRA O DIV
//Div: NOME DO DIV
function abrirDiv(Div) {
	var obj;
	if (type=="IE") 				obj = document.all[Div];
	if (type=="MO" || type=="OP")	obj = document.getElementById(Div);
	obj.style.display = '';
}
//FIM DO BLOCO DE MANIPULAÇÃO DE DIV

//INÍCIO DO BLOCO DE MANIPULAÇÃO DO BROWSER
var xLargura = 0;
var yAltura = 0;
buscarResolucaoVideo();

function buscarResolucaoVideo() {
	xLargura=(screen.availWidth-8);
	yAltura=(screen.availHeight-70);
}

function abrirJanelaConfigurada(nomeArquivo, nomeJanela, largura, altura, toolbar) {
	x=(xLargura-largura)/2;
	y=(yAltura-altura)/2;
	if ((''+toolbar)=='undefined')
		toolbar = 'no';
	window.open(nomeArquivo,nomeJanela,'width='+largura+',height='+altura+',toolbar='+toolbar+',location=no, directories=no,status=yes,menubar=no,resizable=no,scrollbars=1,fullscreen=0,top='+y+',left='+x);
}
//FIM DO BLOCO DE MANIPULAÇÃO DO BROWSER

function isDefined(ckVar) {
	var DEFINED_V=true;
	function handleError() {
		DEFINED_V=false;
		return true;
	}
	var oldOnError=window.onerror;
	window.onerror=handleError;
	try {
		eval(ckVar);
	}
	catch (e) {
		DEFINED_V=false;
	}
	window.onerror=oldOnError;
	return DEFINED_V;
}



