function VerificaCadastro()
{
  ok = true;
  if ( document.cadastro.cadNome.value == "" )
  {
	ok = false;
    alert ("O campo Nome precisa ser preenchido.");
    document.cadastro.cadNome.focus();
    return -1;
  }
  
  if ( document.cadastro.cadEmail.value == "" )
  {
	ok = false;
    alert ( "Precisa ter um E-mail para acessar o site." );
    document.cadastro.cadEmail.focus();
	return -1;
  }
    
  if ( document.cadastro.cadLogin.value == "" )
  {
	ok = false;
    alert( "Precisa de um Apelido(Login) para acessar o site." );
    document.cadastro.cadLogin.focus();
    return -1;
  }
  
  if ( document.cadastro.cadSenha.value == "" )
  {
	  ok = false;
	  alert( "O campo Senha precisa ser preenchido." );
	  document.cadastro.cadSenha.focus();
	  return -1;
  }
  else
  {
	  if ( document.cadastro.cadSenha.value.length < 6 )
	  {
		  ok = false;
		  alert( "A Senha deve ter pelo menos 6 digitos." );
		  document.cadastro.cadSenha.focus();
		  return -1;
	  }
  }
  
  if ( document.cadastro.cadSenhaConf.value == "" )
  {
	  ok = false;
	  alert( "O campo Senha (confirmação) precisa ser preenchido." );
	  document.cadastro.cadSenhaConf.focus();
	  return -1;
  }
  
  if ( document.cadastro.cadSenha.value != document.cadastro.cadSenhaConf.value )
  {
	  ok = false;
	  alert( "A Senha e a Confirmação de Senha estão diferentes." );
	  document.cadastro.cadSenhaConf.focus();
	  return -1;
  }
  
  if ( document.cadastro.cadNascimento.value == "" )
  {
	ok = false;
    alert( "O campo Data da Nascimento precisa ser preenchido.");
    document.cadastro.cadNascimento.focus();
    return -1;
  }
  else
  {
	if ( document.cadastro.cadNascimento.value.length < 10 )
	{
		ok = false;
		alert( "A Data de Nascimento está incompleta." );
		document.cadastro.cadNascimento.focus();
		return -1;
	}
  }
  /*
  if ( document.cadastro.cadFoto.value != "" )
  {
	  PathPhoto = document.cadastro.cadFoto.value;
	  Ext = PathPhoto.substring( PathPhoto.length - 3, PathPhoto.length );
	  ExtFile = Ext.toUpperCase();
	  if ( ExtFile != "PNG" && ExtFile != "JPG" )
	  {
		  ok = false;
	  	  alert( "A Foto deve ter uma extensão jpg ou png" );
		  document.cadastro.cadFoto.focus()
		  return -1;
	  }
  }
  */
  if ( ok == true )
  {
    document.cadastro.submit();
  }
}

function DateValidate( objeto, e )
{
	if ( navigator.userAgent.indexOf( "IE" ) != -1 )
	{
		if ( window.event.keyCode > 47 && window.event.keyCode < 58 && objeto.value.length < 13 )
		{
			if ( objeto.value.length == 2 )
			{
			   objeto.value = objeto.value + "/";
			}
			else if ( objeto.value.length == 5 )
			{
			   objeto.value = objeto.value + "/";
			}
		}
		else
		{
			event.returnValue = false;
		}
	}
}

function HasItemSelected( rbtOptions )
{
	ItemSelected = false;
	
	if ( rbtOptions.length != undefined )
	{
		for ( i = 0; i < rbtOptions.length; i++ )
  		{
  			if ( rbtOptions[i].checked )
			{
    			ItemSelected = true;
				break;
			}
    	}
	}
	else
	{
		ItemSelected = rbtOptions.checked;
	}
	
  	if ( ItemSelected == true )
	{
		return true;
	}
	return false;
}

function AcceptRecordUsers()
{	
  	if ( HasItemSelected( document.record_users.accept_users ) )
	{
		document.record_users.action = "release_users.php?t=1";
    	document.record_users.submit();
	}
  	else
	{
    	alert( "Nenhum usuário selecionado." );
  	}
}

function RefuseRecordUsers()
{	
  	if ( HasItemSelected( document.record_users.accept_users ) )
	{
		if ( confirm( "Tem certeza que deseja descartar estes cadastros?" ) )
		{
			document.record_users.action = "release_users.php?t=2";
    		document.record_users.submit();
		}
	}
  	else
	{
    	alert( "Nenhum usuário selecionado." );
  	}
}

function ValidAdmin()
{
	fo = document.form;
	error = "";
	if ( fo.user.value == "" )
	{
		error += "O campo Usuário deve ser preenchido.\n";
	}
	
	if ( fo.pass.value == "" )
	{
		error += "O campo Senha deve ser preenchido.\n";
	}
	
	if ( error != "" )
	{
		alert( error );
		return false;
	}
	fo.submit();
}

function DeleteDefaultMessage()
{
	if ( document.quadroMensagens.mensagem.value == "Digite aqui a sua mensagem" )
	{
		document.quadroMensagens.mensagem.value = '';
	}
}

function ValidaMsg()
{
	ok = 1;
  	if ( document.quadroMensagens.mensagem.value == "" || document.quadroMensagens.mensagem.value == "Digite aqui a sua mensagem" )
	{
    	ok = 0;
    	alert( "É preciso preencher uma mensagem..." );
    	document.quadroMensagens.mensagem.focus();
    	return -1;
  	}
	
  	if ( ok == 1 )
  	{
    	document.quadroMensagens.submit();
  	}
}

function MaxCharCount()
{
	var Max = 300;
	if ( document.quadroMensagens.mensagem.value.length > Max )
	{
		document.quadroMensagens.total_char.value = "0";
		document.quadroMensagens.mensagem.value = document.quadroMensagens.mensagem.value.substring( 0, Max );
	}
	else
	{
		document.quadroMensagens.total_char.value = Max - document.quadroMensagens.mensagem.value.length;
	}
}

function AcceptMessages()
{	
  	if ( HasItemSelected( document.record_msgs.msg_cod ) )
	{
		document.record_msgs.action = "messages.php?t=1";
    	document.record_msgs.submit();
	}
  	else
	{
    	alert( "Nenhuma mensagem selecionada." );
  	}
}

function RefuseMessages()
{	
  	if ( HasItemSelected( document.record_msgs.msg_cod ) )
	{
		if ( confirm( "Tem certeza que deseja descartar estas mensagens?" ) )
		{
			document.record_msgs.action = "messages.php?t=2";
    		document.record_msgs.submit();
		}
	}
  	else
	{
    	alert( "Nenhuma mensagem selecionada." );
  	}
}

