/// ----------------------------------------------------------------------------------------------- ///
/// ----------------------------------- VARIÁVEIS GLOBAIS ----------------------------------------- ///
///------------------------------------------------------------------------------------------------ ///
var pararEvento = true;
///------------------------------------------------------------------------------------------------ ///


// FUNÇÃO: PopUp
// Descrição: Abre uma janela popup centralizada na tela com o tamanho especificado nos parametros
// Parametros:
		// _arquivo: Arquivo que deve ser aberto no PopUp
		// _nome: Nome da Janela
		// _width: Largura da Janela
		// _height: Altura da Janela
		// _scr: 0 = Sem Scroll  |  1 = Com Scroll
function PopUp(_arquivo,_nome,_width,_height,_scr)
{
	var arquivo = _arquivo;
	var nome = _nome;
	var width = _width;
	var height = _height;
	var scr = _scr;
	
	window.open(arquivo, nome,"width=" + width + ",height=" + height + ",top=" + ((screen.height/2)-(height/2)-50) + ",left=" + ((screen.width/2)-(width/2)) + ",toolbar=0,location=0,directories=0,resizable=1,status=0,,scrollbars=" + scr + ",menubar=0");
}


// FUNÇÃO: showObj
// DESCRIÇÃO: Função utilizada para mostrar ou esconder um Objeto na tela.
// PARAMETROS:
		// _obj: Nome do objeto que sofrerá interferencia da função.
		// _acao: 0 = Esconder | 1 = Mostrar
function showObj(_obj,_acao) {
	var obj = document.getElementById(_obj);
	var acao = _acao;
	
	if (acao == 0) {
		obj.style.display = 'none';
	}
	else {
		obj.style.display = '';
	}
}


// FUNCÃO: verificaCliqueFora
// DESCRIÇÃO: Verifica os cliques dados fora do DIV
// PARAMETROS:
		// ev: Evento
		// _obj: Objeto que deve ser verificado se o clique foi fora dele.
function verificaCliqueFora(ev, _obj) {
	var obj = document.getElementById(_obj);
	if (obj) {
		var ox = parseInt(obj.style.left);
		var oy = parseInt(obj.style.top);
		var ow = parseInt(obj.style.width);
		var oh = parseInt(obj.style.height);

		var ex = ev.clientX;
		var ey = ev.clientY + document.body.scrollTop;

		if ((ex > (ox+ow)) || (ex < ox) || (ey > (oy+oh)) || (ey < oy)) {
			obj.style.display = 'none';
			return true;
		}
	}
	return false;
}


function cliqueGlobal(ev,_arrayObj) {
	if (!pararEvento) {
		var i;
		for (i=0; i<_arrayObj.length; i++) {
			verificaCliqueFora(ev, _arrayObj[i]);
		}
	}
	pararEvento = false;
}


// FUNCÃO: doSubmit
// DESCRIÇÃO: Executa um Submit na página no lugar de um Refrash.
function doSubmit() {
	if (document.Form1)
		document.Form1.submit();
	else
		document.forms[0].submit();
}


// FUNCÃO: mostraDiv
// DESCRIÇÃO: Torna um DIV visível.
// PARAMETROS:
		// ev: Evento
		// _obj: id do DIV
function mostraDiv(ev,_obj) {
	pararEvento = true;
	var obj = document.getElementById(_obj);
	var wObj = parseInt(obj.style.width);
	var pX = (ev.clientX - wObj);
		
	obj.style.left = pX + 'px';
	//obj.style.left = '500px';
	obj.style.top = (ev.clientY + document.body.scrollTop + 10) + 'px';
	obj.style.display = '';
	pararEvento = true;
}			
