//VARIAVEIS GLOBAIS

IE      				 = false;
FF      				 = false;
timeOut 				 = null;
tempoPadraoEsconderBalao = 1;//segundos

//Checa o navegador do usuario

function checarBrowser()
{
	if(navigator.appName == 'Netscape')
	{
			IE = false;
			FF = true;
	}else{
			IE = true;
			FF = false;
	}
}

// Genericas

function criarObjetoDom(idObjeto, tipoObjeto, cssObjeto, objetoContainer)
{
	if(document.getElementById(idObjeto)== null)
	{
		novo_objeto = document.createElement(tipoObjeto);
		novo_objeto.setAttribute('id',idObjeto);
		if(objetoContainer==null)
		{
			   if(document.body!=null)
			   {
			   		  document.body.appendChild(novo_objeto);
			   }else{
					  alert('Esta página não possui corpo (body), por favor, \npasse o objeto que ira abrigar o seu novo elemento !');
			   }
		}else{
			   objetoContainer.appendChild(novo_objeto);
		}
		document.getElementById(idObjeto).className = cssObjeto;
	}
}

function criarObjetoDivInformacao(idObjeto, tipoObjeto, cssObjeto, objetoContainer){

	criarObjetoDom(idObjeto, tipoObjeto, cssObjeto, objetoContainer);
}

function habilitarCombos(){
	selects = document.getElementsByTagName('SELECT');
	
	for(i=0;i<selects.length;i++)
	{
		selects[i].style.visibility = 'visible';
	}
}

function desabilitarCombos(){
	selects = document.getElementsByTagName('SELECT');
	
	for(i=0;i<selects.length;i++)
	{
		selects[i].style.visibility = 'hidden';
	}
}

MyWindow = null;

function jczOpenWindow(theURL,winName) 
{
	if(MyWindow != null)//Se já foi aberta uma janela anteriormente.
	{
		if(!MyWindow.closed) //se a janela aberta anteriormente ainda não foi fechada.
		{
			// se a jenela que está sendo aberta é diferente da anterior
			if(MyWindow.name != winName) 
			{
				MyWindow.close(); //fecha a janela anterior
				MyWindow = window.open(theURL,winName,'resizable=yes,status=yes,scrollbars=no,width=300,height=300');
				//abre uma nova janela
			} else //caso as janelas tenham o mesmo nome
				  {
				MyWindow.focus(); //muda o foco para a janela aberta tanteriormente.
			}
		} else // caso já tenha sido fechada uma janela anteriormente
				{ // abre a nova janela.
			MyWindow = window.open(theURL,winName,'resizable=yes,status=yes,scrollbars=no,width=300,height=300');
		}
	}else //caso nenhuma janela tenha sido aberta anteriormente, i.e., MyWindow == null
		  { //abre uma nova janela.
		MyWindow = window.open(theURL,winName,'resizable=yes,status=yes,scrollbars=no,width=300,height=300');
	}
}

function jczResetWindow(bmp) //esta função deve ser escrita no arquivo queserá aberto na
{ //pela função jczOpenWindow.
	self.moveTo(2,2); //move janela para canto superior esquerdo
	self.resizeTo(bmp.width+50,bmp.height+130); //redimensiona janela baseada em bmp.
}

function jczOpenWindowSize(theURL,winName,width,height) 
{
	if(MyWindow != null)//Se já foi aberta uma janela anteriormente.
	{
		if(!MyWindow.closed) //se a janela aberta anteriormente ainda não foi fechada.
		{
			// se a jenela que está sendo aberta é diferente da anterior
			if(MyWindow.name != winName) 
			{
				MyWindow.close(); //fecha a janela anterior
				MyWindow = window.open(theURL,winName,'resizable=yes,status=yes,scrollbars=yes,menubar=yes,toolbar=yes,location=yes,width='+width+',height='+height);
				//abre uma nova janela
			} else //caso as janelas tenham o mesmo nome
				  {
				MyWindow.focus(); //muda o foco para a janela aberta tanteriormente.
			}
		} else // caso já tenha sido fechada uma janela anteriormente
				{ // abre a nova janela.
			MyWindow = window.open(theURL,winName,'resizable=yes,status=yes,scrollbars=yes,menubar=yes,toolbar=yes,location=yes,width='+width+',height='+height);
		}
	}else //caso nenhuma janela tenha sido aberta anteriormente, i.e., MyWindow == null
		  { //abre uma nova janela.
		MyWindow = window.open(theURL,winName,'resizable=yes,status=yes,scrollbars=yes,menubar=yes,toolbar=yes,location=yes,width='+width+',height='+height);
	}
}
