navegador = navigator.appName;
if (navegador == "Microsoft Internet Explorer"){
  document.write("<link href='estilos/fepecsIE.css' rel='stylesheet' type='text/css'/>");
  this.Nav = "IE";
}
else{
  document.write("<link href='estilos/fepecsIE.css' rel='stylesheet' type='text/css'/>");
  this.Nav = "OS";
  //fepecsOS
}

function EscondeMenu() {
  if(document.getElementById('Vertical').style.display == ''){
    document.getElementById('Vertical').style.display = 'none';
    document.getElementById('principal').style.width = '97%';
    document.getElementById('ModoImp').src = 'images/setaRight.jpg';
  }
  else {
    document.getElementById('Vertical').style.display = '';
    document.getElementById('principal').style.width = '570px';
    document.getElementById('ModoImp').src = 'images/setaLeft.jpg';
  }
  
}

function ExibeDescricaoArquivo(Objeto,Mostra){
  if(Mostra){
    document.getElementById(Objeto).style.display = 'block';
  }
  else{
    document.getElementById(Objeto).style.display = 'none';
  }
}

function ImprimeData(){
  DataToda = new Date();
  DiaHoje = DataToda.getDay();
  MesHoje = DataToda.getMonth();

  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";
  
  NomeMes = new Array(12)
  NomeMes[0] = "Janeiro";
  NomeMes[1] = "Fevereiro";
  NomeMes[2] = "Março";
  NomeMes[3] = "Abril";
  NomeMes[4] = "Maio";
  NomeMes[5] = "Junho";
  NomeMes[6] = "Julho";
  NomeMes[7] = "Agosto";
  NomeMes[8] = "Setembro";
  NomeMes[9] = "Outubro";
  NomeMes[10] = "Novembro";
  NomeMes[11] = "Dezembro";
  
  document.write (NomeDia[DiaHoje] + ', ' + DataToda.getDate() + ' de ' + NomeMes[MesHoje] + ' de ' + DataToda.getYear());
}

function ImprimeRodaPe(){
  document.write ('ESCS - Escola Superior de Ciências da Saúde - SMHN Quadra 03, conjunto A, Bloco 1 Edifício Fepecs CEP 70.710-907 Brasília/DF E-mail:escs@saude.df.gov.br. <br/>desenvolvido por Nucleo de Informática.')
}

function JsSubmit(Action,Valor){
  document.Restrito.action=Action;
  document.Restrito.grupo.value = Valor;
  document.Restrito.method='POST';
  document.Restrito.submit();
  return true;
}


function LerConteudo(ConteudoId){
  location.href = 'lerconteudo.php?ConteudoId=' + ConteudoId;
}

function MenuHorizontal(){
  var objeDiv = document.getElementById('Horizontal');
  objeDiv.style.display = 'block';
  objeDiv.innerHTML = '';
  if(this.Nav == "IE"){
    objeDiv.innerHTML = ObterXML("xml/menuhorizontal.xml", "estilos/menuhorizontal.xsl");
  }
  else{
    objeDiv.appendChild(ObterXML("xml/menuhorizontal.xml", "estilos/menuhorizontal.xsl"));
  }
}

function MenuVertical(){
  var objeDiv = document.getElementById('menu');
  objeDiv.style.display = 'block';
  if(this.Nav == "IE"){
    objeDiv.innerHTML = ObterXML("xml/menuvertical.xml", "estilos/menuvertical.xsl");
  }
  else{
    objeDiv.appendChild(ObterXML("xml/menuvertical.xml", "estilos/menuvertical.xsl"));
  }
}

function ObterContexto(){
  //Calcula o Contexto
  Url = location.href;
  Arquivo = Url.substring(Url.lastIndexOf("/") + 1,Url.length);
  Replace =  Arquivo.replace(".php","");
  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 Pesquisar(ConteudoTxt){
  location.href = 'pesquisar.php?Parametro=' + ConteudoTxt;
}

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 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 EnviarForm(Formulario, ScriptPHP, w, h){
  PopUp('',w,h);
  Formulario.method = 'POST';
  Formulario.target = 'PopUp';
  Formulario.action = ScriptPHP;
  Formulario.submit();
  return true;
}

function TrocaCorDiv(Obj ,Trocar) {
  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';
  }
}
