<!--
  // Autor: Paulo Roberto Ribeiro Filho

  // Processo pós carregamento da página
  function doPostLoading() {
    if ( document.getElementById('pLoadingProgress').style.display == '' ) {
      document.getElementById('pLoadingProgress').style.display = 'none';
    }
  }

  // Processo pré carregamento da página
  function doPreLoading() {
    if ( document.getElementById('pLoadingProgress').style.display == 'none' ) {
      document.getElementById('pLoadingProgress').style.display = '';
    }
  }

  // Mostra o conteúdo da página ao completar carregamento.
  function doExchangeContent() {
    document.getElementById('pCarregando').style.display = 'none';
    document.getElementById('pConteudo').style.display = '';
  }

  // Define o tamanho do plano de fundo da página
  function doTrocaFundo() {
    // 640x480
    if ( screen.width <= '640' ) {
      document.body.style.backgroundImage = 'url(imagens/fundos/640.jpg)';
    }
    // 800x600
    if ( screen.width > '640' && screen.width <= '800' ) {
      document.body.style.backgroundImage = 'url(imagens/fundos/800.jpg)';
    }
    // 1024x768
    if ( screen.width > '800' && screen.width <= '1024' ) {
      document.body.style.backgroundImage = 'url(imagens/fundos/1024.jpg)';
    }
    // 1280x1024
    if ( screen.width > '1024' && screen.width <= '1280' ) {
      document.body.style.backgroundImage = 'url(imagens/fundos/1280.jpg)';
    }
    // 1600x1200
    if ( screen.width > '1280' && screen.width <= '1600' ) {
      document.body.style.backgroundImage = 'url(imagens/fundos/1600.jpg)';
    }
    // 1600+
    if ( screen.width > '1600' && screen.width <= '2048' ) {
      document.body.style.backgroundImage = 'url(imagens/fundos/2048.jpg)';
    }
  }

  // Define e exibe imagem da galeria de fotos da votação
  function doSetFotoVotacao(fileval,dirval,nomeval,tipoval,idval) {
    if ( fileval == 'clear' ) {
      if ( navigator.userAgent.indexOf( "MSIE " ) > 0 ) {
        document.getElementById('pTrocaImagemFiltro').filters.blendTrans.apply();
      }
      doPreLoading();
      document.getElementById('pFotoVotada').value = 'Erro: Nenhuma foto foi selecionada!';
      document.getElementById('pDisplayNome').innerHTML = nomeval;
      document.getElementById('pDisplayTipo').innerHTML = tipoval;
      document.getElementById('pDisplayPicture').title = 'Selecione uma foto na lista ao lado.';
      document.getElementById('pDisplayPicture').src = 'imagens/' + dirval + '/default.jpg';
      if ( navigator.userAgent.indexOf( "MSIE " ) > 0 ) {
        document.getElementById('pTrocaImagemFiltro').filters.blendTrans.play();
      }
    }
    else {
      if ( navigator.userAgent.indexOf( "MSIE " ) > 0 ) {
        document.getElementById('pTrocaImagemFiltro').filters.blendTrans.apply();
      }
      doPreLoading();
      document.getElementById('pFotoVotada').value = 'Festa ' + idval + ' - ' + nomeval;
      document.getElementById('pDisplayNome').innerHTML = nomeval;
      document.getElementById('pDisplayTipo').innerHTML = tipoval;
      if ( nomeval == "" ) {
        document.getElementById('pDisplayPicture').title = tipoval;
      }
      else {
        document.getElementById('pDisplayPicture').title = nomeval + ' - ' + tipoval;
      }
      document.getElementById('pDisplayPicture').src = 'imagens/' + dirval + '/' + fileval + '.jpg';
      if ( navigator.userAgent.indexOf( "MSIE " ) > 0 ) {
        document.getElementById('pTrocaImagemFiltro').filters.blendTrans.play();
      }
    }
  }

  // Define e exibe imagem da galeria de fotos da votação - v2
  function doSetFotoVotacao2(fileval,dirval,nomeval,tipoval,idval) { //v2
    if ( fileval == 'clear' ) {
      if ( navigator.userAgent.indexOf( "MSIE " ) > 0 ) {
        document.getElementById('pTrocaImagemFiltro').filters.blendTrans.apply();
      }
      doPreLoading();
      document.getElementById('pFotoVotada').value = 'Erro: Nenhuma foto foi selecionada!';
      document.getElementById('pDisplayNome').innerHTML = nomeval;
      document.getElementById('pDisplayTipo').innerHTML = tipoval;
      document.getElementById('pDisplayPicture').title = 'Selecione uma foto na lista ao lado.';
      document.getElementById('pDisplayPicture').src = 'imagens/' + dirval + '/default.jpg';
      document.getElementById('pContentSwapperPic').style.display = 'none';
      document.getElementById('pContentSwapperFla').style.display = '';
      if ( navigator.userAgent.indexOf( "MSIE " ) > 0 ) {
        document.getElementById('pTrocaImagemFiltro').filters.blendTrans.play();
      }
    }
    else {
      if ( navigator.userAgent.indexOf( "MSIE " ) > 0 ) {
        document.getElementById('pTrocaImagemFiltro').filters.blendTrans.apply();
      }
      doPreLoading();
      document.getElementById('pFotoVotada').value = 'Festa ' + idval + ' - ' + nomeval;
      document.getElementById('pDisplayNome').innerHTML = nomeval;
      document.getElementById('pDisplayTipo').innerHTML = tipoval;
      if ( nomeval == "" ) {
        document.getElementById('pDisplayPicture').title = tipoval;
      }
      else {
        document.getElementById('pDisplayPicture').title = nomeval + ' - ' + tipoval;
      }
      document.getElementById('pDisplayPicture').src = 'imagens/' + dirval + '/' + fileval + '.jpg';
      document.getElementById('pContentSwapperFla').style.display = 'none';
      document.getElementById('pContentSwapperPic').style.display = '';
      if ( navigator.userAgent.indexOf( "MSIE " ) > 0 ) {
        document.getElementById('pTrocaImagemFiltro').filters.blendTrans.play();
      }
    }
  }

  // Troca a classe do campo do formulário
  function doChangeInputClass(nameID,classval) {
    document.getElementById(nameID).className = classval;
  }

  // Valida o formulário "fale conosco"
  function doValidateFormContato() {
    if ( document.getElementById('Nome').value == '' ) {
      window.alert('Preencha o campo \'Nome completo\'');
      document.getElementById('Nome').focus();
      return false;
    }
    if ( verificaEmail(document.getElementById('Email').value) == true ) {
      window.alert('Preencha o campo \'Correio eletrônico (e-mail)\'');
      document.getElementById('Email').focus();
      return false;
    }
    if ( validaNumero(document.getElementById('Telefone').value) == true ) {
      window.alert('Preencha o campo \'Telefone para contato\'');
      document.getElementById('Telefone').focus();
      return false;
    }
    if ( document.getElementById('Tema').value == '' ) {
      window.alert('Preencha o campo \'Assunto da mensagem\'');
      document.getElementById('Tema').focus();
      return false;
    }
    if ( document.getElementById('Mensagem').value == '' ) {
      window.alert('Preencha o campo \'Texto da mensagem\'');
      document.getElementById('Mensagem').focus();
      return false;
    }
    if ( document.getElementById('checkCadastraEmail').checked == false ) {
      pSureNotCadEmail = window.confirm('Deseja participar das promoções do Kasarão?')
      if ( pSureNotCadEmail == true ) {
        document.getElementById('checkCadastraEmail').click();
      }
    }
  }

  // Valida o formulário "adicionar registro do livro de visitas"
  function doValidateFormAdicionaRegistro() {
    if ( document.getElementById('Nome').value == '' ) {
      window.alert('Preencha o campo \'Nome completo\'');
      document.getElementById('Nome').focus();
      return false;
    }
    if ( verificaEmail(document.getElementById('Email').value) == true ) {
      window.alert('Preencha o campo \'Correio eletrônico (e-mail)\'');
      document.getElementById('Email').focus();
      return false;
    }
    if ( document.getElementById('Assunto').value == '' ) {
      window.alert('Preencha o campo \'Assunto da mensagem\'');
      document.getElementById('Assunto').focus();
      return false;
    }
    if ( document.getElementById('Mensagem').value == '' ) {
      window.alert('Preencha o campo \'Texto da mensagem\'');
      document.getElementById('Mensagem').focus();
      return false;
    }
  }

  // Valida o formulário "reservas"
  function doValidateFormReservas() {
    if ( document.getElementById('Nome').value == '' ) {
      window.alert('Preencha o campo \'Nome completo\'');
      document.getElementById('Nome').focus();
      return false;
    }
    if ( document.getElementById('Empresa').value == '' ) {
      window.alert('Preencha o campo \'Nome da empresa\'\n\nCaso esta não seja uma reserva para empresa digite \'N/A\' em seu respectivo campo.')
      document.getElementById('Empresa').focus();
      return false;
    }
    if ( document.getElementById('Endereco').value == '' ) {
      window.alert('Preencha o campo \'Endereço\'');
      document.getElementById('Endereco').focus();
      return false;
    }
    if ( verificaEmail(document.getElementById('Email').value) == true ) {
      window.alert('Preencha o campo \'Correio eletrônico (e-mail)\'');
      document.getElementById('Email').focus();
      return false;
    }
    if ( document.getElementById('Data').value == '' ) {
      window.alert('Preencha o campo \'Data da reserva\'');
      document.getElementById('Data').focus();
      return false;
    }
    if ( document.getElementById('Hora').value == '' ) {
      window.alert('Preencha o campo \'Horário da reserva\'');
      document.getElementById('Hora').focus();
      return false;
    }
    if ( document.getElementById('Pessoas').value == '' ) {
      window.alert('Preencha o campo \'Número de pessoas\'');
      document.getElementById('Pessoas').focus();
      return false;
    }
    if ( validaNumero(document.getElementById('Telefone').value) == true ) {
      window.alert('Preencha o campo \'Telefone para contato\'');
      document.getElementById('Telefone').focus();
      return false;
    }
    //if ( document.getElementById('Telefone').value == '' ) {
    //  window.alert('Preencha o campo \'Telefone para contato\'');
    //  document.getElementById('Telefone').focus();
    //  return false;
    //}
    if ( document.getElementById('pLocalCavalhada').checked == false && document.getElementById('pLocalGetulio').checked == false ) {
      window.alert('Selecione o \'Local\'');
      document.getElementById('Local').focus();
      return false;
    }
    if ( document.getElementById('pAmbienteChurrascaria').checked == false && document.getElementById('pAmbientePizzaria').checked == false ) {
      window.alert('Selecione o \'Ambiente\'');
      document.getElementById('Ambiente').focus();
      return false;
    }
    if ( document.getElementById('radioFestaSim').checked == true ) {
      if ( document.getElementById('pTipoFesta').selectedIndex == '8' ) {
        if ( document.getElementById('pObsText').value == '' ) {
          window.alert('Especifique o tipo de festa no campo \'Observações\'');
          document.getElementById('pObsText').focus();
          return false;
        }
      }
    }
    if ( document.getElementById('checkCadastraEmail').checked == false ) {
      pSureNotCadEmail = window.confirm('Deseja cadastrar seu e-mail para receber as novidades sobre as promoções do Kasarão?')
      if ( pSureNotCadEmail == true ) {
        document.getElementById('checkCadastraEmail').click();
      }
    }
  }

  // Validação de endereço de e-mail
  function verificaEmail(xemail){
    invalid = Array("~","!","@","#","$","%","^","&","*","(",")","+","=","[","]",":",";",",","\"","'","|","{","}","\\","/","<",">","?"," ");
    if ( xemail.indexOf("@") == -1 ) {
      return true;
    }
    else {
      partes = xemail.split("@");
      if (partes[0]=="" || partes[0].length < 2 ) {
        return true;
      }
      else {
        for ( i=0;i < invalid.length; i++ ) {
          if ( partes[0].indexOf(invalid[i]) != -1 ) {
            return true;
          }
        }
      }
      if ( partes[1] == "" ) {
        return true;
      }
      else {
        if ( partes[1].indexOf(".") == -1 ) {
          return true;
        }
        else {
          ponto = partes[1].split(".")
          if ( ponto[0] == "" || ponto[0].length < 2 ) {
            return true;
          }
          else {
            for ( i=0;i < invalid.length; i++){
              if ( ponto[0].indexOf( invalid[i]) != -1 ) {
                return true
              }
            }
          }
          if ( ponto[1] == "" ) {
            return true;
          }
        }
      }
    }
    return false
  }

  // Validação de número
  function validaNumero(numero){
    resp    = 0;
    if(numero.length==0) { return true }
    for(i=0;i < numero.length; i++){
      for(j=0;j < 11; j++){
        if (numero.substring(i,i+1) == j) resp++;
      }
    }
    if (numero.length != resp) { return true }
    return false;
  }

  // Oculta a seleção de "tipo de festa" no formulário "reservas"
  function doDisableFesta() {
    document.getElementById('pFestaLabel').style.visibility = 'hidden';
    document.getElementById('pFestaSelect').style.visibility = 'hidden';
  }

  // Exibe a seleção de "tipo de festa" no formulário "reservas"
  function doEnableFesta() {
    document.getElementById('pFestaLabel').style.visibility = 'visible';
    document.getElementById('pFestaSelect').style.visibility = 'visible';
  }

  // Exibe ou oculta a mensagem do livro de visitas
  function doExpandCollapseMessagePost(messageID,callerID) {
    if ( document.getElementById(messageID).style.display == '' ) {
      document.getElementById(messageID).style.display = 'none';
      document.getElementById(callerID).title = 'Exibir texto da mensagem';
      return true;
    }
    else {
      document.getElementById(messageID).style.display = '';
      document.getElementById(callerID).title = 'Ocultar texto da mensagem';
      return true;
    }
  }

  // Exibe ou oculta conteúdo
  function doSimpleExpandCollapse(itemID) {
    if ( document.getElementById(itemID).style.display == '' ) {
      document.getElementById(itemID).style.display = 'none';
      return true;
    }
    else {
      document.getElementById(itemID).style.display = '';
      return true;
    }
  }

  // Monta o codigo de segucanca
  function doMostraSecurityCode(codeID) {
    var pSecCode = codeID; //Chama a função ASP e atribui o resultado à variavel texto_segurança
    var pTagStart = '<img src="imagens/security/';
    var pTagMiddle = '.gif" align="absmiddle" width="9" height="11" alt="" title=""';
    var pTagEnd = '/ >';

    for(x = 0; x < pSecCode.length; x ++) {
      pImgCode = pSecCode.charAt(x);
      document.write(pTagStart + pImgCode + pTagMiddle + pImgCode + pTagEnd);
    }
  }

  function doTestRegPicture(tagID,iconPath) {
	  if ( iconPath == '' ) {
		  window.alert('É necessário digitar o endereço da imagem.');
		  tagID.src = 'imagens/icons/noicon.gif';
		  return true;
	  }
	  else {
		  tagID.src = iconPath;
		  return true;
	  }
  }

  function doClearRegPicture(tagID,radioID,picID,pathID) {
	  tagID.src = 'imagens/icons/noicon.gif';
	  radioID.click();
	  radioID.checked = "true";
	  picID.checked = "true";
	  pathID.value = '';
  }
-->