function getSummaryData(update) {
    var XMLHttpRequestObject = getXMLHttpRequestObject();
    if (XMLHttpRequestObject) {
        var url = encodeURI(contextRoot + 's-mary?a=gS&sId=' + sessionId + '&sync=' + Math.random());

        XMLHttpRequestObject.open("GET", url);
        XMLHttpRequestObject.onreadystatechange = function() {
            if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
                hideCustomTooltip('summary_btn_preloader');
                if (XMLHttpRequestObject.responseText == moduleClosedErrCode) {
                    moduleCloseOperation();
                } else if (XMLHttpRequestObject.responseText == sessionTimeOut) {
                    sessionTimeOutOperation();
                } else if (XMLHttpRequestObject.responseText == systemError) {
                    alert('Възникна грешка в системата!');
                } else if (XMLHttpRequestObject.responseText == invalidParameters) {
                    //	                alert('Некоректни параметри!');
                    invalidParametersOperation();
                } else if (XMLHttpRequestObject.responseText == emptyResult) {
                    alert('Кошницата ви е празна!');
                } else if (XMLHttpRequestObject.responseText == seatAndTicketNotMatch) {
                    alert('Открито е несъответствие между билетите и асоциираните към тях места!');
                } else if (XMLHttpRequestObject.responseText == communicationError) {
                    alert('Възникна комуникационна грешка!');
                } else if (XMLHttpRequestObject.responseText == '-8') {
                    alert('Некоректни комуникационни параметри!');
                } else {
                    var response = null;
                    if (_ie) XMLHttpRequestObject.responseXML.loadXML(XMLHttpRequestObject.responseText);
                    response = XMLHttpRequestObject.responseXML.documentElement;
                    if (response != null) {
                        var summaryContent = new StringBuffer();
                        summaryContent.append(summaryTop());
                        var i = 0;
                        var j = 0;
                        var index = 0;
                        var total = 0;
                        var _one_Way = true;
                        var tmpStartPointName;
                        var tmpEndPointName;
                        var tmpDepartureDate;
                        var tmpDepartureHour;
                        var tmpReturnDate;
                        var tmpReturnHour;
                        var tickets;
                        var sum;
                        while (i >= 0) {
                            _one_Way = true;
                            var route = response.childNodes[i];
                            if (route != null) {
                                if ("false" == route.childNodes[0].firstChild.data) {
                                    _one_Way = false;
                                }

                                tickets = route.childNodes[7];
                                sum = route.childNodes[8];

                                tmpStartPointName = (route.childNodes[1] != undefined && route.childNodes[1].firstChild != undefined) ? route.childNodes[1].firstChild.data : "N/A";
                                tmpEndPointName = (route.childNodes[2] != undefined && route.childNodes[2].firstChild != undefined) ? route.childNodes[2].firstChild.data : "N/A";
                                tmpDepartureDate = (route.childNodes[3] != undefined && route.childNodes[3].firstChild != undefined) ? route.childNodes[3].firstChild.data : "N/A";
                                tmpDepartureHour = (route.childNodes[4] != undefined && route.childNodes[4].firstChild != undefined) ? route.childNodes[4].firstChild.data : "N/A";
                                tmpReturnDate = (route.childNodes[5] != undefined && route.childNodes[5].firstChild != undefined) ? route.childNodes[5].firstChild.data : "N/A";
                                tmpReturnHour = (route.childNodes[6] != undefined && route.childNodes[6].firstChild != undefined) ? route.childNodes[6].firstChild.data : "N/A";

                                summaryContent.append(summaryRoute(_one_Way, tmpStartPointName, tmpEndPointName, tmpDepartureDate, tmpDepartureHour, tmpReturnDate, tmpReturnHour));
                                if (tickets != null) {
                                    j = 0;
                                    summaryContent.append(summaryTicketsLabels(new Array('Билет(и):', 'Вид на билета', 'Име на пътник', 'Място отиване', 'Място връщане', 'Цена')));
                                    while (j >= 0) {
                                        var ticket = (tickets.childNodes[j] != undefined) ? tickets.childNodes[j] : null;
                                        if (ticket != null) {
                                            var _oneWay_ = true;
                                            if ("false" == ticket.childNodes[0].firstChild.data) {
                                                _oneWay_ = false;
                                            }
                                            index++;
                                            var tmpTicketName = (ticket.childNodes[1] != undefined && ticket.childNodes[1].firstChild != undefined) ? ticket.childNodes[1].firstChild.data : "";
                                            var tmpPassangerName = (ticket.childNodes[2] != undefined && ticket.childNodes[2].firstChild != undefined) ? ticket.childNodes[2].firstChild.data : "";
                                            var tmpDepartureSeats = (ticket.childNodes[3] != undefined && ticket.childNodes[3].firstChild != undefined) ? ticket.childNodes[3].firstChild.data : "";
                                            var tmpReturnSeats = (ticket.childNodes[4] != undefined && ticket.childNodes[4].firstChild != undefined) ? ticket.childNodes[4].firstChild.data : "";
                                            var tmpTicketPrice = (ticket.childNodes[5] != undefined && ticket.childNodes[5].firstChild != undefined) ? ticket.childNodes[5].firstChild.data : "";
                                            var tmpTicketTypeId = (ticket.childNodes[6] != undefined && ticket.childNodes[6].firstChild != undefined) ? ticket.childNodes[6].firstChild.data : null;
                                            var tmpTravelListId = (ticket.childNodes[7] != undefined && ticket.childNodes[7].firstChild != undefined) ? ticket.childNodes[7].firstChild.data : null;
                                            var tmpReturnTravelListId = (ticket.childNodes[8] != undefined && ticket.childNodes[8].firstChild != undefined) ? ticket.childNodes[8].firstChild.data : null;
                                            var tmpStartPointId = (ticket.childNodes[9] != undefined && ticket.childNodes[9].firstChild != undefined) ? ticket.childNodes[9].firstChild.data : null;
                                            var tmpEndPointId = (ticket.childNodes[10] != undefined && ticket.childNodes[10].firstChild != undefined) ? ticket.childNodes[10].firstChild.data : null;

                                            summaryContent.append(summaryTicket(new Array(_oneWay_, '&nbsp;', tmpTicketName, tmpPassangerName, (('null' == tmpDepartureSeats) ? null : + tmpDepartureSeats), ((!_oneWay_) ? (('null' == tmpReturnSeats) ? null : tmpReturnSeats) : null), tmpTicketPrice + '&nbsp;лв.', '[премахни]', tmpTicketTypeId, tmpTravelListId, tmpReturnTravelListId, tmpStartPointId, tmpEndPointId), index));

                                            total += parseFloat(tmpTicketPrice);
                                            numberOfSummarizedTicket = index;
                                            j++;
                                        } else {
                                            j = -1;
                                        }
                                    }
                                }
                                i++;
                            } else {
                                i = -1;
                            }
                        }
                        summaryContent.append(summaryTotal(total.toFixed(2)));
                        summaryContent.append(summaryBottom());
                        document.getElementById('summaryContent').innerHTML = summaryContent.toString();
                        runFlashCountdownTimer('flashTimerMovie', '0,0');
                        hideTicketsAndVehiclesTooltip();
                        show('summaryInclude');
                        //							if (document.getElementById('summaryInclude') != undefined) {
                        //								document.getElementById('summaryInclude').style.visibility = 'visible';
                        //							}

                        getSummaryStateTimerState();
                        summaryIncludeTooltipShown = true;
                        blockFilters();
                        //managefilterAccordingSelectedTicketType();
                    }
                }
                killXML(XMLHttpRequestObject);
            } else if (XMLHttpRequestObject.readyState != 0) {
                if (!update) {
                    showCustomTooltip('summary_btn_preloader');
                }
            } else {
                alert('There was a problem retrieving the XML data!');
            }
        };
        XMLHttpRequestObject.send(null);
    }
}
;
function getBucket() {
    var XMLHttpRequestObject = getXMLHttpRequestObject();
    if (XMLHttpRequestObject) {
        var _error = '';
        var url = encodeURI(contextRoot + 's-mary?a=gB&sId=' + sessionId + '&sync=' + Math.random());

        XMLHttpRequestObject.open("GET", url);
        XMLHttpRequestObject.onreadystatechange = function() {
            if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
                if (XMLHttpRequestObject.responseText == moduleClosedErrCode) {
                    moduleCloseOperation();
                } else if (XMLHttpRequestObject.responseText == sessionTimeOut) {
                    sessionTimeOutOperation();
                } else if (XMLHttpRequestObject.responseText == invalidParameters) {
                    invalidParametersOperation();
                    //	 				_error = 'Некоректни параметри!';
                } else if (XMLHttpRequestObject.responseText == emptyResult) {
                    _error = 'Кошницата ви е празна!';
                    if (summaryIncludeTooltipShown) {
                        cancelPayment();
                    }
                    setDisabledAlphaNotAllowedCursor(document.getElementById(bucketClearAllButton));
                } else if (XMLHttpRequestObject.responseText == seatAndTicketNotMatch) {
                    _error = 'Открито е несъответствие между билетите и асоциираните към тях места!';
                } else {
                    var response = null;
                    if (_ie) XMLHttpRequestObject.responseXML.loadXML(XMLHttpRequestObject.responseText);
                    response = XMLHttpRequestObject.responseXML.documentElement;
                    if (response != null) {
                        var bucketContent = new StringBuffer();

                        var i = 0;
                        var total = 0;
                        var _one_Way = true;
                        var tmpStartPointName;
                        var tmpEndPointName;
                        var tmpDepartureDate;
                        var tmpDepartureHour;
                        var tmpReturnDate;
                        var tmpReturnHour;
                        var j = 0;
                        var route;
                        var tickets;
                        var totalPriceTag;
                        var ticket;
                        var _oneWay_ = true;

                        var tmpTicketName;
                        var tmpPassangerName;
                        var tmpDepartureSeats;
                        var tmpReturnSeats;
                        var tmpTicketPrice;
                        var tmpTicketTypeId;
                        var tmpTravelListId;
                        var tmpReturnTravelListId;
                        var tmpStartPointId;
                        var tmpEndPointId;

                        bucketContent.append(paymentDetailsTop());
                        bucketContent.append(bucketLine());

                        while (i >= 0) {
                            _one_Way = true;
                            route = response.childNodes[i];
                            if (route != null) {
                                if ("false" == route.childNodes[0].firstChild.data) {
                                    _one_Way = false;
                                }
                                tickets = route.childNodes[7];
                                totalPriceTag = route.childNodes[8];

                                tmpStartPointName = (route.childNodes[1] != undefined && route.childNodes[1].firstChild != undefined) ? route.childNodes[1].firstChild.data : "N/A";
                                tmpEndPointName = (route.childNodes[2] != undefined && route.childNodes[2].firstChild != undefined) ? route.childNodes[2].firstChild.data : "N/A";
                                tmpDepartureDate = (route.childNodes[3] != undefined && route.childNodes[3].firstChild != undefined) ? route.childNodes[3].firstChild.data : "N/A";
                                tmpDepartureHour = (route.childNodes[4] != undefined && route.childNodes[4].firstChild != undefined) ? route.childNodes[4].firstChild.data : "N/A";
                                tmpReturnDate = (route.childNodes[5] != undefined && route.childNodes[5].firstChild != undefined) ? route.childNodes[5].firstChild.data : "N/A";
                                tmpReturnHour = (route.childNodes[6] != undefined && route.childNodes[6].firstChild != undefined) ? route.childNodes[6].firstChild.data : "N/A";

                                bucketContent.append(bucketRecordTopColored(new Array('Маршрут:', tmpStartPointName + '&nbsp;-&nbsp;' + tmpEndPointName + ((!_one_Way) ? '&nbsp;-&nbsp;' + tmpStartPointName : ''))));
                                bucketContent.append(bucketLine());
                                bucketContent.append(bucketRecordTop(new Array('Дати:', tmpDepartureDate + '&nbsp;|&nbsp;' + tmpDepartureHour + '&nbsp;ч.')));
                                bucketContent.append(bucketLine());
                                if (!_one_Way) {
                                    bucketContent.append(bucketRecordTop(new Array('&nbsp;', tmpReturnDate + '&nbsp;|&nbsp;' + tmpReturnHour + '&nbsp;ч.')));
                                    bucketContent.append(bucketLine());
                                }

                                if (tickets != null) {
                                    bucketContent.append(bucketRecordTicketsLabels(new Array('Билет(и):', 'Вид на билета', 'Име на пътник', 'Място отиване', 'Място връщане', 'Цена')));
                                    bucketContent.append(bucketLine());
                                    j = 0;
                                    while (j >= 0) {
                                        ticket = (tickets.childNodes[j] != undefined) ? tickets.childNodes[j] : null;
                                        if (ticket != null) {
                                            _oneWay_ = true;
                                            if ("false" == ticket.childNodes[0].firstChild.data) {
                                                _oneWay_ = false;
                                            }

                                            tmpTicketName = (ticket.childNodes[1] != undefined && ticket.childNodes[1].firstChild != undefined) ? ticket.childNodes[1].firstChild.data : "";
                                            tmpPassangerName = (ticket.childNodes[2] != undefined && ticket.childNodes[2].firstChild != undefined) ? ticket.childNodes[2].firstChild.data : "-";
                                            tmpDepartureSeats = (ticket.childNodes[3] != undefined && ticket.childNodes[3].firstChild != undefined) ? ticket.childNodes[3].firstChild.data : "";
                                            tmpReturnSeats = (ticket.childNodes[4] != undefined && ticket.childNodes[4].firstChild != undefined) ? ticket.childNodes[4].firstChild.data : "";
                                            tmpTicketPrice = (ticket.childNodes[5] != undefined && ticket.childNodes[5].firstChild != undefined) ? ticket.childNodes[5].firstChild.data : "";
                                            tmpTicketTypeId = (ticket.childNodes[6] != undefined && ticket.childNodes[6].firstChild != undefined) ? ticket.childNodes[6].firstChild.data : null;
                                            tmpTravelListId = (ticket.childNodes[7] != undefined && ticket.childNodes[7].firstChild != undefined) ? ticket.childNodes[7].firstChild.data : null;
                                            tmpReturnTravelListId = (ticket.childNodes[8] != undefined && ticket.childNodes[8].firstChild != undefined) ? ticket.childNodes[8].firstChild.data : null;
                                            tmpStartPointId = (ticket.childNodes[9] != undefined && ticket.childNodes[9].firstChild != undefined) ? ticket.childNodes[9].firstChild.data : null;
                                            tmpEndPointId = (ticket.childNodes[10] != undefined && ticket.childNodes[10].firstChild != undefined) ? ticket.childNodes[10].firstChild.data : null;

                                            bucketContent.append(bucketRecordTickets(new Array(_oneWay_, '&nbsp;', tmpTicketName, tmpPassangerName, (('null' == tmpDepartureSeats) ? null : + tmpDepartureSeats), ((!_oneWay_) ? (('null' == tmpReturnSeats) ? null : tmpReturnSeats) : null), tmpTicketPrice + '&nbsp;лв.', '[премахни]', tmpTicketTypeId, tmpTravelListId, tmpReturnTravelListId, tmpStartPointId, tmpEndPointId)));
                                            bucketContent.append(bucketLine());
                                            j++;
                                        } else {
                                            j = -1;
                                        }
                                    }
                                }

                                i++;
                            } else {
                                i = -1;
                            }
                        }
                        tmpTotalPrice = (totalPriceTag != undefined && totalPriceTag.firstChild != undefined) ? totalPriceTag.firstChild.data : "";
                        if (!allSpaces(tmpTotalPrice)) {
                            bucketContent.append(bucketRecordTotalPrice(tmpTotalPrice));
                            bucketContent.append(bucketLine());
                        }
                        bucketContent.append(paymentDetailsBottom());
                        document.getElementById(windowContentId + bucketDIVWindow).innerHTML = bucketContent.toString();
                        setNormalAlphaCursor(document.getElementById(bucketClearAllButton));
                    }
                }
                if (_error.length > 0) {
                    document.getElementById(windowContentId + bucketDIVWindow).innerHTML = getWindowContentSimpleText(_error);
                }
                killXML(XMLHttpRequestObject);
            } else if (XMLHttpRequestObject.readyState != 0) {
                document.getElementById(windowContentId + bucketDIVWindow).innerHTML = getAjaxLoader('зареждане на данните...');
            } else {
                document.getElementById(windowContentId + bucketDIVWindow).innerHTML = getWindowContentSimpleText('There was a problem retrieving the XML data!');
            }
        };
        XMLHttpRequestObject.send(null);
    }
}
;
function clearBucket() {

    var XMLHttpRequestObject = getXMLHttpRequestObject();
    if (XMLHttpRequestObject) {
        var url = encodeURI(contextRoot + 'ticket-mgr?a=clrB&sId=' + sessionId + '&sync=' + Math.random());

        XMLHttpRequestObject.open("GET", url);
        XMLHttpRequestObject.onreadystatechange = function() {
            if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
                if (XMLHttpRequestObject.responseText == moduleClosedErrCode) {
                    moduleCloseOperation();
                } else if (XMLHttpRequestObject.responseText == sessionTimeOut) {
                    sessionTimeOutOperation();
                } else if (XMLHttpRequestObject.responseText == invalidParameters) {
                    //                alert('Некоректни параметри!');
                    invalidParametersOperation();
                } else if (XMLHttpRequestObject.responseText == communicationError) {
                    alert('Възникна комуникационна грешка в системата!');
                } else if (XMLHttpRequestObject.responseText == invalidCommunicationParameter) {
                    alert('Грешни комуникационни параметри!');
                } else if (XMLHttpRequestObject.responseText == systemError) {
                    alert('Възникна грешка в системата!');
                } else if (XMLHttpRequestObject.responseText == responseSuccess) {
                    flashLoadedTime = '0,0';
                    setDisabledAlphaNotAllowedCursor(document.getElementById('flashTimer'));
                    document.getElementById('init_flash_timer').innerHTML = buildFlashTimer(initFlashTimerObjectId);
                    runFlashCountdownTimer('flashTimerMovie', flashLoadedTime);
                    //if (summaryIncludeTooltipShown) {
                    //getSummaryStateTimerState();
                    //} else {
                    //getInitStateTimerState();
                    if (showVehicleSeats) {
                        getSeatData(true);
                    }
                    if (showVehicleReturnSeats) {
                        getReturnSeatData();
                    }
                    //}
                    getTotalTicketsCountAndPrice();
                    getBucket();
                } else {
                    alert('Възникна грешка в системата!');
                }
                killXML(XMLHttpRequestObject);
            } else if (XMLHttpRequestObject.readyState != 0) {
                document.getElementById(windowContentId + bucketDIVWindow).innerHTML = getAjaxLoader('извършване на операцията...');
            } else {
                alert('There was a problem retrieving the XML data!');
            }
        };
        XMLHttpRequestObject.send(null);
    }
}
;
function removeTicketFromBucket(ticketTypeId, travelListId, returnTravelListId, startPointId, endPointId, seat, returnSeat) {

    var _trId = (travelListId != null) ? travelListId : '';
    var _rTrId = (returnTravelListId != null) ? returnTravelListId : '';
    var _sPId = (startPointId != null) ? startPointId : '';
    var _ePId = (endPointId != null) ? endPointId : '';
    var _seat = (seat != null) ? seat : '';
    var _returnSeat = (returnSeat != null) ? returnSeat : '';

    var XMLHttpRequestObject = getXMLHttpRequestObject();
    if (XMLHttpRequestObject) {
        var url = encodeURI(contextRoot + 'ticket-mgr?a=rTfB&tTId=' + ticketTypeId + '&trId=' + _trId + '&rTrId=' + _rTrId + '&sPId=' + _sPId + '&ePId=' + _ePId + '&seat=' + _seat + '&returnSeat=' + _returnSeat + '&sId=' + sessionId + '&sync=' + Math.random());

        XMLHttpRequestObject.open("GET", url);
        XMLHttpRequestObject.onreadystatechange = function() {
            if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
                if (XMLHttpRequestObject.responseText == moduleClosedErrCode) {
                    moduleCloseOperation();
                } else if (XMLHttpRequestObject.responseText == sessionTimeOut) {
                    sessionTimeOutOperation();
                } else if (XMLHttpRequestObject.responseText == invalidParameters) {
                    //                alert('Некоректни параметри!');
                    invalidParametersOperation();
                } else if (XMLHttpRequestObject.responseText == communicationError) {
                    alert('Възникна комуникационна грешка в системата!');
                } else if (XMLHttpRequestObject.responseText == invalidCommunicationParameter) {
                    alert('Некоректни комуникационни параметри!');
                } else if (XMLHttpRequestObject.responseText == systemError) {
                    alert('Възникна грешка в системата!');
                } else if (XMLHttpRequestObject.responseText == responseSuccess || XMLHttpRequestObject.responseText == emptyResult) {
                    if (summaryIncludeTooltipShown) {
                        resetSummaryStateTimer();
                        if (XMLHttpRequestObject.responseText == responseSuccess) {
                            getSummaryData(true);
                        } else {
                            flashLoadedTime = '0,0';
                            setDisabledAlphaNotAllowedCursor(document.getElementById('flashTimer'));
                            document.getElementById('init_flash_timer').innerHTML = buildFlashTimer(initFlashTimerObjectId);
                            runFlashCountdownTimer('flashTimerMovie', flashLoadedTime);
                        }
                    } else {
                        getInitStateTimerState();
                        if (showVehicleSeats) {
                            getSeatData(true);
                        }
                        if (showVehicleReturnSeats) {
                            getReturnSeatData();
                        }
                    }
                    getTotalTicketsCountAndPrice();
                    getBucket();
                } else {
                    alert('Възникна грешка в системата!');
                }
                killXML(XMLHttpRequestObject);
            } else if (XMLHttpRequestObject.readyState != 0) {
                document.getElementById(windowContentId + bucketDIVWindow).innerHTML = getAjaxLoader('извършване на операцията...');
            } else alert('There was a problem retrieving the XML data!');
        };
        XMLHttpRequestObject.send(null);
    }
}
;
function removeTicketFromSummary(ticketTypeId, travelListId, returnTravelListId, startPointId, endPointId, seat, returnSeat) {

    var _trId = (travelListId != null) ? travelListId : '';
    var _rTrId = (returnTravelListId != null) ? returnTravelListId : '';
    var _sPId = (startPointId != null) ? startPointId : '';
    var _ePId = (endPointId != null) ? endPointId : '';
    var _seat = (seat != null) ? seat : '';
    var _returnSeat = (returnSeat != null) ? returnSeat : '';
    var _xmlKilled = false;
    var XMLHttpRequestObject = getXMLHttpRequestObject();
    if (XMLHttpRequestObject) {
        if (document.getElementById('payment_btn_id') != undefined) {
            setDisabledAlphaNotAllowedCursor(document.getElementById('payment_btn_id'));
        }
        var url = encodeURI(contextRoot + 'ticket-mgr?a=rTfB&tTId=' + ticketTypeId + '&trId=' + _trId + '&rTrId=' + _rTrId + '&sPId=' + _sPId + '&ePId=' + _ePId + '&seat=' + _seat + '&returnSeat=' + _returnSeat + '&sId=' + sessionId + '&sync=' + Math.random());
        XMLHttpRequestObject.open("GET", url);
        XMLHttpRequestObject.onreadystatechange = function() {
            if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
                if (XMLHttpRequestObject.responseText == moduleClosedErrCode) {
                    moduleCloseOperation();
                } else if (XMLHttpRequestObject.responseText == sessionTimeOut) {
                    sessionTimeOutOperation();
                } else if (XMLHttpRequestObject.responseText == invalidParameters) {
                    //                alert('Некоректни параметри!');
                    invalidParametersOperation();
                } else if (XMLHttpRequestObject.responseText == communicationError) {
                    alert('Възникна комуникационна грешка в системата!');
                } else if (XMLHttpRequestObject.responseText == invalidCommunicationParameter) {
                    alert('Некоректни комуникационни параметри!');
                } else if (XMLHttpRequestObject.responseText == systemError) {
                    alert('Възникна грешка в системата!');
                } else if (XMLHttpRequestObject.responseText == responseSuccess || XMLHttpRequestObject.responseText == emptyResult) {
                    _xmlKilled = true;
                    killXML(XMLHttpRequestObject);
                    getTotalTicketsCountAndPrice();
                    if (XMLHttpRequestObject.responseText == responseSuccess) {
                        resetSummaryStateTimer();
                        getSummaryData(true);
                    } else {
                        flashLoadedTime = '0,0';
                        setDisabledAlphaNotAllowedCursor(document.getElementById('flashTimer'));
                        document.getElementById('init_flash_timer').innerHTML = buildFlashTimer(initFlashTimerObjectId);
                        runFlashCountdownTimer('flashTimerMovie', flashLoadedTime);
                        cancelPayment();
                    }
                } else {
                    alert('Възникна грешка в системата!');
                }
//                if (document.getElementById('payment_btn_id') != undefined) {
//                    setNormalAlphaCursor(document.getElementById('payment_btn_id'));
//                }
                if (!_xmlKilled) {
                    killXML(XMLHttpRequestObject);
                    document.getElementById('_remove_' + ticketTypeId + '_' + travelListId + '_' + returnTravelListId + '_' + startPointId + '_' + endPointId + '_' + seat + '_' + returnSeat).innerHTML = '[премахни]';
                }
            } else if (XMLHttpRequestObject.readyState != 0) {
                document.getElementById('_remove_' + ticketTypeId + '_' + travelListId + '_' + returnTravelListId + '_' + startPointId + '_' + endPointId + '_' + seat + '_' + returnSeat).innerHTML = '&nbsp;&nbsp;<img src="images/progress-anim.gif" border="0" width="16">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
            } else {
                alert('There was a problem retrieving the XML data!');
            }
        };
        if (document.getElementById('paymentOperatorEPAY').checked || document.getElementById('paymentOperatorEPAY').checked) {
            if (document.getElementById('payment_btn_id') != undefined)
                setNormalAlphaCursor(document.getElementById('payment_btn_id'));
        } else {
            if (document.getElementById('payment_btn_id') != undefined)
                setDisabledAlphaNotAllowedCursor(document.getElementById('payment_btn_id'));
        }
        XMLHttpRequestObject.send(null);
    }
}
;
function getPayments() {
    var XMLHttpRequestObject = getXMLHttpRequestObject();
    if (XMLHttpRequestObject) {
        hideNavigator(paymentsDIVWindow);
        var _error = '';
        var type = errorType;
        var url = encodeURI(contextRoot + 'p-ment?a=ps&sId=' + sessionId + '&sync=' + Math.random());

        XMLHttpRequestObject.open("GET", url);
        XMLHttpRequestObject.onreadystatechange = function() {
            if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
                if (XMLHttpRequestObject.responseText == moduleClosedErrCode) {
                    moduleCloseOperation();
                } else if (XMLHttpRequestObject.responseText == sessionTimeOut) {
                    sessionTimeOutOperation();
                } else if (XMLHttpRequestObject.responseText == systemError) {
                    _error = 'Възникна грешка в системата!';
                } else if (XMLHttpRequestObject.responseText == invalidParameters) {
                    //	 				_error = 'Некоректни параметри!';
                    invalidParametersOperation();
                } else if (XMLHttpRequestObject.responseText == '0') {
                    _error = 'Няма намерени плащания!';
                    type = warningType;
                } else {
                    var response = null;
                    if (_ie) XMLHttpRequestObject.responseXML.loadXML(XMLHttpRequestObject.responseText);
                    response = XMLHttpRequestObject.responseXML.documentElement;
                    if (response != null) {
                        var i = 0;
                        var id;
                        var date;
                        var hour;
                        var total;
                        var code;
                        var status;
                        var tmpId;
                        var tmpDate;
                        var tmpHour;
                        var tmpTotal;
                        var tmpCode;
                        var tmpStatus;

                        while (i >= 0) {
                            var record = response.childNodes[i];

                            if (record != null) {
                                id = record.childNodes[0];
                                date = record.childNodes[1];
                                hour = record.childNodes[2];
                                total = record.childNodes[3];
                                code = record.childNodes[4];
                                status = record.childNodes[5];


                                tmpId = (id != undefined && id.firstChild != undefined) ? id.firstChild.data : "";
                                tmpDate = (date != undefined && date.firstChild != undefined) ? date.firstChild.data : "";
                                tmpHour = (hour != undefined && hour.firstChild != undefined) ? hour.firstChild.data : "";
                                tmpTotal = (total != undefined && total.firstChild != undefined) ? total.firstChild.data : "";
                                tmpCode = (code != undefined && code.firstChild != undefined) ? code.firstChild.data : "";
                                tmpStatus = (status != undefined && status.firstChild != undefined) ? status.firstChild.data : "";

                                paymentsResults[i] = paymentsRecord(tmpId, tmpDate, tmpHour, tmpTotal, tmpCode, tmpStatus);
                                i++;
                            } else {
                                i = -1;
                            }
                        }
                        if (paymentsResults != null && paymentsResults.length > 0) {
                            if (paymentsResults.length > paymentsResultsPerPage) {
                                paymentsPageCount = Math.ceil(paymentsResults.length / paymentsResultsPerPage);
                            }
                        }
                        changeResultsPerPage();
                        if (document.getElementById('saleRowId_' + selectedSaleRowId) != undefined) {
                            document.getElementById('saleRowId_' + selectedSaleRowId).className = 'payments-list-selected-bg';
                        }
                    }
                }
                if (_error.length > 0) {
                    //					document.getElementById(windowContentId + paymentsDIVWindow).innerHTML = getWindowContentSimpleText(_error);
                    document.getElementById(windowContentId + paymentsDIVWindow).innerHTML = getMessageHTML(infoType, paymentErrMsgId);
                    showSystemMessageWithoutResizing(type, paymentErrMsgId, (windowContentId + paymentsDIVWindow), '<br>' + _error + '<br>&nbsp;');

                }
                updateNavigatorState();
                killXML(XMLHttpRequestObject);
            } else if (XMLHttpRequestObject.readyState != 0) {
                document.getElementById(windowContentId + paymentsDIVWindow).innerHTML = getAjaxLoader('зареждане на данните...');
            } else {
                document.getElementById(windowContentId + paymentsDIVWindow).innerHTML = getWindowContentSimpleText('There was a problem retrieving the XML data!');
            }
        };
        XMLHttpRequestObject.send(null);
    }
}
;
function getPaymentDetails(id) {
    var XMLHttpRequestObject = getXMLHttpRequestObject();
    if (XMLHttpRequestObject) {
        var _error = '';
        var url = encodeURI(contextRoot + 'p-ment?a=pds&id=' + id + '&sId=' + sessionId + '&sync=' + Math.random());

        XMLHttpRequestObject.open("GET", url);
        XMLHttpRequestObject.onreadystatechange = function() {
            if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
                if (XMLHttpRequestObject.responseText == moduleClosedErrCode) {
                    moduleCloseOperation();
                } else if (XMLHttpRequestObject.responseText == sessionTimeOut) {
                    sessionTimeOutOperation();
                } else if (XMLHttpRequestObject.responseText == systemError) {
                    _error = 'Възникна грешка в системата!';
                } else if (XMLHttpRequestObject.responseText == invalidParameters) {
                    //	 				_error = 'Некоректни параметри!';
                    invalidParametersOperation();
                } else if (XMLHttpRequestObject.responseText == '-1') {
                    _error = 'Плащането не е намерено!';
                } else if (XMLHttpRequestObject.responseText == '-2') {
                    _error = 'Билетите към плащането не са намерени!';
                } else if (XMLHttpRequestObject.responseText == '-3') {
                    _error = 'Данните за билетите към плащането не са намерени!';
                } else {
                    var response = null;
                    if (_ie) XMLHttpRequestObject.responseXML.loadXML(XMLHttpRequestObject.responseText);
                    response = XMLHttpRequestObject.responseXML.documentElement;
                    if (response != null) {
                        var details = new StringBuffer();

                        var tmpTicketsTag;
                        var tmpRouteName;
                        var tmpDepartureDate;
                        var tmpReturnDate;
                        var tmpTicketName;
                        var tmpPassangerName;
                        var tmpDepartureSeats;
                        var tmpReturnSeats;
                        var tmpTicketPrice;
                        var tmpTotalPrice = 0;
                        var i = 0;
                        var j = 0;

                        var saleDateTag = response.childNodes[0];
                        var saleCodeTag = response.childNodes[1];
                        var saleStatusTag = response.childNodes[2];
                        var userFirstAndLastNameTag = response.childNodes[3];
                        var routesTag = response.childNodes[4];
                        var totalPriceTag = response.childNodes[5];

                        details.append(paymentDetailsTop());
                        details.append(paymentDetailsSaleData(((saleDateTag != undefined && saleDateTag.firstChild != undefined) ? saleDateTag.firstChild.data : "N/A"), ((saleCodeTag != undefined && saleCodeTag.firstChild != undefined) ? saleCodeTag.firstChild.data : "N/A"), ((saleStatusTag != undefined && saleStatusTag.firstChild != undefined) ? ((saleStatusTag.firstChild.data == saleStatusPaid || saleStatusTag.firstChild.data == saleStatusIssued) ? "потвърдено" : "не потвърдено") : "N/A")));
                        details.append(paymentDetailsUserFirstAndLastName(new Array('На името на:', ((userFirstAndLastNameTag != undefined && userFirstAndLastNameTag.firstChild != undefined) ? userFirstAndLastNameTag.firstChild.data : "N/A"))));
                        while (routesTag != null && routesTag != undefined && i >= 0) {
                            var route = routesTag.childNodes[i];
                            if (route != null) {
                                tmpRouteName = (route.childNodes[0] != null && route.childNodes[0] != undefined && route.childNodes[0].firstChild != undefined) ? route.childNodes[0].firstChild.data : "N/A";
                                tmpDepartureDate = (route.childNodes[1] != null && route.childNodes[1] != undefined && route.childNodes[1].firstChild != undefined) ? route.childNodes[1].firstChild.data : "N/A";
                                tmpReturnDate = (route.childNodes[2] != null && route.childNodes[2] != undefined && route.childNodes[2].firstChild != undefined) ? route.childNodes[2].firstChild.data : "";
                                tmpTicketsTag = route.childNodes[3];

                                details.append(paymentDetailsRecordTopColored(new Array('Маршрут:', tmpRouteName)));
                                details.append(paymentDetailsLine());
                                details.append(paymentDetailsRecordTop(new Array('Дати:', tmpDepartureDate)));
                                details.append(paymentDetailsLine());
                                if (!allSpaces(tmpReturnDate)) {
                                    details.append(paymentDetailsRecordTop(new Array('&nbsp;', tmpReturnDate)));
                                    details.append(paymentDetailsLine());
                                }
                                if (tmpTicketsTag != null) {
                                    details.append(paymentDetailsRecordTickets(new Array('Билет(и):', 'Вид на билета', 'Име на пътник', 'Място отиване', 'Място връщане', 'Цена')));
                                    details.append(paymentDetailsLine());
                                    j = 0;
                                    while (j >= 0) {
                                        var ticket = (tmpTicketsTag.childNodes[j] != undefined && tmpTicketsTag.childNodes[j] != null) ? tmpTicketsTag.childNodes[j] : null;
                                        if (ticket != null) {
                                            tmpTicketName = (ticket.childNodes[0] != undefined && ticket.childNodes[0].firstChild != undefined) ? ticket.childNodes[0].firstChild.data : "";
                                            tmpPassangerName = (ticket.childNodes[1] != undefined && ticket.childNodes[1].firstChild != undefined) ? ticket.childNodes[1].firstChild.data : "";
                                            tmpDepartureSeats = (ticket.childNodes[2] != undefined && ticket.childNodes[2].firstChild != undefined) ? ticket.childNodes[2].firstChild.data : "";
                                            tmpReturnSeats = (ticket.childNodes[3] != undefined && ticket.childNodes[3].firstChild != undefined) ? ticket.childNodes[3].firstChild.data : "";
                                            tmpTicketPrice = (ticket.childNodes[4] != undefined && ticket.childNodes[4].firstChild != undefined) ? ticket.childNodes[4].firstChild.data : "";

                                            details.append(paymentDetailsRecordTickets(new Array('&nbsp;', tmpTicketName, tmpPassangerName, '№' + tmpDepartureSeats, ((tmpReturnSeats != null && !allSpaces(tmpReturnSeats)) ? '№' + tmpReturnSeats : '-'), tmpTicketPrice + '&nbsp;лв.')));
                                            details.append(paymentDetailsLine());
                                            j++;
                                        } else {
                                            j = -1;
                                        }
                                    }
                                }
                                i++;
                            } else {
                                i = -1;
                            }
                        }
                        tmpTotalPrice = (totalPriceTag != undefined && totalPriceTag.firstChild != undefined) ? totalPriceTag.firstChild.data : "";
                        if (!allSpaces(tmpTotalPrice)) {
                            details.append(paymentDetailsRecordTotalPrice(tmpTotalPrice));
                            details.append(paymentDetailsLine());
                        }
                        details.append(paymentDetailsBottom());
                        document.getElementById(windowContentId + paymentDetailsDIVWindow).innerHTML = details.toString();
                        selectedSaleRowId = id;
                        if (document.getElementById('saleRowId_' + selectedSaleRowId) != undefined) {
                            document.getElementById('saleRowId_' + selectedSaleRowId).className = 'payments-list-selected-bg';
                        }
                    }
                }

                sendToTopOperation = true;

                if (_error.length > 0) {
                    document.getElementById(windowContentId + paymentDetailsDIVWindow).innerHTML = getWindowContentSimpleText(_error);
                    setDisabledAlphaNotAllowedCursor(document.getElementById(paymentDetailsPDFButton));
                }
                killXML(XMLHttpRequestObject);
            } else if (XMLHttpRequestObject.readyState != 0) {
                document.getElementById(windowContentId + paymentDetailsDIVWindow).innerHTML = getAjaxLoader('зареждане на данните...');
            } else {
                document.getElementById(windowContentId + paymentDetailsDIVWindow).innerHTML = getWindowContentSimpleText('There was a problem retrieving the XML data!');
            }
        };
        XMLHttpRequestObject.send(null);
    }
}
;
function showSummaryInclude() {
    if (!summaryIncludeTooltipShown) {
        getSummaryData(false);
    }
}
;
function hideSummaryTooltip() {
    if (summaryIncludeTooltipShown) {
        document.getElementById('summaryContent').innerHTML = '';
        try {
            clearInterval(timerInterval);
            clearInterval(flashingInterval);
        } catch(e) {
        }
        document.getElementById('summary_cntdwn').innerHTML = '';
        //		hideCustomTooltip('summaryInclude');
        hide('summaryInclude');
        summaryIncludeTooltipShown = false;
        managefilterAccordingSelectedTicketType();
    }
}
;
function cancelPayment() {
    XMLHttpRequestObject = getXMLHttpRequestObject();
    if (XMLHttpRequestObject) {
        var url = encodeURI(contextRoot + 'state-mgr?a=sD&id=-1&sId=' + sessionId + '&sync=' + Math.random());

        XMLHttpRequestObject.open("GET", url);
        XMLHttpRequestObject.onreadystatechange = function() {
            if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
                if (XMLHttpRequestObject.responseText == moduleClosedErrCode) {
                    moduleCloseOperation();
                } else if (XMLHttpRequestObject.responseText == sessionTimeOut) {
                    sessionTimeOutOperation();
                } else if (XMLHttpRequestObject.responseText == systemError) {
                    alert('Възникна грешка в системата!');
                } else if (XMLHttpRequestObject.responseText == invalidParameters) {
                    //               		alert('Некоректни параметри!');
                    invalidParametersOperation();
                } else if (XMLHttpRequestObject.responseText == responseSuccess) {
                    hideSummaryTooltip();
                    showTicketsAndVehiclesTooltip();
                    if (showVehicleSeats) {
                        getSeatData(true);
                    }
                    if (showVehicleReturnSeats) {
                        getReturnSeatData();
                    }
                    if (showSummaryBtn) {
                        showSummaryButton();
                    } else {
                        hideSummaryButton();
                    }
                    document.getElementById('summary_cntdwn').innerHTML = '';
                    //getInitStateTimerState();
                } else {
                    alert('Възникна грешка в системата!');
                }
                killXML(XMLHttpRequestObject);
            } else if (XMLHttpRequestObject.readyState != 0) {
                ;
            } else {
                alert("There was a problem retrieving the XML data!");
            }
        };
        XMLHttpRequestObject.send(null);
    }
}
;
function summaryTop() {
    var sb = new StringBuffer();
    sb.append('<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center">');
    sb.append('<tr>');
    sb.append('<td width="4" height="1" style="background-image:url(images/summary_top_left_border.gif)"></td>');
    sb.append('<td height="1" colspan="12" style="background-image:url(images/summary_border_color.gif); background-repeat:repeat-x; width:100%"></td>');
    sb.append('<td width="4" height="1" style="background-image:url(images/summary_top_right_border.gif); "></td>');
    sb.append('</tr>');
    return sb.toString();
}
;
function summaryBottom() {
    var sb = new StringBuffer();
    sb.append('<tr>');
    sb.append('<td width="4" height="8" style="background-image:url(images/summary_bottom_left_border.gif);background-repeat:no-repeat "></td>');
    sb.append('<td width="100%" colspan="12" height="8" style="background-image:url(images/summary_bottom_border.gif);background-repeat:repeat-x "></td>');
    sb.append('<td width="4" height="8" style="background-image:url(images/summary_bottom_right_border.gif);background-repeat:repeat-y "></td>');
    sb.append('</tr>');
    sb.append('</table>');
    return sb.toString();
}
;

function summaryRoute(oneWay, tmpStartPointName, tmpEndPointName, tmpDepartureDate, tmpDepartureHour, tmpReturnDate, tmpReturnHour) {
    var sb = new StringBuffer();
    sb.append('<tr>');
    sb.append('<td width="4" height="28" style="background-image:url(images/summary_title_left_border.gif); background-repeat:no-repeat"></td>');
    sb.append('<td colspan="12" style="background-image:url(images/summary_title_bg.gif); background-repeat:repeat-x; height:28; width:100%">');
    sb.append('<table cellpadding="0" cellspacing="0" width="100%" border="0">');
    sb.append('<tr>');
    sb.append('<td align="right" width="70" nowrap="nowrap" class="ticket-name" style="font-weight:bold; font-size:12;">&nbsp;&nbsp;<span style="color:#444444;">Маршрут:</span></td>');
    sb.append('<td align="left" nowrap="nowrap" class="ticket-name" style="font-weight:bold; font-size:12;">&nbsp;&nbsp;' + tmpStartPointName + ' - ' + tmpEndPointName + ((!oneWay) ? ' - ' + tmpStartPointName : '') + '&nbsp;&nbsp;</td>');
    sb.append('<td align="right" nowrap="nowrap" class="summary-title-data">');
    if (oneWay) {
        sb.append('&nbsp;&nbsp;&nbsp;От&nbsp;' + tmpStartPointName + ':&nbsp;' + '<span class="summary-content-blue">' + tmpDepartureDate + '&nbsp;|&nbsp;' + tmpDepartureHour + '&nbsp;ч</span>&nbsp;&nbsp;&nbsp;');
    } else {
        sb.append('&nbsp;От&nbsp;' + tmpStartPointName + ':&nbsp;' + '<span class="summary-content-blue">' + tmpDepartureDate + '&nbsp;|&nbsp;' + tmpDepartureHour + '&nbsp;ч</span>');
        sb.append('&nbsp;&nbsp;&nbsp;От&nbsp;' + tmpEndPointName + ':&nbsp;' + '<span class="summary-content-blue">' + tmpReturnDate + '&nbsp;|&nbsp;' + tmpReturnHour + '&nbsp;ч</span>&nbsp;&nbsp;&nbsp;');
    }

    sb.append('</td>');
    sb.append('</tr>');
    sb.append('</table>');
    sb.append('</td>');
    sb.append('<td width="4" height="28" style="background-image:url(images/summary_title_right_border.gif); background-repeat:no-repeat "></td>');
    sb.append('</tr>');
    sb.append(summaryDotline());
    return sb.toString();
}
;
function summaryDotline() {
    var sb = new StringBuffer();
    sb.append('<tr>');
    sb.append('<td width="4" height="1"><img src="images/summary_left_border.gif" width="4"></td>');
    sb.append('<td height="1" colspan="12" nowrap="nowrap" width="100%" style="background-image:url(images/summary_dot_line.gif); background-repeat:repeat-x"></td>');
    sb.append('<td width="4" height="1"><img src="images/summary_right_border.gif" width="4"></td>');
    sb.append('</tr>');
    return sb.toString();
}
;
function summaryTicketsLabels(data) {
    var sb = new StringBuffer();
    if (data != null && data.length > 0) {
        sb.append(summaryLine('#FFFFFF'));
        sb.append('<tr>');
        sb.append('<td width="4" height="20" class="summary-left-border"></td>');
        sb.append('<td width="70" align="left" height="26" nowrap="nowrap" style="background-image:url(images/summary_ticket_title_bg.gif); background-repeat:repeat-x" class="summary-sum-content">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#444444;font-weight:bold; font-size:12;">' + data[0] + '</span></td>');
        sb.append('<td align="left" nowrap="nowrap" style="background-image:url(images/summary_ticket_title_bg.gif); background-repeat:repeat-x" class="summary-sum-content">&nbsp;</td>');
        sb.append('<td align="left" nowrap="nowrap" style="background-image:url(images/summary_ticket_title_bg.gif); background-repeat:repeat-x" class="summary-sum-content">' + data[1] + '</td>');
        sb.append('<td align="left" nowrap="nowrap" style="background-image:url(images/summary_ticket_title_bg.gif); background-repeat:repeat-x" class="summary-sum-content">&nbsp;</td>');
        sb.append('<td align="left" nowrap="nowrap" style="background-image:url(images/summary_ticket_title_bg.gif); background-repeat:repeat-x" class="summary-sum-content">' + data[2] + '</td>');
        sb.append('<td align="left" nowrap="nowrap" style="background-image:url(images/summary_ticket_title_bg.gif); background-repeat:repeat-x" class="summary-sum-content">&nbsp;</td>');
        sb.append('<td align="left" nowrap="nowrap" style="background-image:url(images/summary_ticket_title_bg.gif); background-repeat:repeat-x" class="summary-sum-content">' + data[3] + '</td>');
        sb.append('<td align="left" nowrap="nowrap" style="background-image:url(images/summary_ticket_title_bg.gif); background-repeat:repeat-x" class="summary-sum-content">&nbsp;</td>');
        sb.append('<td align="left" nowrap="nowrap" style="background-image:url(images/summary_ticket_title_bg.gif); background-repeat:repeat-x" class="summary-sum-content">' + data[4] + '</td>');
        sb.append('<td align="left" nowrap="nowrap" style="background-image:url(images/summary_ticket_title_bg.gif); background-repeat:repeat-x" class="summary-sum-content">&nbsp;</td>');
        sb.append('<td align="center" nowrap="nowrap" style="background-image:url(images/summary_ticket_title_bg.gif); background-repeat:repeat-x" class="summary-sum-content">' + data[5] + '&nbsp;</td>');
        sb.append('<td align="right" nowrap="nowrap" style="background-image:url(images/summary_ticket_title_bg.gif); background-repeat:repeat-x" class="summary-sum-content">&nbsp;</td>');
        sb.append('<td width="4" height="20" class="summary-right-border"></td>');
        sb.append('</tr>');
        sb.append(summaryLine('#FFFFFF'));
        sb.append(summaryLine('#EEE4CA'));
    }
    return sb.toString();
}
;
function summaryTicket(data, index) {
    var sb = new StringBuffer();
    if (data != null && data.length > 0) {
        sb.append(summaryLine('#FFFFFF'));
        sb.append('<tr>');
        sb.append('<td width="4" height="26" class="summary-left-border"></td>');
        sb.append('<td align="left" height="26" nowrap="nowrap" class="summary-default-content">' + data[1] + '</td>');
        sb.append('<td align="left" height="26" nowrap="nowrap" class="summary-default-content">&nbsp;</td>');
        sb.append('<td align="left" height="26" nowrap="nowrap" class="summary-default-content">' + data[2] + '</td>');
        sb.append('<td align="left" height="26" nowrap="nowrap" class="summary-default-content">&nbsp;</td>');
        sb.append('<td align="left" height="26" nowrap="nowrap" class="summary-default-content"><input type="text" maxlength="100" class="inet-summary-inbox" name="' + data[8] + '_' + data[9] + '_' + data[10] + '_' + data[11] + '_' + data[12] + '_' + data[4] + '_' + data[5] + '" id="_passagerName_' + index + '" value="' + data[3] + '"></td>');
        sb.append('<td align="left" height="26" nowrap="nowrap" class="summary-default-content">&nbsp;</td>');
        sb.append('<td align="left" height="26" nowrap="nowrap" class="summary-default-content">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + ((data[4] == null) ? 'не е избрано' : '№&nbsp;' + data[4]) + '</td>');
        sb.append('<td align="left" height="26" nowrap="nowrap" class="summary-default-content">&nbsp;</td>');
        if (data[5] == null) {
            sb.append('<td align="left" height="26" nowrap="nowrap" class="summary-default-content">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + ((data[5] == null) ? ((!data[0]) ? 'не е избрано' : '-') : '№&nbsp;' + data[5]) + '</td>');
        } else {
            sb.append('<td align="left" height="26" nowrap="nowrap" class="summary-default-content">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + ((data[5] == null) ? ((!data[0]) ? 'не е избрано' : '-') : '№&nbsp;' + data[5]) + '</td>');
        }
        sb.append('<td align="left" height="26" nowrap="nowrap" class="summary-default-content">&nbsp;</td>');
        sb.append('<td align="right" height="26" nowrap="nowrap" class="summary-default-content">' + data[6] + '&nbsp;</td>');
        if (data[6] != null) {
            sb.append('<td align="right" height="26" nowrap="nowrap" class="summary-default-content"><span class="top-type2" onmouseover="this.style.cursor=\'pointer\'" id="_remove_' + data[8] + '_' + data[9] + '_' + data[10] + '_' + data[11] + '_' + data[12] + '_' + data[4] + '_' + data[5] + '" onclick="removeTicketFromSummary(' + data[8] + ',' + data[9] + ',' + data[10] + ',' + data[11] + ',' + data[12] + ',' + data[4] + ',' + data[5] + ');">' + data[7] + '</span>&nbsp;&nbsp;</td>');
        } else {
            sb.append('<td align="right" height="26" nowrap="nowrap" class="summary-default-content">&nbsp;</td>');
        }
        sb.append('<td width="4" height="26" class="summary-right-border"></td>');
        sb.append('</tr>');
        sb.append(summaryLine('#FFFFFF'));
        sb.append(summaryLine('#EEE4CA'));
    }
    return sb.toString();
}
;

function summaryLine(color) {
    var sb = new StringBuffer();
    sb.append('<tr>');
    sb.append('<td width="4" height="1" class="summary-left-border"></td>');
    sb.append('<td height="1" colspan="12" style="background-color:' + color + '"></td>');
    sb.append('<td width="4" height="1" class="summary-right-border"></td>');
    sb.append('</tr>');
    return sb.toString();
}
;

function summaryTotal(total) {
    var sb = new StringBuffer();
    sb.append(summaryLine('#FFFFFF'));
    sb.append('<tr>');
    sb.append('<td width="4" height="23" class="summary-left-border"></td>');
    sb.append('<td height="23" colspan="12" nowrap="nowrap" style="background-image:url(images/summary_total_bg.gif); background-repeat:repeat-x" class="summary-total-content">');
    sb.append('<table cellpadding="0" cellspacing="0" width="100%" border="0">');
    sb.append('<tr>');
    sb.append('<td align="left" nowrap="nowrap" class="summary-total-content" width="100%">&nbsp;&nbsp;Обща стойност</td>');
    sb.append('<td align="right" nowrap="nowrap" width="50" style="padding-top:1px; " class="summary-total-content">' + total + '&nbsp;лв.&nbsp;&nbsp;</td>');
    sb.append('</tr>');
    sb.append('</table>');
    sb.append('</td>');
    sb.append('<td width="4" height="23" class="summary-right-border"></td>');
    sb.append('</tr>');
    sb.append(summaryLine('#FFFFFF'));
    return sb.toString();
}
;
function paymentsTop() {
    return '<table cellpadding="0" cellspacing="0" border="0" width="100%" id="paymentsRows">';
}
;
function paymentsBottom() {
    return '</table>';
}
;
function paymentsRecord(id, date, hour, total, code, status) {
    var sb = new StringBuffer();
    sb.append('<tr>');
    sb.append('<td id="saleRowId_' + id + '" width="100%" class="payment-summary-content-bg" onmouseover="if (this.className != \'payments-list-selected-bg\') {this.className=\'payment-summary-content-hover-bg\'};" onmouseout="if (this.className != \'payments-list-selected-bg\') {this.className=\'payment-summary-content-bg\'};" onclick="sendToTopOperation=false; clearPreviousSelectedPaymentStyle(' + id + '); this.className=\'payments-list-selected-bg\'; showWindow(' + paymentDetails + ');" >');
    sb.append('<table cellpadding="0" cellspacing="0" width="100%" border="0">');
    sb.append('<tr>');
    sb.append('<td align="center" height="22" width="200" class="payment-summary-content-type1">' + date + '&nbsp;&nbsp;&nbsp;' + hour + '&nbsp;ч.</td>');
    sb.append('<td align="center" height="22" width="120" class="payment-summary-content-type1">' + total + '&nbsp;лв.</td>');
    sb.append('<td align="center" height="22" width="107" class="payment-summary-content-type1">' + code + '</td>');
    sb.append('<td align="center" height="22" width="140" class="payment-summary-content-type1">' + ((status == saleStatusPaid || status == saleStatusIssued) ? "потвърдено" : "не потвърдено") + '</td>');
    sb.append('</tr>');
    sb.append('</table>');
    sb.append('</td>');
    sb.append('</tr>');
    return sb.toString();
}
;
function paymentsLine() {
    var sb = new StringBuffer();
    sb.append('<tr>');
    sb.append('<td width="100%" height="1" style="background-color: #BCBECB"></td>');
    sb.append('</tr>');
    return sb.toString();
}
;
function paymentDetailsTop() {
    return '<table cellpadding="0" cellspacing="0" border="0" width="100%" id="paymentDetailsRows">';
}
;
function paymentDetailsSaleData(saleDate, code, status) {
    var sb = new StringBuffer();
    sb.append(paymentDetailsLine());
    sb.append('<tr>');
    sb.append('<td align="left" height="22" class="payment-details-content-lrb" style="background-image:url(\'images/payments/payment_details_top_bg.gif\'); background-repeat: repeat-x;" colspan="11">');
    sb.append('<table cellpadding="0" cellspacing="0" border="0" width="100%">');
    sb.append('<tr>');
    sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;<b>Дата на плащането:</b></td>');
    sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
    sb.append('<td align="left" height="22" class="payment-summary-content-type1">' + saleDate + '&nbsp;</td>');
    sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;<b>Код:</b></td>');
    sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
    sb.append('<td align="left" height="22" class="payment-summary-content-type1" style="color:#CC0000"><b>' + code + '</b></td>');
    sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
    sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;<b>Статус:<b></td>');
    sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
    sb.append('<td align="left" height="22" class="payment-summary-content-type1">' + status + '</td>');
    sb.append('</tr>');
    sb.append('</table>');
    sb.append('</td>');
    sb.append('</tr>');
    sb.append(paymentDetailsLine());
    return sb.toString();
}
;
function paymentDetailsUserFirstAndLastName(data) {
    var sb = new StringBuffer();
    if (data != null && data.length > 0) {
        sb.append('<tr>');
        sb.append('<td align="left" height="22" class="payment-details-content-lrb" colspan="11">&nbsp;<b>' + data[0] + '</b>&nbsp;&nbsp;' + data[1] + '</td>');
        sb.append('</tr>');
        sb.append(paymentDetailsLine());
    }
    return sb.toString();
}
;
function paymentDetailsRecordTop(data) {
    var sb = new StringBuffer();
    if (data != null && data.length > 0) {
        sb.append('<tr>');
        sb.append('<td align="left" height="22" class="payment-details-content-lb">&nbsp;<b>' + data[0] + '</b></td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-details-content-rb" colspan="9">' + data[1] + '</td>');
        sb.append('</tr>');
    }
    return sb.toString();
}
;
function paymentDetailsRecordTopColored(data) {
    var sb = new StringBuffer();
    if (data != null && data.length > 0) {
        sb.append('<tr class="payment-summary-content-bg">');
        sb.append('<td align="left" height="22" class="payment-details-content-lb">&nbsp;<b>' + data[0] + '</b></td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-details-content-rb" colspan="9">' + data[1] + '</td>');
        sb.append('</tr>');
    }
    return sb.toString();
}
;
function paymentDetailsRecordTickets(data) {
    var sb = new StringBuffer();
    if (data != null && data.length > 0) {
        sb.append('<tr>');
        sb.append('<td align="left" height="22" class="payment-details-content-lb">&nbsp;<b>' + data[0] + '</b></td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">' + data[1] + '</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">' + data[2] + '</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">' + data[3] + '</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">' + data[4] + '</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="right" height="22" class="payment-details-content-rb">' + data[5] + '&nbsp;</td>');
        sb.append('</tr>');
    }
    return sb.toString();
}
;
function paymentDetailsRecordTotalPrice(totalPrice) {
    var sb = new StringBuffer();
    sb.append('<tr>');
    sb.append('<td align="left" height="22" class="payment-details-content-lb" style="background-image:url(\'images/payments/payment_details_top_bg.gif\'); background-repeat: repeat-x;" colspan="5">&nbsp;<b>Обща стойност на плащането</b></td>');
    sb.append('<td align="right" height="22" class="payment-details-content-rb" style="background-image:url(\'images/payments/payment_details_top_bg.gif\'); background-repeat: repeat-x;" colspan="6"><span style="color:#CC0000"><b>' + totalPrice + '&nbsp;лв.&nbsp;</b></span></td>');
    sb.append('</tr>');
    return sb.toString();
}
;
function paymentDetailsLine() {
    var sb = new StringBuffer();
    sb.append('<tr>');
    sb.append('<td width="100%" colspan="11" height="1" style="background-color: #BCBECB"></td>');
    sb.append('</tr>');
    return sb.toString();
}
;
function paymentDetailsBottom() {
    return '</table>';
}
;
function bucketRecordTopColored(data) {
    var sb = new StringBuffer();
    if (data != null && data.length > 0) {
        sb.append('<tr class="payment-summary-content-bg">');
        sb.append('<td align="left" height="22" class="payment-details-content-lb">&nbsp;<b>' + data[0] + '</b></td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1" colspan="9">' + data[1] + '</td>');
        sb.append('<td align="left" height="22" class="payment-details-content-rb">&nbsp;</td>');
        sb.append('</tr>');
    }
    return sb.toString();
}
;
function bucketRecordTop(data) {
    var sb = new StringBuffer();
    if (data != null && data.length > 0) {
        sb.append('<tr>');
        sb.append('<td align="left" height="22" class="payment-details-content-lb">&nbsp;<b>' + data[0] + '</b></td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1" colspan="9">' + data[1] + '</td>');
        sb.append('<td align="left" height="22" class="payment-details-content-rb">&nbsp;</td>');
        sb.append('</tr>');
    }
    return sb.toString();
}
;
function bucketRecordTicketsLabels(data) {
    var sb = new StringBuffer();
    if (data != null && data.length > 0) {
        sb.append('<tr>');
        sb.append('<td align="left" height="22" class="payment-details-content-lb">&nbsp;<b>' + data[0] + '</b></td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">' + data[1] + '</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">' + data[2] + '</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">' + data[3] + '</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">' + data[4] + '</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="right" height="22" class="payment-summary-content-type1">' + data[5] + '&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-details-content-rb">&nbsp;</td>');
        sb.append('</tr>');
    }
    return sb.toString();
}
;
function bucketRecordTickets(data) {
    var sb = new StringBuffer();
    if (data != null && data.length > 0) {
        sb.append('<tr>');
        sb.append('<td align="left" height="22" class="payment-details-content-lb">&nbsp;<b>' + data[1] + '</b></td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">' + data[2] + '</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">' + data[3] + '</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">' + ((data[4] == null) ? 'не е избрано' : '№' + data[4]) + '</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">' + ((data[5] == null) ? ((!data[0]) ? 'не е избрано' : '-') : '№' + data[5]) + '</td>');
        sb.append('<td align="left" height="22" class="payment-summary-content-type1">&nbsp;</td>');
        sb.append('<td align="right" height="22" class="payment-summary-content-type1">' + data[6] + '&nbsp;</td>');
        if (data[6] != null) {
            sb.append('<td align="left" height="22" class="payment-details-content-rb"><span class="top-type2" onmouseover="this.style.cursor=\'pointer\'" onclick="removeTicketFromBucket(' + data[8] + ',' + data[9] + ',' + data[10] + ',' + data[11] + ',' + data[12] + ',' + data[4] + ',' + data[5] + ');">' + data[7] + '&nbsp;&nbsp;</span></td>');
        } else {
            sb.append('<td align="left" height="22" class="payment-details-content-rb">&nbsp;</td>');
        }
        sb.append('</tr>');
    }
    return sb.toString();
}
;
function bucketRecordTotalPrice(totalPrice) {
    var sb = new StringBuffer();
    sb.append('<tr>');
    sb.append('<td align="left" height="22" class="payment-details-content-lb" style="background-image:url(\'images/payments/payment_details_top_bg.gif\'); background-repeat: repeat-x;" colspan="5">&nbsp;<b>Обща стойност</b></td>');
    sb.append('<td align="right" height="22" class="payment-details-content-rb" style="background-image:url(\'images/payments/payment_details_top_bg.gif\'); background-repeat: repeat-x;" colspan="7"><span style="color:#CC0000"><b>' + totalPrice + '&nbsp;лв.&nbsp;</b></span></td>');
    sb.append('</tr>');
    return sb.toString();
}
;
function bucketLine() {
    var sb = new StringBuffer();
    sb.append('<tr>');
    sb.append('<td width="100%" colspan="12" height="1" style="background-color: #BCBECB"></td>');
    sb.append('</tr>');
    return sb.toString();
}
;
function clearPreviousSelectedPaymentStyle(id) {
    if (document.getElementById('saleRowId_' + selectedSaleRowId) != undefined) {
        document.getElementById('saleRowId_' + selectedSaleRowId).className = 'payment-summary-content-bg';
    }
    selectedSaleRowId = id;
}
;

function openPaymentDetailsPDF(id) {
    checkSession(id);
}
;
function openNewPDFWindow(id) {
    if (id == null || id == 'null') {
        if (selectedSaleRowId != null) {
            window.open(protocol + '://' + host + ((port == -1) ? '' : ':' + port) + contextRoot + 'g-pdf?a=pdsPDF&id=' + selectedSaleRowId + '&sId=' + sessionId + '&sync=' + Math.random(), 'Детайли', '');
        } else {
            alert("Възникна грешка в системата!");
        }
    } else {
        window.open(protocol + '://' + host + ((port == -1) ? '' : ':' + port) + contextRoot + 'g-pdf?a=pdsPDF&id=' + id + '&t=1&sId=' + sessionId + '&sync=' + Math.random(), 'Детайли', '');
    }
}
;
function getSelectedPaymentOperator() {
    if (document.getElementById('paymentOperatorEPAY').checked) {
        return document.getElementById('paymentOperatorEPAY').value;
    } else if (document.getElementById('paymentOperatorDSK').checked) {
        return document.getElementById('paymentOperatorDSK').value;
    } else {
        return false;
    }
}
;
function getPassangerNameForParameters() {
    var ticketElement = null;
    var parameters = new StringBuffer();
    for (var i = 1; i <= numberOfSummarizedTicket; i++) {
        ticketElement = document.getElementById('_passagerName_' + i);
        if (ticketElement != undefined) {
            parameters.append('&_passagerName_=' + ticketElement.name + '_' + ticketElement.value)
        }
    }
    return parameters.toString();
}
;
function validateAllData() {
    var paymentOperatorId = getSelectedPaymentOperator();
//    alert('paymentOperatorId ' + paymentOperatorId);
//    return false;
    if (paymentOperatorId == null) {
        alert('Моля изберете платежен оператор!');
    }
    var XMLHttpRequestObject = getXMLHttpRequestObject();
    if (XMLHttpRequestObject) {

        var url = encodeURI(contextRoot + 'data-validation?sId=' + sessionId + '&poId=' + paymentOperatorId + '&sync=' + Math.random() + getPassangerNameForParameters());
        var chechOK = false;
        XMLHttpRequestObject.open("GET", url);
        XMLHttpRequestObject.onreadystatechange = function() {
            if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
                if (XMLHttpRequestObject.responseText == moduleClosedErrCode) {
                    moduleCloseOperation();
                } else if (XMLHttpRequestObject.responseText == sessionTimeOut) {
                    sessionTimeOutOperation();
                }
                if (XMLHttpRequestObject.responseText == systemError) {
                    alert('Възникна грешка в системата!');
                } else if (XMLHttpRequestObject.responseText == invalidParameters) {
                    //	            	alert('Невалидни параметри!');
                    invalidParametersOperation();
                } else if (XMLHttpRequestObject.responseText == seatAlreadyLocked) {
                    alert('Местата, които сте избрали не са заключени!');
                } else if (XMLHttpRequestObject.responseText == communicationError) {
                    alert('Възникна комуникационна грешка!');
                } else if (XMLHttpRequestObject.responseText == invalidCommunicationParameter) {
                    alert('Некоректни комуникационни параметри!');
                } else if (XMLHttpRequestObject.responseText == '1') {
                    chechOK = true;
                }
                killXML(XMLHttpRequestObject);
                if (chechOK) {
                    if (paymentOperatorId_EPAY == paymentOperatorId) {
                        document.location.href = contextRoot + 'epay-send?sId=' + sessionId + '&sync=' + Math.random();
                    } else if (paymentOperatorId_DSK == paymentOperatorId) {
                        document.location.href = contextRoot + 'dskSend.jsp?sync=' + Math.random();
                    } else {
                        alert('Некоректен оператор!');
                    }
                }
            } else if (XMLHttpRequestObject.readyState != 0) {
                ;
            } else {
                alert('Възникна проблем с извличането на XML данните!');
            }
        };
        XMLHttpRequestObject.send(null);
    }
}
;
function goAndPay() {
    setDisabledAlphaNotAllowedCursor(document.getElementById('payment_btn_id'))
    if (!validatePassangerName()) {
        return false;
    }
    if (canPay && userLogged) {
        validateAllData();
    } else if (!userLogged) {
        alert("За да извършите плащането трябва да бъдете логнат в системата!");
    }
    return false;
}
;
