﻿/*
* ========================================
* SCRIPT PARA TRATAR CAMPOS DA CONSULTA
* ========================================
*  VICTORIA GONÇALVES
* ========================================
*/
    function data_copy() {

        if (document.form1.datachegada.value != "Fecha de llegada") {
            "data_copy==yes";
            document.form1.datasaida.value = document.form1.datachegada.value;
        }
        else {
            document.form1.datasaida.value = "Fecha de partida";
        }
    };
    
    if (!document.layers && !document.all)
        event = "test";
        
    function Mostra(current, e, text) {
        if (document.all) {
            titulo = text.split('<BR>')
            if (titulo.length > 1) {
                titulos = ''
                for (i = 0; i < titulo.length; i++)
                    titulos += titulo[i]
                current.title = titulos
            }
            else
                current.title = text
        }
        else if (document.layers) {
            document.texto.document.write('<layer bgColor="white" style="border:1px solid black;font-size:15px;font-family:Sans-Serif, Arial;font-size:9pt;font-weight:bold">' + text + '</layer>')
            document.texto.document.close()
            document.texto.left = e.pageX + 5
            document.texto.top = e.pageY + 5
            document.texto.visibility = "show"
        }
    };
    function Esconde() {
        if (document.layers)
            document.texto.visibility = "hidden"
    };
    function data_copy() {
        if (document.form1.datachegada.value != "Fecha de llegada") {
            "data_copy==yes";
            document.form1.datasaida.value = document.form1.datachegada.value;
        }
        else {
            document.form1.datasaida.value = "Fecha de partida";
        }
    };
    function limpa_nome() {
    if (document.form1.nome.value == "Nombre") {
            "limpa_nome==yes";
            document.form1.nome.value = "";
        }
    };
    function completa_nome() {
        if (document.form1.nome.value == "") {
            "completa_nome==yes";
            document.form1.nome.value = "Nombre";
        }
    };
    function limpa_email() {
        if (document.form1.email.value == "E-mail") {
            "limpa_email==yes";
            document.form1.email.value = "";
        }
    };
    function completa_email() {
        if (document.form1.email.value == "") {
            "completa_email==yes";
            document.form1.email.value = "E-mail";
        }
    };
    function limpa_chegada() {
        if (document.form1.datachegada.value == "Fecha de llegada") {
            "limpa_chegada==yes";
            document.form1.datachegada.value = "";
        }
    };
    function completa_chegada() {
        if (document.form1.datachegada.value == "") {
            "completa_datachegada==yes";
            document.form1.datachegada.value = "Fecha de llegada";
        }
    };
    function limpa_saida() {
        if (document.form1.datasaida.value == "Fecha de partida") {
            "limpa_saida==yes";
            document.form1.datasaida.value = "";
        }
    };
    function completa_saida() {
        if (document.form1.datasaida.value == "") {
            "completa_datasaida==yes";
            document.form1.datasaida.value = "Fecha de partida";
        }
    };
  function checkEmailNome() {
        var x=document.form1.email.value;
        var atpos=x.indexOf("@");
        var dotpos=x.indexOf(".");
        var flagError = false;
        var error="";
    
        if (document.form1.nome.value == "" || document.form1.nome.value == " " )  {
            error = "¡Por favor, rellene su nombre antes de enviar!";
            document.getElementById('nome').focus();
            alert(error);
            flagError = true;
            }
            else if (document.form1.nome.value == "Nombre" )  {
                error = "¡Por favor, rellene su nombre antes de enviar! ";
                document.getElementById('nome').focus();
                alert(error);
                flagError = true;
                }
        if (flagError != true) {     
            if (document.form1.email.value == "" || document.form1.email.value == " ") {
                error = "¡Por favor, rellene su correo antes de enviar! ";
                document.getElementById('email').focus();
                alert(error);
                flagError = true;
                }
            else if (document.form1.email.value == "E-mail") {
                error = "¡Por favor, rellene su correo antes de enviar! ";
                document.getElementById('email').focus();
                alert(error);
                flagError = true;
                }
            }
        if (flagError != true) {
            if (atpos<1 || dotpos < atpos+2 || dotpos+2 >= x.length) {
                error = "¡Por favor, rellene un dirección electronica valida!";
                document.getElementById('email').focus();
                alert(error);
                flagError = true;
                }
            }    
      return !flagError }
