function submeterLogin()
{
	if (LoginSenha())
	{
		return true;
	}
	else
	{
		return false;
	}
}

function LoginSenha()
{
	var senha = document.getElementById('senha');
	var login = document.getElementById('login');
	
	var reSenha = new RegExp('^[a-z0-9.,]{4,}$');
	

  if (!ValidarEmail(login.value))
	{
		alert('Login inválido!');
		login.className = 'invalido';
		//new Effect.Pulsate(login);
		login.focus();
		return false;
	}
	else
	{
		login.className = 'input';
	}
	
	if (!senha.value.match(reSenha))
	{
		alert('Senha inválida!');
		senha.className = 'invalido';
		//new Effect.Pulsate(senha);
		
		senha.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function initCls()
{
	
}

function SubmeterListagem(form, tarefa)
{
	var trf = document.getElementById('tarefa');
	var lsForm = document.getElementById(form);
	
	if (trf != null && lsForm != null)
	{
		trf.value = tarefa; 
		lsForm.submit();
	}
}

function Pulsar(form, nome, texto)
{
	var elemento;
	
	// elementos que estavam como inválidos ficam válidos
	for (i = 0; i < form.elements.length; ++i)
	{
		elemento = form.elements[i];
		
		if (elemento.className == 'invalido')
		{
			elemento.className = '';
		}
	}
	
	alert(texto); // disparando mensagem de erro
	nome.className = 'invalido'; // elemento fica marcado como inválido...
	//new Effect.Pulsate(nome); // pulsando..
	nome.focus(); // colocando o cursor no elemento que deve ser preenchido
	return false;
}

function clsNovaJanela(url, nome, altura, largura, outros)
{
	if (largura == '' || largura <= 0)
	{
		largura = 100;
	}
	
	if (altura == '' || altura <= 0)
	{
		altura = 100;
	}
	
	var params = 'width=' + largura + ', height=' + altura;
	
	if (outros != '')
	{
		params +=  ',' + outros;
	}
	
	window.open(url, nome, params);
}

function clsEsconder(id)
{
	//safe function to hide an element with a specified id
	if (document.getElementById) 
	{ 
		var element = document.getElementById(id);
		// DOM3 = IE5, NS6
                element.style.display = 'none';
	}
	else 
	{
		if (document.layers) 
		{ 
			// Netscape 4
			document.id.display = 'none';
		}
		else 
		{ 
			// IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function clsMostrar(id)
{
	if (document.getElementById) 
	{ 
		// DOM3 = IE5, NS6
		var element = document.getElementById(id);
		
		if (element)
		{
			element.style.display = '';
			return element;
		}
	}
	else 
	{
		if (document.layers) 
		{ 
			// Netscape 4
			document.id.display = '';
		}
		else 
		{ // IE 4
			document.all.id.style.display = '';
		}
	}
	
}


var ASPAS_SIMPLES=39, ASPAS_DUPLAS = 34;
var BACKSPACE = 8, TAB = 0;

function Ajusta_Hora(input, evnt){
	//Ajusta máscara de Hora e só permite digitação de números
 	if (input.value.length == 2){
 		if(clientNavigator == "IE"){
 			input.value += ":";
 		}else{
 			if(evnt.keyCode == 0){
 				input.value += ":";
 			}
 		}
 	}
	//Chama a função Bloqueia_Caracteres para só permitir a digitação de números
 	return Bloqueia_Caracteres(evnt);
}


function Bloqueia_Caracteres(evnt){
	//Função permite digitação de números
 	if (clientNavigator == "IE"){
 		if (evnt.keyCode < 48 || evnt.keyCode > 57){
 			return false
 		}
 	}else{
 		if ((evnt.charCode < 48 || evnt.charCode > 57) && evnt.keyCode == 0){
 			return false
 		}
 	}
}

function ValidaObrigatorios(obrigatorios) {

	for(i=0; i < obrigatorios.length; i++) {
		
		valor_campo = eval("document.getElementById('" + obrigatorios[i] + "').value");
		
		if(valor_campo == '' || valor_campo == 0) {
		
			eval("document.getElementById('msg_" + obrigatorios[i] +"').innerHTML=' Campo Obrigatório! ';");
			eval("document.getElementById('" + obrigatorios[i] +"').style.background='#F88D83';");
			eval("document.getElementById('" + obrigatorios[i]+ "').style.color='#FFFFFF';");			
			eval("document.getElementById('" + obrigatorios[i] + "').focus();");
			//eval("Effect.Pulsate('" + obrigatorios[i] + "', {duration:1.5});");
			return false;
		} else {
			eval("document.getElementById('msg_" + obrigatorios[i] +"').innerHTML='';");
			eval("document.getElementById('" + obrigatorios[i] +"').style.background='#FFFFFF';");
			eval("document.getElementById('" + obrigatorios[i]+ "').style.color='#000000';");
		}
	}
	return true;
}

function BuscaProfundidade(no,chave)
{
  var filhos = no.childNodes;
  var resposta;
  for (i=0; i<filhos.length; ++i)
  {
    if (filhos[i].id != undefined && filhos[i].id == chave)
      return filhos[i];
    else BuscaProfundidade(filhos[i],chave);
  }
}

function BuscaProfundidadeTeste(um,dois)
{
  alert('uma');
  return BuscaProfundidadeTeste(um,dois);
}

function ValidaObrigatoriosNome(obrigatorios,ref_form,form)
{
  //alert(ref_form);
  for(i=0; i < obrigatorios.length; i++) {
    
    valor_campo = eval("document."+form+"."+obrigatorios[i]+".value;");
    
    var div_msg, nos;
    nos = ref_form.childNodes;
    
    //div_msg = BuscaProfundidade(ref_form,'msg_'+obrigatorios[i]);
    
    //alert(div_msg.id);
    if(valor_campo == '' || valor_campo == 0) {
      //div_msg.innerHTML=' Campo Obrigatório! ';
      eval("document."+form+"."+obrigatorios[i]+".style.background='#F88D83';");
      eval("document."+form+"."+obrigatorios[i]+".style.color='#FFFFFF';");
      eval("document."+form+"."+obrigatorios[i]+".focus();");
      //eval("Effect.Pulsate(document."+form+"."+obrigatorios[i]+", {duration:1.5});");
      return false;
    } else {
      //div_msg.innerHTML='';
      eval("document."+form+"."+obrigatorios[i]+".style.background='#FFFFFF';");
      eval("document."+form+"."+obrigatorios[i]+".style.color='#000000';");
    }
  }
  return true;
}


function clsLoading(img)
{
	var div = clsMostrar(img);
}

function toggleVisibility(name)
{
	var me = document.getElementById(name);
	
	if (me.style.visibility=="hidden")
	{
		me.style.visibility="visible";
	}
	else {
		me.style.visibility="hidden";
	}
}
