/*
* Funções mais utilizadas
* Thiago Fernandes Oliveira de Lima
*/

function $(elemento)
{
  var e = document.getElementById(elemento);
  
  if( e )
  {
    return e;
  }
  
  else
  {
    //alert("Erro: Elemento ID '"+elemento+"' não está contido no documento.");
    return false;
  }
}

function $V(elemento)
{
  var e = document.getElementById(elemento);
  
  if( e )
  {
    return e.value;
  }
  
  else
  {
    alert("Erro: Elemento ID '"+elemento+"' não está contido no documento.");
    return false;
  }
}

function $L(elemento)
{
  var e = document.getElementById(elemento);

  if( e )
  {
    return e.value.length;
  }
  
  else
  {
    alert("Erro: Elemento ID '"+elemento+"' não está contido no documento.");
    return false;
  }
}


function $E(local, tag)
{
  var e = local.getElementsByTagName(tag);
  
  if(e)
  {
    return e;
  }
  
  else
  {
    alert("Erro: O elemento '"+local+"' não existe ou não foram encontrados elementos com a tag '"+tag+"'");
    return false;
  }
}

function addEvent(obj, evType, fn)
{
    if (obj.addEventListener)
    {
       obj.addEventListener(evType, fn, false);
       return true;
    }
    else if (obj.attachEvent)
    {
       var r = obj.attachEvent("on"+evType, fn);
       return r;
    } 
    else
    {
       return false;
    }
}

/*
  getSource
  Elcio Ferreira - 2004 - http://elcio.locaweb.com.br
*/

function getSource(e)
{
	if(typeof e == 'undefined')
  {
    var e = window.event;
  }
	
  var source = typeof e.target != 'undefined' ? e.target:typeof e.srcElement != 'undefined' ? e.srcElement : true
	
  if(source.nodeType == 3)
  {
    source=source.parentNode;
  }
  
	return source
}

function ajax() 
{
  var ajaxx;
  
  try 
  {
    ajaxx = new XMLHttpRequest();
  } 
  
  catch(ee) 
  {
    try 
    {
      ajaxx = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    
    catch(e)
    {
        try
        {
          ajaxx = new ActiveXObject("Microsoft.XMLHTTP");
        }
        
        catch(E)
        {
          ajaxx = false;
        }
      }
    }

    return ajaxx;
}

function formataData(e)
{
  var inp = getSource(e);
  var vlr = inp.value;
  var dat = new String();
  vlr = vlr.replace(/[^0-9\/]/ig,"");
  var i = vlr.length;

  if( i == 2 || i == 5)
  {
    inp.value += "/";
  }
}

function formataHora(e)
{
  var inp = getSource(e);
  var vlr = inp.value;
  var dat = new String();
  vlr = vlr.replace(/[^0-9\/]/ig,"");
  var i = vlr.length;

  if( i == 2 )
  {
    inp.value += ":";
  }
}

function dadosOption(tag)
{
  var t = $(tag);

  with(t.options[t.selectedIndex])
  {
    var dados = new Array();
    dados["texto"] = text;
    dados["valor"] = value;
  }
  
  return dados;
}

function limpaMensagem()
{
  $("msg-status").style.display = "none";
  clearTimeout("limpaMensagem()");
}

addEvent(window,"load",function()
{
if( $("msg-status") )
{
  setTimeout("limpaMensagem()",10000);
}});

startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("menu");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}
window.onload=startList;

