// Класс управления формой резервирования номеров

function reserveForm( ctrl_action ) {
    this.action = ctrl_action;
    this.wait_code = '<div align="center" style="font-size:8pt;">Обработка запроса:<br><img src="/wings/images/ajax-loader.gif" style="margin:auto;"></div>';
    
    // -------------------------------------------------------------------
    // load() - загрузка формы бронирования в объект in_element через ajax
    // def_item - выбранный по умолчанию элемент "Гостиница"
    // -------------------------------------------------------------------
    this.load = function( in_element, city_id, hotel_id, room_id ) {
        if (this.action != '' && in_element != '') {
            if (hotel_id == null) hotel_id = 0;
            if (city_id == null) city_id = 0;
            if (room_id == null) room_id = 0;

            $(in_element).html(this.wait_code);
            $.get(  this.action, 
                    { 'ctrl': 'hotel', 'action': 'reserve_form', 'city_id': city_id, 'hotel_id': hotel_id, 'room_id': room_id }, 
                    function(data) {
                        $(in_element).html(data);
                    }
            );
        }
    }

    this.load_rooms = function( in_element, hotel_id ) {
        if (this.action != '' && in_element != '') {
            if (hotel_id == null) {
                hotel_id = 0;
            }

            $(in_element).html('<img src="/wings/images/ajax-loader-line.gif">');
            $.get( this.action, { 'ctrl': 'room', 'action': 'ajax_select', 'hotel_id': hotel_id }, function(data) {
                $(in_element).html(data);
            });
        }
    }

}

