/**
* FUNCOES QUE CONTROLAM O LAYOUT DO SITE.
* OBSERVAÇÃO: Esse script depende do cookiemanager.js para funcionar.
*/
var DOM2 = document.getElementById;
var valorinicial;

function estendido(umoudois) {
   if (umoudois == 2) {
       document.getElementById("wrapper").style.width = 100 + "%";
   } else {
       document.getElementById("wrapper").style.width=778 + "px";
   }
   set_cookie("estendido", umoudois);
}
/*
function zoom(Marcos)	{
    if (Marcos.indexOf('mais') == 0) valorinicial = valorinicial + 0.3;
	if (Marcos.indexOf('menos') == 0) valorinicial = valorinicial - 0.3;
	if (Marcos.indexOf('padrao') == 0) valorinicial = 1;
	if (DOM2) {
         mudarTamanho(valorinicial);
         set_cookie("mudaL", valorinicial);
    }
}
*/
function initzoom() {
	var valor = get_cookie("mudaL");
	var largura = get_cookie("estendido");

	if (isNaN(valor) || valor == 0) {
		valor = 1
	}

	if (isNaN(largura) || largura == 0) {
		largura = 1
	}

    mudarTamanho(valor);
    valorinicial = valor;
	estendido(largura)
}

function elemento(elemento, valor){
	if (DOM2) {
        document.getElementById(elemento).style.fontSize=valor + "em";
        document.getElementById(elemento).innerHTML;
    }
}

function mudarTamanho(valor) {
    if (DOM2) {
		/* Verifica a existencia do elemento na página */
		if (document.getElementById("header")) {
            elemento("header" , (valor)); //ok
		} else if (document.getElementById("header_es")) {
            elemento("header_es" , (valor)); //ok
		} else if (document.getElementById("header_en")) {
            elemento("header_en" , (valor)); //ok
		}

        elemento("menu" , (valor)); //ok
        elemento("formataOnde" , (valor-.4));//ok
        elemento("conteudo" , (valor));//ok
   }
}



/**
* FUNCOES QUE CONTROLAM A EXPANSAO/CONTRACAO DO MENU DE ACESSIBILIDADE.

var trocaimagem = 0;
var enablepersist;
var collapseprevious="yes"; //Collapse previously open content when opening present? (yes/no)

function mudaimagem() {
    if (trocaimagem == 0) {
         document.getElementById("botao").style.backgroundImage='url(imgs/fechado.gif)';
		 trocaimagem = 1;
	} else {
          document.getElementById("botao").style.backgroundImage='url(imgs/aberto.gif)';
		  trocaimagem = 0;
	}
}

function initIcone() {
    statusmenu = get_cookie("enablepersist");
    statusmenu = (statusmenu == "") ? "none" : statusmenu;
    if (statusmenu == "none") {
		trocaimagem = 0;
	} else {
		trocaimagem = 1;
	}
	mudaimagem();
}

function restoreCollapseState() {
    enablepersist = get_cookie("enablepersist");
    enablepersist = (enablepersist == "") ? "none" : enablepersist;
    document.getElementById("extras").style.display = enablepersist;
}

function getElementbyClass(classname) {
    ccollect = new Array();
    var inc = 0;
    var alltags = document.all? document.all : document.getElementsByTagName("*");
    for (i=0; i<alltags.length; i++) {
        if (alltags[i].className == classname) {
             ccollect[inc++]=alltags[i];
		}
    }
}

function contractcontent(omit) {
    var inc = 0;
    while (ccollect[inc]) {
        if (ccollect[inc].id != omit) {
            ccollect[inc].style.display="none";
	    }
        inc++;
    }
}

function expandcontent(cid) {
   if (typeof ccollect!="undefined") {
      if (collapseprevious=="yes") {
          contractcontent(cid);
	  }
      enablepersist = (document.getElementById(cid).style.display!="block")? "block" : "none";
      document.getElementById(cid).style.display = enablepersist;
      //document.cookie = "enablepersist=" + escape(enablepersist);
	  set_cookie("enablepersist", escape(enablepersist)); //TODO
   }
}

function revivecontent() {
   contractcontent("omitnothing");
   selectedItem = getselectedItem();
   selectedComponents = selectedItem.split("|");

   for (i=0; i < selectedComponents.length-1; i++) {
       document.getElementById(selectedComponents[i]).style.display = "block";
   }
}

function getselectedItem() {
   if (get_cookie(window.location.pathname) != "") {
      selectedItem = get_cookie(window.location.pathname);
      return selectedItem;
   } else {
      return "";
   }
}

function saveswitchstate() {

    var inc = 0, selectedItem = "";
    while (ccollect[inc]) {
        if (ccollect[inc].style.display == "block") {
            selectedItem += ccollect[inc].id + "|";
		}
        inc++;
    }

    document.cookie = window.location.pathname + "=" + selectedItem;

}

function do_onload() {
    getElementbyClass("switchcontent");
    if (enablepersist=="on" && typeof ccollect!="undefined") {
        revivecontent();
	}
	initIcone();
	restoreCollapseState();
}

if (window.addEventListener) {
    window.addEventListener("load", do_onload, false);
} else if (window.attachEvent) {
    window.attachEvent("onload", do_onload);
} else if (document.getElementById) {
    window.onload=do_onload;
}

if (enablepersist=="on" && document.getElementById) {
    window.onunload = saveswitchstate;
}

if (document.getElementById){
    document.write('<style type="text/css">');
    document.write('.reveal{display:none;}');
    document.write('</style>');
}
*/
/**
* FUNCAO QUE LIMPA OS INPUT TEXT.
*/
function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}
