/**
 * Klasse zum Anzeigen der Terminliste
 * 
 * @author Daniel Lembicz
 */

/**
 * Konstruktor
 */

function TTTerminList () {
    /* Terminzeilen-Element */
    this.elemRow = null;
    /* Erfolgreich geprüfte Termine nach der Vakanz */
    this.checkedTermineOk = [];
    // aktuelle Sortierung
    this.currentSort = 'preis';
    // alternative Angebote vorhanden
    this.alternative = false;
    this.terminListGroupName = '';
}

/**
 * Anzeigen der Liste
 */

TTTerminList.prototype.showList = function(reload, groupName) {
    var skipNode = null;
    this.alternative = false;
    
    /* Liste erst anzeigen wenn alle Daten vorhanden */
    if (pStrecke.objects.type != 'termine') {
        if (!reload) {
            reload = false;
        }
        setTimeout("pTermine.showList(" + reload + ")", 100);
        return;
    }
    
    if (pStrecke.stepHasChanged) {
        if (pStrecke.config.bestOfferModule) {
            pBom.emptyFilterCollected();
        }
    }
    
    if (typeof TTTerminListCustomer.init == 'function') {
        TTTerminListCustomer.init();
    } else {
        alert('Methode TTTerminListCustomer.init() nicht implementiert');
    }
    
    // Termine bearbeiten: Fehler-Termin einfügen
    if (pStrecke.config.onVacancyError.insertErrorItem == 1 && typeof pStrecke.lastCheckedItem.data != 'undefined' && typeof pStrecke.lastCheckedItem.data.vakanz != 'undefined' && pStrecke.lastCheckedItem.data.vakanz.status == 'ERROR') {
        this.insertErrorItem();
    }
    
    /* Bei Veranstaltervergleich oder Service-Vergleich nach Preis sortieren */
    if (pStrecke.objects.groupType == '1' || pStrecke.objects.groupType == '5') {
        pStrecke.terminObjects.sort(this.priceSort);
    }
    
    var elemListHeader = document.getElementById('idListHeader');
    var elemListFooter = document.getElementById('idListFooter');
    var elemList = document.getElementById('idListContent');
    var elemHeadline, elemNavi, elemFooter;
    this.elemRow = document.getElementById('idTerminRow');
    elemList.innerHTML = '';
    var elemHeader, elemFooter;
    
    // Listen-Header nur bauen wenn noch nicht vorhanden bzw. leer
    if (pStrecke.stepHasChanged || pStrecke.config.reloadListHeaders.offers || pStrecke.reqByDreamreader) {
        if (typeof TTTerminListCustomer.getListHeader == 'function') {
            elemListHeader.innerHTML = '';
            elemHeader = TTTerminListCustomer.getListHeader();
            elemListHeader.appendChild(elemHeader);
        }   
        
        if (typeof TTTerminListCustomer.writeCollectedItems == 'function') {
            TTTerminListCustomer.writeCollectedItems();
        }
    }
    
    // Leistungsvergleich
    if (pStrecke.objects.groupType == '5') {
        this.removeDuplicateEntries();
    }
    
    // einzelne Termine der Strecke hinzufügen
    if (pStrecke.objects.groupType == '5') {
        /* Vergleich von Leistungen (i.d.R. anderes Design) */
        TTTerminListCustomer.writeList();   
    } else if (pStrecke.config.terminListCalendar) {
        pTerminListCalendar.setData(pStrecke.terminObjects);
        pTerminListCalendarCustomer.show();        
    } else {
        // normales Zeilendesign
        var elemTmp = jQuery('#idListContent')[0];
        var item;
        
        if (pStrecke.config.bestOfferModule) {
            pBom.clearListObjects();
        } 
        
        if (pStrecke.config.groupByServicesAjaxTermin) {
            if (pStrecke.oSkip.curSite < 1) {
                pStrecke.oSkip.curSite = 1;
            }
            var incr = 0;
            var minPos = parseInt(pStrecke.oSkip.curSite - 1) * pStrecke.config.numToShow.offers;
            
            // erster Seitenaufruf
            if (typeof groupName == 'undefined' || groupName == '') {
                if (typeof pStrecke.terminObjectsGrouped[0] != 'undefined') {
                    groupName = pStrecke.terminObjectsGrouped[0].type;
                }
            }
            
            for (var i = 0; i < pStrecke.terminObjectsGrouped.length; i++) {
                if (groupName == pStrecke.terminObjectsGrouped[i].type) {
                    if (pStrecke.terminObjectsGrouped[i].data != null) {
                        pStrecke.oSkip.numResults = pStrecke.terminObjectsGrouped[i].data.length;
                        
                        for (var k = 0; k < pStrecke.terminObjectsGrouped[i].data.length; k++) {
                            if (k < minPos) {
                                continue;
                            }
                                                    
                            item = pStrecke.terminObjectsGrouped[i].data[k].getRow(incr);
                            
                            // Jede Terminzeile erhält die BuchungsId als Attribut
                            if (typeof jQuery(item).attr('bookingId') == 'undefined') {
                                jQuery(item).attr('bookingId', pStrecke.terminObjectsGrouped[i].data[k].data.bookingId);
                            }
                            
                            elemTmp.appendChild(item);
                            // Alternativangebot
                            if (!this.alternative && (pStrecke.terminObjectsGrouped[i].data[k].data.alternativTermin == '1' || pStrecke.terminObjectsGrouped[i].data[k].data.alternative == '1')) {
                                this.alternative = true;
                                if (typeof TTTerminListCustomer.callAlternative == 'function') {
                                    TTTerminListCustomer.callAlternative(item);
                                }
                            }  
                            
                            incr++; 
                            
                            if (incr == pStrecke.config.numToShow.offers) {
                                break;
                            }                           
                        }
                    }
                }
            }
        } else if (!pStrecke.config.hideOffers) {
            // normale Premium+
            for (var i = 0; i < pStrecke.terminObjects.length; i++) {
                if (pStrecke.terminObjects[i].data != null) {
                    // BestOfferModul aktiviert (Daten sammeln)
                    if (pStrecke.config.bestOfferModule) {
                        pBom.addListObject(pStrecke.terminObjects[i]);
                    } 
                    
                    item = pStrecke.terminObjects[i].getRow(i);
                    
                    // Jede Terminzeile erhält die BuchungsId als Attribut
                    if (typeof jQuery(item).attr('bookingId') == 'undefined') {
                        jQuery(item).attr('bookingId', pStrecke.terminObjects[i].data.bookingId);
                    }
                    
                    elemTmp.appendChild(item);
                    // Alternativangebot
                    if (!this.alternative && (pStrecke.terminObjects[i].data.alternativTermin == '1' || pStrecke.terminObjects[i].data.alternative == '1')) {
                        this.alternative = true;
                        if (typeof TTTerminListCustomer.callAlternative == 'function') {
                            TTTerminListCustomer.callAlternative(item);
                        }
                    }
                }
            }
        }
    }
    
    // Listen-Footer/Header nur bauen wenn noch nicht vorhanden bzw. leer
    if (pStrecke.stepHasChanged || pStrecke.config.reloadListFooters.offers) {
        if (typeof TTTerminListCustomer.getListFooter == 'function') {
            elemFooter = TTTerminListCustomer.getListFooter();
            
            // Listen-Footer nur bauen wenn noch nicht vorhanden bzw. leer
            if (elemListFooter && elemListFooter.innerHTML == '' && elemFooter) {
                elemListFooter.appendChild(elemFooter);
            }            
        }
    }    
    
    /* Keine Ergebnisse gefunden */     
    if (pStrecke.terminObjects && pStrecke.terminObjects.length < 1) {
        pStrecke.noResults();
    }
    
    if (typeof ttUnitTestNumItems != 'undefined') {
        ttUnitTestNumItems = pStrecke.terminObjects.length;
    }
    
    // Muss wieder gelöscht werden für Skipwechsel etc.
    pStrecke.lastCheckedItem = {};
    
    if (typeof TTTerminListCustomer.onload == 'function') {
        TTTerminListCustomer.onload();
    } else {
        alert('Methode TTTerminListCustomer.onload() nicht implementiert');
    }
    
    if (pStrecke.terminRegionData.regionName != undefined) {
        // Name des Reisezieles
        pStrecke.nameTravelTarget = pStrecke.terminRegionData.regionName;        
    }
    
    if (pStrecke.terminRegionData.zg != undefined) {
        // Name der Top-Region
        pStrecke.nameTopRegion = pStrecke.terminRegionData.zg;        
    }
    
    if (pStrecke.terminHotelData.hotelName != undefined) {
        // Name des letzten Hotels
        pStrecke.nameHotel = pStrecke.terminHotelData.hotelName;            
    }

    if (pStrecke.config.fullAjax) {
        addHistoryEntry('termine');
    }
    
    pStrecke.afterBuildingList();    
}

/**
 * GoogleMap entsprechend zoomen
 */

TTTerminList.prototype.zoomOnHotel = function() {
    var objHotel = pStrecke.objects.hotelData;
    
    if (typeof objHotel != 'undefined' && typeof objHotel.coords != 'undefined') {
        objHotel.coords.x = objJSON.coords.x;
        objHotel.coords.y = objJSON.coords.y;
        TTG.zoomOnHotel(objHotel);
        jQuery('#idMapName').html(objHotel.region);        
    } else {
        if (typeof TTG.noMapAvailable == 'function') {
            TTG.noMapAvailable();
        }
    }
}

/**
 * Formularfelder mit der Gruppenauswahl belegen
 * @param {int} num
 */

TTTerminList.prototype.setGroup  = function(num) {
    jQuery('#action').val('group');
    jQuery('#groupType').val(num);
}

/**
 * Zeigt die Liste gruppiert nach Veranstaltern
 */

TTTerminList.prototype.showListGrouped  = function(status) {
    pStrecke.objects.type = 'none';
    pTermine.setGroup(status);
    sendPostRequest(pathDevAbsolute + 'booking/ibe_ajax/inc/getTerminData.script.php?sortierung=preis&IFF=' + pStrecke.objects.iff + '&topReg=' + pStrecke.topReg, 'formSearch', 'idListContent', null, null, null, true); 
    pTermine.showList();
}

/**
 * Gibt das Termin-Objekt anhand der Buchungs-ID zurück
 */

TTTerminList.prototype.getTerminByBookingId = function(bookingId, getFullData, byCollectedItem) {
    if (byCollectedItem) {
        var aObj = this.checkedTermineOk;
    } else {
        var aObj = pStrecke.terminObjects;
    }
    
    for (var i = 0; i < aObj.length; i++) {
        if (aObj[i].data != null && aObj[i].data.bookingId == bookingId) {
            if (!getFullData) {
                return aObj[i].data;
            } else {
                return aObj[i];
            }
        }
    }
}

/**
 * Callback der Vakanzprüfung
 */

TTTerminList.prototype.callbackVakanz = function() {
    var data = objJSON;
    var obj;
    var elemExists = false;
    var objToInsert = {};
    
    //--- Debug-Popup fuer agent=IBErequestByIP ---------------------
    if (getParams.agent && getParams.agent == 'IBErequestByIP') {
        var debugWin = window.open(pathDevAbsolute + 'booking/ttVakDebugPopup.php?clusterIpByBID=' + data.debugRequest.clusterIp + '&port=' + data.debugRequest.port + '&str_exe=' + data.debugRequest.strExe + '', 'ttVakDebugPopup', 'width=500,height=700,scrollbars=yes');
    }
    
    // Prüfung war ein weiterer Flug ...
    if (data.moreFlights == '1') {
        // Übergeordneter Termin muss kopiert werden (mit bookingId des weiteren Fluges),
        // da die weiteren Flüge nicht als Objekte vorliegen
        obj = this.getTerminByBookingId(data.parentBookingId, true);
        var newObj = {};
        newObj = deepCopy(obj);
        // Booking-ID des weiteren Fluges
        newObj.data.bookingId = data.bookingId;
        objToInsert = newObj;
    } else {
        // Da bei bestimmten Terminseite die Angebotsobjekte nicht immer in den globalen
        // Terminobjekten zu finden sind, hat man die Möglichkeit das Objekt selbst zu suchen 
        if (typeof TTTerminListCustomer.getObjectAfterVacancy == 'function') {
            objToInsert = TTTerminListCustomer.getObjectAfterVacancy(data.bookingId);
        } else {
            objToInsert = this.getTerminByBookingId(data.bookingId, true);
        }
    }
    
    if (typeof objToInsert != 'undefined') {
        objToInsert.data.vakanz = data;
        // Vakanzprüfung erfolgreich
        if (data.status == 'SUCCESS') {
            /* Geprüfte Termine sammeln */
            if (pStrecke.config.collectItems.maxItems > 0) {
                for (var i = 0; i < pStrecke.config.collectItems.maxItems; i++) {
                    if (typeof this.checkedTermineOk[i] != 'undefined' && this.checkedTermineOk[i].data.bookingId == data.bookingId) {
                        elemExists = true;
                    }
                }
                
                if (!elemExists) {
                    // Neuen Termin am Anfang einfügen
                    this.checkedTermineOk.unshift(objToInsert);
                    
                    // letztes Element entfernen, wenn max. Sammelanzahl überschritten wurde
                    if (this.checkedTermineOk.length > pStrecke.config.collectItems.maxItems) {
                        var item = this.checkedTermineOk.pop();
                        // Geprüften Termin wieder auf ungeprüft setzen
                        if (typeof TTTerminListCustomer.resetCheckedListItem == 'function') {
                            TTTerminListCustomer.resetCheckedListItem(item.data);
                        }
                    }
                }
            }       
        }
        
        TTTerminListCustomer.callbackVakanz(objToInsert.data);
        
        // Sollte ein Termin bereits gesammelt sein, und im kundenspezifischen 
        // Callback nachträglich auf "fehlgeschlagen" gesetzt worden sein, 
        // so muss er nachträglich wieder entfernt werden        
        if (objToInsert.data.vakanz.status == 'ERROR') {
            for (var j = 0; j < this.checkedTermineOk.length; j++) {
                if (this.checkedTermineOk[j].data.bookingId == objToInsert.data.bookingId) {
                    this.checkedTermineOk.splice(j, 1);
                }
            }            
        } else {
            if (typeof TTTerminListCustomer.writeCollectedItems == 'function') {
                TTTerminListCustomer.writeCollectedItems();
            }
        }
        
        // Im Fehlerfall soll Liste neu geladen werden
        if (pStrecke.config.onVacancyError.reloadList == 1 && objToInsert.data.vakanz.status == 'ERROR') {
            sendPostRequest(pathDevAbsolute + '/booking/ibe_ajax/inc/getTerminData.script.php?sortierung=' + pTermine.currentSort, pStrecke.config.idForm, null, 'pTermine.showList(true)');
        }        
    }
    
    jQuery('#vacancyObjectData').val('');
}

/**
 * Vakanzprüfung für die weiteren Flüge
 * 
 * @param {string} bookingId
 * @param {string} bookingIdMoreFlights
 * @param {string} hotelAtts
 */

TTTerminList.prototype.vakanzMoreFlights = function(bookingId, bookingIdMoreFlights, hotelAtts, price) {
    var objMoreFlights = {
        'bookingId': bookingIdMoreFlights, 
        'hotelAttributes': hotelAtts,
        'price': price};
    this.vakanz(bookingId, objMoreFlights);
}

/**
 * Vakanzprüfung durchführen
 * 
 * @param {string} bookingId
 * @param {object} objMoreFlights
 */

TTTerminList.prototype.vakanz = function(bookingId, objMoreFlights, obj) {
    var params = [];
    var obj;
    
    if (typeof obj == 'undefined') {
        obj = this.getTerminByBookingId(bookingId);
    }
    
    var bookingId   = obj.bookingId;
    var attr;
    var price       = obj.price;
    var moreFlights = 0;
    
    if (typeof obj.hotelattribute != 'undefined') {
        attr = obj.hotelattribute.raw;
    }
    
    // Vakanzprüfung erfolgt durch einen "weiteren Flug"
    if (objMoreFlights != null && typeof objMoreFlights == 'object') {
        moreFlights = 1;
        params.push('parentBookingId=' + bookingId);
        bookingId = objMoreFlights.bookingId;
        attr      = objMoreFlights.hotelAttributes;
        price     = objMoreFlights.price;
    }
    
    // Parameter für die Vakanzprüfung
    params.push('bookingId='     + bookingId);
    params.push('kid='           + pStrecke.objects.kid);
    params.push('attr='          + attr);
    params.push('port='          + pStrecke.objects.port);
    params.push('price='         + price);
    params.push('start='         + obj.airport.kuerzel);
    params.push('ziel='          + obj.zielflughafen);
    params.push('va='            + obj.tourOperator);
    params.push('moreFlights='   + moreFlights);
    params.push('flightTimes='   + pStrecke.config.flightTimes);
    params.push('maxItems='      + pStrecke.config.collectItems.maxItems);
    params.push('ibeIdentifier=' + ibeIdentifier);
    params.push('vacancyUseOnlineIPs=' + pStrecke.config.vacancyUseOnlineIPs);
    
    
    //if (typeof jQuery('#IFF').val() == 'undefined') {
        params.push('IFF=' + pStrecke.terminHotelData.iff);
    //}
    
    //crs bei Fewo????
    
    //if (typeof jQuery('#personen').val() == 'undefined') {
        params.push('personen=' + obj.hotelattribute.personenUnparsed);
    //}
    
    //if (typeof jQuery('#zgk').val() == 'undefined') {
        params.push('zgk=' + pStrecke.terminHotelData.zgk);
    //}
    
    // Objektdaten des zu prüfenden Termines an die Vakanzprüfung übermitteln
    // macht aber nur Sinn wenn auch Termine gesammelt werden
    if (pStrecke.config.collectItems.maxItems > 0) {
        if (document.getElementById('vacancyObjectData') == null) {
            var newInput  = document.createElement('input');
            newInput.id   = 'vacancyObjectData';
            newInput.type = 'hidden';
            newInput.name = 'vacancyObjectData';
            
            if (typeof jQuery('#' + pStrecke.config.idForm)[0] == 'undefined') {
                jQuery(newInput).appendTo(jQuery("form[name='" + pStrecke.config.idForm + "']"));
            } else {
                jQuery(newInput).appendTo(jQuery('#' + pStrecke.config.idForm));
            }
        }
        
        jQuery('#vacancyObjectData').val(json_encode({data:obj}));        
    }
    
    // Aktuell zu prüfendes Angebot wird als letztes "geprüftes" markiert
    pStrecke.lastCheckedItem = new TTTerminElement(obj);
    
    pStrecke.reqGetVacancy = sendPostRequest(
        pathDevAbsolute + 'booking/ibe_ajax/inc/checkVakanz.script.php?' + params.join('&'), 
        pStrecke.config.idForm, 
        obj, 
        'pTermine.callbackVakanz()', 
        null, 
        true);
        
    if (pTracking != null && typeof(pTracking.track) != 'undefined') {
        pTracking.track('vakanz');
    }        
}

/**
 * Zur Buchen-Seite gehen
 */

TTTerminList.prototype.goToBooking  = function(bookingId, oCustomer, byCollectedItem) {
    var obj;
    
    // Es besteht die Möglichkeit das komplette Datenobjekt zu übergeben
    if (typeof oCustomer != 'undefined' && oCustomer != null && oCustomer != false) {
        obj = oCustomer;
    } else {
        obj = this.getTerminByBookingId(bookingId, false, byCollectedItem);
    }
    
    var elemForm = document.bengine;
    var hotelData = pStrecke.terminHotelData;
    var bookingVakanz = obj.vakanz.vakanz.split('###')[1];
    
    elemForm.detail.value = 'buchung';
    jQuery('#vakanz').val(bookingVakanz);
    jQuery('#b_hotelName').val(hotelData.hotelName);
    jQuery('#b_city').val(hotelData.city);
    jQuery('#b_region').val(hotelData.region);
    jQuery('#b_country').val(hotelData.country);
    jQuery('#b_category').val(hotelData.stars);
    jQuery('#b_agent').val(jQuery('#agent').val());
    jQuery('#str_termine').val(hotelData.hotelName + ';' + hotelData.city + ';' + hotelData.iff + ';' + hotelData.region + ';' + hotelData.country);
    jQuery('#startposition_termine').val(pStrecke.objects.startposition);
    elemForm.method = 'POST';
    elemForm.action = pStrecke.config.bookingUrl;
    
    if (typeof TTMainCustomer.beforeBookingSubmit == 'function') {
        TTMainCustomer.beforeBookingSubmit(obj);
    }

    // wenn von Merkzettel kommt ...
    if (typeof pStrecke.config.comeFromMerkzettel != 'undefined' && pStrecke.config.comeFromMerkzettel == true) {
        jQuery('#shotel').val('');
        jQuery('#scode').val('');
        jQuery('#dauer').val('');
        jQuery('#marke').val('');
        jQuery('#abflughafen').val('');
    }
    
    elemForm.submit();      
}

/**
 * Verpflegungen werden von der Engine doppelt ausgegeben, also entfernen ...
 */

TTTerminList.prototype.removeDuplicateEntries  = function() {
    var bookingIds2 = [];
    var bookingIds3 = [];
    
    for (var i = 0; i < pStrecke.terminObjects.length; i++) {
        if (in_array(pStrecke.terminObjects[i].data.bookingId, bookingIds2) && pStrecke.terminObjects[i].data.specialGroupType == '2') {
            pStrecke.terminObjects[i].data = null;
        } else if (in_array(pStrecke.terminObjects[i].data.bookingId, bookingIds3) && pStrecke.terminObjects[i].data.specialGroupType == '3') {
            pStrecke.terminObjects[i].data = null;
        } else {
            if (pStrecke.terminObjects[i].data.specialGroupType == '2') {
                bookingIds2.push(pStrecke.terminObjects[i].data.bookingId);
            } else {
                bookingIds3.push(pStrecke.terminObjects[i].data.bookingId);
            }
        }
    }    
}

/**
 * Objekte nach einem Preis sortieren
 * 
 * @param {Object} a
 * @param {Object} b
 */

TTTerminList.prototype.priceSort = function(a, b) {
    if (a.data && b.data) {
        return a.data.price - b.data.price;
    }
}

/**
 * Nach Vakanzprüfung wird der fehlgeschlagene Termin in die Liste eingefügt.
 * Das letzte Element wird dabei entfernt, genauso wie der doppelte Termin, falls
 * er erneut vond er Engine zurückgeliefert werden sollte.
 */

TTTerminList.prototype.insertErrorItem = function() {
    var duplicateItem = false;
    
    // Sollte der als Fehler geprüfte Termin erneut zurückgeliefert werden, 
    // so muss dieser aus der Liste entfernt werden
    for (var i = 0; i < pStrecke.terminObjects.length; i++) {
        if (pStrecke.terminObjects[i].data.bookingId == pStrecke.lastCheckedItem.data.bookingId) {
            duplicateItem = true;
            pStrecke.terminObjects.splice(pStrecke.lastCheckedItem.data.counter, 1, pStrecke.lastCheckedItem);
        }
    }
    
    // kein doppelter Termin gefunden
    if (!duplicateItem) {
        pStrecke.terminObjects.splice(pStrecke.lastCheckedItem.data.counter, 0, pStrecke.lastCheckedItem);
        pStrecke.terminObjects.pop();
    }
}

/**
 * Terminliste neu sortieren
 * 
 * @param {Object} type
 */

TTTerminList.prototype.sortTerminList = function(type) {
    this.currentSort = type;
    sendPostRequest(pathDevAbsolute + '/booking/ibe_ajax/inc/getTerminData.script.php?sortierung=' + type, pStrecke.config.idForm, null, 'pTermine.showList(true)');
    
    if (typeof TTTerminListCustomer.sort == 'function') {
        TTTerminListCustomer.sort(type);
    }
}

/**
 * Geprüftes Element aus der Sammlung löschen
 * 
 * @param {string} bookingId
 */

TTTerminList.prototype.deleteCheckedItem = function(bookingId) {
    for (var j = 0; j < this.checkedTermineOk.length; j++) {
        if (this.checkedTermineOk[j].data.bookingId == bookingId) {
            this.checkedTermineOk.splice(j, 1);
        }
    }
}

/**
 * Initialisiert das BestOfferModul und übergibt die von der MiddleWare 
 * zurückgegebene Daten
 */

TTTerminList.prototype.responseBom = function() {
    var data = objJSON;
    pBom.init(data);

    // Objekte zusammenbauen
    pStrecke.buildObjects();     
    this.showList();
}

TTTerminList.prototype.clearAllOtherVacancies = function(bookingId) {
    var rows = jQuery('#idListContent').children();
    
    
    for (var i = 0; i < rows.length; i++) {

        if (jQuery(rows[i]).attr('bookingId') != bookingId && jQuery(rows[i]).attr('bookingId') != '' && typeof jQuery(rows[i]).attr('bookingId') != 'undefined') {
            var data   = this.getTerminByBookingId(jQuery(rows[i]).attr('bookingId'));
            var rowObj = new TTTerminElement(data);
            var elem   = rowObj.getRow(i);
            jQuery(elem).attr('bookingId', data.bookingId);
            jQuery(rows[i]).replaceWith(elem);
        }
    }    
}

/**
 * Zeigt eine gruppierte Liste an (ajaxbasierte Terminseite als Veranstalterportal)
 * @param {Object} obj
 */
TTTerminList.prototype.showListGroupedOnAjaxTerminPage = function(board, room, summation) {
    pStrecke.stepHasChanged = false;
    pStrecke.oSkip.curSite = 1;
    
    if (summation == 'true') {
        this.terminListGroupName = 'summation';
        this.showList(false, 'summation');        
    } else {
        this.terminListGroupName = board + '||' + room;
        this.showList(false, board + '||' + room);        
    }
}
