/*
	Main Javascript
	Common Functions
	21/11/2007
*/

//Functions
function docRules() {
	var theRules = new Array();
	//
	if(document.styleSheets[0].cssRules){
		theRules = document.styleSheets[0].cssRules
	}else if(document.styleSheets[0].rules){
		theRules = document.styleSheets[0].rules
	}
	return theRules;
}
function openCloseBox(pDiv, pItem){
	var _div = pDiv;
	var _item = document.getElementById(pItem);
	//
	if(_div.className == "titBoxBlueSel"){
		_div.className = "titBoxBlue";
		_item.style.display = "none";
	}else{
		_div.className = "titBoxBlueSel";
		_item.style.display = "block";
	}	
}
function openTab(){
	var tabCont = document.getElementById("tabCont");
	var tabela = document.getElementById("tabela");
	var fndPop = document.getElementById("fndPop");
	var popWidth = document.body.clientWidth;
	var popHeight = document.body.clientHeight;
	var popScroll = document.body.scrollHeight;
	var rules = docRules();
	//
	if (popWidth == 0) {
		popWidth = document.documentElement.clientWidth;
		popHeight = document.documentElement.clientHeight;
		popScroll = document.documentElement.scrollHeight;
	}
	tabCont.style.display = "block";
	tabCont.style.overflow = "auto";
	tabCont.style.overflowY = "auto";
	tabCont.style.overflowX = "hidden";
	tabela.style.left = ((popWidth/2) - (tabela.offsetWidth/2)) + "px";
	tabela.style.top = ((popHeight/2) - (tabela.offsetHeight/2)) + "px";
	fndPop.style.height = popHeight + "px";
	if(tabela.offsetHeight > popHeight){
		fndPop.style.height = (popHeight + 120 + (tabela.offsetHeight - popHeight)) + "px";
		tabela.style.top = 80 + "px";
	}
	rules[1].style.overflowX = "hidden";
	rules[1].style.overflowY = "hidden";	
	rules[1].style.overflow = "hidden";
	tabCont.scrollTop = 0;
	window.scrollTo(0,0);
}


//Init
window.onload = function(){
	var btnClose = document.getElementById("btnClose");
	//
	if(btnClose){
		btnClose.onclick = function(){
			var tabCont = document.getElementById("tabCont");
			var rules = docRules();
			//
			tabCont.style.display = "none";
			tabCont.style.overflow = "hidden";
			tabCont.style.overflowY = "hidden";
			rules[1].style.overflowY = "auto";	
			rules[1].style.overflow = "auto";
		}	
	}
}

  function show_div(mes,ano){                        
            if (mes == "") {
                alert("Selecione o mês desejado.");
                return false;
            }
            if (ano == "") {
                alert("Selecione o ano desejado.");
                return false;
            }
            else{
                var divExibir = document.getElementById("show_" + mes + "_" + ano);
                var texto_div_atual = document.getElementById("atualDiv").value;
                if (texto_div_atual != "")
                {
                    divEsconder                  = document.getElementById(texto_div_atual);
                    divEsconder.style.visibility = "hidden";
                    divEsconder.style.display    = "none";
                }
                
                showNaoPossui = document.getElementById("show_nao_possui");
                
                if(divExibir != undefined)
                {
                    showNaoPossui.style.visibility            = "hidden";
                    showNaoPossui.style.display               = "none";
                    divExibir.style.visibility                = "visible";
                    divExibir.style.display                   = "inline";
                    document.getElementById("atualDiv").value = "show_" + mes + "_" + ano;
                }
                else{
                    showNaoPossui.style.visibility = "visible";
                    showNaoPossui.style.display    = "inline";
                }
            }
            ano = "";
            mes = "";
        }
