﻿// Limpia el valor por defecto del campo de texto de un formulario
function clearTextBox(objTextBox)
{
    if(objTextBox.defaultValue == objTextBox.value)
    { 
        objTextBox.value='';
    }
}

function readKeyTextBox(evtEvent)
{
    if (evtEvent.keyCode == 13) 
    {
        alert(evtEvent.keyCode);
        document.form1.submit();
    }
}

function OpenInfo()
        {
            var windoName;
            windowName =window.open('Info.html','faq','width=400,height=400,Toolbar =NO,Titlebar=NO,Status =NO,Menubar =NO,Location =NO,Directories =NO,Resizable=SI,resizable=si');
            windowName.focus();
        }
 //INICIO AÑADIDO PHP (25/04/2008)
function mostrarLeyenda() {
    window.open("Leyenda.html","Leyenda","width=690,height=380,scrollbars=NO,Toolbar =NO,Titlebar=NO,Status =NO,Menubar =NO,Location =NO,Directories =NO,Resizable=NO");
}

//FIN AÑADIDO PHP (25/04/2008)
 function mostrarCondiciones() {
    window.open("condiciones.html","Condiciones","width=400,height=400,top=200px,left=450px,scrollbars=NO,Toolbar =NO,Titlebar=NO,Status =NO,Menubar =NO,Location =NO,Directories =NO,Resizable=NO");
}


function OpenAlertCookies()
{
    var windoName;
    windowName =window.open('AlertCookies.aspx','faq','width=300,height=110,top=100,left=150,scrollbars=no,resizable=no');
    windowName.focus();
}

function OpenPrint(modo)
{
    var windoName;
    windowName =window.open('PrintRoute.aspx?modo=' + modo,'faq','width=800,height=800,scrollbars=yes,resizable=yes');
    windowName.focus();
}

function ShowPois(IdTable)
{
    var Table=document.getElementById (IdTable);
    
    if (Table.style.display =='table')
    {
        Table.style.display ='none';
    }
    else
    {
        Table.style.display ='table';
    }
}




//////COMPROBACIÓN DE SI EL USUARIO TIENE HABILITADAS LAS COOKIES

function CogerValorCookie(indice) {   
    //indice indica el comienzo del valor   
    var galleta = document.cookie  
    //busca el final del valor, dado por ;, a partir de indice   
    var finDeCadena = galleta.indexOf(";", indice)   
    //si no existe el ;, el final del valor lo marca la longitud total de la cookie   
    if (finDeCadena == -1)   
        finDeCadena = galleta.length  
  
    return unescape(galleta.substring(indice, finDeCadena))   
    }   
  
function CogerCookie(nombre) {   
    var galleta = document.cookie  
    //construye la cadena con el nombre del valor   
    var arg = nombre + "="  
    var alen = arg.length           //longitud del nombre del valor   
    var glen = galleta.length       //longitud de la cookie   
  
    var i = 0   
    while (i < glen) {   
        var j = i + alen                    //posiciona j al final del nombre del valor   
        if (galleta.substring(i, j) == arg) //si en la cookie estamo ya en nombre del valor        
            return CogerValorCookie(j)      //devuleve el valor, que esta a partir de j   
  
        i = galleta.indexOf(" ", i) + 1     //pasa al siguiente   
        if (i == 0)   
            break                           //fin de la cookie   
    }   
    return null                             //no se encuentra el nombre del valor   
}   
  
function GuardarCookie (nombre, valor) {   
    //crea la cookie: incluye el nombre y la ruta donde esta guardada   
    //cada valor esta separado por ; y un espacio   
    document.cookie = nombre + "=" + escape(valor) + "; path=/"  
}   
  
//inicia secuencia de test   
//guarda la cookie   
GuardarCookie("miCOOKIE", "Prueba")   
//espera 1 segundo (algunos navegadores requieren un tiempo para guardar la cookie)   
var rep= setTimeout("test()",1000)   
//lee la cookie y muestra un mensaje u otro en funcion de que la lectura tenga exito o no   
function test() {   
    if ( CogerCookie("miCOOKIE") == "Prueba" ) {   
       // alert("Las cookies están habilitadas.")   
    } else {   
       
       alert("Lo sentimos, no tienes las cookies habilitadas, es necesario que las habilites para ver correctamente el mapa. Si necesitas ayuda pincha en el icono '?'")   
      //   OpenAlertCookies();
    }   
    clearTimeout(rep);
}   
  
//INICIO AÑADIDO PHP (02/06/2008)
        function confirmarRutaSegura() {           
            var  aceptadoTerminos= document.getElementById("CheckBAceptoTerminos");
                var aceptado=false;
                if (!aceptadoTerminos.checked)
                {                
                    var aceptar = confirm("Conozco  y acepto las condiciones de utilización del presente servicio.");
                    if (aceptar == true) 
                    { 
                           aceptado=true;    
                           aceptadoTerminos.checked=true;                        
                    }
                    else
                    {
                        aceptado=false;  
                    }
                 }
                 else
                 {
                    aceptado=true;
                 }
                 if (aceptado)
                 {
                        var segura = document.getElementById("CTL_WR_ROW_ROUTERPOILIST1_lnkSecureRoute");
                     
                        if (navigator.appVersion.indexOf('MSIE 7.0')>0)
                        {
                            segura.click();
    
                        }
                        else
                        {
                            if (navigator.appVersion.indexOf('MSIE 6.0')>0)
                            {   segura.click();
                                
                            }
                            else
                            {
                               // no es explorer
                               __doPostBack('CTL_WR_ROW_ROUTERPOILIST1$lnkSecureRoute','');
                               
                            }
                        }
                }
        }
         
        
        function buenViaje() {
            window.open("http://www.buenviajecepsa.com/");
        }
        
        

var esrutaSeguraScript="1";

function cambiaresSegura(nuevoestado)
{
    esrutaSeguraScript=nuevoestado;
}

    function confirmarInicioRutaSegura() {
          
             if (esrutaSeguraScript=="1")
             {
                var  aceptadoTerminos= document.getElementById("CheckBAceptoTerminos");
                var aceptado=false;
                if (!aceptadoTerminos.checked)
                {                
                    var aceptar = confirm("Conozco  y acepto las condiciones de utilización del presente servicio.");
                    if (aceptar == true) 
                    { 
                           aceptado=true;    
                           aceptadoTerminos.checked=true;                        
                    }
                    else
                    {
                        aceptado=false;  
                    }
                 }
                 else
                 {
                    aceptado=true;
                 }
                 if (aceptado)
                 {
                           var segura = document.getElementById("CTL_WR_SEL_ORIGINDEST1_LinkButtonSegura");
                           
                           if (navigator.appVersion.indexOf('MSIE 7.0')>0)
                            {
                                segura.click();
                            }
                            else
                            {
                                if (navigator.appVersion.indexOf('MSIE 6.0')>0)
                                {
                                    segura.click();
                                }
                                else
                                {
                                   // no es explorer
                                   __doPostBack('CTL_WR_SEL_ORIGINDEST1$LinkButtonSegura','');
                                }
                            }
                 }
             }
             else if (esrutaSeguraScript=="2")
             {
                 var segura = document.getElementById("CTL_WR_SEL_ORIGINDEST1_LinkButtonRapida");
                       
                       if (navigator.appVersion.indexOf('MSIE 7.0')>0)
                        {
                            segura.click();
                        }
                        else
                        {
                            if (navigator.appVersion.indexOf('MSIE 6.0')>0)
                            {
                                segura.click();
                            }
                            else
                            {
                               // no es explorer
                               __doPostBack('CTL_WR_SEL_ORIGINDEST1$LinkButtonRapida','');
                            }
                        }
                 

             }    
              else if (esrutaSeguraScript=="3")
             {
                 var segura = document.getElementById("CTL_WR_SEL_ORIGINDEST1_LinkButtonCorta");
                        
                       if (navigator.appVersion.indexOf('MSIE 7.0')>0)
                        {
                            segura.click();
                        }
                        else
                        {
                            if (navigator.appVersion.indexOf('MSIE 6.0')>0)
                            {
                                segura.click();
                            }
                            else
                            {
                               // no es explorer
                               __doPostBack('CTL_WR_SEL_ORIGINDEST1$LinkButtonCorta','');
                            }
                        }
                 
                  
             }
              
        }
        //FIN AÑADIDO PHP (02/06/2008)