function MostraStatus() 
{
	theTime = window.setTimeout("MostraStatus()", 10);
	window.status='';
}
MostraStatus();

function abre(janela,nome,rolagem,largura,altura)
{
	window.open (janela,nome,"toolbar=no,left=20,top=20,location=no,directories=no,status=no,menubar=no,scrollbars="+rolagem+",resizable=yes,copyhistory=no,width="+largura+",height="+altura+"");
}

// função de validação de CPF
	function CPF(campo) 
	{
		var CPF = campo; 
 	    CPF = CPF.replace('.','');
		CPF = CPF.replace('.','');
		CPF = CPF.replace('-','');
			
		var POSICAO, I, SOMA, DV, DV_INFORMADO;
		var DIGITO = new Array(10);
		DV_INFORMADO = CPF.substr(9, 2);
		
		for (I=0; I<=8; I++) 
		{
			DIGITO[I] = CPF.substr( I, 1);
		}	

		POSICAO = 10;
		SOMA = 0;
	   	for (I=0; I<=8; I++) 
		{
      		SOMA = SOMA + DIGITO[I] * POSICAO;
      		POSICAO = POSICAO - 1;
   		}
		DIGITO[9] = SOMA % 11;
   		if (DIGITO[9] < 2) 
		{
    	    DIGITO[9] = 0;
		}
	   else
	   {
       	DIGITO[9] = 11 - DIGITO[9];
		}

		POSICAO = 11;
		SOMA = 0;
	   	for (I=0; I<=9; I++) 
		{
      		SOMA = SOMA + DIGITO[I] * POSICAO;
      		POSICAO = POSICAO - 1;
   		}
		DIGITO[10] = SOMA % 11;
   		if (DIGITO[10] < 2) 
		{
        	DIGITO[10] = 0;
   		}
   		else 
		{
        	DIGITO[10] = 11 - DIGITO[10];
   		}

		DV = DIGITO[9] * 10 + DIGITO[10];
   		if (DV != DV_INFORMADO) 
		{
      		return false;
   		} 
		return true;		
	}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
// função de validação de datas
data="1234567890/";
function Data(campo)
{
	str_data=campo;
	for (var i=1;i<=str_data.length;i++)
   	{
		if (data.indexOf(str_data.charAt(i))<0)
     	{
			return false;
     	}
 	}
	if (campo.length<10)
   	{
		return false;
 	}
	if (campo.indexOf("/")!=2||campo.lastIndexOf("/")!=5)
 	{
		return false;
 	}
	dia=str_data.substr(0,2);
	mes=str_data.substr(3,2);
	ano=str_data.substr(6,4);
	if (dia>31||dia<1)
 	{
		return false;
 	}
	if (mes>12||mes<1)
 	{
		return false;
 	}
	if (ano<1889)
 	{
		return false;
 	}
	return true;
}
		
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// função de abertura do pop-up de visualização de amostra de dados
function AbreNoticia(id)
{
	var Noticia = window.open ("pop_noticia.asp?idnoticia="+id+"","Noticia","toolbar=no,left=200,top=200,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=454,height=350");
	Noticia.focus();
}

// função de validação dos dados de login
function VerificaLogin()
{
	if (document.frmlogin.nome.value=='')
	{
		window.alert("Digite o nome do usuário.");
		document.frmlogin.nome.focus();
       	return false;
	}
	
	if (document.frmlogin.senha.value=='')
	{
		window.alert("Digite a senha do usuário.");
		document.frmlogin.senha.focus();
       	return false;
	}
	
	return true;
}

// função de validação dos dados de login
function VerificaDestino()
{
	if (document.frmdestino.idviagem.value=='0')
	{
		window.alert("Selecione o destino desejado.");
		document.frmdestino.idviagem.focus();
       	return false;
	}
	
	return true;
}



// função de validação dos dados de login
function VerificaBusca()
{
	if (document.frmbusca.busca.value=='')
	{
		window.alert("Digite o texto da busca.");
		document.frmbusca.busca.focus();
       	return false;
	}
	else if (document.frmbusca.busca.value.length < 3)
	{
		window.alert("O texto da busca deve ter pelo menos 3 caracteres.");
		document.frmbusca.busca.focus();
       	return false;	
	}
	return true;
}
// função de abertura do pop-up de visualização de amostra de dados
function AbreMande(id)
{
	var Mande = window.open ("pop_mande.asp","Mande","toolbar=no,left=200,top=200,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=454,height=390");
	Mande.focus();
}

// função de abertura do pop-up de visualização de amostra de dados
function AbreLembrar()
{
	var Lembrar = window.open ("pop_esqueci.asp","Lembrar","toolbar=no,left=200,top=200,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=354,height=200");
	Lembrar.focus();
}

// função de abertura do pop-up de visualização de amostra de dados
function AbreGrupo(logado)
{
	if (logado ==1)
	{
		var Grupo = window.open ("pop_novogrupo.asp","Grupo","toolbar=no,left=200,top=200,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=454,height=315");
		Grupo.focus();
	}
	else
	{
		window.alert("Para criar grupos você deve se cadastrar.\nCaso já esteja cadastrado, efetue o login no box ao lado.");
	}
}

// função de abertura do pop-up de visualização de amostra de dados
function AlterarGrupo(idgrupo)
{
	var Grupo = window.open ("pop_alteragrupo.asp?idgrupo="+idgrupo+"","Grupo","toolbar=no,left=200,top=200,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=454,height=315");
	Grupo.focus();
}

function abrirJanelaModal(url, width, height) 
{
	position=2;
	vheight=height-20;
	vwidth = width-20;
	name='janelaModal';
	evnt= null;
	
	var properties = "dialogHeight:" + vheight + "px; dialogWidth:" + vwidth + "px; dialogTop: 10px; edge: Sunken; center: Yes; help: No; resizable: No; scroll: Yes; status: No;"

	var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt

	if(navigator.appName == "Microsoft Internet Explorer")
	{
		screenY = document.body.offsetHeight
		screenX = window.screen.availWidth
	}
	else
	{ 	screenY = screen.height;
		screenX = screen.width;
	}

	leftvar = (screenX - width) / 2
	rightvar = (screenY - height) / 2
		
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		leftprop = leftvar
		topprop = rightvar
	}
	else
	{ // adjust Netscape coordinates for scrolling
		leftprop = (leftvar - pageXOffset)
		topprop = (rightvar - pageYOffset)
	}

	return showModalDialog (url,name,properties)	
//	closePopup();
}


// função de abertura do pop-up de visualização de amostra de dados
function AbreCadastro(id,tipo)
{
	var Cadastro = window.open ("cadastro.asp?idgrupo="+id+"","Cadastro","toolbar=no,left=500,top=250,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=800,height=650");
	Cadastro.focus();
	
}



email="qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM@0123456789-_.";
	function Email(campo)
	{
		str_email=campo;
		tamanho=campo.length-1;
		for (var i=0;i<=str_email.length;i++)
	   	{
			if (email.indexOf(str_email.charAt(i))<0)
       		{
				return false;
       		}
   		}
		if (campo.indexOf(".")==0||campo.indexOf("@")==0||campo.indexOf("@")==tamanho||campo.indexOf(".")==tamanho)
	   	{
			return false;
   		}
		if (campo.indexOf(".")<0||campo.indexOf("@")<0)
	   	{
			return false;
		}
		if (campo.indexOf(".com")<0 && campo.indexOf(".net")<0&& campo.indexOf(".br")<0&& campo.indexOf(".org")<0&& campo.indexOf(".gov")<0)
	   	{
			return false;
   		}
		posicao_antes=campo.indexOf("@");
		posicao_antes=posicao_antes-1;
		posicao_depois=campo.indexOf("@");
		posicao_depois=posicao_depois+1;
		if (campo.indexOf(".")==posicao_antes||campo.indexOf(".")==posicao_depois)
	   	{
			return false;
   		}
		return true;
	}
	
	function VerificaContato()
	{   	
		if (document.frmcontato.nome.value=='')
   		{
			window.alert("Informe seu nome.");
			document.frmcontato.nome.focus();
	    	return false;
   		}
		if (document.frmcontato.email.value=='')
   		{
			window.alert("Informe seu email.");
			document.frmcontato.email.focus();
	    	return false;
   		}
		else
   		{
			if (!Email(document.frmcontato.email.value))
	       	{
				window.alert("Email inválido.");
				document.frmcontato.email.focus();
        		return false;
	       	}
   		}	 
	}
	
	function VerificaMensagem()
	{   	
		if (document.frmmensagem.assunto.value=='')
   		{
			window.alert("Informe o assunto da mensagem.");
			document.frmmensagem.assunto.focus();
	    	return false;
   		}
		if (document.frmmensagem.descmensagem.value=='')
   		{
			window.alert("Informe a sua mensagem.");
			document.frmmensagem.descmensagem.focus();
	    	return false;
   		}
	}
