/*ESTE BLOCO RESOLVE A AUTOMAÇÃO DOS CAMPO DE DATA EXISTENTES NAS PÁGINAS agenda.php e agenda_admin.php*/
function focoLigado(id,valor)
{
	var objeto = document.getElementById(id);
	if(objeto.value==valor)
		objeto.value='';
}
function focoDesligado(id,valor)
{
	var objeto = document.getElementById(id);
	if(objeto.value=='')
		objeto.value=valor;
}

var vetorDias	= new Array('dia', 'diainicial', 'diafinal');
var vetorMeses	= new Array('mes', 'mesinicial', 'mesfinal');
var vetorAnos	= new Array('ano', 'anoinicial', 'anofinal');

for(i = 0; i<3; i++)
{
	Dia = document.getElementById(vetorDias[i]);
	Mes = document.getElementById(vetorMeses[i]);
	Ano = document.getElementById(vetorAnos[i]);

	var anterior;

	if(Dia != null && Mes != null && Ano != null)
	{
		Dia.onfocus = function (){anterior = this.value; focoLigado(this.id,this.value);};
		Dia.onblur = function (){focoDesligado(this.id,anterior);};
		Dia.onkeyup = new Function("if(document.getElementById('" + vetorDias[i] + "').value.length == 2) document.getElementById('" + vetorMeses[i] + "').focus();");
		Mes.onfocus = function (){anterior = this.value; focoLigado(this.id,this.value)};
		Mes.onblur = function (){focoDesligado(this.id,anterior)};
		Mes.onkeyup = new Function("if(document.getElementById('" + vetorMeses[i] + "').value.length == 2) document.getElementById('" + vetorAnos[i] + "').focus();");
		Ano.onfocus = function (){anterior = this.value; focoLigado(this.id,this.value)};
		Ano.onblur = function (){focoDesligado(this.id,anterior)};
	}
}
if(document.getElementById(vetorAnos[1]) != null)
{
	document.getElementById(vetorAnos[1]).onkeyup = function (){if(document.getElementById(vetorAnos[1]).value.length == 4) document.getElementById(vetorDias[2]).focus();};
}
/*FIM DO BLOCO*/