﻿/** Search Option Info Help **/
var iPopUpCount = 0;
function ShowSearchTypeInfoHelp(SearchTypeIndex) {
    RailEurope.HTMLService.GetSearchTypeInformation("SearchTypeInfo", parseInt(SearchTypeIndex), OnSearchShowSearchTypeInfoHelpSucceeded);
}
function OnSearchShowSearchTypeInfoHelpSucceeded(result) {
    if (result != null) { $get('SearchTypeInfo').innerHTML = result; }
    OpenjQueryPopup('SearchTypeInfo');
}
/** Seat Reservation Search Result **/
function SeatReservationDisplay() {
    window.setTimeout("SearchResultPriceDisplay('Price')", 1000);
}
/** Search By Price Tab Color Changes **/
function defaultPriceTabSelection() {
    PriceTabColorChanges();
    SearchResultPriceDisplay('Price');
}
/** Search By Flexible Color Changes **/
function defaultFlexibleTabSelection() {
    FlexiTabColorChanges();
    SearchResultFlexibleDisplay('Flexibility');
}
/** Color Changes in Price tab level **/
function PriceTabColorChanges() {
    $get('dvFlexibilityTab').style.backgroundColor = "#FFFFFF";
    $get('dvPriceTab').style.backgroundColor = "#2F8BD0";
    $get('lnkFlexibilityTab').style.color = "#000000";
    $get('lnkPriceTab').style.color = "#FFFFFF";
}
/** Color Changes in Flexi tab level **/
function FlexiTabColorChanges() {
    $get('dvFlexibilityTab').style.backgroundColor = "#2F8BD0";
    $get('dvPriceTab').style.backgroundColor = "#FFFFFF";
    $get('lnkFlexibilityTab').style.color = "#FFFFFF";
    $get('lnkPriceTab').style.color = "#000000";
}

/** Search By Price Result **/
function showPriceGrid() {
    PriceTabColorChanges();
    jQuery('#dvSearchResultGridFlexible').hide();
    InsertEventLog(1, 0, jQuery('.hdnLoggedUserName').val(), false);
    DisplayPrice();
}
/** Hide and Display div for Price Display **/
function DisplayPrice() {
    jQuery('.hdnUserSelectedSearchOption').val('Price');
    jQuery('.hdnUserSelectedSearchOption').val('Price');
    if ($get('dvSearchResultGridPrice').innerHTML == '') {
        InterestialPageDisplay();
        SearchResultPriceDisplay('Price');
    }
    else {
        jQuery('#dvSearchResultGridPrice').show();
    }
}
/** Loading Search by Price Result **/
function SearchResultPriceDisplay(SearchType) {
    RailEurope.HTMLService.SearchResultGridDisplay("dvSearchResultGridPrice", SearchType, "Outbound", OnSearchSucceededSearchResultPriceDisplay);
}
function OnSearchSucceededSearchResultPriceDisplay(result) {
    jQuery('.hdnUserSelectedSearchOption').val('Price');
    if ($get('dvInterestial').style.display == '') {
        $get('dvInterestial').style.display = 'none';
    }
    if (result == null || result == '') {        
        window.location.href = "/Default.aspx?tabid=112";
    }
    if (result != null) {
        jQuery('#dvSearchResultGridPrice').show();
        jQuery('#dvSearchResultGridFlexible').hide();
        jQuery('#dvSearchResultGridPrice').html(result);
        //alert(jQuery('#dvSearchResultGridPrice').find('#legInfoContainer').length); 
        /**  No Records Found **/
        if (jQuery('#dvSearchResultGridPrice').find('#legInfoContainer').length <= 0) {
            window.location.href = "/Default.aspx?tabid=112";
        }
    }
}
/** Back to Price from Flexi PopUp **/
function showPriceGridFromFlexiPopUp() {
    PriceTabColorChanges();
    jQuery('#dvSearchResultGridFlexible').hide();
    InsertEventLog(1, 2, jQuery('.hdnLoggedUserName').val(), false);
    DisplayPrice();
}
/** Search By Flexible Result **/
function ShowFlexibileGrid() {
    FlexiTabColorChanges();
    jQuery('#dvSearchResultGridPrice').hide();
    InsertEventLog(2, 0, jQuery('.hdnLoggedUserName').val(), false);
    DisplayFlexible();
}
/** Hide and Display div for Flexi Display **/
function DisplayFlexible() {
    jQuery('.hdnUserSelectedSearchOption').val('Flexibility');
    if ($get('dvSearchResultGridFlexible').innerHTML == '') {
        InterestialPageDisplay();
        SearchResultFlexibleDisplay('Flexibility');
    }
    else {
        jQuery('#dvSearchResultGridFlexible').show();
    }
}
/** Back to Flexi from Price PopUp **/
function showFlexiGridFromPricePopUp() {
    FlexiTabColorChanges();
    jQuery('#dvSearchResultGridPrice').hide();
    InsertEventLog(2, 1, jQuery('.hdnLoggedUserName').val(), false);
    DisplayFlexible();
}
/** Loading Search by Flexible Result **/
function SearchResultFlexibleDisplay(SearchType) {
    RailEurope.HTMLService.SearchResultGridDisplay("dvSearchResultGridFlexible", SearchType, "Outbound", OnSearchSucceededSearchResultFlexibleDisplay);
}
function OnSearchSucceededSearchResultFlexibleDisplay(result) {
    jQuery('.hdnUserSelectedSearchOption').val('Flexibility');
    if ($get('dvInterestial').style.display == '') {
        $get('dvInterestial').style.display = 'none';
    }
    if (result == null || result == '') {
        window.location.href = "/Default.aspx?tabid=112";
    }
    if (result != null) {
        jQuery('#dvSearchResultGridFlexible').show();
        jQuery('#dvSearchResultGridPrice').hide();
        jQuery('#dvSearchResultGridFlexible').html(result);
        /**  No Records Found **/
        if (jQuery('#dvSearchResultGridFlexible').find('#legInfoContainer').length <= 0) {
            window.location.href = "/Default.aspx?tabid=112";
        }
    }
}
/** Selected Price Journey PopUp**/
function SelectedPriceExpandedJourney(SelectedSolutionId, SelectedSolutionIndex, isReturnSearchResult, CheapestSolutionPrice) {
    OpenjQuery947Popup('dvPopUpInterestialPage');
    SelectedPriceJourney(SelectedSolutionId, SelectedSolutionIndex, isReturnSearchResult, CheapestSolutionPrice)
}
/** Selected Package Price **/
function SelectedPriceExpandedJourneyWithSleeperOptions(SelectedSolutionId, SelectedSolutionIndex, isReturnSearchResult, CheapestSolutionPrice, IsTravellingWithin7Days, IsTODBasketEmpty) {

    if (CheapestSolutionPrice == 0 && IsTravellingWithin7Days == 'True' && IsTODBasketEmpty == 'True') {
        ClosejQueryPopup('dvPopUpInterestialPage');
        OpenjQueryPopup('dvZeroPrice');
    }
    else {
        RailEurope.HTMLService.GetSearchByPriceExpandedJournetDetails("dvExpandedResultPopup", SelectedSolutionId, SelectedSolutionIndex, isReturnSearchResult, OnSearchInfoSucceededExpandedJourney);
    }
}

/** Selected Flexible Journey PopUp**/
function SelectedFlexibilityExpandedJourney(SelectedSolutionId, SelectedSolutionIndex, isReturnSearchResult) {
    OpenjQuery947Popup('dvPopUpInterestialPage');
    SelectedFlexibilityJourney(SelectedSolutionId, SelectedSolutionIndex, isReturnSearchResult);
}
/** Selected Flexible Package Fare **/
function SelectedFlexibilityJourney(SelectedSolutionId, SelectedSolutionIndex, isReturnSearchResult) {
    RailEurope.HTMLService.GetSearchByFlexibilityExpandedJournetDetails("dvExpandedResultPopup", SelectedSolutionId, SelectedSolutionIndex, isReturnSearchResult, OnSearchInfoSucceededExpandedJourney);
}
function OnSearchInfoSucceededExpandedJourney(result) {
    if (result != null) {
        jQuery('#dvExpandedResultPopup').html(result);
        OpenjQuery947Popup('dvExpandedResultPopup');
        ClosejQueryPopup('dvPopUpInterestialPage');
    }
}
// Selected Price Grid PopUp
function BackToSearchByPriceFocus(divId) {
    ClosejQueryPopup(divId);
    showPriceGridFromFlexiPopUp();
}
// Selected Flexible Grid PopUp
function BackToSearchByFlexibleFocus(divId) {
    ClosejQueryPopup(divId);
    showPriceGridFromFlexiPopUp();
}
/** Calling Search Event Log Method **/
function InsertEventLog(eventType, eventRaisedFrom, LoggedUserName, isPaid) {
    RailEurope.HTMLService.InsertSearchEventLog(eventType, eventRaisedFrom, LoggedUserName, isPaid);
}

/** Ineterstial Page **/
function InterestialPageDisplay() {
    jQuery('#dvInterestial').show();
    jQuery('#dvSearchResultGridPrice').hide();
    jQuery('#dvSearchResultGridFlexible').hide();
}
/** Earlier and Later Train **/
function EarlierLaterSearchTrain(EalierLaterType) {
    var SearchType = jQuery('.hdnUserSelectedSearchOption').val();
    if (SearchType == 'Price') {
        RailEurope.HTMLService.EarlierLaterSearchTrainGridDisplay("dvSearchResultGridPrice", SearchType, EalierLaterType, OnSearchSucceededSearchResultEarlierLaterPriceDisplay);
    }
    else {
        RailEurope.HTMLService.EarlierLaterSearchTrainGridDisplay("dvSearchResultGridFlexible", SearchType, EalierLaterType, OnSearchSucceededSearchResultEarlierLaterFlexibleDisplay);
    }
}
function ShowWaitPageForSearchResults() {
    DisplayImageORFlash();
    jQuery('#waitPageContainer').show();
    window.scroll(0, 0);
}
function HideWaitPageForSearchResults() {
    jQuery('#waitPageContainer').hide();
}
function EarlierLaterSearchTrainGridDisplay(EalierLaterType) {
    ShowWaitPageForSearchResults();
    EarlierLaterSearchTrain(EalierLaterType)
}
function OnSearchSucceededSearchResultEarlierLaterPriceDisplay(result) {
    if (result != null) {
        HideWaitPageForSearchResults();
        var tabId;
        switch (result) {
            case 101:
                SearchResultPriceDisplay('Price');
                break;
            case 111:
                window.location.href = "/Default.aspx?tabid=111";
                break;
        }
    }
}
function OnSearchSucceededSearchResultEarlierLaterFlexibleDisplay(result) {
    if (result != null) {
        HideWaitPageForSearchResults();
        var tabId;
        switch (result) {
            case 101:
                SearchResultFlexibleDisplay('Flexibility');
                break;
            case 111:
                window.location.href = "/Default.aspx?tabid=111";
                break;
        }
    }
}
/** Choose Package Fare **/
function ChoosePricePackageFare(SolutionId, SolutionIndex, isReturnSearchResult, PackageId, ShowGenderOption, SearchOption) {

    if (ShowGenderOption == 'false' || ShowGenderOption == 'False') {
        ChoosePricePackageFareWithGenderOption(SolutionId, SolutionIndex, isReturnSearchResult, PackageId, ShowGenderOption, SearchOption, null);
        ShowWaitPageForEarlierLaterOption();
        //RailEurope.HTMLService.GetSleeperNightPopUp("DvSleeperPricePopUp", SolutionId, SolutionIndex, isReturnSearchResult, PackageId, ShowGenderOption, SearchOption, OnSearchSucceededPriceGetSleeperNightPopUp);            
    }
    else {
        RailEurope.HTMLService.GetSleeperNightPopUp("DvSleeperPricePopUp", SolutionId, SolutionIndex, isReturnSearchResult, PackageId, ShowGenderOption, SearchOption, OnSearchSucceededPriceGetSleeperNightPopUp);
    }


}
// Overnight Sleeper Option 
function OnSearchSucceededPriceGetSleeperNightPopUp(result) {

    if (result != null) {
        jQuery('#DvSleeperPricePopUp').empty();
        jQuery('#DvSleeperPricePopUp').html(result);
    }
    OpenjQuery621Popup('DvSleeperPricePopUp');
}
// Overnight Sleeper Option gender option Update in session
function ChoosePricePackageFareWithGenderOption(SolutionId, SolutionIndex, isReturnSearchResult, PackageId, ShowGenderOption, SearchOption, GenderBookingCode) {
    if (GenderBookingCode != null) {
        RailEurope.Validation.ValidationService.PackageFareSelection(PackageId, isReturnSearchResult, SearchOption, GenderBookingCode, OnSearchSucceededChoosePackageFare);
        ClosejQueryPopup('DvSleeperPricePopUp');
    }
    else {
        RailEurope.Validation.ValidationService.PackageFareSelection(PackageId, isReturnSearchResult, SearchOption, GenderBookingCode, OnSearchSucceededChoosePackageFare);
    }
}

/** Search Grid Sorting **/
function SortSearchResultDiv(sortBy, solutions, sortedSearchResultDiv) {
    var sorted;
    switch (sortBy) {
        case 'TIME|ASC':
            sorted = jQuery(solutions).sort(function (a, b) {
                if (a.time == b.time) {
                    return 0;
                }
                return (a.time < b.time ? 1 : -1) * -1;
            });
            break;
        case 'TIME|DESC':
            sorted = jQuery(solutions).sort(function (a, b) {
                if (a.time == b.time) {
                    return 0;
                }
                return (a.time > b.time ? 1 : -1) * -1;
            });
            break;
        case 'CHEAPESTPRICE|ASC':
            sorted = jQuery(solutions).sort(function (a, b) {
                if (a.cheapestPrice == b.cheapestPrice) {
                    return 0;
                }
                return (a.cheapestPrice < b.cheapestPrice ? 1 : -1) * -1;
            });
            break;
        case 'MOSTEXPENSIVEPRICE|DESC':
            sorted = jQuery(solutions).sort(function (a, b) {
                if (a.cheapestPrice == b.cheapestPrice) {
                    return 0;
                }
                return (a.cheapestPrice > b.cheapestPrice ? 1 : -1) * -1;
            });
            break;
    }
    jQuery(sorted).each(function (index, item) {
        item.html = '<DIV class="sl" id=' + item.slId + '>' + jQuery('#' + item.slId).html() + '</div>';
    });

    jQuery(sortedSearchResultDiv).empty();

    jQuery(sorted).each(function (index, item) {
        jQuery(sortedSearchResultDiv).append(item.html);
    });
}

function SortSearchResult(option) {
    //TODO
    var solutions;
    SearchOption = jQuery('.hdnUserSelectedSearchOption').val();
    //alert(SearchOption);
    switch (SearchOption) {
        case 'Price':
            solutions = solPrice;
            break;
        case 'Flexibility':
            solutions = solFlexibility;
            break;
        default:
            alert('Search criteria mismatch found.');
            return;
    }

    var sortedSearchResultDiv = '#sortedSearchResult' + SearchOption + '';
    var sortBy = option.value;
    SortSearchResultDiv(sortBy, solutions, sortedSearchResultDiv);
}

function SortDivsBasedOnOrder() {
    var topDiv = '#divPaymentFloatingOptions';
    if (divContent != null || typeof (divContent) != 'undefined') {
        SortDivs(divContent, topDiv);
    }
}

function SortDivs(divCommonContent, topDiv) {
    var sorted;
    sorted = jQuery(divCommonContent).sort(function (a, b) {
        if (a.order == b.order) {
            return 0;
        }
        return (a.order < b.order ? 1 : -1) * -1;
    });
    jQuery(sorted).each(function (index, item) {
        item.html = '<DIV id=' + item.divId + '>' + jQuery('#' + item.divId).html() + '</div>';
        if (jQuery('#' + item.divId).html() == null) {
            item.html = '<DIV style="display:none" id=' + item.divId + '>' + jQuery('#' + item.divId).html() + '</div>';
        }

    });
    jQuery(topDiv).empty();
    jQuery(sorted).each(function (index, item) {
        jQuery(topDiv).append(item.html);
    });

}

function SortDivsLoggedInUser() {
    var divId = '#divPaymentLoggedInUser';

    if (divLoggedInContent != null || typeof (divLoggedInContent) != 'undefined') {
        SortDivs(divLoggedInContent, divId);
    }
}
//window.location.href = "#" + "divBasketTotalLink";

/** Choose package fare with sleeper Option from Flexible**/
function ChooseFlexiblePackageFare(SolutionId, SolutionIndex, isReturnSearchResult, PackageId, ShowGenderOption, SearchOption) {
    if (ShowGenderOption == 'false' || ShowGenderOption == 'False') {
        ChoosePackageFareFlexibleWithGenderOption(SolutionId, SolutionIndex, isReturnSearchResult, PackageId, ShowGenderOption, SearchOption, null);
        ShowWaitPageForEarlierLaterOption();
    }
    else {
        RailEurope.HTMLService.GetSleeperNightPopUp("DvSleeperFlexibleInbound", SolutionId, SolutionIndex, isReturnSearchResult, PackageId, ShowGenderOption, SearchOption, OnSearchSucceededFlexibleGetSleeperNightPopUp);
    }
}
function ChoosePackageFareFlexibleWithGenderOption(SolutionId, SolutionIndex, isReturnSearchResult, PackageId, ShowGenderOption, SearchOption, GenderBookingCode) {

    if (GenderBookingCode != null) {
        RailEurope.Validation.ValidationService.PackageFareSelection(PackageId, isReturnSearchResult, SearchOption, GenderBookingCode, OnSearchSucceededChoosePackageFare);
        ClosejQueryPopup('DvSleeperFlexibleInbound');
    }
    else {
        RailEurope.Validation.ValidationService.PackageFareSelection(PackageId, isReturnSearchResult, SearchOption, GenderBookingCode, OnSearchSucceededChoosePackageFare);
        ShowWaitPageForEarlierLaterOption();
    }
}
/** Navigate to proper page after selected package fare **/
function OnSearchSucceededChoosePackageFare(result) {
    ClosejQueryPopup('dvExpandedResultPopup');
    ShowWaitPageForEarlierLaterOption();
    window.location.href = "/Default.aspx?tabid=" + parseInt(result, 0) + "";
}
/** Navigate to proper page after selected package fare from sleeper options**/
function OnSearchSucceededFlexibleGetSleeperNightPopUp(result) {
    if (result != null) {
        jQuery('#DvSleeperFlexibleInbound').empty();
        jQuery('#DvSleeperFlexibleInbound').html(result);
    }
    OpenjQuery621Popup('DvSleeperFlexibleInbound');
}
// Search Option Info Icon Help
function ShowFlexibleTypeHelp(TypeIndex) {
    RailEurope.HTMLService.GetFlexibleTypeHelpInformation("dvFlexibleInfoSearch", parseInt(TypeIndex), OnSearchFlexibleTypeHelpSucceeded);
}
function OnSearchFlexibleTypeHelpSucceeded(result) {
    if (result != null) { $get('dvFlexibleInfoSearch').innerHTML = result; }
    OpenjQuery621Popup('dvFlexibleInfoSearch');
}
// Common Small PopUp 
function OpenSellingTextPopup(Params) {
    RailEurope.HTMLService.GetSellingText("dvSellingTextPopUp", Params, OnSellingTextsucceeded);
}
function OnSellingTextsucceeded(result) {
    if (result != null) {
        jQuery('#dvSellingTextPopUp').html(result);
    }
    OpenjQuery621Popup('dvSellingTextPopUp');
}
function OpenSearchByPriceFareConditionPopup(Params) {
    RailEurope.HTMLService.GetFareConditionsText("dvFareConditionPopUp", Params, OnFareConditionsucceeded);
}
function OnFareConditionsucceeded(result) {
    if (result != null) {
        jQuery('#dvFareConditionPopUp').html(result);
    }
    OpenjQuery621Popup('dvFareConditionPopUp');
}
function SelectedPriceColorChange(divId) {
    if (jQuery.browser.msie &&
        jQuery.browser.version != 9.0 &&
        jQuery(divId).text().length > 0) {
        if (jQuery(divId).hasClass('SelectedFare')) {
        }
        else {
            jQuery(divId).addClass("mouseOverSelectedFare");
        }
    }
    else if (jQuery.browser.msie &&
        jQuery.browser.version == 9.0 &&
        jQuery(divId).text().length > 83) {
        if (jQuery(divId).hasClass('SelectedFare')) {
        }
        else {
            jQuery(divId).addClass("mouseOverSelectedFare");
        }
    }
    else if (jQuery(divId).text().length > 83) {
        if (jQuery(divId).hasClass('SelectedFare')) {
        }
        else {
            jQuery(divId).addClass("mouseOverSelectedFare");
        }
    }

}

function SelectedPriceColorRevert(divId) {
    if (jQuery.browser.msie && jQuery(divId).text().length > 0) {
        if (jQuery(divId).hasClass('mouseOverSelectedFare')) {
            jQuery(divId).removeClass('mouseOverSelectedFare');
        }
    }
    else if (jQuery(divId).text().length > 83) {
        if (jQuery(divId).hasClass('mouseOverSelectedFare')) {
            jQuery(divId).removeClass('mouseOverSelectedFare');
        }
    }
}

function CloseMediumSizejQueryPopup(a) {
    a = "div#" + a;
    jQuery(a).dialog("close")
};
/** RELCRS-31 Big Size PopUp jQuery fn **/
/** function OpenjQuery947Popup(a) {
a = "div#" + a; jQuery(a).dialog(
{
bgiframe: true, width: 947, modal: true, autoOpen: true, resizable: false,
zIndex: 100009, closeOnEscape: true,
show: 'blind',
hide: 'explode',
open: function (type, data) {
jQuery(this).parent().appendTo('form');
}
});
jQuery(a).dialog("open");
} **/

function OpenjQuery947Popup(a) {
    b = 'div#' + a;
    jQuery(b).dialog({
        bgiframe: true,
        width: 947,
        modal: true,
        autoOpen: false,
        resizable: false,
        zIndex: 100009,
        closeOnEscape: false,
        open: function (type, data) { jQuery(this).parent().appendTo('form'); }
    });
    jQuery(b).dialog('open');
    iPopUpCount = 1;
}

/** RELCRS-31 Medium Size PopUp jQuery fn **/
function OpenjQuery621Popup(a) {
    a = "div#" + a; jQuery(a).dialog({
        bgiframe: true, width: 621,
        modal: true, autoOpen: true,
        resizable: false, zIndex: 100009,
        closeOnEscape: false,
        draggable: true,
        dialogClass: '',
        open: function (type, data) {
            jQuery(this).parent().appendTo('form');
        }
    });
    jQuery(a).dialog("open")
    iPopUpCount = 2;

    /** jQuery(a).keydown(function (event) {
    if (jQuery(a).hasOpenDialogs() &&
    event.keyCode &&
    event.keyCode === jQuery.ui.keyCode.ESCAPE) {
    jQuery(jQuery(a)).dialog("close");
    event.preventDefault();

    event.stopPropagation();
    }
    }); **/

}

/** Sleeper Logic **/
function SetMaleGender(value) {
    document.getElementById('lblMaleGender').value = value;
}

function SetFemaleGender(value) {
    document.getElementById('lblFemaleGender').value = value;
}

function TogglePageRedirection(stopRedirection) {
    var criteria = "a";
    jQuery(criteria).die("click"); //To avoid rebinding on postaback

    if (stopRedirection) {
        jQuery(criteria).live('click', function (e) {
            alert("Please wait your request is in process.");
            e.preventDefault;
            return false;
        });
    }
}
function BackToOutBoundResult() {
    window.location.href = "/Default.aspx?tabid=101#divBasketTotalLink";
}
// THis fn for closing the popup using esc key
jQuery(document).keyup(function (e) {
    if (e.keyCode == 27) {
        switch (iPopUpCount) {
            case 1:
                ClosejQueryPopup('#dvExpandedResultPopup');
                ClosejQueryPopup('#dvSelectedTripDetails');
                ClosejQueryPopup('#dvPassengerDOBDetails');
                ClosejQueryPopup('#dvBasketBookingFormPopUp');
                ClosejQueryPopup('#deliveryTypeInfo');
                ClosejQueryPopup('#dvEmptyBasketBookingFormPopUp');
                ClosejQueryPopup('#divShippingInfo');
                ClosejQueryPopup('#dvPassInformation');
                for (var i = 0; i < 10; i++) {
                    ClosejQueryPopup('#divReservationBookingForm' + i);
                }
                break;
            case 2:
                ClosejQueryPopup('#dvSellingTextPopUp');
                ClosejQueryPopup('#DvSleeperFlexibleInbound');
                ClosejQueryPopup('#dvFlexibleInfoSearch');
                ClosejQueryPopup('#DvSleeperPricePopUp');
                ClosejQueryPopup('#dvSellingTextPopUp');
                ClosejQueryPopup('#dvFareConditionPopUp');
                ClosejQueryPopup('#dvConnectionTimePopUp');
                iPopUpCount = 1;
                break;
        }
    }
});
function OpenConnectionTimePopup(divId) {
    RailEurope.HTMLService.GetConnectionTimesText(divId, OpenConnectionTimeSucceeded);
}

function OpenConnectionTimeSucceeded(result) {
    if (result != null)
        $get('dvConnectionTimePopUp').innerHTML = result;
    OpenjQuery621Popup('dvConnectionTimePopUp');
}
function OpenSelectedTripDetails(divId) {
    RailEurope.HTMLService.GetSelectedTripDetails(divId, OpenGetSelectedTripDetailsSucceeded);
}
function OpenGetSelectedTripDetailsSucceeded(result) {
    if (result != null)
        $get('dvSelectedTripDetails').innerHTML = result;
    OpenjQuery947Popup('dvSelectedTripDetails');
}
function eTicketsOptionsSelected() {
    ShowWaitPage();
}
function ValidateEmailAddress(controlID) {

    if ((controlID.value == null) || (controlID.value == "")) {
        alert("Please Enter your Email ID")
        controlID.focus();
        return false
    }

    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if (reg.test(controlID.value) == false) {
        alert('Invalid Email Address');
        controlID.focus();
        return false;
    }
    return true
}

function OpenSeatreservationInformation(divId) {
    RailEurope.HTMLService.GetSeatreservationInformation(divId, OnOpenSeatreservationInformationSucceeded);
}
function OnOpenSeatreservationInformationSucceeded(result) {
    if (result != null)
        $get('dvBasketBookingFormPopUp').innerHTML = result;
    OpenjQuery947Popup('dvBasketBookingFormPopUp');
}

function OpenGetSelectedPTPDetails(divId) {
    RailEurope.HTMLService.GetSelectedPTPDetails(divId, OnGetSelectedPTPDetailsSuccess);
}
function OnGetSelectedPTPDetailsSuccess(result) {
    if (result != null) {
        jQuery('#dvSelectedPTPDetails').html(result);
        OpenjQuery947Popup('dvSelectedPTPDetails');
    }
}
