function trocarImagem(tipo, elemento) {
	if (tipo == 'on') {
		document.getElementById(elemento).style.backgroundImage = "url('./imagens/bg_menu_on.gif')";
	}
	if (tipo == 'out') {
		document.getElementById(elemento).style.backgroundImage = "none";
	}
}

function trocarCor (tipo, elemento) {
	if (tipo == 'on') {
		document.getElementById(elemento).style.backgroundColor = 'F5F5F5';
	}
	if (tipo == 'out') {
		document.getElementById(elemento).style.backgroundColor = 'FFFFFF';
	}
}
	
function validarContato() { // Valida formulário de Contato
  var passou = true;
  var alerta = "O sistema encontrou os seguintes erros no preenchimento do formulário:\n\n";

  // validações dos campos gerais
  if (document.getElementById("firma").value == "") {
	 passou = false; alerta += "- Empresa preenchido incorretamente.\n";
  }
  
  if (document.getElementById("nome").value == "") {
	 passou = false; alerta += "- Nome preenchido incorretamente.\n";
  }
  
  if (document.getElementById("endereco").value == "") {
	 passou = false; alerta += "- Endereço preenchido incorretamente.\n";
  }
  
  if (document.getElementById("numero").value == "") {
	 passou = false; alerta += "- Número preenchido incorretamente.\n";
  }
  
  if (document.getElementById("bairro").value == "") {
	 passou = false; alerta += "- Bairro preenchido incorretamente.\n";
  }
  
  if (document.getElementById("cidade").value == "") {
	 passou = false; alerta += "- Cidade preenchido incorretamente.\n";
  }
  
  if (document.getElementById("cep").value.length < 9) {
     passou = false; alerta += "- CEP preenchido incorretamente. Siga o padrão: 00000-000\n";
  }
  
  if (document.getElementById("estado").value == "-1") {
     passou = false; alerta += "- Estado preenchido incorretamente.\n";
  }
  
  if (document.getElementById("telefone").value.length < 11) {
     passou = false; alerta += "- Telefone preenchido incorretamente. Siga o padrão: 00 00000000\n";
  }

  if (document.getElementById("fax").value.length < 11) {
     passou = false; alerta += "- Fax preenchido incorretamente. Siga o padrão: 00 00000000\n";
  }

  if (document.form1.email.value == "") {
     passou = false; alerta += "- E-mail preenchido incorretamente.\n";
  }else{
      if (!validarEmail(document.form1.email.value)) {
           passou = false; alerta += "- E-mail preenchido incorretamente.\n";
      }
  }
  if (document.getElementById("assunto").value == "") {
	 passou = false; alerta += "- Assunto preenchido incorretamente.\n";
  }
  if (document.getElementById("mensagem").value == "") {
	 passou = false; alerta += "- Mensagem preenchido incorretamente.\n";
  }

  if (passou == true) { return true; }
  else { alert(alerta); return false; }
}

function validarEmail(email)
{
	var s = email;
	var filter=/^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	if (s.length == 0 ) return true;
	if (filter.test(s))
	return true;
	else
	return false;
}

function numeros (evento) {
   navegador = /msie/i.test(navigator.userAgent);
   if (navegador) {
      var tecla = event.keyCode;
   } else {
      var tecla = evento.which;
   }

   if ((tecla > 47 && tecla < 58) || (tecla > 95 && tecla < 106)) {
      return true;
   } else {
      if (tecla != 8 && tecla != 9 && tecla != 32 && tecla != 109 && tecla != 189) {
      return false;
      } else {
      return true;
      }
   }
}
