﻿function WriteDate() 
{
	hoje = new Date();
	dia = hoje.getDate();
	dias = hoje.getDay();
	mes = hoje.getMonth();
	ano = hoje.getFullYear();
	
	if (dia < 10)
	{
		dia = "0" + dia;
	}
		
	if (ano < 2000)
	{
		ano = "19" + ano
	}
    

	NomeDia = new Array(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 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 ("<font face=Arial, Verdana size=1px, color=#002b5a>" + NomeDia[dias] + ", " + dia + " de " + NomeMes[mes] + " de " + ano + "</font>");
}


/**********************************************************************
Funcionalidade: Formatar durante a digitação uma data no formato 'dd/MM/yyyy'
Autor: Ronaldo Lourenço dos Santos
Data: 18/09/2006
**********************************************************************/

function mascararData(evento, objeto)
{

	var intKey = new Number();
	var strNumero = new String('');
	var strData = new String(objeto.value);
	
	if (document.all)
	{
	
	    var intKey = evento.keyCode;
	
	}
	else
	{
	
	    var intKey = evento.which;
	
	}

    for (var intIndice = 0; intIndice < strData.length; intIndice++)
    {
	
        if (!isNaN(strData.substr(intIndice, 1)))
        {

	        strNumero += strData.substr(intIndice, 1);
			
        }
	
    }

    if (
        intKey != 8
        && intKey != 9
        && intKey != 13
        && intKey != 16
        && intKey != 27
        && intKey != 37
        && intKey != 38
        && intKey != 39
        && intKey != 40
        && intKey != 46
        )
    {
    
        switch (strNumero.length)
        {
        
            case 0:

                strNumero = '';
            
                break;

            case 1:
            
                strNumero = strNumero.substr(0, 1);
            
                break;

            case 2:
            
                strNumero = strNumero.substr(0, 2) + '/';
            
                break;

            case 3:
            
                strNumero = strNumero.substr(0, 2) + '/' + strNumero.substr(2, 1);
            
                break;

            case 4:
            
                strNumero = strNumero.substr(0, 2) + '/' + strNumero.substr(2, 2) + '/';
            
                break;
                
            default:
        
                strNumero = strNumero.substr(0, 2) + '/' + strNumero.substr(2, 2) + '/' + strNumero.substr(4);
            
        }

        objeto.value = strNumero;
    
    }

}





/**********************************************************************
Funcionalidade: Formatar durante a digitação uma data no formato 'MM/yyyy'
Autor: Ronaldo Lourenço dos Santos
Data: 18/09/2006
**********************************************************************/

function MesAno(evento, objeto)
{

	var intKey = new Number();
	var strNumero = new String('');
	var strData = new String(objeto.value);
	
	if (document.all)
	{
	
	    var intKey = evento.keyCode;
	
	}
	else
	{
	
	    var intKey = evento.which;
	
	}

    for (var intIndice = 0; intIndice < strData.length; intIndice++)
    {
	
        if (!isNaN(strData.substr(intIndice, 1)))
        {

	        strNumero += strData.substr(intIndice, 1);
			
        }
	
    }

    if (
        intKey != 8
        && intKey != 9
        && intKey != 13
        && intKey != 16
        && intKey != 27
        && intKey != 37
        && intKey != 38
        && intKey != 39
        && intKey != 40
        && intKey != 46
        )
    {
    
        switch (strNumero.length)
        {
        
            case 0:

                strNumero = '';
            
                break;

            case 1:
            
                strNumero = strNumero.substr(0, 1);
            
                break;

            case 2:
            
                strNumero = strNumero.substr(0, 2) + '/';
            
                break;

            case 3:
            
                strNumero = strNumero.substr(0, 2) + '/'+  strNumero.substr(2, 1);
            
                break;

            case 4:
            
                strNumero = strNumero.substr(0, 2) + '/'+ strNumero.substr(2, 4) ;
            
                break;
                
            default:
        
                strNumero = strNumero.substr(0, 2) + '/' + strNumero.substr(2,3) //+ '/' + strNumero.substr(4);
            
        }

        objeto.value = strNumero;
    
    }

}


