 hoje = new Date();
dia = hoje.getDate();
dias = hoje.getDay();
mes = hoje.getMonth();
var ano = hoje.getYear();
if(ano < 2000) ano = hoje.getYear() + 1900;
    
if (dia < 10) dia = "0" + dia;
NomeDia = new CriaArray(7);
NomeDia[0] = "Domingo";
NomeDia[1] = "Segunda-feira";
NomeDia[2] = "Terça-feira";
NomeDia[3] = "Quarta-feira";
NomeDia[4] = "Quinta-feira";
NomeDia[5] = "Sexta-feira";
NomeDia[6] = "Sábado";
NomeMes = new CriaArray(12);
NomeMes[0]  = "Janeiro";
NomeMes[1]  = "Fevereiro";
NomeMes[2]  = "Mar&ccedil;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";

var todaysDate = NomeDia[dias] + ", " + dia + " de " + NomeMes[mes] + " de " + ano + "";
var hojedata = dia + " de " + NomeMes[mes] + " de " + ano + "";

function CriaArray(n) {
   this.length = n
}

function removeAcentos(str) {
	str = str.toLowerCase();
	str = str.replace("â", "a");
	str = str.replace("ã", "a");
	str = str.replace("á", "a");
	str = str.replace("à", "a");
	str = str.replace("é", "e");
	str = str.replace("è", "e");
	str = str.replace("í", "i");
	str = str.replace("ì", "i");
	str = str.replace("ô", "o");
	str = str.replace("õ", "o");
	str = str.replace("ó", "o");
	str = str.replace("ò", "o");
	str = str.replace("ú", "u");
	str = str.replace("ù", "u");
	str = str.replace("ü", "u");
	str = str.replace("ç", "c");
	return str;
}

function sugerirLogin() {
    var inputLogin = document.getElementById('cadastroAdministrador:login');
    var nome = document.getElementById('cadastroAdministrador:nome').value;

    if(inputLogin.value != "") return;

    if(nome.indexOf(" ") > 0) {
        var arrNome = nome.split(" ");
        var login = arrNome[0] + "." + arrNome[arrNome.length-1];
	login = removeAcentos(login);
        inputLogin.value = login;
    } else {
	nome = removeAcentos(nome);
        inputLogin.value = nome;
    }
}

var inputFocus = function()
{
   var sfEls = document.getElementsByTagName("INPUT");

   for (var i=0; i<sfEls.length; i++)
   {
	  if(sfEls[i].type.toLowerCase() == 'text' || sfEls[i].type.toLowerCase() == 'password')
	  {
		  sfEls[i].onfocus=function() {
		   this.className ='camposelecionado';
                   if( this.id == 'cadastroAdministrador:login' ) {
                    sugerirLogin();
                   }
		  }

		  sfEls[i].onblur=function() {
		   this.className='';
		  }
	  }
	  else if(sfEls[i].type.toLowerCase() == 'checkbox') 
	  {
		  sfEls[i].className = 'check';
	  }
   }
}

if (window.attachEvent) window.attachEvent("onload", inputFocus);
       

/**
 * Exibe a mensagem de carregando enquanto a solicitação estiver sendo
 * solicitada.
 **/

function showHelpMessage() {

   //elemento para acessar a url via ajax
   try{
       xmlhttp = new XMLHttpRequest();
   }catch(ee){
       try{
          xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
      }catch(e){
          try{
           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
           xmlhttp = false;
        }
      }
   }
   
   xmlhttp.open("GET", "/restrito/administrador/detalhe_correio.html",true);

   //Executada quando o navegador obtiver o código
   xmlhttp.onreadystatechange=function() {
    
    if (xmlhttp.readyState==4){
       createHelpMessage(xmlhttp.responseText);
    }
   }
   
   xmlhttp.send(null);

}

function createHelpMessage(html) {
    var div = document.getElementById('divHelp');
    div.innerHTML = html;
        
    //verifica a resolução do monitor, aplicando estilos diferentes, padrão 1024
    if( parseInt(screen.width) <= 800 ) {
        div.id = "divHelp800";
    } else if(parseInt(screen.width) > 1024) {
        div.id = "divHelp1280";
    }
}

  <!--
            function AbreJanela(param, h, w)
            {
            novaJanela = window.open(param, 'eventos','height=' + h + ',width=' + w + ',scrollbars=yes');
            }
            // -->

//fecha a div

function toggle(obj) {
var el = document.getElementById(obj);
if ( el.style.display != 'none' ) {
el.style.display = 'none';
}
else {
el.style.display = '';
}
}
