/* funcao para filtro de fotos */
function escolheFoto(){
	document.frmExec.action="fun_exibe_foto.php?exec=1&pri=1&idtpev=0";
	document.frmExec.submit();
}

/* funcao para links */
function netie(net, ie) {
  if ((navigator.appVersion.substring(0,3) >= net && navigator.appName == 'Netscape' && net != -1) || (navigator.appVersion.substring(0,3) >= ie && navigator.appName.substring(0,9) == 'Microsoft' && ie != -1))
    return true;
else return false;
}

/* abre janela de popup */
function launch(url,tamh,tamv,resizeble,scroll,posl,post) {
   self.name = "opener";
   remote = open(url, "remote", "resizable=" + resizeble + ",scrollbars=" + scroll + ",left=" + posl + ",top=" + post + ",width=" + tamh + ",height=" + tamv + ",bgcolor=white");
}

/* abre nova janela */
function NewWindow (width, height, myname, url,scroll,status,toolbar,menubar,location,directories,resizeble)
{
  var left, top;

  if (screen.width < width)
    left = 0;
  else
    left = (screen.width  - width) / 2;

  if (screen.height < height)
    top = 0;
  else
    top = (screen.height - height) / 4;

  if ( navigator.appName == "Netscape" )
  {  var w = window.open (url, myname, "height="+height+",width="+width+
    ",screenX=" + left + ",screenY=" + top + ",scrollbars="+ scroll + ",status=" + status + ",toolbar=" + toolbar + ",menubar=" + menubar + ",location=" + location + ",directories=" + directories + ",resizeble=" + resizeble + "");}
  else
  {  var w = window.open (url, myname, "height="+height+",width="+width+
    ",left=" + left + ",top=" + top + ",scrollbars="+ scroll + ",status=" + status + ",toolbar=" + toolbar + ",menubar=" + menubar + ",location=" + location + ",directories=" + directories + ",resizeble=" + resizeble + "");}

  if (w)
   w.focus ();

}

function trocaPagina(hp,opc)
{
	location.href=hp+"&opc="+opc;
}

/* funcoes de validacao - inicio */
function incluirAgenda()
{
	iErro=0;
	str1 = "";
	msg = "Campo inválido - ";
	
	indiceTpEvento = document.frmExecIncAgenda.idtpevento.selectedIndex;
	indiceDia = document.frmExecIncAgenda.dia.selectedIndex;
	indiceMes = document.frmExecIncAgenda.mes.selectedIndex;
	indiceAno = document.frmExecIncAgenda.ano.selectedIndex;
	
	/* tipo de evento */
	if (document.frmExecIncAgenda.idtpevento.options[indiceTpEvento].value=="0")
	{
		window.alert(msg + 'Tipo de evento');
		iErro=1;
	}
	
	/* nome */
	str1 = document.frmExecIncAgenda.nome.value;
	if ((str1=="") || (str1=="0") || (str1==" ") || (str1.length<3))
	{
		window.alert(msg + 'Nome');
		iErro=1;
	}
	
	/* data */
	if (document.frmExecIncAgenda.dia.options[indiceDia].value=="0")
	{
		window.alert(msg + 'Dia');
		iErro=1;
	}
	
	if (document.frmExecIncAgenda.mes.options[indiceMes].value=="0")
	{
		window.alert(msg + 'Mês');
		iErro=1;
	}
	
	if (document.frmExecIncAgenda.ano.options[indiceAno].value=="0")
	{
		window.alert(msg + 'Ano');
		iErro=1;
	}
	
	/* localagenda */
	str1 = document.frmExecIncAgenda.local.value;
	if ((str1=="") || (str1=="0") || (str1==" ") || (str1.length<3))
	{
		window.alert(msg + 'Local');
		iErro=1;
	}
	
	/* endereco */
	str1 = document.frmExecIncAgenda.endereco.value;
	if ((str1=="") || (str1=="0") || (str1==" ") || (str1.length<3))
	{
		window.alert('Campo inválido - Endereço');
		iErro=1;
	}
	
	/* cidade */
	str1 = document.frmExecIncAgenda.cidade.value;
	if ((str1=="") || (str1=="0") || (str1==" ") || (str1.length<3))
	{
		window.alert(msg + 'Cidade');
		iErro=1;
	}
	
	/* uf */
	str1 = document.frmExecIncAgenda.uf.value;
	if ((str1=="") || (str1=="0") || (str1==" ") || (str1.length<1))
	{
		window.alert(msg + 'UF');
		iErro=1;
	}
	
	/* censura */
	str1 = document.frmExecIncAgenda.censura.value;
	if ((str1=="") || (str1=="0") || (str1==" ") || (str1.length<3))
	{
		window.alert(msg + 'Censura');
		iErro=1;
	}
	
	/* horario */
	str1 = document.frmExecIncAgenda.horario.value;
	if ((str1=="") || (str1=="0") || (str1==" ") || (str1.length<3))
	{
		window.alert(msg + 'Horario');
		iErro=1;
	}
	
	/* imagem */
	str1 = document.frmExecIncAgenda.imagem.value;
	if ((str1=="") || (str1=="0") || (str1==" ") || (str1.length<3))
	{
		window.alert(msg + 'Imagem');
		iErro=1;
	}
	
	/* entrada */
	str1 = document.frmExecIncAgenda.entrada.value;
	if ((str1=="") || (str1=="0") || (str1==" ") || (str1.length<1))
	{
		window.alert(msg + 'Entrada');
		iErro=1;
	}
	if(iErro==0)
	{
		document.frmExecIncAgenda.action="?incluiagenda=1&opc=8";
		document.frmExecIncAgenda.submit;
	}
}
/* funcoes de validacao - fim */

/* funcao para inicio de popup */
function Start(URL, WIDTH, HEIGHT, TOP, LEFT) {
	windowprops = "left=" + LEFT + ",top=" + TOP + ",width=" + WIDTH + ",height=" + HEIGHT;
	preview = window.open(URL, "preview", windowprops);
	if (closetime)
		setTimeout("preview.close();", closetime*1000);
}

closetime = 0; // Close window after __ number of seconds?
// 0 = do not close, anything else = number of seconds
