window.onload = function()
                {
                  var links = document.links;
                  for (var i=0, s=links.length; i<s; i++)
                    if (links[i].rel == 'external')
                      links[i].target = '_blank';
                }

function Invisivel(Tipo)
{
  if (Tipo=="S")
  {
    document.getElementById("invisivel").style.visibility="visible";
    document.getElementById("invisivel").style.display="block";
    document.getElementById("inv_href").innerHTML = "<a href='#' onClick='return Invisivel(\"N\")'>Clique aqui para ocultar informações sobre esta vinícola.</a>";
  }
  else
  {
    document.getElementById("invisivel").style.visibility="hidden";
    document.getElementById("invisivel").style.display="none";
    document.getElementById("inv_href").innerHTML = "<a href='#' onClick='return Invisivel(\"S\")'>Clique aqui para mostrar informações sobre esta vinícola.</a>";
  }
  return true;
}

function Janela1(url,lar,alt,rol)
{
  window.open(url,"","location=no,directories=no,resizable=yes,toolbar=no,status=no,menubar=no,scrollbars="+rol+",width="+lar+",height="+alt);
}

function Janela2(NomeParam,ValorParam,Url,Lar,Alt,Rol)
{
  window.open(Url+"?"+NomeParam+"="+ValorParam,"","location=no,directories=no,resizable=yes,toolbar=no,status=no,menubar=no,scrollbars="+Rol+",width="+Lar+",height="+Alt);
}

function Saudacao()
{
  var DataHora = new Date();
  var Hora = DataHora.getHours();
  if (Hora < 6)
      document.write("Boa Madrugada");
    else if (Hora < 12)
      document.write("Bom Dia");
    else if (Hora <= 17)
      document.write("Boa Tarde");
    else
      document.write("Boa Noite");
}

function VerificaSeguranca(Objeto)
{
  Comandos = new Array(";","|","&","#","\\","--","alter ","cookie","create ","delete ","document ","drop ","grant ","insert ","javascript","join ","language","load ","lock ","replace ","revoke ","script","select ","table ","truncate ","update ","vbscript");
  QtdCmp   = document.getElementById(Objeto).elements.length;
  for (Ind1=0;Ind1<QtdCmp;Ind1++)
    for(Ind2=0;Ind2<Comandos.length;Ind2++)
	{
      if (document.getElementById(Objeto).elements[Ind1].value.toLowerCase().indexOf(Comandos[Ind2]) != -1)
        return false;
	}
  return true;
}

function ValidaForm(Objeto)
{
  QtdCmp = document.getElementById(Objeto).elements.length;
  for (Ind=0;Ind<QtdCmp;Ind++)
    if (document.getElementById(Objeto).elements[Ind].value.length < 1)
      return false;
  return true;
}

function ValidaFormGeral(Objeto)
{
  if (!ValidaForm(Objeto))
  {
    window.alert("Todos os campos deste formulário devem ser preenchidos!");
    return false;
  }
  if (!VerificaSeguranca(Objeto))
  {
    window.alert("Foram digitados caracteres e/ou palavras inválidas nesse formulário!");
    return false;
  }
  return true;
}

function ValidaFormCampos(Objeto,Campos)
{
  VetCmp = Campos.split("-");
  QtdCmp = VetCmp.length;
  for (Ind=0;Ind<QtdCmp;Ind++)
    if (document.getElementById(Objeto).elements[VetCmp[Ind]].value.length == 0)
    {
      window.alert("O campo " + document.getElementById(Objeto).elements[VetCmp[Ind]].title + " deste formulário deve ser preenchido!");
      return false;
    }
  if (!VerificaSeguranca(Objeto))
  {
    window.alert("Foram digitados caracteres e/ou palavras inválidas nesse formulário!");
    return false;
  }
  return true;
}

function DataExtenso()
{
dia = new Date();
ano = dia.getYear();
if (ano < 2000) // correçao para browsers que retornam 100 no ano 2000
  {
  ano = 1900 + dia.getYear();
  }
mes = new Array("Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro")
dia_semana = new Array("Domingo","Segunda-feira","Terça-feira","Quarta-feira","Quinta-feira","Sexta-feira","Sábado");
document.write(dia_semana[dia.getDay()] + ", " + dia.getDate() + " de " +  mes[dia.getMonth()] + " de " + ano + ".");
}

function VerificaSql(texto)
{
  if (texto.indexOf('insert',0) != -1 || texto.indexOf('update',0) != -1 || texto.indexOf('delete',0) != -1 || texto.indexOf('drop',0) != -1 || texto.indexOf('exec',0) != -1 || texto.indexOf('--',0) != -1 || texto.indexOf('@@',0) != -1 || texto.indexOf(';',0) != -1 || texto.indexOf("\'",0) != -1 || texto.indexOf("'",0) != -1 || texto.indexOf('""',0) != -1)
  {
    return true;
  }
  return false;
}

function VerificaEmail(email)
{
  var reEmail = /^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
  if (reEmail.test(email))
  {
    return false;
  }
  return true;
}

function ValidaIndicaSite(Objeto)
{
  if (!ValidaForm(Objeto))
  {
    window.alert("Todos os campos do formulário devem ser preenchidos!");
    return false;
  }
  if (VerificaEmail(document.IndicaSite.EmailA.value))
  {
    window.alert("É necessário que o seu E-mail seja válido!");
    return false;
  }
  if (VerificaEmail(document.IndicaSite.EmailB.value))
  {
    window.alert("É necessário que o E-mail do(a) amigo(a) seja válido!");
    return false;
  }
  return true;
}

//function ValidaForm(Objeto)
//{
//  QtdCmp = Objeto.elements.length;
//  for (Ind=0;Ind<QtdCmp;Ind++)
//  {
//    if (Objeto.elements[Ind].value.length < 1)
//      return false;
//  }
//  return true;
//}

function ValidaPesquisa(Objeto)
{
  if (!ValidaForm(Objeto))
  {
    window.alert("Deve ser fornecido um termo para pesquisa!");
    return false;
  }
  return true;
}

//function Favoritos(pagina,titulo,descricao)
//{
// Internet Explorer
//if (window.external)
//  Link = "<a class='cabecalho' href=\"javascript:window.external.AddFavorite('"+pagina+"','"+titulo+"');\">"+descricao+"</a>";
//else
  // Gecko (Mozilla, Firefox, Firebird & Netscape)
//  if (window.sidebar)
//    Link = "<a class='cabecalho' href=\"javascript:window.sidebar.addPanel('"+titulo+"','"+pagina+"','');\">"+descricao+"</a>";
//  else
    // Opera & Outros
//    Link = "<a class='cabecalho' href='"+pagina+"' rel='sidebar' title='"+titulo+"'>"+descricao+"</a>";
//return Link;
//}
