﻿function login() {
    cssClassDefault = 'input_log';
    cssClassDefaultError = 'input_log_error';
    var time = new Date();

    if (ValidarGroup('Login')) {
        var currPage = getCurrentPage();
        if (currPage == "") {
            currPage = "/";
        }
        document.frmLogin.hidLogin.value = 'login';
        document.frmLogin.hidParametroGenerico.value = time.toString();
        document.frmLogin.action = currPage;
        document.frmLogin.submit();
    }
}
function validaCantPax(textbox) {
    var cantidad = textbox.value;
    if (parseInt(cantidad) > parseInt(document.getElementById('hidGruposHasta').value)) {
        textbox.value = "";
        textbox.focus();
        alert("El restaurante no acepta tantos comensales.");
    }
}
function loginRestaurante() {
    cssClassDefault = 'input_log';
    cssClassDefaultError = 'input_log_error';

    if (ValidarGroup('LoginResto')) {
        document.Form.hidAction.value = 'Login';
        document.Form.submit();
    }
}
function recordar() {
    openPopup("/recordar.aspx", 450, 245, false, false, 'recordar');
}
function recomienda() {
    openPopup("/pop_recomienda.aspx", 450, 343, false, false, 'recomendar');
}
function getCurrentPage() {
    var url = location.href;
    var strQueryString = "";
    var strURL = "";
    var arrURL;

    //me fijo si tiene parámetros, y los separo de la url, porque pueden tener "/" e interferir con la función
    if (url.indexOf("?") > -1) {
        arrURL = url.split('?');
        strURL = arrURL[0];
        strQueryString = "?" + arrURL[1];
    } else {
        strURL = url;
    }

    var arrPrevPage = strURL.split('/');
    strURL = arrPrevPage[arrPrevPage.length - 1];
    //url = url.replace("?","||").replace("&","{|}");
    return strURL + strQueryString;
}/*
function getIdioma() {
    var idIdioma = 1;
    var url = location.href;

    if (url.indexOf('.com') > -1) {
        idIdioma = 2;
    } else if (url.indexOf('.it') > -1) {
        idIdioma = 3;
    } else if (url.indexOf('.fr') > -1) {
        idIdioma = 4;
    }
    return idIdioma;
}*/

function idioma(idIdioma) {
    var url = location.href;
    var arrPaginasEsp = new Array('reserva-de-restaurantes', 'promocionar-restaurante', 'guia-de-restaurantes');
    var arrPaginasIng = new Array('spanish-restaurants-reviews', 'fine-dining-restaurants-in-spain', 'book-restaurant-online');
    var arrDominios = new Array('', '.es/', '.com/', '.it/', '.fr/');
    var bEncontro = false;
    
    if (url.indexOf(arrDominios[idIdioma]) == -1) {
        
        url = url.replace('.com/', arrDominios[idIdioma]).replace('.it/', arrDominios[idIdioma]).replace('.fr/', arrDominios[idIdioma]).replace('.es/', arrDominios[idIdioma]);

        var url2 = url.split(arrDominios[idIdioma]);

        url2 = url2[0];
        
        switch(idIdioma) {
            case 1: url2 = url2 + '.es/'; break;
            case 2: url2 = url2 + '.com/'; break;
            case 3: url2 = url2 + '.it/'; break;
            case 4: url2 = url2 + '.fr/'; break;
            default: url2 = url2 + '.es/'; break;
        }

        window.location = url2;
    }
    
    /*
    if (url.indexOf(arrDominios[idIdioma]) == -1) {
        url = url.replace('.com', arrDominios[idIdioma]).replace('.it', arrDominios[idIdioma]).replace('.fr', arrDominios[idIdioma]).replace('.es', arrDominios[idIdioma]);
        
        if (document.getElementById('hidURLTranslate') != null && document.getElementById('hidURLTranslate').value != '' && document.getElementById('hidURLTranslate').value.indexOf('|') == -1) {
            //url = url.replace(getCurrentPage(), document.getElementById('hidURLTranslate').value);
        } else {
            var arrCiudades = new Array();
            if (document.getElementById('hidURLTranslate') != null && document.getElementById('hidURLTranslate').value.indexOf('|') > -1) { //tiene los nombres de las ciudades separados por |
                arrCiudades = document.getElementById('hidURLTranslate').value.split('|');
            }
            
            /*
            if (arrCiudades.length > 3) {
                url = url.replace(arrCiudades[getIdioma() - 1], arrCiudades[idIdioma - 1]);
            }

            switch (getIdioma()) {
                case 1:
                    for (i = 0; i < arrPaginasEsp.length; i++) {
                        if (url.indexOf(arrPaginasEsp[i]) > -1) {
                            url = url.replace(arrPaginasEsp[i], 'default');
                            bEncontro = true;
                            break;
                        }
                    }
                    if (!bEncontro && url.indexOf('restaurantes-') > -1) {
                        switch (idIdioma) {
                            case 2:
                                url = url.replace('restaurantes-en', 'restaurants-in');
                                url = url.replace('restaurantes-', 'restaurants-');
                                break;
                            case 3:
                                url = url.replace('restaurantes-en', 'ristoranti-a');
                                url = url.replace('restaurantes-', 'ristoranti-');
                                break;
                            case 4:
                                url = url.replace('restaurantes-en', 'restaurants-a');
                                url = url.replace('restaurantes-', 'restaurants-');
                                break;
                        }
                    }
                    break;
                case 2:
                    for (i = 0; i < arrPaginasIng.length; i++) {
                        if (url.indexOf(arrPaginasIng[i]) > -1) {
                            url = url.replace(arrPaginasIng[i], 'default');
                            bEncontro = true;
                            break;
                        }
                    }
                    if (!bEncontro && url.indexOf('restaurants-') > -1) {
                        switch (idIdioma) {
                            case 1:
                                url = url.replace('restaurants-in', 'restaurantes-en');
                                url = url.replace('restaurants-', 'restaurantes-');
                                break;
                            case 3:
                                url = url.replace('restaurants-in', 'ristoranti-a');
                                url = url.replace('restaurants-', 'ristoranti-');
                                break;
                            case 4:
                                url = url.replace('restaurants-in', 'restaurants-a');
                                url = url.replace('restaurants-', 'restaurants-');
                                break;
                        }
                    }
                    break;
                case 3:
                    for (i = 0; i < arrPaginasEsp.length; i++) {
                        if (url.indexOf(arrPaginasEsp[i]) > -1) {
                            url = url.replace(arrPaginasEsp[i], 'default');
                            bEncontro = true;
                            break;
                        }
                    }
                    for (i = 0; i < arrPaginasIng.length; i++) {
                        if (url.indexOf(arrPaginasIng[i]) > -1) {
                            url = url.replace(arrPaginasIng[i], 'default');
                            bEncontro = true;
                            break;
                        }
                    }
                    if (!bEncontro && url.indexOf('ristoranti-') > -1) {
                        switch (idIdioma) {
                            case 1:
                                url = url.replace('ristoranti-a', 'restaurantes-en');
                                url = url.replace('ristoranti-', 'restaurantes-');
                                break;
                            case 2:
                                url = url.replace('ristoranti-a', 'restaurants-in');
                                url = url.replace('ristoranti-', 'restaurants-');
                                break;
                            case 4:
                                url = url.replace('ristoranti-a', 'restaurants-a');
                                url = url.replace('ristoranti-', 'restaurants-');
                                break;
                        }
                    }
                    break;
                case 4:
                    for (i = 0; i < arrPaginasEsp.length; i++) {
                        if (url.indexOf(arrPaginasEsp[i]) > -1) {
                            url = url.replace(arrPaginasEsp[i], 'default');
                            bEncontro = true;
                            break;
                        }
                    }
                    for (i = 0; i < arrPaginasIng.length; i++) {
                        if (url.indexOf(arrPaginasIng[i]) > -1) {
                            url = url.replace(arrPaginasIng[i], 'default');
                            bEncontro = true;
                            break;
                        }
                    }
                    if (!bEncontro && url.indexOf('restaurants-') > -1) {
                        switch (idIdioma) {
                            case 1:
                                url = url.replace('restaurants-a', 'restaurantes-en');
                                url = url.replace('restaurants-', 'restaurantes-');
                                break;
                            case 2:
                                url = url.replace('restaurants-a', 'restaurants-in');
                                url = url.replace('restaurants-', 'restaurants-');
                                break;
                            case 3:
                                url = url.replace('restaurants-a', 'ristoranti-a');
                                url = url.replace('restaurants-', 'ristoranti-');
                                break;
                        }
                    }
                    break;
            }
        }
    }*/
}

function logout() {
    var currPage = getCurrentPage();
    if (currPage == "") {
        currPage = "/";
    }
    var time = new Date();
    document.frmLogin.hidLogin.value = 'logout';
    document.frmLogin.hidParametroGenerico.value = time.toString();
    document.frmLogin.action = currPage;
    document.frmLogin.submit();
}


var rbComida = '';

var changedTxtCiudad = false;
var urlBuscador = "/restaurantes/"

function buscar1(chkGrupos, chkEmpresas, searchType, param, buscador) {

    chkGrupos = chkGrupos ? 1 : 0;
    
    if (chkGrupos == '') {
        chkGrupos = (document.getElementById('chkGrupos') != null && document.getElementById('chkGrupos').checked ? 1 : 0);
    }
    if (chkEmpresas == '') {
        chkEmpresas = (document.getElementById('chkEmpresas') != null && document.getElementById('chkEmpresas').checked ? 1 : 0);
    }
    if (chkOfertas == '') {
        chkOfertas = (document.getElementById('chkOfertas') != null && document.getElementById('chkOfertas').checked ? 1 : 0);
    }
    
    var chkOfertas = (document.getElementById('chkOfertas') != null && document.getElementById('chkOfertas').checked ? 1 : 0);
    var chkReserva = (document.getElementById('chkReserva') != null && document.getElementById('chkReserva').checked ? '&chkReserva=on' : '');
    var chkMapa = (document.getElementById('chkMapa') != null && document.getElementById('chkMapa').checked ? 1 : 0);
    var chkSalasPrivadas = "";
    
    if (buscador == 'home') {
    
        if (chkOfertas == 0 || chkOfertas == '') {
            chkOfertas = (jQuery("#chkOfertas").attr("value") == 'on' || jQuery("#chkOfertas").attr("value") == '1') ? 0 : 1;
        }
        if (chkGrupos == 0 || chkGrupos == '') {
            chkGrupos = (jQuery("#chkGrupos").attr("value") == 'on' || jQuery("#chkGrupos").attr("value") == '1') ? 0 : 1;
        }
    } else {
        if (chkOfertas == 0 || chkOfertas == '') {
            chkOfertas = (jQuery("#chkOfertas").attr("value") == 'on' || jQuery("#chkOfertas").attr("value") == '1') ? 1 : 0;
        }
        if (chkEmpresas == 0 || chkEmpresas == '') {
            chkEmpresas = (jQuery("#chkEmpresas").attr("value") == 'on' || jQuery("#chkEmpresas").attr("value") == '1') ? 1 : 0;
        }
    }
    
//    chkGrupos = (chkGrupos != undefined ? 1 : 0);
//    chkEmpresas = (chkEmpresas != undefined ? 1 : 0);

    
    var soloDescuentos7 = '';

    try {
        soloDescuentos70 = ((document.getElementById('soloDescuentos70') != null && document.getElementById('soloDescuentos70').checked) ? 'on' : '');
        if (soloDescuentos70 == "" && buscador != 'home') {
            soloDescuentos70 = document.getElementById('soloDescuentos70').value;
        }
    } catch (error) {
        soloDescuentos70 = '';
    }
    
    
    
    var query = '';
    
    var idioma = getIdioma();
    
    switch (idioma) {
        case 1: urlBuscador = "/restaurantes/"; break;
        case 2: urlBuscador = "/restaurants/"; break;
        case 3: urlBuscador = "/ristoranti/"; break;
        case 4: urlBuscador = "/restaurants/"; break;
    }
    
    
    
    searchType = (searchType != undefined ? true : false);
    if (!searchType) {
        var url = location.href;
        searchType = url.indexOf(urlBuscador) > 0 ? true : false;
    }
    searchType = true;
    
    cssClassDefault = 'imput_buscador3';
    cssClassDefaultError = 'imput_buscador3Error';
    
    if (jQuery('#txtCiudad'))
    if (  jQuery('#txtCiudad').attr( 'value' ) == hiddenText ) {
		
		jQuery('#txtCiudad').attr( 'value', '' );
    }

    if (jQuery('#txtPalabraClave'))
        if (jQuery('#txtPalabraClave').attr('value') == hiddenText) {

            jQuery('#txtPalabraClave').attr('value', '');
    }

	var validado = true;
    
    if (buscador != 'tipo') {
        if (ValidarGroup('buscador1')) {
        
            if (document.getElementById('rbComida') != null) {
                arrComida = getElementsByName_iefix('input', 'rbComida');
                for (i = 0; i < arrComida.length; i++) {
                    if (arrComida[i].selected) {
                        if (searchType)
                            rbComida = arrComida[i].Text;
                        else
                            rbComida = arrComida[i].value;
                        break;
                    }
                }
            }
        }
        else {
            validado = false;
        }
    } 
    
    if ( validado ) {
    
        var cmbTipoCocina = "";
        var cmbPrecios = "";
        var hidIdBF = "";
        var hidBar = "";
        var txtComensales = "";
        var cmbAmbientes = "";
        
        var cmbServicios = "";

        var txtCiudad = document.getElementById('txtCiudad').value;

        var txtFecha = (document.getElementById('txtFecha') != null && document.getElementById('txtFecha').value != "" ? "&txtFecha=" + document.getElementById('txtFecha').value : "");
        if (document.getElementById('txtComensales')!=null && document.getElementById('txtComensales').value != "") {
            txtComensales = "&txtComensales=" + document.getElementById('txtComensales').value;
        }
        if (document.getElementById('cmbTipoCocina') != null && document.getElementById('cmbTipoCocina').value != "0") {
            
            if (searchType)
                cmbTipoCocina = "&cmbTipoCocina=" + jQuery("#cmbTipoCocina option:selected").text();
            else
                cmbTipoCocina = "&cmbTipoCocina=" + document.getElementById('cmbTipoCocina').value;
        }
        if (document.getElementById('cmbAmbientes') != null && document.getElementById('cmbAmbientes').value != "0") {
            
            if (searchType)
                cmbAmbientes = "&cmbAmbientes=" + jQuery("#cmbAmbientes option:selected").text();
            else
                cmbAmbientes = "&cmbAmbientes=" + document.getElementById('cmbAmbientes').value;    
        }
        if (document.getElementById('cmbPrecios')!=null && document.getElementById('cmbPrecios').value != "0") {

            if (searchType) {
                if (jQuery("#cmbPrecios option:selected").text() == "") {
                    //alert(1 + document.getElementById('cmbName').value);
                    if (document.getElementById('cmbName')!=null)
                        cmbPrecios = "&cmbPrecios=" + document.getElementById('cmbName').value;
                }
                else {
                    //alert(2 + jQuery("#cmbPrecios option:selected").text());
                    cmbPrecios = "&cmbPrecios=" + jQuery("#cmbPrecios option:selected").text();
                }
            }
            else {
                //alert(3 + document.getElementById('cmbPrecios').value);
                cmbPrecios = "&cmbPrecios=" + document.getElementById('cmbPrecios').value;
            }
        }

        if (document.getElementById('cmbServicios') != null && document.getElementById('cmbServicios').value != "0") {
            
            if (searchType)
                cmbServicios = "&cmbServicios=" + jQuery("#cmbServicios option:selected").text();
            else
                cmbServicios = "&cmbServicios=" + document.getElementById('cmbServicios').value;
        }
        
        var hidIdBF = "";
        var hidIdServ = "";
        var tipoOf = "";
        var hidZona = "";
        
        if ( document.getElementById('hidIdBF') != null && document.getElementById('hidIdBF').value != "0" ){
            if (searchType) {
                if (document.getElementById('nameBf') != null) {
                    hidIdBF = "&hidIdBF=" + document.getElementById('nameBf').value;
                }
            }
            else {
                hidIdBF = "&hidIdBF=" + document.getElementById('hidIdBF').value;
            }
        }
        if ( document.getElementById('hidIdServ') != null && document.getElementById('hidIdServ').value != "0" ){

            if (searchType) {
                if (document.getElementById('nameServ') != null) {
                    hidIdServ = "&hidIdServ=" + document.getElementById('nameServ').value;
                }
            }
            else
                hidIdServ = "&hidIdServ=" + document.getElementById('hidIdServ').value;
        }
        
        if ( document.getElementById('tipoOf') != null ){
            if (searchType) {
                if (document.getElementById('nameOf') != null) {
                    tipoOf = "&tipoOf=" + document.getElementById('nameOf').value;
                }
            }
            else
                tipoOf = "&tipoOf=" + document.getElementById('tipoOf').value;
        }
        if ( document.getElementById('hidZona') != null && document.getElementById('hidZona').value != "0" ){

            if (searchType) {
                if (document.getElementById('nameZona') != null) {
                    hidZona = "&hidZona=" + document.getElementById('nameZona').value;
                }
            }
            else
                hidZona = "&hidZona=" + document.getElementById('hidZona').value;
        }
        
        if (document.getElementById('hidBar') != null) {
            hidBar = "&hidBar=" + document.getElementById('hidBar').value;
        }
        
        if (document.getElementById('chkSalasPrivadas') != null) {
            chkSalasPrivadas = (document.getElementById('chkSalasPrivadas').checked ? '&chkSalasPrivadas=on' : '');
        }
        
        if ( document.getElementById('cmbIdealesPara') != null && document.getElementById('cmbIdealesPara').value != "0" ){
            if (searchType)
                hidIdBF = "&hidIdBF=" + jQuery("#cmbIdealesPara option:selected").text();
            else
                hidIdBF = "&hidIdBF=" + document.getElementById('cmbIdealesPara').value;
        }
        /* Added by Josex*/
        
        

        /* End */
        
        var buscarPor = "";

        var showBuscadprPrefix = true;
        var typeOfSearch = "";
        var searchIdentifier = "";
        
        if (buscador == 'tipo') {
            
            var rbCampoBusqueda = 0;
            for (i = 0; i < 7; i++) {
                if (document.getElementById('rbCampoBusqueda_' + i) != null) {
                    if (document.getElementById('rbCampoBusqueda_' + i).checked) {
                        rbCampoBusqueda = i + 1;
                        break;
                    }
                }
            }

            if (rbCampoBusqueda == 0) {
                for (i = 0; i < 7; i++) {
                    if (document.getElementById('Buscador1_rbCampoBusqueda_' + i).checked) {
                        rbCampoBusqueda = i + 1;
                        break;
                    }
                }
            }
            
            buscarPor = "";

            if (rbCampoBusqueda > 0) {
                
                var txtPalabraClave = document.getElementById('txtPalabraClave').value;
                //window.location = "/resultados.aspx?rbCampoBusqueda=" + rbCampoBusqueda + "&txtPalabraClave=" + txtPalabraClave + "&chkGrupos=" + chkGrupos + "&chkEmpresas=" + chkEmpresas + "&reset=Si";
                
                if (searchType) {
                    switch (rbCampoBusqueda) {
                        case 1:
                            //buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "nobar" : idioma == 2 ? "nobar" : idioma == 3 ? "nobar" : "nobar");
                            //buscarPor = "";
                            
                            //searchIdentifier = (idioma == 1 ? "restaurante" : idioma == 2 ? "restaurant" : idioma == 3 ? "ristorante" : "restaurant");
                            break;
                        case 2:
                            //buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "bar" : idioma == 2 ? "bar" : idioma == 3 ? "bar" : "bar");
                            //buscarPor = "";
                            
                            //searchIdentifier = (idioma == 1 ? "restaurante" : idioma == 2 ? "restaurant" : idioma == 3 ? "ristorante" : "restaurant");
                            break;
                        case 3:
                            buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "restaurantes" : idioma == 2 ? "restaurants" : idioma == 3 ? "ristoranti" : "restaurants");
                            searchIdentifier = (idioma == 1 ? "restaurantes" : idioma == 2 ? "restaurants" : idioma == 3 ? "ristoranti" : "restaurants");
                            break;
                        case 4:
                            buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "calle" : idioma == 2 ? "calle" : idioma == 3 ? "calle" : "calle");
                            searchIdentifier = (idioma == 1 ? "calle" : idioma == 2 ? "calle" : idioma == 3 ? "calle" : "calle")
                            break;
                        case 5:
                            buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "cocina" : idioma == 2 ? "cuisine" : idioma == 3 ? "cucina" : "cuisine");
                            searchIdentifier = (idioma == 1 ? "cocina" : idioma == 2 ? "cuisine" : idioma == 3 ? "cucina" : "cuisine");
                            break;
                        case 6:
                            buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "cp" : idioma == 2 ? "cp" : idioma == 3 ? "cp" : "cp");
                            searchIdentifier = (idioma == 1 ? "cp" : idioma == 2 ? "cp" : idioma == 3 ? "cp" : "cp");
                            break;
                        case 7:
                            buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "estacion-tren" : idioma == 2 ? "estacion-tren" : idioma == 3 ? "estacion-tren" : "estacion-tren");
                            searchIdentifier = (idioma == 1 ? "estacion-tren" : idioma == 2 ? "estacion-tren" : idioma == 3 ? "estacion-tren" : "estacion-tren");
                            break;
                        case 7:
                            buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "estacion-metro" : idioma == 2 ? "estacion-metro" : idioma == 3 ? "estacion-metro" : "estacion-metro");
                            searchIdentifier = (idioma == 1 ? "estacion-metro" : idioma == 2 ? "estacion-metro" : idioma == 3 ? "estacion-metro" : "estacion-metro");
                            break;
                        case 8:
                            buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "ideal" : idioma == 2 ? "best-for" : idioma == 3 ? "ideale" : "ideal-pour");
                            searchIdentifier = (idioma == 1 ? "ideal" : idioma == 2 ? "best-for" : idioma == 3 ? "ideale" : "ideal-pour");
                            break;
                    }

                    buscarPor = "";
                }
                
                //query = buscarPor + "&txtPalabraClave=" + txtPalabraClave + "&chkGrupos=" + chkGrupos + "&chkEmpresas=" + chkEmpresas;
                //var query = buscarPor + (rbCampoBusqueda!=3?"&txtPalabraClave="+txtPalabraClave:"") + "&chkGrupos=" + chkGrupos + "&chkEmpresas=" + chkEmpresas;
                
                /*
                if (searchType)
                    window.location = urlBuscador + encode(query);
                else
                    window.location = "/resultados.aspx?" + query;*/
            } else {
                switch (getIdioma()) {
                    case 1:
                        showAlert("Debe seleccionar una opción de búsqueda.", 230, 90);
                        break;
                    case 2:
                        showAlert("Please select a search option.", 230, 90);
                        break;
                    case 3:
                        showAlert("Debe seleccionar una opción de búsqueda.", 230, 90);
                        break;
                    case 4:
                        showAlert("Debe seleccionar una opción de búsqueda.", 230, 90);
                        break;
                }
            }

        } else if (buscador == 'home') {
        
            try {
                var isCiudad = false;
                switch (document.getElementById('NombreTabla').value) {
                    
                    case 'nobar':
                        
                        if (searchType){
                            //buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "nobar" : idioma == 2 ? "nobar" : idioma == 3 ? "nobar" : "nobar") + "&txtPalabraClave=" + txtCiudad;
                        }
                        else {
                            //buscarPor = "rbCampoBusqueda" + "=" + 1 + "&txtPalabraClave=" + txtCiudad;
                        }

                        //searchIdentifier = (idioma == 1 ? "restaurante" : idioma == 2 ? "restaurant" : idioma == 3 ? "ristorante" : "restaurant");
                        
                        break;
                    case 'bar':

                        if (searchType) {
                            //buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "bar" : idioma == 2 ? "bar" : idioma == 3 ? "bar" : "bar") + "&txtPalabraClave=" + txtCiudad;
                        } else {
                            //buscarPor = "rbCampoBusqueda" + "=" + 2 + "&txtPalabraClave=" + txtCiudad;
                        }
                        //searchIdentifier = (idioma == 1 ? "restaurante" : idioma == 2 ? "restaurant" : idioma == 3 ? "ristorante" : "restaurant");

                        break;
                    case 'ciudades':
                        //buscarPor = "rbCampoBusqueda" + "=" + 3 + "&txtPalabraClave=" + txtCiudad; break;
                        buscarPor = "&txtCiudad=" + txtCiudad;
                        showBuscadprPrefix = false;
                        break;
                    case 'calle':
                        
                        if (searchType)
                            buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "calle" : idioma == 2 ? "calle" : idioma == 3 ? "calle" : "calle") + "&txtPalabraClave=" + txtCiudad;
                        else
                            buscarPor = "rbCampoBusqueda" + "=" + 4 + "&txtPalabraClave=" + txtCiudad;
                        
                        searchIdentifier = (idioma == 1 ? "calle" : idioma == 2 ? "calle" : idioma == 3 ? "calle" : "calle");
                        
                        break;
                    case 'cocina':
                        
                        if (searchType)
                            buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "cocina" : idioma == 2 ? "cuisine" : idioma == 3 ? "cucina" : "cuisine") + "&txtPalabraClave=" + txtCiudad;
                        else
                            buscarPor = "rbCampoBusqueda" + "=" + 5 + "&txtPalabraClave=" + txtCiudad;
                        
                        searchIdentifier = (idioma == 1 ? "cocina" : idioma == 2 ? "cuisine" : idioma == 3 ? "cucina" : "cuisine");
                        break;
                    case 'cp':

                        if (searchType)
                            buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "cp" : idioma == 2 ? "cp" : idioma == 3 ? "cp" : "cp") + "&txtPalabraClave=" + txtCiudad;
                        else
                            buscarPor = "rbCampoBusqueda" + "=" + 6 + "&txtPalabraClave=" + txtCiudad;
                        
                        searchIdentifier = (idioma == 1 ? "cp" : idioma == 2 ? "cp" : idioma == 3 ? "cp" : "cp");
                        break;
                    case 'estacion_tren':
                        
                        if (searchType)
                            buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "estacion-tren" : idioma == 2 ? "estacion-tren" : idioma == 3 ? "estacion-tren" : "estacion-tren") + "&txtPalabraClave=" + txtCiudad;
                        else
                            buscarPor = "rbCampoBusqueda" + "=" + 7 + "&txtPalabraClave=" + txtCiudad;
                        
                        searchIdentifier = (idioma == 1 ? "estacion-tren" : idioma == 2 ? "estacion-tren" : idioma == 3 ? "estacion-tren" : "estacion-tren");
                        break;
                    case 'estacion_metro':
                        
                        if (searchType)
                            buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "estacion-metro" : idioma == 2 ? "estacion-metro" : idioma == 3 ? "estacion-metro" : "estacion-metro") + "&txtPalabraClave=" + txtCiudad;
                        else
                            buscarPor = "rbCampoBusqueda" + "=" + 7 + "&txtPalabraClave=" + txtCiudad;
                        
                        searchIdentifier = (idioma == 1 ? "estacion-metro" : idioma == 2 ? "estacion-metro" : idioma == 3 ? "estacion-metro" : "estacion-metro");
                        break;
                    case 'bestfor':
                        
                        if (searchType)
                            buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "ideal" : idioma == 2 ? "best-for" : idioma == 3 ? "ideale" : "ideal-pour") + "&txtPalabraClave=" + txtCiudad;
                        else
                            buscarPor = "rbCampoBusqueda" + "=" + 8 + "&txtPalabraClave=" + txtCiudad;
                        
                        searchIdentifier = (idioma == 1 ? "ideal" : idioma == 2 ? "best-for" : idioma == 3 ? "ideale" : "ideal-pour");
                        break;
                    case 'zonas':
                        
                        if (searchType)
                            buscarPor = "rbCampoBusqueda" + "=" + (idioma == 1 ? "zona" : idioma == 2 ? "area" : idioma == 3 ? "zona" : "quartier") + "&txtPalabraClave=" + txtCiudad;
                        else
                            buscarPor = "rbCampoBusqueda" + "=" + 9 + "&txtPalabraClave=" + txtCiudad;
                        searchIdentifier = (idioma == 1 ? "zona" : idioma == 2 ? "area" : idioma == 3 ? "zona" : "quartier");
                        break;
                    default:
                        
                        if (searchType) {
                            buscarPor = /*"rbCampoBusqueda" + "=" + (idioma == 1 ? "completa" : idioma == 2 ? "completa" : idioma == 3 ? "completa" : "completa") + "&"+*/"txtPalabraClave=" + txtCiudad;
                        }
                        else
                            buscarPor = /*"rbCampoBusqueda" + "=" + 100 + "&"+*/"txtPalabraClave=" + txtCiudad;
                        break;
                }

                if (searchIdentifier != "" && showBuscadprPrefix) {
                    buscarPor = "&txtPalabraClave=" + searchIdentifier + "-" + txtCiudad;
                }
                else if (showBuscadprPrefix) {
                    buscarPor = "&txtPalabraClave=" + txtCiudad;
                }
            } catch (error) {
                
            }
        } else {
            
            if (txtCiudad != '') {
                buscarPor = "txtCiudad" + "=" + txtCiudad;
                showBuscadprPrefix = false;
            }
        }

        
        
        var cmbOrden = "";
        var cmbCerca = "";
        
        if (document.getElementById('cmbCerca') != null && document.getElementById('cmbCerca').value != "0")
            cmbCerca = "&cmbCerca=" + jQuery("#cmbCerca option:selected").text();
        
        if (document.getElementById('cmbOrden') != null && document.getElementById('cmbOrden').value != "0")
            cmbOrden = "&cmbOrden=" + jQuery("#cmbOrden option:selected").text();
        
        query = buscarPor + txtFecha + txtComensales + hidIdBF + hidIdServ + tipoOf + hidZona + "&rbComida=" + rbComida + "&chkOfertas=" + chkOfertas + "&chkMapa=" + chkMapa + cmbTipoCocina + cmbAmbientes + cmbPrecios + cmbServicios + "&chkGrupos=" + chkGrupos + "&chkEmpresas=" + chkEmpresas + chkSalasPrivadas + hidBar + chkReserva + "&soloDescuentos70=" + soloDescuentos70 + cmbCerca + cmbOrden;
        
        if (document.getElementById("txtPalabraClave") != null && document.getElementById("txtPalabraClave").value != "" /*&& buscador != undefined*/) {
            if (searchIdentifier == "") {
                query = query + "&txtPalabraClave=" + document.getElementById("txtPalabraClave").value;
            }else {
                query = query + "&txtPalabraClave=" + searchIdentifier + "-" + document.getElementById("txtPalabraClave").value;
            }
        }
        
        var query2 = (showBuscadprPrefix ? urlBuscador : '/') + encode(query).replace('//', '/') + (param != undefined ? param : "");
        
        if (searchType)
            window.location = query2;
        else
            window.location = "/resultados.aspx?" + query;
    }
}

function checkMaxNumbers(textBox) {
    if (textBox.value.length > 1)
        initAutoComplete = true;
    else
        initAutoComplete = false;
}


function buscar2(chkGrupos, chkEmpresas) {

    if (ValidarGroup('buscador2')) {
        
        var rbCampoBusqueda = 0;
        
        for (i = 0; i < 7; i++) {
            if (document.getElementById('rbCampoBusqueda_' + i) != null) {
                if (document.getElementById('rbCampoBusqueda_' + i).checked) {
                    rbCampoBusqueda = i + 1;
                    break;
                }
            }
        }
        if (rbCampoBusqueda > 0) {

            buscar1(chkGrupos, chkEmpresas, true, '', 'tipo');
            
        } else {
            switch (getIdioma()) {
                case 1:
                    showAlert("Debe seleccionar una opción de búsqueda.", 230, 90);
                    break;
                case 2:
                    showAlert("Please select a search option.", 230, 90);
                    break;
                case 3:
                    showAlert("Debe seleccionar una opción de búsqueda.", 230, 90);
                    break;
                case 4:
                    showAlert("Debe seleccionar una opción de búsqueda.", 230, 90);
                    break;
            }
        }
    }
}
function verTodosRestaurantes(txtCiudad, tipoListado, bar, grupos, empresas) {
    if (bar == undefined) {
        bar = 0;
    }
    if (grupos == undefined) {
        grupos = "";
    }
    if (empresas == undefined) {
        empresas = "";
    }
    window.location = '/resultados.aspx?txtCiudad=' + txtCiudad + '&hidBar=' + bar + '&chkGrupos=' + grupos + '&chkEmpresas=' + empresas;
}
function getElementsByName_iefix(tag, name) {
    var elem = document.getElementsByTagName(tag);
    var arr = new Array();
    for (i = 0, iarr = 0; i < elem.length; i++) {
        att = elem[i].getAttribute("name");
        if (att == name) {
            arr[iarr] = elem[i];
            iarr++;
        }
    }
    return arr;
}
/*
function showAlert(strTexto, width, height) {
    try {
        document.getElementById('tblAlert').style.display = '';
        document.getElementById('divAlert').innerHTML = strTexto;
        self.scrollTo(0, 0);
        //window.location = "#tblAlert";
    } catch (err) {
        setTimeout("showAlert('" + strTexto + "'," + width + ", " + height + ")", 1000);
    }
}*/
function espera(intentos) {
    //var lightboxtext = '<div class="overlay2"></div><div style="position:absolute;top:330px;left:600px;"><img src="/images/espera.gif" /></div>';

    //var body = document.getElementsByTagName("body").item(0);
    //body.innerHTML += lightboxtext;
    document.getElementById('divEspera1').style.display = '';
    document.getElementById('divEspera2').style.display = '';
}

function showAlertPop(strTexto, width, height) {
    try {
        Lightbox.showBoxString(strTexto, width, height);
    } catch (err) {
        setTimeout("showAlertPop('" + strTexto + "'," + width + ", " + height + ")", 1000);
    }
}
function showByAjax(strUrl, width, height) {
    try {
        Lightbox.showBoxByAJAX(strUrl, width, height);
    } catch (err) {
        setTimeout("showByAjax('" + strUrl + "'," + width + ", " + height + ")", 1000);
    }
}
function verMapa(coordenadas, nombre) {
    coordenadas = coordenadas.replace('(', '').replace(')', '');
    openPopup("http://maps.google.com/maps?f=q&q=" + coordenadas + "+(" + nombre.replace("&","") + ")&z=16", 800, 600, true, true, 'mapa');
}

function registrar() {
    cssClassDefault = 'imput_filtro';
    cssClassDefaultCombo = 'imput_filtro';
    cssClassDefaultErrorCombo = 'imput_buscador3Error';
    if (ValidarGroup('registro')) {
        document.Form.hidAction.value = 'guardar';
        document.Form.submit();
    }
}
function registrarse() {
    cssClassDefault = 'imput_filtro';
    cssClassDefaultCombo = 'imput_filtro';
    if (ValidarGroup('registro')) {
        if (document.getElementById('txtEmailR').value != document.getElementById('txtEmail2').value) {
            SetControlInvalido(document.getElementById('txtEmailR'));
            SetControlInvalido(document.getElementById('txtEmail2'));
        } else {
            SetControlValido(document.getElementById('txtEmailR'));
            SetControlValido(document.getElementById('txtEmail2'));
            if (document.getElementById('txtPasswordR').value != document.getElementById('txtPassword2').value) {
                SetControlInvalido(document.getElementById('txtPasswordR'));
                SetControlInvalido(document.getElementById('txtPassword2'));
            } else {
                SetControlValido(document.getElementById('txtPasswordR'));
                SetControlValido(document.getElementById('txtPassword2'));
                if (!document.getElementById('chkAcepto').checked) {
                    alert("Debe aceptar la política de privacidad.");
                } else {
                    document.Form.hidAction.value = 'guardar';
                    document.Form.submit();
                }
            }
        }
    }
}
function subscribe() {
    //window.location = '/registro.aspx?em=' + document.Form.txtSuscribe.value;
    if (ValidarGroup('suscribe')) {
        document.Form.hidAction.value = 'suscribe';
        document.Form.submit();
    }
}
function MasZona(intBar) {
    window.location = "/resultados.aspx?hidZona=" + document.getElementById('hidZona').value + "&hidBar=" + intBar;
}
function agregarFavorito(id) {
    var pagina = getCurrentPage();
    simple_ajax('/ajaxAgregaFavorito.aspx', 'GET', 'idR=' + id + '&pag=' + pagina);
}
function borrarTexto(textbox) {
    if (texto_borrar != undefined) {
        if (textbox.value == texto_borrar) {
            textbox.value = "";
        }
    }
}
function borrarTexto2(textbox, texto) {
    if (textbox.value == texto) {
        textbox.value = "";
    }
}

function verOcultar(txtNombreDiv, nombreLink) {
    var div = document.getElementById(txtNombreDiv);
    if (div.style.display == 'none') {
        div.style.display = '';
        if (nombreLink != undefined && document.getElementById('hidOcultar') != null) {
            document.getElementById(nombreLink).innerHTML = document.getElementById('hidOcultar').value;
        }
    } else {
        div.style.display = 'none';
        if (nombreLink != undefined && document.getElementById('hidVer') != null) {
            document.getElementById(nombreLink).innerHTML = document.getElementById('hidVer').value;
        }
    }
}
function dejarComentario(bar) {
    var idR = document.getElementById('hidIdRestaurante').value;
    simple_ajax('/ajaxRedirecciona.aspx', 'GET', 'pag=opinar.aspx||idR=' + idR + '&a=3');
}
function verPuntos() {
    simple_ajax('/ajaxRedirecciona.aspx', 'GET', 'pag=misPuntos.aspx&a=1');
}
function recomendar() {
    simple_ajax('/ajaxRedirecciona.aspx', 'GET', 'pag=misRecomendados.aspx&a=2');
}
function anadirAmigoExistente(strNombre, strEmail, iCont) {
    var tdEmails = document.getElementById('tdEmails');
    var tdNombres = document.getElementById('tdNombres');
    if (parseInt(document.Form.hidCantidad.value) < 20) {
        if (iCont == 1) {
            document.getElementById('txtNombre1').value = strNombre;
            document.getElementById('txtEmail1').value = strEmail;
        } else {
            document.Form.hidCantidad.value = parseInt(document.Form.hidCantidad.value) + 1;
            //var intCantidad = document.Form.hidCantidad.value;

            var elmTBODY = document.getElementById('tblAmigos');
            var intCantidad = elmTBODY.rows.length;

            var elmTR = elmTBODY.insertRow(intCantidad);

            //Creo los TDS
            //Inserto la descripción en la celda 1
            elmTD = elmTR.insertCell(0);
            elmTD.setAttribute("style", "padding-top:5px");
            elmTD.setAttribute("class", "txt_destacado7");
            elmTD.innerHTML = "<input name=\"txtNombre\" id=\"txtNombre" + intCantidad + "\" value=\"" + strNombre + "\" type=\"text\" class=\"imput_news\" style=\"width:130px;\" validationgroupname=\"Recomendados\" />";

            //inserto el codigo en la celda 2
            elmTD = elmTR.insertCell(1);
            elmTD.setAttribute("style", "padding-top:5px");
            elmTD.setAttribute("class", "txt_destacado7");
            elmTD.innerHTML = "<input name=\"txtEmail\" id=\"txtEmail" + intCantidad + "\" value=\"" + strEmail + "\"  type=\"text\" tipo=\"EMail\" class=\"imput_news\" style=\"width:160px;\" validationgroupname=\"Recomendados\" />";
        }
    }
}
function cambiaCiudad() {
    alert("filtro en desarrollo");
}

function agregarSolicitud(restaurante, menu, precio, fechaHora, Pax) {
    document.getElementById('tblSolicitudes').style.display = '';

    var elmTBODY = document.getElementById('tblListaSolicitudes');
    var intCantidad = elmTBODY.rows.length;
    var elmTR = elmTBODY.insertRow(intCantidad);

    //Creo los TDS
    //Inserto la descripción en la celda 1
    elmTD = elmTR.insertCell(0);
    elmTD.setAttribute("style", "padding-top:5px");
    elmTD.setAttribute("class", "txt_destacado7");
    elmTD.innerHTML = "<input name=\"chkSolicitud\" id=\"chkSolicitud\" type=\"checkbox\" value=\"" + intCantidad + "\" />";

    //inserto el codigo en la celda 2
    elmTD = elmTR.insertCell(1);
    elmTD.setAttribute("style", "padding-top:5px");
    elmTD.setAttribute("class", "txt_destacado7");
    elmTD.innerHTML = restaurante;
    //inserto el codigo en la celda 3
    elmTD = elmTR.insertCell(2);
    elmTD.setAttribute("style", "padding-top:5px");
    elmTD.setAttribute("class", "txt_destacado7");
    elmTD.innerHTML = menu;
    //inserto el codigo en la celda 4
    elmTD = elmTR.insertCell(3);
    elmTD.setAttribute("style", "padding-top:5px");
    elmTD.setAttribute("class", "txt_destacado7");
    elmTD.innerHTML = precio;
    //inserto el codigo en la celda 5
    elmTD = elmTR.insertCell(4);
    elmTD.setAttribute("style", "padding-top:5px");
    elmTD.setAttribute("class", "txt_destacado7");
    elmTD.innerHTML = fechaHora;
    //inserto el codigo en la celda 5
    elmTD = elmTR.insertCell(5);
    elmTD.setAttribute("style", "padding-top:5px");
    elmTD.setAttribute("class", "txt_destacado7");
    elmTD.innerHTML = Pax + " pax";
}
function eliminarSolicitudes() {
    var arrChecks = document.getElementsByName('chkSolicitud');
    var seleccionados = "";
    if (arrChecks.length) {
        for (i = 0; i < arrChecks.length; i++) {
            if (arrChecks[i].checked) {
                if (seleccionados != "") {
                    seleccionados += ",";
                }
                seleccionados += arrChecks[i].value;
            }
        }
    } else {
        seleccionados = arrChecks.value
    }
    limpiarSolicitudes();
    simple_ajax('/ajaxSolicitudes.aspx', 'GET', "accion=eliminar&sol=" + seleccionados);
}
function limpiarSolicitudes() {
    var elmTBODY = document.getElementById('tblListaSolicitudes');
    for (i = elmTBODY.rows.length - 1; i > -1; i--) {
        elmTBODY.deleteRow(i);
    }
}
function enviarSolicitudes() {
    window.location = "/solicitar1.aspx";
}
/*
function loadNiceToBook(strCiudad) {
    setTimeout("loadNiceToBookAjax('" + strCiudad + "');", 3000);
}*/
/*function loadNiceToBookAjax(strCiudad) {
    var div = "divNice2BookContent";

    if (window.ActiveXObject) {
        var req = new ActiveXObject("Microsoft.XMLHTTP");
    } else if (window.XMLHttpRequest) {
        var req = new XMLHttpRequest();
    }

    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            document.getElementById(div).innerHTML = '';
            var wrappingDiv = document.createElement('div');
            wrappingDiv.innerHTML = req.responseText;
            if (wrappingDiv.innerHTML != "") {
                document.getElementById(div).appendChild(wrappingDiv);
                document.getElementById('leftBlockNice2Book').style.display = '';
            }
        }
    }

    req.open('GET', '/ajaxNiceToBook.aspx?ciudad=' + strCiudad, true);
    req.send(null);
}*/

function reservaConPuntos() {
    showAlert(document.getElementById('hidTextoReservaConPuntos').value, 0, 0);
}
function mostrarDesplegableMenu(id_menu) {
    var div = document.getElementById('divDesplegable' + id_menu);
    if (div.style.display == 'none') {
        div.style.display = '';
    } else {
        div.style.display = 'none';
    }
}

var showingAdvancedSearch = false;
// Added Abril 13 2010
function mostrarBusquedaAvanzada() {

    if (showingAdvancedSearch) {

        jQuery('#divBusqAvanzada').slideUp();
        jQuery('#advancedHolder').html('>>');

        jQuery('#masBuscados').slideDown();
        
    } else {

    jQuery('#divBusqAvanzada').slideDown();
        jQuery('#masBuscados').slideUp();
        jQuery('#advancedHolder').html('<<');
    }

    showingAdvancedSearch = !showingAdvancedSearch;
}