function confirmacao(mensagem, href) {
         if (confirm(mensagem)) {
            location.href = href;
         }
}

function espacamento(espacamento) {
         var novo_espacamento = document.createElement("div");
         novo_espacamento.id = "espacamento_" + espacamento;
         return novo_espacamento;
}

function linha(espacamento) {
         var novo_div = document.createElement("div");
         novo_div.appendChild(this.espacamento(espacamento));
         var nova_linha = document.createElement("div");
         nova_linha.id = "linha";
         novo_div.appendChild(nova_linha);
         novo_div.appendChild(this.espacamento(espacamento));
         return novo_div;
}

function linha_grossa(espacamento) {
         var novo_div = document.createElement("div");
         novo_div.appendChild(this.espacamento(espacamento));
         var nova_linha = document.createElement("div");
         nova_linha.id = "linha_grossa";
         novo_div.appendChild(nova_linha);
         novo_div.appendChild(this.espacamento(espacamento));
         return novo_div;
}

function montar_a(href, objeto, texto, classe) {
         var novo_a = document.createElement("a");
         novo_a.href = href;
         if (objeto) {novo_a.appendChild(objeto);}
         if (texto) {novo_a.innerHTML = texto;}
         novo_a.className = classe;
         return novo_a;
}

function montar_a_blank(href, objeto, texto, classe) {
         var novo_a = document.createElement("a");
         novo_a.href = href;
         novo_a.target = "_blank";
         if (objeto) {novo_a.appendChild(objeto);}
         if (texto) {novo_a.innerHTML = texto;}
         novo_a.className = classe;
         return novo_a;
}

function montar_div(div, objeto, texto) {
         var novo_div = document.createElement("div");
         novo_div.id = div;
         if (objeto) {novo_div.appendChild(objeto);}
         if (texto) {novo_div.innerHTML = texto;}
         return novo_div;
}

function montar_estatisticas_img(item) {
         var coluna = document.createElement("td");
         coluna.appendChild(this.montar_img("../ekmf_cms/imagens/" + item + ".gif", 0, 0));
         coluna.align = "middle";
         coluna.width = "30";
         return coluna;
}

function montar_estatisticas_span(item) {
         var coluna = document.createElement("td");
         coluna.appendChild(this.montar_span("tabela_material_texto_10", 0, item));
         coluna.align = "middle";
         coluna.width = "30";
         return coluna;
}

function montar_estatisticas(comentarios, downloads, nota, visitas, idiomas) {
         var novo_table = document.createElement("table");
         novo_table.border = "0";
         novo_table.cellpadding = "0";
         novo_table.cellspacing = "0";
         novo_table.id = "tabela_estatisticas";

         var corpo = document.createElement("tbody");
         
         var linha = document.createElement("tr");
         corpo.appendChild(linha)
         linha.appendChild(this.montar_estatisticas_img("comentarios"));
         linha.appendChild(this.montar_estatisticas_img("downloads"));
         linha.appendChild(this.montar_estatisticas_img("nota"));
         linha.appendChild(this.montar_estatisticas_img("visitas"));
         idiomas_partes = idiomas.split(", ");
         for (var i = 0; i < idiomas_partes.length; i++) {
             linha.appendChild(this.montar_estatisticas_img(idiomas_partes[i]));
         }

         var linha = document.createElement("tr");
         corpo.appendChild(linha)
         linha.appendChild(this.montar_estatisticas_span(comentarios));
         linha.appendChild(this.montar_estatisticas_span(downloads));
         linha.appendChild(this.montar_estatisticas_span(nota));
         linha.appendChild(this.montar_estatisticas_span(visitas));
         for (var i = 0; i < idiomas_partes.length; i++) {
             linha.appendChild(this.montar_estatisticas_span(idiomas_partes[i]));
         }
         
         novo_table.appendChild(corpo);
         return this.montar_p("center", novo_table, 0);
}

function montar_img(src, height, width) {
         var novo_img = document.createElement("img");
         novo_img.src = src;
         if (height) {novo_img.height = height;}
         if (width) {novo_img.width = width;}
         return novo_img;
}

function montar_material(tipo, titulo) {
         var novo_table = document.createElement("table");
         novo_table.border = "0";
         novo_table.cellpadding = "0";
         novo_table.cellspacing = "0";
         novo_table.id = "tabela_material";

         var corpo = document.createElement("tbody");

         var linha = document.createElement("tr");
         corpo.appendChild(linha)
         var coluna = document.createElement("td");
         coluna.appendChild(this.montar_img("imagens/" + tipo + ".gif", 0, 0));
         coluna.align = "middle";
         coluna.width = "21";
         linha.appendChild(coluna);
         var coluna = document.createElement("td");
         coluna.appendChild(this.montar_span("tabela_revisoes_texto_10", 0, titulo));
         linha.appendChild(coluna);

         novo_table.appendChild(corpo);
         return novo_table;
}

function montar_p(alinhamento, objeto, texto) {
         var novo_p = document.createElement("p");
         novo_p.align = alinhamento;
         if (objeto) {novo_p.appendChild(objeto);}
         if (texto) {novo_p.innerHTML = texto;}
         return novo_p;
}

function montar_span(span, objeto, texto) {
         var novo_span = document.createElement("span");
         novo_span.id = span;
         if (objeto) {novo_span.appendChild(objeto);}
         if (texto) {novo_span.innerHTML = texto;}
         return novo_span;
}

fs = 100;		// Tamanho padrão
fmin = 10;		// Tamanho mínimo
fmax = 500;		// Tamanho máximo
fstep = 1;		// Intervalos em % entre zoom-in e zoom-out

function mudar_tamanho_fonte(n) {
         if (n == 1) fs = 99;
         if (n == 2 && fs > fmin) fs = fs - fstep;
         if (n == 3 && fs < fmax) fs = fs + fstep;
         document.getElementById("principal_texto_10verdana").style.fontSize = "20px";
//             var elemento = document.all ? document.all : document.getElementsByTagName("*");
//             for (j = 0; j < elemento.length; j++) {
//                 elemento[j].style.fontSize = fs + "%";
//             }
//         }
}

function validar_data(campo, e) {
         var expReg = /^([0-9])$/;
         myVal = campo.value;
         var aux = myVal.substr(myVal.length - 1, myVal.length);
         if (myVal.length > 2 && !myVal.match(/\//)) {
            myVal = '';
         }
         else {
              if (window.event) {
                 keycode = window.event.keyCode;
              }
              else if (e) {
                   keycode = e.which;
              }
              if (!aux.match(expReg)) {
                 myVal = myVal.substr(0, (myVal.length - 1));
              }
              if ((myVal.length == 2 || myVal.length == 5) && (keycode != 8)) {
                 myVal += '/';
              }
         }
         campo.value = myVal;
}

function popup(url, nome, altura, largura) {
         var left = (screen.width - largura) / 2;
         var top = (screen.height - altura) / 2;
         var parametros = "width = " + largura + ", height = " + altura;
         parametros += ", top = " + top + ", left = " + left;
         parametros += ", directories = no";
         parametros += ", location = no";
         parametros += ", menubar = no";
         parametros += ", resizable = no";
         parametros += ", scrollbars = no";
         parametros += ", status = no";
         parametros += ", toolbar = no";
         newwin = window.open(url, "nome", parametros);
         if (window.focus) {
            newwin.focus();
         }
         return false;
}

