/***************************************************************************
*  Variáveis e Funções Globais                                             *
*                                                                          *
*  Autor: Flávio Gonçalves Garcia                                          *
*  Tipo: JavaScript                                                        *
*  Arquivo: vc_menu.js                                                     *
*  Versão: 1.0.0 betha                                                     *
*  Data de Criação:    10/09/2002 10:01:30                                 *
*  Última atualizaçõa: 23/09/2002 09:28:30                                 *
*                                                                          *
*                                            Desenvolvimento - ViaCerrado  *
***************************************************************************/

//Verificando se o browser eh netscape ou Internet Explorer
var ie5=(document.all && document.getElementById)
var ns6=(!document.all && document.getElementById)
/******************************************
        Tags que de identificação de 
  elementos do html como tabela, div, etc
******************************************/

//Identificadores de Div
var tag_Div = "Div_"
var tag_Div_Mnu = "Div_Mnu_"
//Identificador de Tabela
var tag_Tbl = "Tlb_"
//Identificador de Coluna
var tag_Td = "Td_"

//Tags de tipo do menu pai
var tag_vc_Hori = "mnu_Horizontal"
var tag_vc_Vert = "mnu_Vertical"

//Flags para estado geral do menu ativo na janela
var flag_vc_mnu_Ativo = ""
var flag_vc_mnu_Dentro = 0

//Timer que da ação
var Global_Timer = 350


//Função de timer para controle de menu.

function Timer_Detona(){
	Acao_Global = setTimeout("Detona_Arvore()",350)
}

//Função que controla o desaparecimento dos menus.

function Detona_Arvore(idName){
	if (!flag_vc_mnu_Dentro){
		if (flag_vc_mnu_Ativo != ""){
			if (idName==null){
				idName = flag_vc_mnu_Ativo
			}
			with(eval(idName)){
				if(Tipo=="vc_IMH"){
					with(eval(Filho)){
						for (var i=0;i<qtd_Itens;i++){
							with(eval(Itens[i])){
								if(Ativado){
									Detona_Arvore(Nome)
								}
							}
						}
					}
					Out()
					Oculta_Filho()
				}
				else{
					with(eval(Filho)){
						for (var i=0;i<qtd_Itens;i++){
							with(eval(Itens[i])){
								if(Ativado){
									Detona_Arvore(Nome)
								}
							}
						}
					}
					Out()
					Oculta_Filho()
				}
			}
		}
	}
}


//Função que faz a ação do objeto

function Faz_Acao(Acao,Script){
	if(!Script){
		document.location = Acao
	}
	else{
		eval(Acao)
	}
}



/***************************************************************************
*  Classe: vc_MenuPai                                                      *
*                                                                          *
*                                                                          *
*  Autor: Flávio Gonçalves Garcia                                          *
*  Tipo: JavaScript - Classe                                               *
*  Arquivo: vc_menu.js                                                     *
*  Versão: 1.0.0 betha                                                     *
*  Data de Criação:    09/09/2002 14:11:30                                 *
*  Última atualizaçõa: 20/09/2002 10:04:30                                 *
*                                                                          *
*                                            Desenvolvimento - ViaCerrado  *
***************************************************************************/

function vc_MenuPai(Nome,Altura,Largura,posX,posY,Tipo){
	
	//String que vai guardar o resultado que vai ser impresso na página
	this.Str_Result = ""
	
	//Propriedades de definição
	this.Nome = Nome
	this.Pai = ""
	this.Filho = ""
	this.Tipo = Tipo
	
	//Propriedades de design
	this.Altura = Altura
	this.Largura = Largura
	this.posX = posX
	this.posY = posY
	
	
	//Repositório de ítens
	this.Itens = new Array
	this.qtd_Itens = 0
	
	//Alias dos métodos
	this.Monta = Monta_vc_MH
	this.Adiciona = Adiciona_Item_vc_MH
	this.Posiciona = Posiciona_vc_MV
	
	function Monta_vc_MH(){
		//alert(tag_Div_Mnu)
		with (this){
			if (Tipo==tag_vc_Hori){
				//Alterando essa linha para que o menu fique centralizado!!!!
				//Str_Result = "<div id=\"" + tag_Div + Nome + "\"><table background=\"fundo_mnu.jpg\" onmouseout=\"Timer_Detona();flag_vc_mnu_Dentro = 0;\" cellpadding=\"0\" cellspacing=\"0\" width=\""+Largura+"\" class=\"borda_vc_menu_horizontal\" id=\"" + tag_Tbl + Nome + "\"><tr><td><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td class=\"span_vc_mnu_horizontal\" width=\"*\">&nbsp;</td>"
				//Linha original!!!img/
				Str_Result = "<div id=\"" + tag_Div + Nome + "\"><table background=\""+vc_VIRTUAL_IMAGE_DESIGN+"fundo_mnu.jpg\" onmouseout=\"Timer_Detona();flag_vc_mnu_Dentro = 0;\" cellpadding=\"0\" cellspacing=\"0\" width=\""+Largura+"\" class=\"borda_vc_menu_horizontal\" id=\"" + tag_Tbl + Nome + "\"><tr><td><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr>"
			}
			else{
				Str_Result = "<div id=\"" + tag_Div + Nome + "\"><table onmouseout=\"Timer_Detona();flag_vc_mnu_Dentro = 0;\" cellpadding=\"1\" cellspacing=\"0\" width=\""+Largura+"\" class=\"borda_vc_menu_horizontal\" id=\"" + tag_Tbl + Nome + "\"><tr><td><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">"	
			}
			
			for (var i=0;i<qtd_Itens;i++){
				Str_Result = Str_Result + eval(Itens[i]).Escreve()
			}
			if (Tipo==tag_vc_Hori){
				Str_Result = Str_Result + "<td class=\"span_vc_mnu_horizontal\" width=\"*\">&nbsp;</td></tr></table></td></tr></table></div>"	
			}
			else{
				Str_Result = Str_Result + "<tr><td class=\"span_vc_mnu_horizontal\" height=\"*\">&nbsp;</td></tr></table></td></tr></table></div>"
			}
			
			//alert(Str_Result)
			//document.write(Str_Result)
			document.write(Str_Result)
			document.getElementById(tag_Div + Nome).style.position = "absolute"
			Posiciona()
		}
	}
	
	function Adiciona_Item_vc_MH(Item){
		with (this){
			Itens[qtd_Itens] = Item
			qtd_Itens++
			return (qtd_Itens - 1)
		}
	}
	
	function Posiciona_vc_MV(){
		with(this){
			document.getElementById(tag_Div + Nome).style.top = posY
			document.getElementById(tag_Div + Nome).style.left = posX
			//alert(parseInt(document.getElementById(tag_Div + Nome).currentStyle.offsetTop))
		}
	}
}

/***************************************************************************
*  Classe: vc_ItemMenuPai                                                  *
*                                                                          *
*                                                                          *
*  Autor: Flávio Gonçalves Garcia                                          *
*  Tipo: JavaScript - Classe                                               *
*  Arquivo: vc_menu.js                                                     *
*  Versão: 1.0.0 betha                                                     *
*  Data de Criação:    09/09/2002 14:50:30                                 *
*  Última atualizaçõa: 25/09/2002 11:58:00                                 *
*                                                                          *
*                                            Desenvolvimento - ViaCerrado  *
***************************************************************************/

function vc_ItemMenuPai(Nome,Pai,Rotulo,Altura,Largura,Acao,Script){
	
	//String que vai guardar o resultado que vai ser impresso na página
	this.Str_Result = ""
	this.Tipo = "vc_IMH"
	
	//Propriedades de definição
	this.Nome = Nome
	this.Pai = eval(Pai)
	this.Filho = ""
	this.Index = 0
	
	
	//Propriedades de ação
	this.Acao = Acao
	this.Script = Script
	
	//Propriedades de design
	this.Altura = Altura
	this.Largura = Largura
	this.Borda = ""
	this.Cor_Atu =  "out_vc_mnu_horizontal"
	
	
	//Proriedades de Conteúdo
	this.Rotulo = Rotulo
	
	//Propriedades de estado
	this.Ativado = 0
	
	//Alias das funções
	this.Escreve = Escreve_vc_IMH
	this.Controla = Controla_vc_IMH
	
	
	
	//Funções de desingn
	this.Out = Out_vc_IMH
	this.Over = Over_vc_IMH
	this.Oculta_Filho = Oculta_Filho_vc_IMH
	this.Mostra_Filho = Mostra_Filho_vc_IMH
	
	function Escreve_vc_IMH(){
		with (this){
			Concat_Str = ""
			if(Acao!=""){
				if (Script==1){
					Concat_Str =  "onclick=\"Faz_Acao(" + this.Acao + "," + this.Script + ")\""
				}
				else{
					Concat_Str =  "onclick=\"Faz_Acao('" + this.Acao + "'," + this.Script + ")\""
				}
			}
			if (Pai.Tipo==tag_vc_Hori){
				Str_Result = "<td " + Concat_Str + " height=\""+Pai.Altura+"\" class=\"out_vc_mnu_horizontal\" onmouseout=\"" + Nome + ".Controla()\" onmouseover=\"Detona_Arvore(flag_vc_mnu_Ativo);" + Nome + ".Controla()\" id=\"" + tag_Td + Nome + "\" width=\"" + Largura + "\"><img align=\"absmiddle\" src=\""+vc_VIRTUAL_IMAGE_DESIGN+"mark-esq.jpg\" width=\"10\" height=\"14\" alt=\"\" border=\"0\">&nbsp;" + Rotulo + "</td>"
			}
			else{
				Str_Result = "<tr " + Concat_Str + " ><td height=\""+Pai.Altura+"\" class=\"out_vc_mnu_horizontal\" onmouseout=\"" + Nome + ".Controla()\" onmouseover=\"Detona_Arvore(flag_vc_mnu_Ativo);" + Nome + ".Controla()\" id=\"" + tag_Td + Nome + "\" width=\"" + Largura + "\"> " + Rotulo + "</td></tr>"
			}
			
			return Str_Result
		}
	}
	
	function Controla_vc_IMH(Limpa){
		flag_vc_mnu_Dentro = 1
		with(this){
			nome_tmp = Nome
			with(Pai){
				for (var i=0;i<qtd_Itens;i++){
					with(eval(Itens[i])){
						if((Nome!=nome_tmp)&&(Ativado)){
							Out()
							Oculta_Filho()
						}
					}
				}
			}
			if(Filho==""){
				if (Cor_Atu == "out_vc_mnu_horizontal"){
					
					Over()
				}
				else{
					Out()
				}
			}
			else{
				Over()
				Mostra_Filho()
			}
		}
	}
	
	
	function Out_vc_IMH(){
		with(this){
			document.getElementById(tag_Td + Nome).className = "out_vc_mnu_horizontal"
			Cor_Atu =  "out_vc_mnu_horizontal"
			if (ns6){
				window.setCursor("auto")
			}
		}
	}
	function Over_vc_IMH(){
		with(this){
			document.getElementById(tag_Td + Nome).className = "over_vc_mnu_horizontal"
			Cor_Atu = "over_vc_mnu_horizontal"
			if (ns6){
				window.setCursor("pointer")
			}
		}
	}
	function Oculta_Filho_vc_IMH(){
		with (this){
			Ativado = 0
			flag_vc_mnu_Ativo=""
			with(eval(Filho)){
				Some()
				Ativado = 0
			}
		}
	}
	function Mostra_Filho_vc_IMH(){
		with(this){
			Ativado = 1
			flag_vc_mnu_Ativo=Nome
			with(eval(Filho)){
				Mostra()
				Ativado=1
			}
		}
	}
	
	
	
	//Ações a serem tomadas durante a construção do objeto!!!
	with (this){
		Index = Pai.Adiciona(Nome)
	}
}

/***************************************************************************
*  Classe: vc_MenuFilho                                                    *
*                                                                          *
*                                                                          *
*  Autor: Flávio Gonçalves Garcia                                          *
*  Tipo: JavaScript - Classe                                               *
*  Arquivo: vc_menu.js                                                     *
*  Versão: 1.0.0 betha                                                     *
*  Data de Criação:    18/09/2002 23:17:45                                 *
*  Última atualizaçõa: 23/09/2002 23:17:45                                 *
*                                                                          *
*                                            Desenvolvimento - ViaCerrado  *
***************************************************************************/

function vc_MenuFilho(Nome,Pai,Largura,posX,posY){
	//String que vai guardar o resultado que vai ser impresso na página
	this.Str_Result = ""
	
	//Propriedades de definição
	this.Nome = Nome
	this.Pai = eval(Pai)
	
	//Propriedades de design
	this.Largura = Largura
	this.posX = posX
	this.posY = posY
	
	//Repositório de ítens
	this.Itens = new Array
	this.qtd_Itens = 0
	
	//Propriedades de estado
	this.Ativado = 0
	this.EmCima = 0
	this.JaPassou = 0
	
	//Alias dos métodos
	this.Monta = Monta_vc_MV
	this.Adiciona = Adiciona_Item_vc_MV
	this.Posiciona = Posiciona_vc_MV
	this.Mostra = Mostra_vc_MV
	this.Some = Some_vc_MV
	
	function Monta_vc_MV(){
		with (this){
			Str_Result = "<div id=\"" + tag_Div + Nome + "\"><table onmouseout=\"Timer_Detona();flag_vc_mnu_Dentro = 0;\" cellpadding=\"1\" cellspacing=\"0\" width=\""+Largura+"\" class=\"borda_vc_menu_vertical\" id=\"" + tag_Tbl + Nome + "\"><tr><td><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">"
			for (var i=0;i<qtd_Itens;i++){
				Str_Result = Str_Result + eval(Itens[i]).Escreve()
			}
			Str_Result = Str_Result + "</table></td></tr></table></div>"
			document.write(Str_Result)
			document.getElementById(tag_Div + Nome).style.position = "absolute"
			if(Pai==""){
				document.getElementById(tag_Div + Nome).style.visibility = "hidden"
			}
			else{
				document.getElementById(tag_Div + Nome).style.visibility = "hidden"
			}
			Posiciona()
		}
	}
	
	
	function Mostra_vc_MV(){
		with(this){
			document.getElementById(tag_Div + Nome).style.visibility = "visible"
			Ativado = 1
		}
	}
	
	function Some_vc_MV(){
		with(this){
			document.getElementById(tag_Div + Nome).style.visibility = "hidden"
			Ativado = 0
		}
	}
	
	function Adiciona_Item_vc_MV(Item){
		with (this){
			Itens[qtd_Itens] = Item
			qtd_Itens++
			return (qtd_Itens - 1)
		}
	}
	function Posiciona_vc_MV(){
		with(this){
			posX_Real = 0
			posY_Real = 0
			if (Pai==""){
				posX_Real = posX
				posY_Real = posY
			}
			else{
				with(Pai){
					Ind_Pos = Index
					if (Tipo == "vc_IMH"){
						with(Pai){
							if (Tipo==tag_vc_Hori){
								
								for (var i=0;i<Ind_Pos;i++){
									posX_Real = posX_Real + eval(Itens[i]).Largura + 2
								}
								if (Ind_Pos==0){
									posX_Real = posX_Real + posX 
								}
								else{
									posX_Real = posX_Real + posX + 1
								}
								posY_Real = posY + Altura + 5
								}
							else{
								for (var i=0;i<Ind_Pos;i++){
									posY_Real = posY_Real + eval(Itens[i]).Altura + 1
								}
								if (Ind_Pos==0){
									posY_Real = posY_Real + posY 
								}
								else{
									posY_Real = posY_Real + posY + 1
								}
								posX_Real = posX + Largura + 1
							}
						}
					}
					else{
						with(Pai){
							for (var i=0;i<Ind_Pos;i++){
								posY_Real = posY_Real + eval(Itens[i]).Altura
							}
							if (Ind_Pos==0){
								posY_Real = posY_Real + posY
							}
							else{
								posY_Real = posY_Real + posY+2
							}
							posX_Real = posX + Largura - 1
						}
					}
				}
			}
			posX = posX_Real
			posY = posY_Real
			
			document.getElementById(tag_Div + Nome).style.left = posX
			document.getElementById(tag_Div + Nome).style.top = posY
		}
	}
	with(this){
		
			Pai.Filho = Nome
			with(Pai){
				if (Tipo=="vc_IMV"){
					document.getElementById(tag_Td + Nome + "_Dir").innerHTML =  "<img src=\""+vc_VIRTUAL_IMAGE_DESIGN+"vc_mnu/arrow.gif\" width=\"10\" height=\"10\" alt=\"\" border=\"0\">"
				}
			}
	}
}

/***************************************************************************
*  Classe: vc_ItemMenuFilho                                                *
*                                                                          *
*                                                                          *
*  Autor: Flávio Gonçalves Garcia                                          *
*  Tipo: JavaScript - Classe                                               *
*  Arquivo: vc_menu.js                                                     *
*  Versão: 1.0.0 betha                                                     *
*  Data de Criação:    18/09/2002 23:17:45                                 *
*  Última atualizaçõa: 25/09/2002 11:58:45                                 *
*                                                                          *
*                                            Desenvolvimento - ViaCerrado  *
***************************************************************************/

function vc_ItemMenuFilho(Nome,Pai,Rotulo,Altura,Acao,Script){
	//String que vai guardar o resultado que vai ser impresso na página
	this.Str_Result = ""
	
	//Propriedades de definição
	this.Nome = Nome
	this.Pai = eval(Pai)
	this.Filho = ""
	this.Index = 0
	
	//Propriedades de ação
	this.Acao = Acao
	this.Script = Script
	
	this.Tipo = "vc_IMV"
	
	//Propriedades de desing
	this.Cor_Atu =  "out_meio_vc_mnu_vertical"
	this.Altura = Altura
	
	//Propriedades de estado
	this.Ativado = 0
	this.EmCima = 0
	
	//Proriedades de Conteúdo
	this.Rotulo = Rotulo
	
	//Alias das funções
	this.Escreve = Escreve_vc_IMV
	this.Controla = Controla_vc_IMV
	
	//Funções de desingn
	this.Out = Out_vc_IMV
	this.Over = Over_vc_IMV
	this.Oculta_Filho = Oculta_Filho_vc_IMV
	this.Mostra_Filho = Mostra_Filho_vc_IMV
	
	
	function Escreve_vc_IMV(){
		Concat_Str = ""
		with (this){
			if(Acao!=""){
				if (Script==1){
					Concat_Str =  "onclick=\"Faz_Acao(" + this.Acao + "," + this.Script + ")\""
				}
				else{
					Concat_Str =  "onclick=\"Faz_Acao('" + this.Acao + "'," + this.Script + ")\""
				}
			}
			Str_Result = "<tr " + Concat_Str + " onmouseout=\"" + Nome + ".Controla()\" onmouseover=\"" + Nome + ".Controla()\"><td id=\"" + tag_Td + Nome + "_Esq" + "\" class=\"out_esq_vc_mnu_vertical\" width=\""+Altura+"\">&nbsp;</td><td width=\"*\" height=\""+Altura+"\" class=\"out_meio_vc_mnu_vertical\" id=\"" + tag_Td + Nome + "\">&nbsp;" + Rotulo + "</td><td id=\"" + tag_Td + Nome + "_Dir" + "\" class=\"out_dir_vc_mnu_vertical\" width=\""+Altura+"\" align=\"right\" valign=\"middle\">&nbsp;</td></tr>"
			return Str_Result
		}
	}
	
	function Controla_vc_IMV(){
		flag_vc_mnu_Dentro = 1
		with(this){
			with(Pai){
				for (var i=0;i<qtd_Itens;i++){
					with(eval(Itens[i])){
						if((Nome!=nome_tmp)&&(Ativado)){
							Out()
							Oculta_Filho()
						}
					}
				}
			}
			if(Filho==""){
				nome_tmp = Nome
				if (Cor_Atu == "out_meio_vc_mnu_vertical"){
					
					Over()
				}
				else{
					Out()
				}
			}
			else{
				Over()
				Mostra_Filho()
				with(eval(Filho)){
					for (var i=0;i<qtd_Itens;i++){
						with(eval(Itens[i])){
							if(Ativado){
								Out()
								Oculta_Filho()
							}
						}
					}
				}
			}
		}
	}
	function Out_vc_IMV(){
		with(this){
			document.getElementById(tag_Td + Nome).className = "out_meio_vc_mnu_vertical"
			document.getElementById(tag_Td + Nome + "_Esq").className = "out_esq_vc_mnu_vertical"
			document.getElementById(tag_Td + Nome + "_Dir").className = "out_dir_vc_mnu_vertical"
			Cor_Atu =  "out_meio_vc_mnu_vertical"
			
		}
	}
	function Over_vc_IMV(){
		with(this){
			with(Pai){
				EmCima = 1
				JaPassou = 1
			}
			document.getElementById(tag_Td + Nome).className = "over_meio_vc_mnu_vertical"
			document.getElementById(tag_Td + Nome + "_Esq").className = "over_esq_vc_mnu_vertical"
			document.getElementById(tag_Td + Nome + "_Dir").className = "over_dir_vc_mnu_vertical"
			Cor_Atu = "over_meio_vc_mnu_vertical"
		}
	}
	function Oculta_Filho_vc_IMV(Selector){
		with (this){
			Ativado = 0
			with(eval(Filho)){
				for (var i=0;i<qtd_Itens;i++){
					with(eval(Itens[i])){
						if((Nome!=nome_tmp)&&(Ativado)){
							Out()
							Oculta_Filho()
						}
					}
				}
				Some()
				Ativado = 0
			} 
		}
	}
	function Mostra_Filho_vc_IMV(){
		with(this){
			Ativado = 1
			with(eval(Filho)){
				Mostra()
				Ativado=1
			}
		}
	}
	
	
	//Ações a serem tomadas durante a construção do objeto!!!
	with (this){
		
		Index = Pai.Adiciona(Nome)
	}
}

