﻿// ============================================================================================================
// ------------------------------------------------------------------------------------------------------------
// El manejador de inicio de JQUERY inicializa el widget de puntos de venta.
// ------------------------------------------------------------------------------------------------------------
$(function () {
    //Manejar pestañas de mapa/oficionas/coches 
    indexSalepointsHandler.init();
});
// ------------------------------------------------------------------------------------------------------------
// El manejador 'indexSalepointsHandler' gestiona la visualización del widget de puntos de venta listado/mapa/vehiculos.
// ------------------------------------------------------------------------------------------------------------
var indexSalepointsHandler = {
    changeBlind: function () {
        //$('#rentalServicePoints #map_portada, #rentalServicePoints #navServicePoints, #rentalServicePoints #navVehiclePoints' ).toggle();
        $('#rentalServicePoints .header-box-points a').parent().toggleClass('selected');
    },
    updateVisibleArea: function (target) {
        $('#navServicePoints li').removeClass('selected');
        $(target).parent().addClass('selected');

        $('#navServicePoints li:not(.selected) ul').hide();
        //$('#navServicePoints li.selected ul').animate({ height: '115px' });
        $('#navServicePoints li.selected ul').show()
    },
    init: function () {
        $('#rentalServicePoints .header-box-points a').click(function (e) { indexSalepointsHandler.changeBlind(); e.preventDefault(); });
        $('#navServicePoints li:not(.selected) ul').hide();
        $('#navServicePoints h5').hover(function () { $(this).parent().toggleClass('hover'); }, function () { $(this).parent().toggleClass('hover'); }).click(function (e) { indexSalepointsHandler.updateVisibleArea(this); });
        $('#navVehiclePoints li:not(.selected) ul').hide();
        $('#navVehiclePoints h5').hover(function () { $(this).parent().toggleClass('hover'); }, function () { $(this).parent().toggleClass('hover'); }).click(function (e) { indexSalepointsHandler.updateVisibleArea(this); });
    }
}
$(document).ready(function () {
    $('#btnBookings').click(function () {
        $.blockUI({
            message: $('img#displayBox'),
            css: {
                top: ($(window).height() - 261) / 2 + 'px',
                left: ($(window).width() - 261) / 2 + 'px',
                width: '261px'
            }
        });
    });
    $('#rentalServicePoints .header-box-points #mapPoints a').click(function () {
        $('#rentalServicePoints #map_portada').show();
        $('#rentalServicePoints #navServicePoints').hide();
        $('#rentalServicePoints #navVehiclePoints').hide();
        $('#rentalServicePoints .header-box-points #mapPoints').removeClass('selected')
        $('#rentalServicePoints .header-box-points #listPoints').removeClass('selected')
        $('#rentalServicePoints .header-box-points #vehiclesPoints').removeClass('selected')
        $('#rentalServicePoints .header-box-points #mapPoints').addClass('selected')
    });
    $('#rentalServicePoints .header-box-points #listPoints a').click(function () {
        $('#rentalServicePoints #map_portada').hide();
        $('#rentalServicePoints #navServicePoints').show();
        $('#rentalServicePoints #navVehiclePoints').hide();
        $('#rentalServicePoints .header-box-points #mapPoints').removeClass('selected')
        $('#rentalServicePoints .header-box-points #listPoints').removeClass('selected')
        $('#rentalServicePoints .header-box-points #vehiclesPoints').removeClass('selected')
        $('#rentalServicePoints .header-box-points #listPoints').addClass('selected')
    });
    $('#rentalServicePoints .header-box-points #vehiclesPoints a').click(function () {
        $('#rentalServicePoints #map_portada').hide();
        $('#rentalServicePoints #navServicePoints').hide();
        $('#rentalServicePoints #navVehiclePoints').show();
        $('#rentalServicePoints .header-box-points #mapPoints').removeClass('selected')
        $('#rentalServicePoints .header-box-points #listPoints').removeClass('selected')
        $('#rentalServicePoints .header-box-points #vehiclesPoints').removeClass('selected')
        $('#rentalServicePoints .header-box-points #vehiclesPoints').addClass('selected')
    });
});
