

function Imprimir()
{
	self.print();void(0)
}

function verificarTecla(evento)
{
	if(evento.keyCode == 13)
	{
		return false;
	}
	else
	{
		return true;	
	}
}
function Excluir()
{
	if (confirm("Voce deseja realmente excluir este registro? \nLembre-se: Todas as dependências também serão excluídas."))
	{ 
		return true
	}
	else	
	{
		alert("O registro nao foi excluido.")
		return false
	}
}

function ExcluirUsuario()
{
	if (confirm("Voce deseja realmente excluir?"))
	{ 
		return true
	}
	else	
	{
		return false
	}
}

function Abrepopup()
{
	document.window.open('http://www.cursoanglo.com.br/popup.asp?img=tom.jpg','Pop','width=304,height=404');
}	
function nova(url,nome,propriedades) 
{
	window.open(url,nome,propriedades);void(0)
}

function novaJanela(id, IdDesteModulo)
{
	window.open('upload.aspx?modulo='+ IdDesteModulo +'&id='+id,'upload','Permissoes_Excluir","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,height=90,width=350');
}

function AbreEnquete(IdEnquete)
{
	window.open('Enquete.aspx?IdEnquete=' + IdEnquete, 'Enquete','height=300,width=305,scrollbars=yes');
	void(0);
}

function AbreInscricao(IUAtividade)
{
	window.open('InscricaoAtividade.aspx?IUAtividade=' + IUAtividade, 'Inscrição','height=150,width=305,scrollbars=yes');
	void(0);
}

function FechaJanela(destino)
{
	window.opener.location = destino;
	window.close();
}

function Ocultar()
{
	var formulario = document.getElementById('Form1');
	with(formulario)
	{
		for(i=0; i < formulario.length; i++)
		{
			if(elements[i].name.indexOf("hid",0) != -1)
			{
				elements[i].style.visibility = "hidden"; 
			}
		}
	}
}
			
function DateFormat(vDate, vEvent) 
{
// Formata a data "DD/MM/YYYY"
// Chamada:  onKeyUp="DateFormat(this,event)" 
  isNav4 = navigator.appName == "Netscape" && navigator.appVersion < "5";
  strSeperator = '/';

  if (!isNav4) {
    if ((vDate.value.length == 2 || vDate.value.length == 5)  )  
      if (vEvent.keyCode != 46)    // Del 
        if (vEvent.keyCode != 8)   // Back Space
          vDate.value = vDate.value + strSeperator;   
        else
          vDate.value = vDate.value.substr(0,vDate.value.length-1);   
  }
  else 
    if (vDate.value.length == 8) 
      vDate.value = vDate.value.substr(0,2) + strSeperator + 
                    vDate.value.substr(2,2) + strSeperator + 
                    vDate.value.substr(4,4);

}


function ChecarData(Controle) {
	// Verifica se o ano tem 4 dígitos
	// Chamada:  OnBlur = "ChecarData(this)" 

	if(Controle.value != ""){
		if(Controle.value.length == 8){
			UltimaBarra = Controle.value.indexOf("/", 3);
			AnoDigitado = Controle.value.substr(UltimaBarra + 1 , UltimaBarra + 2);
			Hoje = new Date();
			SeculoAtual = Hoje.getFullYear();
			SeculoAtualTexto = new String(SeculoAtual);
			SeculoAtualTexto = SeculoAtualTexto.substr(0, 2);
			AnoCompleto = SeculoAtualTexto.concat(AnoDigitado);
			Controle.value = Controle.value.substr(0, 6) + AnoCompleto;
		}


		Errou = false;
	
		if(Controle.value.length != 10){
			Errou = true;
		}

		
		QtdBarras = 0
		for(i = 0; i < Controle.value.length; i++)
			if(Controle.value.charAt(i) == "/")
				QtdBarras++;
		if(QtdBarras != 2)
			Errou = true;


		if(Errou){
			alert("Digite a data no formato DD/MM/AAAA");
			Controle.value = "";
			Controle.focus();
		}

	}

}

function AvaliarEmail(email){
	if(email.indexOf(" ") != -1){
		alert("Não são permitidos espaços em branco no campo email. É permitido apenas um email por usuário.\n");
		return false;
	}

	if(email.indexOf("www") != -1){
		alert("Endereços de email geralmente não possuem www. Informe-se com seu provedor qual seu endereço de email correto.\n");
		return false;
	}		
	
	if(email.indexOf("/") != -1 || email.indexOf("\\") != -1){
		alert("Não são permitidas barras no campo email. É permitido apenas um email por usuário.\n");
		return false;
	}

	if(email.indexOf(",") != -1 || email.indexOf(";") != -1){
		alert("Não são permitidos os caracteres vírgula ou ponto-e-vírgula no campo email. É permitido apenas um email por usuário.\n");
		return false;
	}

	if(email.indexOf("@") == -1){
		alert("Digite seu email no formato seunome@seuprovedor.com.br. É permitido apenas um email por usuário.\n");
		return false;
	}

	return true;
}

function IsNumber(myfield, e)
{
  var key;
  var keychar;
  
  if (window.event)
     key = window.event.keyCode;
  else if (e)
     key = e.which;
  else
     return true;
		keychar = String.fromCharCode(key);
  
  // control keys
  if ((key==null) || (key==0) || (key==8) || 
      (key==9) || (key==13) || (key==27) )
     return true;
  
  // numbers
  else if ((("0123456789").indexOf(keychar) > -1))
     return true;
  
  else
     return false;
  }
  
  //-----> máscara cpf: 
function m_CPF(campo,tammax) {
    var vr = campo.value;
    vr = vr.replace( "-", "" );
    vr = vr.replace( ".", "" );
    vr = vr.replace( ".", "" );

    var tam = vr.length;
    if (tam < tammax) { tam = vr.length + 1; }

    tam = tam - 1;
    if ( (tam > 2) && (tam <= 11) ) {
        vr = vr.substr( 0, tam - 1 ) + '-' + vr.substr( tam - 1, tam ); }

    if ( (tam == 10) ) {
        vr = vr.substr( 0, tam - 7 ) + '.' + vr.substr( tam - 7, 3 ) + '.' + vr.substr( tam - 4, tam ); }

    campo.value = vr;
}

function soNumeros(e){
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if (whichCode == 0 || whichCode ==8) return true;//Teclas de direção ou backspace
    var strCheck = '0123456789';
    key = String.fromCharCode(whichCode); // Valor para o código da Chave
    if (strCheck.indexOf(key) == -1) return false; // Chave inválida
}

function validaData(source, clientside_arguments)
{
   if(clientside_arguments.Value.length == 0)
   {
       clientside_arguments.IsValid=true;
       return;
   }
   else
   {
       if(clientside_arguments.Value.length != 10)
       {
           clientside_arguments.IsValid=false;
           return;
       }
   }
   
    dia = (clientside_arguments.Value.substring(0,2)); 
    mes = (clientside_arguments.Value.substring(3,5)); 
    ano = (clientside_arguments.Value.substring(6,10)); 

    cons = true; 

    // verifica se foram digitados números
    if (isNaN(dia) || isNaN(mes) || isNaN(ano))
    {
    clientside_arguments.IsValid=false;
    }

   // verifica o dia valido para cada mes 
    if ((dia < 01)||(dia < 01 || dia > 30) && (mes == 04 || mes == 06 || mes == 09 || mes == 11 ) || dia > 31) 
    { 
    cons = false; 
    } 

    // verifica se o mes e valido 
    if (mes < 01 || mes > 12 ) 
    { 
        cons = false; 
    } 

    // verifica se e ano bissexto 
    if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) 
    { 
        cons = false; 
    } 

    if (ano < 1800)
    {
        cons = false;
    }
       
    if (cons == false) 
    { 
    clientside_arguments.IsValid=false;
    } 
    else
    {
        clientside_arguments.IsValid=true;
    }
}

