navegador = navigator.appName;
if (navegador == "Microsoft Internet Explorer"){
  document.write("<link href='Estilos/IE.css' rel='stylesheet' type='text/css'/>");
  this.Nav = "IE";
}
else{
  document.write("<link href='Estilos/Open.css' rel='stylesheet' type='text/css'/>");
this.Nav = "OS";
}
this.Ficha = null;

function AtualizarCadastro(Ficha){
  Contexto = ObterContexto();
  if(this.Ficha != null){
    document.getElementById(this.Ficha).style.display = 'none';
  };
  this.Ficha = Ficha;
  if(eval(this.Servico)){
    document.getElementById(this.Servico).style.display = 'none';
  }
  document.getElementById('AtualizacaoCadastro').style.display = 'block';
  document.getElementById(this.Ficha).style.display = 'block';
  document.getElementById('Sindicalizacao').style.display = 'none';
  if(Contexto == 'index'){
    document.getElementById('NoticiaPrincipalTeste').style.display = 'none';
    //document.getElementById('NoticiaSec').style.display = 'none';
    //document.getElementById('BannerBottom').style.display = 'block';
  }
  else if((Contexto == 'imprensa') || (Contexto == 'juridico') || (Contexto == 'links') || (Contexto == 'valorizese') || (Contexto == 'galeria') || (Contexto == 'videos')){
    document.getElementById('ConteudoPrincipal').style.display = 'none';
  }
}

function Confirmar(LinkArquivo){
  result = confirm('A responsabilidade pelo conteúdo, confecção e divulgação do Clipping de Brasília é de Alfredo Bessow, fones 8410 8797 e 9613 8140.\nHavendo interesse em receber o clipping, via e-mail, contatar o Sr. Alfredo Bessow:  clipping.debrasilia@gmail.com.\n\nPara ver o clipping clique em [OK]');
  if(result){
    PopUp(LinkArquivo);
  }
}

function DiretoriasAnteriores(Id) {
  if(Id != '0'){
    Link = 'diretoriasanteriores/' + Id;
    PopUp(Link);
  }
}

function escondeDiv(){
  var objDiv = document.getElementById("EventoSindMedico");
  if(objDiv != null){
    objDiv.style.display = "none";
  }
}

function FechaDiretoriaPainel(){
  document.getElementById('Diretoriapainel').style.display = 'none';
  document.getElementById(this.Id).style.display = 'none';
  this.Id = 0;
  return true;
}

function FechaServico(){
  if(this.Contexto == 'index'){
    document.getElementById('NoticiaPrincipalTeste').style.display = 'block';
    //document.getElementById('NoticiaSec').style.display = 'block';
    //document.getElementById('BannerBottom').style.display = 'block';
  }
  else if(this.Contexto == 'diretoria'){
    document.getElementById('Diretoria').style.display = 'block';
    document.getElementById('Trienio').style.display = 'block';
  }
  else if((this.Contexto == 'imprensa') || (this.Contexto == 'juridico') || (this.Contexto == 'links') || (this.Contexto == 'valorizese') || (this.Contexto == 'galeria') || (Contexto == 'videos')){
    document.getElementById('ConteudoPrincipal').style.display = 'block';
  }
  document.getElementById(this.Servico).style.display = 'none';
  return true;
}

function GetFromValues(Formulario){
  var str = "";
  var formObject = Formulario;

  for(var n = 0; n < formObject.elements.length; n++) {
    if(formObject.elements[n].type == "radio") {
      if(!str) {
        if(formObject.elements[n].checked == true) {
           str = formObject.elements[n].name + '=' + encodeURIComponent(formObject.elements[n].value);
        }
        else {
          str = str;
        }
      }
      else {
        if(formObject.elements[n].checked == true) {
          str = str + '&' + formObject.elements[n].name + '=' + encodeURIComponent(formObject.elements[n].value);
        }
        else {
          str = str;
        }
      }
    }
    else if(formObject.elements[n].type == "checkbox") {
      if(!str) {
        if(formObject.elements[n].checked == true) {
          str = formObject.elements[n].name + '=' + encodeURIComponent(formObject.elements[n].value);
        }
        else {
          str = str;
        }
      }
      else {
        if(formObject.elements[n].checked == true) {
          str = str + '&' + formObject.elements[n].name + '=' + encodeURIComponent(formObject.elements[n].value);
        }
        else {
          str = str;
        }
      }
    }
    else if(formObject.elements[n].type == "button") {
      str = str;
    }
    else if(formObject.elements[n].type != "fieldset"){
      if(!str) {
        str = formObject.elements[n].name + '=' + encodeURIComponent(formObject.elements[n].value);
      }
      else {
        str = str + '&' + formObject.elements[n].name + '=' + encodeURIComponent(formObject.elements[n].value);
      }
    }
  }
  return (str);
}

function LerNoticia(NoticiaID){
  location.href = 'LerNoticia.php?NoticiaId=' + NoticiaID + '&Contexto=' + ObterContexto();
}

function MostraData(){
  DataToda = new Date();
  DiaHoje = DataToda.getDay();

  NomeDia = new Array(7)
  NomeDia[0] = "Dom";
  NomeDia[1] = "Seg";
  NomeDia[2] = "Ter" ;
  NomeDia[3] = "Qua";
  NomeDia[4] = "Qui";
  NomeDia[5] = "Sex";
  NomeDia[6] = "Sáb";
  document.write (NomeDia[DiaHoje] + ', ' + DataToda.getDate() + ' de ' + DataToda.getYear());
}

function MostraDiretoriaPainel(DiretorId) {
  if (this.Id > 0){
    FechaDiretoriaPainel();
  }
  this.Id = DiretorId;
  document.getElementById(Id).style.display = 'block';
  document.getElementById('Diretoriapainel').style.display = 'block';
  return true;
}

function MenuDireito(){
  var objeDiv = document.getElementById('apoio');
  objeDiv.style.display = 'block';
  objeDiv.innerHTML = '';
  if(this.Nav == "IE"){
    objeDiv.innerHTML = ObterXML("DadosXML/MenuApoio.xml", "Estilos/MenuApoio.xsl");
  }
  else{
   objeDiv.appendChild(ObterXML("DadosXML/MenuApoio.xml", "Estilos/MenuApoio.xsl"));
  }
}

function MenuBannerBottom(){
  var objeDiv = document.getElementById('BannerBottom');
  objeDiv.innerHTML = '';
  if(this.Nav == "IE"){
    objeDiv.innerHTML = ObterXML("DadosXML/MenuApoio.xml", "Estilos/MenuBanners.xsl");
  }
  else{
    objeDiv.appendChild(ObterXML("DadosXML/MenuApoio.xml", "Estilos/MenuBanners.xsl"));
  }
}

function MenuBannerEsquerdo(){
  var objeDivLeft = document.getElementById('BannerEsquerdo');
  if(this.Nav == "IE"){
    objeDivLeft.innerHTML = ObterXML("DadosXML/MenuApoio.xml", "Estilos/MenuBannerEsquerdo.xsl");
  }
  else{
    objeDivLeft.appendChild(ObterXML("DadosXML/MenuApoio.xml", "Estilos/MenuBannerEsquerdo.xsl"));
  }
}


function MenuHorizontal(){
  var objeDiv = document.getElementById('MenuHoriz');
  objeDiv.style.display = 'block';
  objeDiv.innerHTML = '';
  if(this.Nav == "IE"){
    objeDiv.innerHTML = ObterXML("DadosXML/MenuHorizontal.xml", "Estilos/MenuHorizontal.xsl");
  }
  else{
    objeDiv.appendChild(ObterXML("DadosXML/MenuHorizontal.xml", "Estilos/MenuHorizontal.xsl"));
  }

}

function MenuVertical(){
  var objeDiv = document.getElementById('menuVert');
  objeDiv.style.display = 'block';
  if(this.Nav == "IE"){
    objeDiv.innerHTML = ObterXML("DadosXML/MenuServico.xml", "Estilos/MenuServico.xsl");
  }
  else{
    objeDiv.appendChild(ObterXML("DadosXML/MenuServico.xml", "Estilos/MenuServico.xsl"));
  }
}

function MontarFicha(Ficha){
  document.getElementById(Ficha).style.display = 'block';
  document.getElementById(this.Ficha).style.display = 'none';
  this.Ficha = Ficha;
}

function MostraServico(ServicoId) {
  if (this.Controle == "A"){
    FechaServico();
  }
  this.Servico = ServicoId;
  //Calcula o Contexto
  //Url = location.href;
  //Arquivo = Url.substring(Url.lastIndexOf("/") + 1,Url.length);
  this.Contexto = ObterContexto();
  
  document.getElementById(this.Servico).style.display = 'block';
  if(this.Contexto == 'index'){
    document.getElementById('NoticiaPrincipalTeste').style.display = 'none';
    //document.getElementById('NoticiaSec').style.display = 'none';
    //document.getElementById('BannerBottom').style.display = 'none';

    document.getElementById('AtualizacaoCadastro').style.display = 'none';
    document.getElementById('Sindicalizacao').style.display = 'none';
  }
  else if(this.Contexto == 'diretoria'){
    document.getElementById('Diretoria').style.display = 'none';
    document.getElementById('Trienio').style.display = 'none';
  }
  else if((this.Contexto == 'imprensa') || (this.Contexto == 'juridico') || (this.Contexto == 'links') || (this.Contexto == 'valorizese') || (this.Contexto == 'galeria') || (Contexto == 'videos')){    document.getElementById('ConteudoPrincipal').style.display = 'none';
    
    document.getElementById('AtualizacaoCadastro').style.display = 'none';
    document.getElementById('Sindicalizacao').style.display = 'none';
  }
  this.Controle = "A";
}

function ObterContexto(){
  //Calcula o Contexto
  Url = location.href;
  Arquivo = Url.substring(Url.lastIndexOf("/") + 1,Url.length);
  Replace =  Arquivo.replace(".php","");
  if(Replace.length == 0) {
    return 'index';
  }
  return Replace.toLowerCase();
}

function ObterXML(ArquivoXML, ArquivoXSL) {
  var objeXml;
  var objeXsl;

  //Para funcionar no Internet Explorer
  if (window.ActiveXObject) {
    //Carregando o Arquivo XML
    var objeXml = new ActiveXObject("Microsoft.XMLDOM");
    objeXml.async = false;
    objeXml.load(ArquivoXML);

    //Carregando o Arquivo XSL
    var objeXsl = new ActiveXObject("Microsoft.XMLDOM");
    objeXsl.async = false;
    objeXsl.load(ArquivoXSL);

    //Transformacao e Retorno
    return objeXml.transformNode(objeXsl);
  }
  //Para funcionar no Mozilla/Firefox
  else if(window.XMLHttpRequest) {
    var objeXSLTProcessor;
    var objeXmlDoc;
    var objeXSLT;
    //Criando o processador de XLST
    objeXSLTProcessor = new XSLTProcessor();

    //Carregando o arquivo XSL
    objeXsl = new XMLHttpRequest();
    objeXsl.open("GET", ArquivoXSL, false);
    objeXsl.send(null);

    objeXSLT = objeXsl.responseXML;
    objeXSLTProcessor.importStylesheet(objeXSLT);

    //Carregando o arquivo XML
    objeXml = new XMLHttpRequest();
    objeXml.open("GET", ArquivoXML, false);
    objeXml.send(null);

    objeXmlDoc = objeXml.responseXML;

    //Transformacao e Retorno
    return objeXSLTProcessor.transformToFragment(objeXmlDoc, document);
  }
}

function PainelDiretoria(){
  var objeDiv = document.getElementById('Diretoriapainel');
  objeDiv.innerHTML = '';
  if(this.Nav == "IE"){
    objeDiv.innerHTML = ObterXML("DadosXML/PainelDiretoria.xml", "Estilos/PainelDiretoria.xsl");
  }
  else{
    objeDiv.appendChild(ObterXML("DadosXML/PainelDiretoria.xml", "Estilos/PainelDiretoria.xsl"));
  }

}

function PopUp(sArquivo,w,h){
  if(!eval(w)){
    var w = 740;
  }
  if(!eval(h)){
    var h = 460;
  }
  var left = (screen.width - w) / 2;
  var top = (screen.height - h) / 2;
  Opcoes = 'width='+w+',height='+h+',top='+top+',left='+left+',toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1'
  win = window.open(sArquivo,'PopUp',Opcoes);
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function SubmitForm(Formulario, ScriptPHP, Ficha){
  PopUp('');
  Formulario.method = 'POST';
  Formulario.target = 'PopUp';
  Formulario.action = ScriptPHP;
  Formulario.submit();

  Contexto = ObterContexto();
  document.getElementById(Ficha).style.display = 'none';
  if(Contexto == 'index'){
    document.getElementById('NoticiaPrincipalTeste').style.display = 'block';
    document.getElementById('NoticiaSec').style.display = 'block';
  }
  else if((Contexto == 'imprensa') || (Contexto == 'juridico') || (Contexto == 'links') || (Contexto == 'valorizese') || (Contexto == 'galeria') || (Contexto == 'videos')){
    document.getElementById('ConteudoPrincipal').style.display = 'block';
  }
  return true;
}

function Replace(str,find,repla){
  var newStr = ""
  for(i=0;i<=str.length-1;i++){
    strValue = str.substring(i,i+1)
    if (strValue == find){
      newStr += repla;
    }
    else{
      newStr += str.substring(i,i+1);
    }
  }
  return newStr
}

function Sindicalizacao(Ficha){
  Contexto = ObterContexto();
  if(this.Ficha != null){
    document.getElementById(this.Ficha).style.display = 'none';
  };
  this.Ficha = Ficha;
  if(eval(this.Servico)){
    document.getElementById(this.Servico).style.display = 'none';
  }
  document.getElementById('Sindicalizacao').style.display = 'block';
  document.getElementById(this.Ficha).style.display = 'block';
  document.getElementById('AtualizacaoCadastro').style.display = 'none';
  if(Contexto == 'index'){
    document.getElementById('NoticiaPrincipalTeste').style.display = 'none';
    //document.getElementById('NoticiaSec').style.display = 'none';
    //document.getElementById('BannerBottom').style.display = 'block';
  }
  else if((Contexto == 'imprensa') || (Contexto == 'juridico') || (Contexto == 'links') || (Contexto == 'valorizese') || (Contexto == 'galeria') || (Contexto == 'videos')){
   document.getElementById('ConteudoPrincipal').style.display = 'none';
  }
}

function TrocaCorDiv(Obj ,Trocar) {
  Contexto = ObterContexto();
  if(Contexto == 'index') {
    if(Trocar){
      Obj.style.background = '#E1F2E0';
      Obj.style.border = 'solid 1px #95BC92';
    }
    else {
      Obj.style.background = '#FFFFFF';
      Obj.style.border = 'none';
      Obj.style.borderBottom = 'solid 2px #95BC92';
    }
  }
  if(Contexto == 'diretoria') {
    if(Trocar){
      Obj.style.background = '#D8DEE2';
      Obj.style.border = 'solid 1px #9BB9CA';
    }
    else {
      Obj.style.background = '#FFFFFF';
      Obj.style.border = 'none';
      Obj.style.borderBottom = 'solid 2px #9BB9CA';
    }
  }
  if(Contexto == 'juridico') {
    if(Trocar){
      Obj.style.background = '#F1E2DC';
      Obj.style.border = 'solid 1px #D3A18F';
    }
    else {
      Obj.style.background = '#FFFFFF';
      Obj.style.border = 'none';
      Obj.style.borderBottom = 'solid 2px #D3A18F';
    }
  }
  else if(Contexto == 'imprensa') {
    if(Trocar){
      Obj.style.background = '#D3DBEF';
      Obj.style.border = 'solid 1px #94a4d7';
    }
    else {
      Obj.style.background = '#FFFFFF';
      Obj.style.border = 'none';
      Obj.style.borderBottom = 'solid 2px #94a4d7';
    }
  }
  else if(Contexto == 'valorizese') {
    if(Trocar){
      Obj.style.background = '#F1ECDE';
      Obj.style.border = 'solid 1px #F0DB98';
    }
    else {
      Obj.style.background = '#FFFFFF';
      Obj.style.border = 'none';
      Obj.style.borderBottom = 'solid 2px #F0DB98';
    }
  }
  else if(Contexto == 'galeria') {
    if(Trocar){
      Obj.style.background = '#FFECFF';
      Obj.style.border = 'solid 1px #FFD7FF';
    }
    else {
      Obj.style.background = '#FFFFFF';
      Obj.style.border = 'none';
      Obj.style.borderBottom = 'solid 2px #FFD7FF';
    }
  }
  else if(Contexto == 'videos') {
    if(Trocar){
      Obj.style.background = '#EFEFEF';
      Obj.style.border = 'solid 1px #E0E0E0';
    }
    else {
      Obj.style.background = '#FFFFFF';
      Obj.style.border = 'none';
      Obj.style.borderBottom = 'solid 2px #E0E0E0';
    }
  }
}
