function validaContato(){
 var rtn = true;
 var err = $('error');
 if($('nome').value == ''){
  err.innerHTML = 'Campo Nome deve ser preenchido corretamente!';
  $('nome').focus();
  rtn = false;
 }
 if($('email').value == ''){
  err.innerHTML = 'Campo E-mail deve ser preenchido corretamente!';
  $('nome').focus();
  rtn = false;
 }
 if($('comentarios').value == ''){
  err.innerHTML = 'Campo Comentarios deve ser preenchido corretamente!';
  $('nome').focus();
  rtn = false;
 }
 return rtn;
}

function $(obj){
  return document.getElementById(obj);
}

startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("csstopmenu");
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;

/*
**************************************
* String.isCPF Function v1.0         *
* Autor: Carlos R. L. Rodrigues      *
**************************************
*/
String.prototype.isCPF = function(){
    var c = this;
    if((c = c.replace(/[^\d]/g,"").split("")).length != 11) return false;
    if(new RegExp("^" + c[0] + "{11}$").test(c.join(""))) return false;
    for(var s = 10, n = 0, i = 0; s >= 2; n += c[i++] * s--);
    if(c[9] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
    for(var s = 11, n = 0, i = 0; s >= 2; n += c[i++] * s--);
    if(c[10] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
    return true;
};

function ObjControlDisabled(idObj){
 $(idObj).disabled = ($(idObj).disabled == false)?true:false;
}

function addMask(obj, mascara){
 obj.value = obj.value.mask(mascara);
}

MaskInput = function(f, m){
    function mask(e){
        var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[À-ÿ]/i, "8": /./ },
            rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8};
        function accept(c, rule){
            for(var i = 1, r = rules[rule] || 0; i <= r; i<<=1)
                if(r & i && patterns[i].test(c))
                    break;
                return i <= r || c == rule;
        }
        var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length;
        (!k || k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) && (r[0] = r[2].indexOf(c) + 1) + 1 ?
            r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) || r[0]
            : (l = (f.value += m.substr(l, (r = /[A|9|C|\*]/i.exec(m.substr(l))) ?
            r.index : l)).length) < m.length && accept(c, m.charAt(l))) || e.preventDefault();
    }
    for(var i in !/^(.)\^(.*)$/.test(m) && (f.maxLength = m.length), {keypress: 0, keyup: 1})
        addEvent(f, i, mask,'');
};

/*
**************************************
* Event Listener Function v1.4       *
* Autor: Carlos R. L. Rodrigues      *
**************************************
*/
addEvent = function(o, e, f, s){
	var r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []), a, c, d;
	r[r.length] = [f, s || o], o[e] = function(e){
		try{
			(e = e || event).preventDefault || (e.preventDefault = function(){e.returnValue = false;});
			e.stopPropagation || (e.stopPropagation = function(){e.cancelBubble = true;});
			e.target || (e.target = e.srcElement || null);
			e.key = (e.which + 1 || e.keyCode + 1) - 1 || 0;
		}catch(f){}
		for(d = 1, f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? c = a.call(o, e) : (o._ = a, c = o._(e), o._ = null), d &= c !== false));
		return e = null, !!d;
    }
};

removeEvent = function(o, e, f, s){
 for(var i = (e = o["_on" + e] || []).length; i;)
  if(e[--i] && e[i][0] == f && (s || o) == e[i][1])
   return delete e[i];
  return false;
};

function nextField(strObj, nextObj, lengthObj){
 if(strObj.length == lengthObj){
  $(nextObj).focus();
 }
}

String.prototype.capitalize = function(){
 return this.replace(/\w+/g, function(a){
 return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase();
 });
};

function sCaptalize(sObj){
 sObj.value = sObj.value.capitalize();
}

function sToUpperCase(sObj){
 sObj.value = sObj.value.toUpperCase();
}

isDate = function(y, m, d){
 if(typeof y == "string" && m instanceof RegExp && d){
    if(!m.test(y)) return 1;
    y = RegExp["$" + d.y], m = RegExp["$" + d.m], d = RegExp["$" + d.d];
  }
  
  d = Math.abs(d) || 0, m = Math.abs(m) || 0, y = Math.abs(y) || 0;
  
  return arguments.length != 3 ? 1 : d < 1 || d > 31 ? 2 : m < 1 || m > 12 ? 3 : /4|6|9|11/.test(m) && d == 31 ? 4
: m == 2 && (d > ((y = !(y % 4) && (y % 1e2) || !(y % 4e2)) ? 29 : 28)) ? 5 + !!y : 0;
};


getDateMsg = function(x){
  return x == 0 ? "Data válida"
  : x == 1 ? "Formato de data inválido"
  : x == 2 ? "Dia inválido"
  : x == 3 ? "Mês inválido"
  : x == 4 ? "Nos meses de abril, junho, setembro e novembro não existe o dia 31"
  : x == 5 ? "Fevereiro só tem 28 dias"
  : x == 6 ? "Em anos bissextos, fevereiro tem 29 dias" : "=]";
};


function isEmail(text){
   var    arroba = "@",
         ponto = ".",
         posponto = 0,
         posarroba = 0;
   
    if (text =="") return false;
   
    for (var indice = 0; indice < text.length; indice++){
       if (text.charAt(indice) == arroba) {
          posarroba = indice;
            break;
       }
    }
   
   for (var indice = posarroba; indice < text.length; indice++){
      if (text.charAt(indice) == ponto) {
         posponto = indice;
           break;
      }
   }
   if (posponto == 0 || posarroba == 0) return false;
   if (posponto == (posarroba + 1)) return false;
   if ((posponto + 1) == text.length) return false;
   return true;
}

function tryAjax () {
  try {
    ajax = new ActiveXObject("Microsoft.XMLHTTP");
  }catch(e) {
    try {
      ajax = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(ex) {
      try {
        ajax = new XMLHttpRequest();
      }catch(exc) {
        alert("Esse browser não tem os recursos necessarios para o uso da funcionalidade requisitada!");
        ajax = null;
      }
    }
  }
  return ajax;
}


function esqueci(){
	$('esqueci_minha_senha').style.display = ($('esqueci_minha_senha').style.display == 'none')?'block':'none'; 
}


var arrMeses = ['Janeiro',
				'Fevereiro',
				'Março',
				'Abril',
				'Maio',
				'Junho',
				'Julho',
				'Agosto',
				'Setembro',
				'Outubro',
				'Novembro',
				'Dezembro'];

var objDate = new Date();
var dAnoAtual = objDate.getFullYear();


function voltar(){
	window.history.back(-1);
}