﻿// Name:        BookingControls.BookingResultContainer.BookingResultContainer.debug.js
// Assembly:    BookingControls
// Version:     1.0.0.0
// FileVersion: 1.0.0.0

/// <reference name="MicrosoftAjax.js"/>
/// <reference path="AjaxControlToolkit/ExtenderBase/BaseScripts.js" />
/// <reference path="AjaxControlToolkit/Common/Common.js" />
/// <reference path="AjaxControlToolkit/DragPanel/FloatingBehavior.js" />

Type.registerNamespace("BookingControls");
/* =============================================== SortField =============================================== */
BookingControls.SortField = function() { };
BookingControls.SortField.prototype = {
    None : 0x00,
    Title : 0x01,
    Price : 0x02,
    Commune : 0x03,
    Classement : 0x04,
    Distance : 0x05,
    Pertinence : 0x06
};
BookingControls.SortField.registerEnum("BookingControls.SortField", true);
/* =============================================== FilterField =============================================== */
BookingControls.FilterField = function() { };
BookingControls.FilterField.prototype = {
    None : 0x00,
    Price : 0x01,
    Service : 0x02
};
BookingControls.FilterField.registerEnum("BookingControls.FilterField", true);
/* =============================================== BookingResultContainer =============================================== */
BookingControls.BookingResultContainer = function(element) {

    BookingControls.BookingResultContainer.initializeBase(this, [element]);
    /* ------------------------------------------- Constants ------------------------------------ */
    this._MARKER_IMAGEURL_ADDON = 'http://maps.google.fr/mapfiles/ms/micons/yellow.png'
    this._MARKER_IMAGEURL = 'App_Themes/Default/Images/marker.png';
    this._MARKER_IMAGEURL_OVER = 'App_Themes/Default/Images/marker-over.png';
    this._MARKER_IMAGEURL_CENTER = 'App_Themes/Default/Images/marker-selected.png';
    this._MARKER_IMAGEURL_CENTER_OVER = 'App_Themes/Default/Images/marker-selected-over.png';
    /* ------------------------------------------- Variables ------------------------------------ */
    this._results = null;
    this._filteredResults = null;
    this._pageIndex = 0;
    this._pageSize = 10;
    this._totalCount = 0;
    this._sortField = BookingControls.SortField.None;
    this._sortAsc = true;
    this._sortServer = null;
    this._filterPrice = null;
    this._filterService = null;
    this._filterServiceData = null;
    this._googleMapsKey = null;
    this._resumeSearch = null;
    this._autoPostBackId = null;
    this._filteredServicesContainer = null;
    this._geoRefX = 0;
    this._geoRefY = 0;
    this._searchOiType = null;
    this._cartState = null;
    this._dynamicServicePath = null;
    this._isJQueryUIVersion = null;

    this._loaded = false;
    this._resultCarto = null;
    this._dragBehavior = null;
    this._resizeBehavior = null;
    this._mapScriptLoaded = false;
    this._map = null;
    this._mapBounds = null;
    this._filterServices = [
        { code: "b30a259f-5a42-42a8-b55d-f2a72a608d46", name: BookingControls.Resources.filterService0, classname: "service_0", alias: "piscine", hot: true, loc: true, camp: true, ls: false, lc: false, mpc: false },
        { code: "3de29232-a6d6-4234-a48a-071e4f3fe866", name: BookingControls.Resources.filterService1, classname: "service_1", alias: "sallesport", hot: true, loc: false, camp: true, ls: false, lc: false, mpc: false },
        { code: "e52cc53b-4c49-439e-90fb-bc20d409bb91", name: BookingControls.Resources.filterService2, classname: "service_2", alias: "roomservice", hot: false, loc: false, camp: false, ls: false, lc: false, mpc: false },
        { code: "0c6062bb-2c03-4d3e-bc20-feb9ba9d1e92", name: BookingControls.Resources.filterService3, classname: "service_3", alias: "parking", hot: true, loc: true, camp: true, ls: true, lc: true, mpc: true },
        { code: "b5e54bf3-1b74-41c1-98dc-2ef03597415c", name: BookingControls.Resources.filterService4, classname: "service_4", alias: "climatisation", hot: true, loc: true, camp: false, ls: false, lc: false, mpc: false },
        { code: "684bb5cd-9533-452d-9013-5d0ffd1df037", name: BookingControls.Resources.filterService5, classname: "service_5", alias: "internet", hot: true, loc: true, camp: true, ls: false, lc: false, mpc: false },
        { code: "d3318624-6891-4446-90b7-1ba2936cb6ce", name: BookingControls.Resources.filterService6, classname: "service_6", alias: "restaurant", hot: true, loc: false, camp: true, ls: false, lc: false, mpc: false },
        { code: "3b794b55-dc5d-4bbd-a2aa-10f353a7f2db", name: BookingControls.Resources.filterService7, classname: "service_7", alias: "cafe-bar", hot: true, loc: false, camp: true, ls: false, lc: false, mpc: false },
        { code: "7562d1c1-237f-4cdf-8eb9-d99a24a9889b", name: BookingControls.Resources.filterService8, classname: "service_8", alias: "animaux", hot: true, loc: true, camp: true, ls: false, lc: false, mpc: false },
        { code: "3ee258f7-6beb-42bc-af95-11ee9f846fa7", name: BookingControls.Resources.filterService9, classname: "service_9", alias: "acceshandi", hot: true, loc: true, camp: true, ls: true, lc: true, mpc: true },
        { code: "e67a42ad-b9b1-4f1d-952e-76527882767a", name: BookingControls.Resources.filterService10, classname: "service_10", alias: "disco", hot: true, loc: false, camp: true, ls: false, lc: false, mpc: false },
        { code: "c5722d10-d6f4-4ab3-93ba-b602dddc5be4", name: BookingControls.Resources.filterService11, classname: "service_11", alias: "chauffage", hot: false, loc: true, camp: false, ls: false, lc: false, mpc: false },
        { code: "e5817d3f-93b8-44a3-8003-6bcee86a7004", name: BookingControls.Resources.filterService12, classname: "service_12", alias: "cheminee", hot: false, loc: true, camp: false, ls: false, lc: false, mpc: false },
        { code: "e79796c4-4ef0-4cb9-8a21-573c0bae7f77", name: BookingControls.Resources.filterService13, classname: "service_13", alias: "garage", hot: false, loc: true, camp: false, ls: false, lc: false, mpc: false },
        { code: "919c9c01-15fa-4f9c-9213-8524ba0c4faf", name: BookingControls.Resources.filterService14, classname: "service_14", alias: "jardin", hot: false, loc: true, camp: false, ls: false, lc: false, mpc: false },
        { code: "ecb403eb-e011-417d-9bb8-f56d41197be2", name: BookingControls.Resources.filterService15, classname: "service_15", alias: "sallebainprivee", hot: false, loc: true, camp: false, ls: false, lc: false, mpc: false },
        { code: "9217c25f-3809-43f2-9d99-011039d04f4a", name: BookingControls.Resources.filterService16, classname: "service_16", alias: "commalim", hot: false, loc: false, camp: true, ls: false, lc: false, mpc: false },
        { code: "c65a5849-ccd2-4cea-945f-d36ba93acd70", name: BookingControls.Resources.filterService17, classname: "service_17", alias: "babyclub", hot: false, loc: false, camp: true, ls: false, lc: false, mpc: false },
        { code: "9946f8cf-5f6e-48f1-a9b1-bc2bdd8dadbe", name: BookingControls.Resources.filterService18, classname: "service_18", alias: "clubenfant", hot: false, loc: false, camp: true, ls: false, lc: false, mpc: false }
    //{ code: "9946f8cf-5f6e-48f1-a9b1-bc2bdd8dadbe", name: BookingControls.Resources.filterService19, classname: "service_19", alias: "piscinechauffee", hot: false, loc: false, camp: true, ls: false, lc: false, mpc: false }
    ];
    this._filterServiceCodes = [
        "b30a259f-5a42-42a8-b55d-f2a72a608d46",
        "3de29232-a6d6-4234-a48a-071e4f3fe866",
        "e52cc53b-4c49-439e-90fb-bc20d409bb91",
        "0c6062bb-2c03-4d3e-bc20-feb9ba9d1e92",
        "b5e54bf3-1b74-41c1-98dc-2ef03597415c",
        "684bb5cd-9533-452d-9013-5d0ffd1df037",
        "d3318624-6891-4446-90b7-1ba2936cb6ce",
        "3b794b55-dc5d-4bbd-a2aa-10f353a7f2db",
        "7562d1c1-237f-4cdf-8eb9-d99a24a9889b"];
    this._filterServiceNames = [
        BookingControls.Resources.filterService0,
        BookingControls.Resources.filterService1,
        BookingControls.Resources.filterService2,
        BookingControls.Resources.filterService3,
        BookingControls.Resources.filterService4,
        BookingControls.Resources.filterService5,
        BookingControls.Resources.filterService6,
        BookingControls.Resources.filterService7,
        BookingControls.Resources.filterService8
        ];
    this._filterServiceIconsOn = [
        "services_piscine_on.png",
        "services_sallesport_on.png",
        "servives_roomservice_on.png",
        "services_parking_on.png",
        "services_climatisation_on.png",
        "services_internet_on.png",
        "services_restaurant_on.png",
        "services_cafe-bar_on.png",
        "services_animaux_on.png"
        ];
    this._filterServiceIconsOff = [
        "services_piscine_off.png",
        "services_sallesport_off.png",
        "servives_roomservice_off.png",
        "services_parking_off.png",
        "services_climatisation_off.png",
        "services_internet_off.png",
        "services_restaurant_off.png",
        "services_cafe-bar_off.png",
        "services_animaux_off.png"
        ];
    this._resultServices = null;
    this._resultResumeSearch = null;
    this._cartoVisible = false;
    this._resultPageWait = null;
    this._resultsAddons = null;
    this._needReload = false;

    this._app_onload$delegate = Function.createDelegate(this, this._app_onload);
    this._result_oncartoclicked$delegate = Function.createDelegate(this, this._result_oncartoclicked);
    this._result_oncartopopulated$delegate = Function.createDelegate(this, this._result_oncartopopulated);
    this._carto_onclose$delegate = Function.createDelegate(this, this._carto_onclose);
    this._carto_onresize$delegate = Function.createDelegate(this, this._carto_onresize);
    this._carto_onloaded$delegate = Function.createDelegate(this, this._carto_onloaded);
    this._result_onbuildmodechanged$delegate = Function.createDelegate(this, this._result_onbuildmodechanged);
    this._onfilterservices$delegate = Function.createDelegate(this, this._onfilterservices);
};
BookingControls.BookingResultContainer.prototype = {
    /* ------------------------------------------- Properties ------------------------------------ */
    get_results: function() {
        if (this.isnull(this._results)) {
            this._results = [];
        }
        return this._results;
    },
    get_filteredResults: function() {
        if (this.get_sortServer() == true)
            return this.get_results();
        else if (this._filteredResults == null) {
            this.filterResults();
        }
        return this._filteredResults;
    },

    get_pageIndex: function() {
        return this._pageIndex;
    },
    set_pageIndex: function(value) {
        if (this._pageIndex != value) {
            if (value >= 0 && value < this.get_pageCount()) {
                var oldPageIndex = this._pageIndex;
                this._pageIndex = value;
                if (this._loaded) {
                    this.hidePageResults(oldPageIndex);
                    this.showPageResults();
                    this.raisePageChanged();
                }
                this.raisePropertyChanged("pageIndex");
            }
        }
    },

    get_pageSize: function() {
        return this._pageSize;
    },
    set_pageSize: function(value) {
        if (this._pageSize != value) {
            this._pageSize = value;
            this.raisePropertyChanged("pageSize");
        }
    },

    get_totalCount: function() {
        return this._totalCount;
    },
    set_totalCount: function(value) {
        if (this._totalCount != value) {
            this._totalCount = value;
            this.raisePropertyChanged("totalCount");
        }
    },

    get_resultCount: function() {
        if (this.get_sortServer() == false) {
            var results = this.get_filteredResults();
            return results.length;
        } else
            return this.get_totalCount();
    },
    get_pageCount: function() {
        var resultCount = this.get_totalCount();
        var pageCount = Math.floor(resultCount / this._pageSize);
        if (resultCount % this._pageSize > 0)
            pageCount++;
        return pageCount;
    },


    get_sortField: function() {
        return this._sortField;
    },
    set_sortField: function(value) {
        if (this._sortField != value) {
            this._sortField = value;
            //            if (this._loaded) {
            //                this.sortResults();
            ////                this.raiseSortChanged();
            ////                this._pageIndex = 0;
            ////                this.hideAllResults();
            ////                this.showPageResults();
            //            }
            this.raisePropertyChanged("sortField");
        }
    },

    get_sortAsc: function() {
        return this._sortAsc;
    },
    set_sortAsc: function(value) {
        if (this._sortAsc != value) {
            this._sortAsc = value;
            //            if (this._loaded) {
            //                this.sortResults();
            ////                this.raiseSortChanged();
            ////                this._pageIndex = 0;
            ////                this.hideAllResults();
            ////                this.showPageResults();
            //            }
            this.raisePropertyChanged("sortAsc");
        }
    },

    get_sortServer: function() {
        if (this.isnull(this._sortServer))
            this._sortServer = (this._totalCount > this.get_results().length);
        return this._sortServer;
    },
    set_sortServer: function(value) {
        if (this.isnull(this._sortServer) || this._sortServer != value) {
            this._sortServer = value;
            this.raisePropertyChanged("sortServer");
        }
    },

    get_filterPrice: function() {
        return this._filterPrice;
    },
    set_filterPrice: function(value) {
        if (this._filterPrice != value) {
            this._filterPrice = value;
            if (this._loaded) {
                this._pageIndex = -1;
                this._needReload = true;
                this.set_pageIndex(0);
                //                this._pageIndex = 0;
                //                this.hideAllResults();
                //                if (this.get_sortServer() == true) {
                //                    this._filteredResults = [];
                //                    this._results = [];
                //                    this._needReload = true;
                //                } else {
                //                    this.filterResults();
                this.raiseFilterChanged();
                //                }
                //                this.showPageResults();
            }
            this.raisePropertyChanged("filterPrice");
        }
    },

    get_googleMapsKey: function() {
        return this._googleMapsKey;
    },
    set_googleMapsKey: function(value) {
        if (this._googleMapsKey != value) {
            this._googleMapsKey = value;
            this.raisePropertyChanged("googleMapsKey");
        }
    },

    get_resumeSearch: function() {
        return this._resumeSearch;
    },
    set_resumeSearch: function(value) {
        if (this._resumeSearch != value) {
            this._resumeSearch = eval('(' + value + ')');
            this.raisePropertyChanged("resumeSearch");
        }
    },

    get_filteredServicesContainer: function() {
        return this._filteredServicesContainer;
    },
    set_filteredServicesContainer: function(value) {
        if (this._filteredServicesContainer != value) {
            this._filteredServicesContainer = value;
            this.raisePropertyChanged("filteredServicesContainer");
        }
    },

    get_filterServiceData: function() {
        return this._filterServiceData;
    },
    set_filterServiceData: function(value) {
        this._filterServiceData = eval('(' + value + ')');
        this.raisePropertyChanged("filterServiceData");
    },

    get_autoPostBackId: function() {
        return this._autoPostBackId;
    },
    set_autoPostBackId: function(value) {
        this._autoPostBackId = value;
    },

    get_geoRefX: function() {
        return this._geoRefX;
    },
    set_geoRefX: function(value) {
        if (this._geoRefX != value) {
            this._geoRefX = value.replace(',', '.');
            this.raisePropertyChanged("geoRefX");
        }
    },

    get_geoRefY: function() {
        return this._geoRefY;
    },
    set_geoRefY: function(value) {
        if (this._geoRefY != value) {
            this._geoRefY = value.replace(',', '.');
            this.raisePropertyChanged("geoRefY");
        }
    },

    get_cartState: function() {
        return this._cartState;
    },
    set_cartState: function(value) {
        if (this._cartState != value) {
            this._cartState = eval('(' + value + ')');
            this.raisePropertyChanged("cartState");
        }
    },

    get_searchOiType: function() {
        return this._searchOiType;
    },
    set_searchOiType: function(value) {
        if (this._searchOiType != value) {
            this._searchOiType = value;
            this.raisePropertyChanged("searchOiType");
        }
    },

    get_map: function() {
        if (!this._map && this._mapScriptLoaded)
            this._loadmap();
        return this._map;
    },

    is_IE: function() {
        return (Sys.Browser.agent == Sys.Browser.InternetExplorer);
    },

    get_GLatLng: function() {
        if (!this._mapScriptLoaded)
            return null;
        var x = this.get_geoRefX();
        var y = this.get_geoRefY();
        return (x != 0 || y != 0) ? new google.maps.LatLng(x, y) : null;
    },
    is_GeoPos: function() {
        var x = this.get_geoRefX();
        var y = this.get_geoRefY();
        return (x != 0 || y != 0);
    },

    get_dynamicServicePath: function() {
        return this._dynamicServicePath;
    },
    set_dynamicServicePath: function(value) {
        if (this._dynamicServicePath != value) {
            this._dynamicServicePath = value;
            this.raisePropertyChanged('dynamicServicePath');
        }
    },

    get_isJQueryUIVersion: function() {
        return this._isJQueryUIVersion;
    },
    set_isJQueryUIVersion: function(value) {
        if (this._isJQueryUIVersion != value) {
            this._isJQueryUIVersion = value;
            this.raisePropertyChanged('isJQueryUIVersion');
        }
    },


    /* ------------------------------------------- Methods ------------------------------------ */
    initialize: function() {
        BookingControls.BookingResultContainer.callBaseMethod(this, "initialize");
        var elt = this.get_element();
        this._results = [];
        $common.addCssClasses(elt, ["blocGlobalResultContainer"]);
        Sys.Application.add_load(this._app_onload$delegate);
    },

    dispose: function() {
        Sys.Application.remove_load(this._app_onload$delegate);
        if (this._mapScriptLoaded)
            google.maps.Unload();
        BookingControls.BookingResultContainer.callBaseMethod(this, "dispose");
    },

    saveClientState: function() {
        var state = {
            PageIndex: this._pageIndex
        };
        return Sys.Serialization.JavaScriptSerializer.serialize(state);
    },
    getPanierQuantite: function(idoffre, uniteIndex) {
        if (!this._cartState)
            return 0;
        for (var i = 0; i < this._cartState.length; i++)
            if (this._cartState[i].idOffre == idoffre && this._cartState[i].uniteIndex == uniteIndex)
            return this._cartState[i].quantite;
        return 0;
    },

    /* ------------------------------------------- Pagination ------------------------------------ */
    add_PageChanged: function(handler) {
        this.get_events().addHandler("pageChanged", handler);
    },
    remove_PageChanged: function(handler) {
        this.get_events().removeHandler("pageChanged", handler);
    },
    raisePageChanged: function() {
        var eh = this.get_events().getHandler("pageChanged");
        if (eh) {
            eh(this, Sys.EventArgs.Empty);
        }
    },

    showPageResults: function() {
        if (this.get_sortServer() == false) {
            this.showPageResults_Client();
        } else {
            //            var endindex = Math.min(this._totalCount, this._pageSize * (this._pageIndex + 1));
            //            if (this._needReload == true || endindex > this.get_results().length)
            if (this._needReload == true)
                this.populate_ServerPage();
            else
                this.showPageResults_Client();
        }
    },
    showPageResults_Client: function() {
        var results = this.get_filteredResults();
        var startindex = Math.max(0, this._pageSize * this._pageIndex);
        var endIndex = Math.min(startindex + this._pageSize, results.length);
        for (var i = startindex; i < endIndex; i++) {
            results[i]._show();
            if (!results[i]._isContentLoaded)
                results[i].add_populated(this._result_oncartopopulated$delegate);
        }
        this.showPageResultsCarto();
    },
    showPageResultsCarto: function() {
        var results = this.get_filteredResults();
        var startindex = Math.max(0, this._pageSize * this._pageIndex);
        var endIndex = Math.min(startindex + this._pageSize, results.length);
        this._clearBounds();
        for (var i = startindex; i < endIndex; i++) {
            if (results[i]._isContentLoaded)
                this._extendBounds(results[i], false);
        }
        var map = this.get_map();
        if (map) {
            map.checkResize();
            if (this._mapScriptLoaded) {
                this._showBounds();
            }
        }
        if (this._resultsAddons && this._resultsAddons._results) {
            for (var i = 0; i < this._resultsAddons._results.length; i++) {
                this._resultsAddons._results[i]._isAddon = true;
                if (!this._resultsAddons._results[i]._isContentLoaded)
                    this._resultsAddons._results[i].add_populated(this._result_oncartopopulated$delegate);
                else {
                    if (this._mapScriptLoaded)
                        this._resultsAddons._results[i].showMarker(map, true);
                    else
                        this.add_maploaded(this._resultsAddons._results[i]._owner_oncartoloaded$delegate);
                }
            }
        }
    },
    hidePageResults: function(pageIndex) {
        var results = this.get_filteredResults();
        var startindex = Math.max(0, this._pageSize * pageIndex);
        var endIndex = Math.min(startindex + this._pageSize, results.length);
        for (var i = startindex; i < endIndex; i++) {
            results[i]._hide();
            this.remove_maploaded(results[i]._owner_oncartoloaded$delegate);
        }
    },
    hideAllResults: function() {
        var results = this.get_results();
        for (var i = 0; i < results.length; i++) {
            results[i]._hide();
            this.remove_maploaded(results[i]._owner_oncartoloaded$delegate);
        }
    },

    pagePrev: function() {
        this._needReload = true;
        this.set_pageIndex(this._pageIndex - 1);
    },
    pageNext: function() {
        this._needReload = true;
        this.set_pageIndex(this._pageIndex + 1);
    },
    pageFirst: function() {
        this._needReload = true;
        this.set_pageIndex(0);
    },
    pageLast: function() {
        this._needReload = true;
        this.set_pageIndex(this.get_pageCount() - 1);
    },

    find_resultIndex: function(idoi) {
        for (var i = 0; i < this._results.length; i++) {
            if (this._results[i]._idOI == idoi)
                return i;
        }
        return -1;
    },

    populate_ServerPage: function(contextKey) {
        $common.setVisible(this._resultPageWait, true);
        var pricemin = '';
        var pricemax = '';
        if (this._filterPrice) {
            pricemin = parseFloat(this._filterPrice.min);
            pricemax = parseFloat(this._filterPrice.max);
        }
        if (this._dynamicServicePath) {
            var services = Sys.Serialization.JavaScriptSerializer.serialize(this._filterService);
            Sys.Net.WebServiceProxy.invoke(this._dynamicServicePath, "GetServerPage", false,
            { bookingResultContainerID: this.get_id(), clientPageIndex: this.get_pageIndex(), sortField: this._sortField, sortAsc: this._sortAsc, filterService: services, priceMin: pricemin, priceMax: pricemax },
            Function.createDelegate(this, this._onServerPageComplete), Function.createDelegate(this, this._onServerPageError),
            0);
        }
    },
    _onServerPageComplete: function(result, userContext, methodName) {
        this.disposePageResults();
        try {
            var _pageResults = eval("(" + result + ")");
            for (var i = 0; i < _pageResults.page.length; i++) {
                this._addAsyncResult(_pageResults.page[i]);
            }
            this.set_totalCount(_pageResults.total);
            this._filterServiceData = _pageResults.services;
            this.buildServices($get(this.get_filteredServicesContainer()));
            this.raisePageChanged();
            this.raiseFilterChanged();
            this.raiseSortChanged();
            $common.setVisible(this._resultPageWait, false);
            //this.showPageResults_Client();
        } catch (err) {
            alert(result);
            $common.setVisible(this._resultPageWait, false);
            this._resultPageWait = $common.createElementFromTemplate({ nodeName: "div", cssClasses: ["pagewait", "ui-state-error", "ui-corner-all"], children: [
                { nodeName: "span", cssClasses: ["ui-icon", "ui-icon-alert"] },
                { nodeName: "span", properties: { innerHTML: 'Erreur de chargement: ' + err.message} }
                ]
            }, this.get_element());
        }
        this._needReload = false;
    },
    _onServerPageError: function(result, userContext, methodName) {
        var elt = this.get_element();
        var error = String.format("Echec du chargement dynamique - Erreur {0} : {1} ", webServiceError.get_statusCode(), webServiceError.get_message());
        if (elt)
            elt.appendChild(document.createTextNode(error));
        this._needReload = false;
    },
    _addAsyncResult: function(properties) {
        var resultid = properties.clientID;
        //if (!$get(resultid)) {
        var elt = this.get_element();
        var id = this.get_id();
        var _result = $common.createElementFromTemplate({ nodeName: "div", properties: { id: resultid }, cssClasses: ["blocDetailResult"] }, elt);
        //$common.setVisible(_result, false);
        $create(BookingControls.BookingResult, null, null, { 'owner': id }, _result);
        var r = $find(resultid);
        r._idOI = properties.idOI;
        r._owner = this;
        r._title = properties.title;
        r._typeOI = properties.typeOI;
        r._isOIHebergement = properties.isOIHebergement;
        r._classementOfficiels = properties.classementOfficiels;
        r._classementClassName = properties.classementClassName;
        r._price = parseFloat(properties.price).toFixed(2);
        r._priceMax = parseFloat(properties.priceMax).toFixed(2);
        r._commune = properties.commune;
        r._tarifs = properties.tarifs;
        r._services = properties.services;
        r._defaultImageUrl = properties.defaultImageUrl;
        r._idEctVente = properties.idEctVente;

        r._dynamicServicePath = properties.dynamicServicePath;
        r._dynamicServiceMethod = properties.dynamicServiceMethod;
        r._panierServicePath = properties.panierServicePath;

        //r.initialize();

        r.add_clickedCarto(this._result_oncartoclicked$delegate);
        r.add_buildmodechanged(this._result_onbuildmodechanged$delegate);
        r.add_populated(this._result_oncartopopulated$delegate);

        r._show();
        //}
    },
    _buildPageWait: function(container) {
        var elt = container;
        if (!this.is_IE() && this._resultPageWait)
            elt.appendChild(this._resultPageWait);
        else {
            this._resultPageWait = $common.createElementFromTemplate({ nodeName: "div", cssClasses: ["pagewait ui-state-hover ui-corner-all"], children: [
                { nodeName: "div", cssClasses: ["spinner", "ui-corner-all", "ui-state-active"] },
                { nodeName: "span", properties: { innerHTML: 'Chargement en cours ...'} }
                ]
            }, elt);
        }
        $common.setVisible(this._resultPageWait, false);
    },
    disposePageResults: function() {
        //var elt = this.get_element();
        for (var i = 0; i < this._results.length; i++) {
            this._results[i].dispose();
            //elt.removeChild(this._results[i].get_element());
        }
        this._filteredResults = [];
        this._results = [];
    },
    /* ------------------------------------------- Tri ------------------------------------ */
    add_SortChanged: function(handler) {
        this.get_events().addHandler("sortChanged", handler);
    },
    remove_SortChanged: function(handler) {
        this.get_events().removeHandler("sortChanged", handler);
    },
    raiseSortChanged: function() {
        var eh = this.get_events().getHandler("sortChanged");
        if (eh) {
            eh(this, Sys.EventArgs.Empty);
        }
    },

    sortByTitle: function(r1, r2) {
        var title1 = r1.get_title().toLowerCase();
        var title2 = r2.get_title().toLowerCase();
        return ((title1 == title2) ? 0 : ((title1 < title2) ? -1 : 1));
    },
    sortByCommune: function(r1, r2) {
        var commune1 = r1.get_commune().toLowerCase();
        var commune2 = r2.get_commune().toLowerCase();
        return ((commune1 == commune2) ? 0 : ((commune1 < commune2) ? -1 : 1));
    },
    sortByPrice: function(r1, r2) {
        var price1 = parseFloat(r1.get_price());
        var price2 = parseFloat(r2.get_price());
        return (price1 - price2);
        //return ((price1 == price2) ? 0 : ((price1 < price2) ? -1 : 1));
    },
    sortByClassement: function(r1, r2) {
        var classement1 = r1.get_classementOfficiels();
        var classement2 = r2.get_classementOfficiels();
        return ((classement1 == classement2) ? 0 : ((classement1 < classement2) ? -1 : 1));
    },
    sortByDistance: function(r1, r2) {
        var d1 = r1._distance;
        var d2 = r2._distance;
        return ((d1 == d2) ? 0 : ((d1 < d2) ? -1 : 1));
    },

    sortResults: function() {
        this._pageIndex = 0;
        this.hideAllResults();
        if (this.get_sortServer() == true) {
            //            this._filteredResults = [];
            //            this._results = [];
            this._needReload = true;
        } else {
            this.sortResults_Client();
        }
        this.raiseSortChanged();
        this.showPageResults();
    },
    sortResults_Client: function() {
        if (this._sortField && this._sortField != BookingControls.SortField.None) {
            var sortMethod = "";
            switch (this._sortField) {
                case BookingControls.SortField.Title:
                    sortMethod = this.sortByTitle;
                    break;
                case BookingControls.SortField.Price:
                    sortMethod = this.sortByPrice;
                    break;
                case BookingControls.SortField.Commune:
                    sortMethod = this.sortByCommune;
                    break;
                case BookingControls.SortField.Classement:
                    sortMethod = this.sortByClassement;
                    break;
                case BookingControls.SortField.Distance:
                    sortMethod = this.sortByDistance;
                    break;
            }
            this._results.sort(sortMethod);
            var elt = this.get_element();
            if (!this._sortAsc)
                this._results.reverse();
            for (var i = 0; i < this._results.length; i++)
                elt.appendChild(this._results[i].get_element());
            this.filterResults();
        }
    },
    /* ------------------------------------------- Filtre ------------------------------------ */
    add_FilterChanged: function(handler) {
        this.get_events().addHandler("filterChanged", handler);
    },
    remove_FilterChanged: function(handler) {
        this.get_events().removeHandler("filterChanged", handler);
    },
    raiseFilterChanged: function() {
        var eh = this.get_events().getHandler("filterChanged");
        if (eh) {
            eh(this, Sys.EventArgs.Empty);
        }
        this.buildServices($get(this.get_filteredServicesContainer()));
    },

    filterResults: function() {
        this._filteredResults = [];
        if (this.get_sortServer() == false && (this._filterPrice || this._filterService)) {
            for (var i = 0; i < this._results.length; i++) {
                if (this._results[i]._evalFilter(BookingControls.FilterField.Price, this._filterPrice)) {
                    if (this._results[i]._evalFilter(BookingControls.FilterField.Service, this._filterService))
                        this._filteredResults.push(this._results[i]);
                }
            }
        } else
            this._filteredResults = this._results;
    },

    set_filterService: function(values) {
        this._filterService = values;
        if (this._loaded) {
            this._pageIndex = 0;
            this.hideAllResults();
            if (this.get_sortServer() == true) {
                //                this._filteredResults = [];
                //                this._results = [];
                this._needReload = true;
            } else {
                this.filterResults();
                this.raiseFilterChanged();
            }
            this.showPageResults();
        }
    },
    buildServices: function(container) {
        if (this.get_sortServer() == false)
            this.buildServices_OLD(container);
        else
            this.buildServices_NEW(container);
    },
    buildServices_OLD: function(container) {
        var elt = container;
        $common.addCssClasses(elt, ["loadingcontent"]);
        elt.innerHTML = "";
        var results = this.get_filteredResults();
        this._resultServices = $common.createElementFromTemplate({ nodeName: "div" }, elt);
        for (var i = 0; i < this._filterServiceCodes.length; i++) {
            var serviceCount = 0;
            for (var j = 0; j < results.length; j++)
                if (results[j]._findService(this._filterServiceCodes[i]))
                serviceCount++;
            var isChecked = this._isFilterService(this._filterServiceCodes[i]);
            if (isChecked || serviceCount > 0) {
                var service = $common.createElementFromTemplate({ nodeName: "div", properties: { code: this._filterServiceCodes[i] }, cssClasses: ["service_" + i] }, this._resultServices);
                var checkbox = $common.createElementFromTemplate({ nodeName: "input", properties: { type: "checkbox", checked: isChecked }, events: { click: this._onfilterservices$delegate} }, service);
                checkbox.checked = isChecked;
                $common.createElementFromTemplate({ nodeName: "div", properties: { innerHTML: String.format("{0} ({1})", this._filterServiceNames[i], serviceCount) }, cssClasses: ["filterservicetext"] }, service);
                //service.appendChild(document.createTextNode(String.format("{0} ({1})", this._filterServiceNames[i], serviceCount)));

                var baseIconUrl = "App_Themes/Default/Images/icons/";
                var iconOn = baseIconUrl + "checked_03.png"; //his._filterServiceIconsOn[i];
                var iconOff = baseIconUrl + "unchecked_03.png"; //this._filterServiceIconsOff[i];
                $create(AjaxControlToolkit.ToggleButtonBehavior, { "UncheckedImageUrl": iconOff, "CheckedImageUrl": iconOn, "ImageWidth": 25, "ImageHeight": 25 }, null, null, checkbox);

            }
        }
        $common.removeCssClasses(elt, ["loadingcontent"]);
    },
    buildServices_NEW: function(container) {
        var elt = container;
        $common.addCssClasses(elt, ["loadingcontent"]);
        elt.innerHTML = "";
        this._resultServices = $common.createElementFromTemplate({ nodeName: "div" }, elt);
        if (this.isnullorempty(this._searchOiType)) {
            for (var i = 0; i < this._filterServiceData.length; i++)
                this._builFilterService(this._filterServiceData[i], false);
        }
        else {
            for (var i = 0; i < this._filterServices.length; i++)
                if (this._matchFilterServiceOIType(this._filterServices[i], this._searchOiType)) {
                var filterServiceData = null;
                for (var j = 0; j < this._filterServiceData.length; j++)
                    if (this._filterServiceData[j].id == this._filterServices[i].code)
                    filterServiceData = this._filterServiceData[j];
                if (!this.isnull(filterServiceData))
                    this._builFilterService(filterServiceData, true);
            }
        }
        $common.removeCssClasses(elt, ["loadingcontent"]);
        if (this.get_isJQueryUIVersion() == true) {
            $("#blocContenuAffinerServices div.ui-state-default").click(function() {
                var ctlRef = $(this).find(".filterservice.active");
                if (ctlRef.attr("servactive") == "off") {
                    ctlRef.attr("servactive", "on");
                    ctlRef.attr("class", "filterservice " + ctlRef.attr("classon"));
                }
                else {
                    ctlRef.attr("servactive", "off");
                    ctlRef.attr("class", "filterservice " + ctlRef.attr("classoff"));
                }
                var serviceCodes = new Array();
                $(".filterservice[servactive='on']").each(function() { serviceCodes.push($(this).attr("code")); });
                filterServices(serviceCodes);
            }).hover(function() { $(this).addClass("ui-state-hover"); }, function() { $(this).removeClass("ui-state-hover"); }); ;
        } else {
            $(".filterservice.active").click(function() {
                if ($(this).attr("servactive") == "off") {
                    $(this).attr("servactive", "on");
                    $(this).attr("class", "filterservice " + $(this).attr("classon"));
                }
                else {
                    $(this).attr("servactive", "off");
                    $(this).attr("class", "filterservice " + $(this).attr("classoff"));
                }
                var serviceCodes = new Array();
                try {
                    //$(".filterservice[servactive='on']").each(function() { serviceCodes.push($(this).attr("code")); alert('code=' + code); });
                    $(".filterservice.on").each(function() { serviceCodes.push($(this).attr("code")); });
                } catch (err) {
                    alert("Erreur sur les services: " + err.message);
                }
                filterServices(serviceCodes);
            });
        }
    },
    _builFilterService: function(filterServiceData, showNoCount) {
        var classon = this.get_isJQueryUIVersion() ? "ui-icon ui-icon-check" : "on";
        var classoff = this.get_isJQueryUIVersion() ? "ui-icon ui-icon-grip-dotted-horizontal" : "off";
        var isFilterChecked = this._isFilterService(filterServiceData.id);
        var classstatus = (isFilterChecked || filterServiceData.count > 0) ? "active" : "inactive";
        var parentStatus = "";
        if (this.get_isJQueryUIVersion() == true)
            parentStatus = isFilterChecked ? "ui-state-default ui-state-highlight" : ((filterServiceData.count > 0) ? "ui-state-default" : "ui-state-disabled");
        if (isFilterChecked || showNoCount || filterServiceData.count > 0) {
            var servactive = isFilterChecked ? "on" : "off";
            var servclass = isFilterChecked ? classon : classoff;
            var service = $common.createElementFromTemplate({ nodeName: "div", cssClasses: [parentStatus] }, this._resultServices);
            $common.createElementFromTemplate({ nodeName: "div", properties: { code: filterServiceData.id, servnb: 0, servactive: servactive, classon: classon, classoff: classoff }, cssClasses: ["filterservice", servclass, classstatus] }, service);
            $common.createElementFromTemplate({ nodeName: "div", properties: { innerHTML: String.format("{0} ({1})", filterServiceData.name, filterServiceData.count) }, cssClasses: ["filterservicetext", classstatus] }, service);
        }
    },
    _isFilterService: function(serviceCode) {
        if (!this._filterService)
            return false;
        for (var i = 0; i < this._filterService.length; i++)
            if (this._filterService[i] == serviceCode)
            return true;
        return false;
    },
    getFilterServices: function(typeOI) {
        var _serv = [];
        for (var i = 0; i < this._filterServices.length; i++) {
            var f = this._filterServices[i];
            if (this._matchFilterServiceOIType(f, typeOI))
                _serv.push(f);
        }
        return _serv;
    },
    _matchFilterServiceOIType: function(filterService, typeOI) {
        return (
            (typeOI == "fdfbac6f-4422-4046-b394-f9ff5193623b" && filterService.hot == true) ||
            (typeOI == "3cdf2761-22a8-4353-b96d-6a06122d4ed7" && filterService.loc == true) ||
            (typeOI == "5e305462-69b3-4fd6-9394-98fa4a0f97ac" && filterService.camp == true) ||
            (typeOI == "ea652fed-bfd4-4139-a656-0693e97c3ab4" && filterService.mpc == true) ||
            (typeOI == "ea9cd2e5-76aa-45c8-8b77-38502764fddb" && filterService.ls == true) ||
            (typeOI == "6caf58a6-e775-4309-8bdd-b01f8b1ba437" && filterService.lc == true)
        );
    },
    /* ------------------------------------------- Carto ------------------------------------ */
    _buildCarto: function() {
        var elt = this.get_element();
        var id = this.get_id();
        this._resultCarto = $common.createElementFromTemplate({
            nodeName: "div",
            properties: { id: id + "_carto" },
            cssClasses: ["blocDetailResultCarto"]
        }, elt);
        var cartoHeader = $common.createElementFromTemplate({
            nodeName: "div",
            properties: { id: id + "_cartoHeader" },
            cssClasses: ["blocDetailResultCartoHeader"],
            children: [{ nodeName: "div", cssClasses: ["blocDetailResultCartoHeaderClose"], events: { click: this._carto_onclose$delegate}}]
        }, this._resultCarto);
        var cartoContent = $common.createElementFromTemplate({
            nodeName: "div",
            properties: { id: id + "_cartoContent" },
            cssClasses: ["blocDetailResultCartoContent"]
        }, this._resultCarto);
        //            var cartoResizer = $common.createElementFromTemplate({
        //                nodeName: "div",
        //                cssClasses: ["resizingCarto", "handleText"]
        //            }, this._resultCarto);

        if (!this._dragBehavior && this.is_IE()) {
            this._dragBehavior = $create(AjaxControlToolkit.FloatingBehavior, { "handle": cartoHeader }, null, null, this._resultCarto);
        }
        if (!this._resizeBehavior) {
            this._resizeBehavior = $create(AjaxControlToolkit.ResizableControlBehavior, {
                "MinimumWidth": 200,
                "MinimumHeight": 100,
                "MaximumWidth": 1280,
                "MaximumHeight": 1024,
                "HandleOffsetX": 5,
                "HandleOffsetY": 5,
                "ResizableCssClass": "resizingCarto",
                "HandleCssClass": "handleText"
            }, null, null, this._resultCarto);
            this._resizeBehavior.add_resize(this._carto_onresize$delegate);
        }
        //$("#"+id + "_carto").dragResize({ grid: 20 });
        //$("#" + id + "_carto").jqDrag('.blocDetailResultCartoHeader').jqResize('.resizingCarto');
    },
    _showCarto: function() {
        this._cartoVisible = true;
        if (!this._mapScriptLoaded)
            this._loadingMapScript();
        $common.setVisible(this._resultCarto, true);
    },
    _hideCarto: function() {
        this._cartoVisible = false;
        $common.setVisible(this._resultCarto, false);
    },
    _loadmap: function() {
        if (!this._resultCarto)
            this._buildCarto();
        if (GBrowserIsCompatible() && !this._map) {
            var elt = $get(this.get_id() + "_cartoContent");
            this._map = new google.maps.Map2(elt);
            var point = new google.maps.LatLng(46.64, 2.46);
            this._map.setCenter(point, 6);
            this._map.addControl(new google.maps.SmallMapControl());
            this._map.addControl(new google.maps.MapTypeControl());
            this._map.addMapType(G_PHYSICAL_MAP);
            //this._map.addControl(new imStreetViewControl());

            //this._map.addMapType(G_SATELLITE_3D_MAP);
            //this._map.setMapType(G_NORMAL_MAP);
            this._map.setMapType(G_PHYSICAL_MAP);
            this._map.checkResize();
        }
    },

    _loadedMapScript: function() {
        this._mapScriptLoaded = true;
        if (this._resultsAddons)
            this._resultsAddons._mapScriptLoaded = true;
        this._loadmap();
        if (!this.is_IE())
            var objectToDrag = new google.maps.DraggableObject(this._resultCarto, { draggingCursor: "pointer", draggableCursor: "pointer" });
        if (this._cartoVisible)
            this._showCarto();
        else
            this._hideCarto();

        this.raiseMapLoaded();
        this.showPageResultsCarto();
    },
    _loadingMapScript: function() {
        if (!this._mapScriptLoaded) {
            var script = document.createElement("script");
            script.src = String.format("http://www.google.com/jsapi?key={0}&callback=loadMaps", this._googleMapsKey);
            script.type = "text/javascript";
            document.getElementsByTagName("head")[0].appendChild(script)
        }
    },
    _clearBounds: function() {
        if (this._mapScriptLoaded)
            this._mapBounds = new google.maps.LatLngBounds();
    },
    _extendBounds: function(result, refresh) {
        if (this._mapScriptLoaded) {
            if (!this._mapBounds)
                this._mapBounds = new google.maps.LatLngBounds();
            var latlong = result.get_GLatLng();
            if (latlong)
                this._mapBounds.extend(latlong);
            if (refresh)
                this._showBounds();
        } else
            this.add_maploaded(result._owner_oncartoloaded$delegate);
    },
    _showBounds: function() {
        if (this._mapBounds) {
            var map = this.get_map();
            if (map && this._cartoVisible) {
                map.checkResize();
                var zoom = map.getBoundsZoomLevel(this._mapBounds);
                zoom = (zoom && zoom > 0) ? zoom : map.getZoom();
                var center = this._mapBounds.getCenter();
                map.setCenter(center, zoom);
                map.checkResize();
            }
        }
    },
    add_maploaded: function(handler) {
        this.get_events().addHandler("maploaded", handler);
    },
    remove_maploaded: function(handler) {
        this.get_events().removeHandler("maploaded", handler);
    },
    raiseMapLoaded: function(e) {
        var eh = this.get_events().getHandler("maploaded");
        if (eh) {
            eh(this, e);
        }
    },
    /* ------------------------------------------- Build Mode Change ------------------------------------ */
    add_buildmodechanged: function(handler) {
        this.get_events().addHandler("result_buildmodechanged", handler);
    },
    remove_buildmodechanged: function(handler) {
        this.get_events().removeHandler("result_buildmodechanged", handler);
    },
    raiseBuildModeChanged: function(e) {
        var eh = this.get_events().getHandler("result_buildmodechanged");
        if (eh) {
            eh(this, e);
        }
    },
    showResultsModeCompact: function() {
        for (var i = 0; i < this._results.length; i++) {
            if (this._results[i]._buildMode != BookingControls.BuildMode.Compact) {
                this._results[i]._buildMode = BookingControls.BuildMode.Compact;
                this._results[i]._build();
            }
        }
        this.showPageResults();
        this.raiseBuildModeChanged({ mode: BookingControls.BuildMode.Compact });
    },
    buildResultsModeLight: function(targetContainer) {
        targetContainer.innerHTML = "";
        var results = this.get_filteredResults();
        var startindex = 0; // Math.max(0, this._pageSize*this._pageIndex);
        var endindex = results.length; //Math.min(startindex+this._pageSize, results.length);
        for (var i = startindex; i < endindex; i++) {
            results[i]._build_light(targetContainer);
        }
    },
    buildResultsModeMedium: function(targetContainer) {
        targetContainer.innerHTML = "";
        var results = this.get_filteredResults();
        var startindex = 0; // Math.max(0, this._pageSize*this._pageIndex);
        var endindex = results.length; //Math.min(startindex+this._pageSize, results.length);
        for (var i = startindex; i < endindex; i++) {
            results[i]._build_medium(targetContainer);
        }
    },
    buildResumeSearch: function(targetContainer, uniteIndex) {
        $common.createElementFromTemplate({
            nodeName: "div",
            cssClasses: ["blocDetailResumeSearch"],
            children: [{ nodeName: "span", properties: { innerHTML: String.format(BookingControls.Resources.ResumeSearchPrefixFormat, this.getResumeSearchText(uniteIndex))}}]
        }, targetContainer);
    },
    getResumeSearchText: function(uniteIndex) {
        var _resumeText = String.format(BookingControls.Resources.ResumeSearchUniteFormat, this._resumeSearch.Unites[uniteIndex].NbAdultes);
        if (this._resumeSearch.Unites[uniteIndex].NbEnfants > 0) {
            _resumeText += String.format(BookingControls.Resources.ResumeSearchUniteEnfantsFormat, this._resumeSearch.Unites[uniteIndex].NbEnfants);
        }
        _resumeText += String.format(". " + BookingControls.Resources.ResumeSearchPeriodeFormat, this._resumeSearch.Date, this._resumeSearch.DateTo);
        return _resumeText;
    },

    /* ------------------------------------------- Utils ------------------------------------ */
    isnull: function(elt) {
        return (elt === undefined || elt === null);
    },
    isnullorempty: function(elt) {
        return (this.isnull(elt) || elt == '');
    },

    /* ------------------------------------------- Panier changed ------------------------------------ */
    add_cartchanged: function(handler) {
        this.get_events().addHandler("result_cartchanged", handler);
    },
    remove_cartchanged: function(handler) {
        this.get_events().removeHandler("result_cartchanged", handler);
    },
    raiseCartchanged: function(e) {
        var eh = this.get_events().getHandler("result_cartchanged");
        if (eh) {
            eh(this, e);
        }
    },
    raiseResultSelected: function(idOffre, idPrestation, idOI, tarif, idEctVente) {
        __doPostBack(this.get_id(), "selected:" + idOffre + "_" + idPrestation + "_" + idOI + "_" + tarif + "_" + idEctVente);
    },
    /* ------------------------------------------- Events ------------------------------------ */
    _app_onload: function(sender, e) {
        this._buildPageWait(this.get_element());
        if (this._results.length > 0) {
            for (var i = 0; i < this._results.length; i++) {
                this._results[i].add_clickedCarto(this._result_oncartoclicked$delegate);
                this._results[i].add_buildmodechanged(this._result_onbuildmodechanged$delegate);
            }
            this.showPageResults();
            if ($get(this.get_filteredServicesContainer()))
                this.buildServices($get(this.get_filteredServicesContainer()));
            this._loaded = true;
        }
    },
    _result_oncartoclicked: function(sender, args) {
        this._showCarto();
        var map = this.get_map();
        if (map) {
            sender.showMarker(map);
            var latlong = sender.get_GLatLng();
            if (latlong) {
                this._unselectMarkers();
                sender.set_isSelected(true);
                sender._selectMarker();
                map.setCenter(latlong, 12);
            }
        }
    },
    _unselectMarkers: function() {
        for (var i = 0; i < this._results.length; i++) {
            if (this._results[i]._isSelected) {
                this._results[i].set_isSelected(false);
                this._results[i]._unselectMarker();
            }
        }
    },
    _result_oncartopopulated: function(sender, args) {
        if (this._mapScriptLoaded) {
            var map = this.get_map();
            if (map)
                sender.showMarker(map, sender._isAddon);
        }
        this._extendBounds(sender, !sender._isAddon);
    },
    _result_onbuildmodechanged: function(sender, args) {
        //alert('_result_onbuildmodechanged: args.mode='+args.mode);
        for (var i = 0; i < this._results.length; i++) {
            if (this._results[i]._idOI != sender._idOI) {
                if (this._results[i]._buildMode != BookingControls.BuildMode.Compact) {
                    this._results[i]._buildMode = BookingControls.BuildMode.Compact;
                    this._results[i]._build();
                }
                this._results[i]._hide();
            }
        }
        sender._show();
        this.raiseBuildModeChanged(args);
    },

    _carto_onclose: function(sender, e) {
        this._hideCarto();
    },
    _carto_onresize: function(sender, e) {
        var content = $get(this.get_id() + "_cartoContent");
        content.style.width = sender.get_element().clientWidth + "px";
        content.style.height = (sender.get_element().clientHeight - 20) + "px";
        var map = this.get_map();
        if (map)
            map.checkResize();
        this._showBounds();
    },
    _onfilterservices: function(sender, e) {
        var serviceNodes = sender.target.parentNode.parentNode.childNodes;
        var serviceCodes = new Array();
        for (var i = 0; i < serviceNodes.length; i++) {
            if (serviceNodes[i].childNodes[0].checked || serviceNodes[i].childNodes[1].checked)
                serviceCodes.push(serviceNodes[i]["code"]);
        }
        this.set_filterService(serviceCodes);
    },
    _onfilterservices_NEXT: function(sender, e) {
        if (sender.target["servactive"] == "on") {
            sender.target["servactive"] = "off";
            sender.target["servactive"] = "filterservice " + sender.target["classon"];
        }
        else {
            sender.target["servactive"] = "on";
            sender.target["servactive"] = "filterservice " + sender.target["classoff"];
        }
        var serviceNodes = sender.target.parentNode.childNodes;
        var serviceCodes = new Array();
        for (var i = 0; i < serviceNodes.length; i++) {
            if (serviceNodes[i]["servactive"] == "on")
                serviceCodes.push(serviceNodes[i]["code"]);
        }
        this.set_filterService(serviceCodes);
    }
};
BookingControls.BookingResultContainer.registerClass("BookingControls.BookingResultContainer", AjaxControlToolkit.ControlBase);

Type.registerNamespace('BookingControls');
BookingControls.Resources={
"PasswordStrength_InvalidWeightingRatios":"Strength Weighting ratios must have 4 elements",
"Animation_ChildrenNotAllowed":"AjaxControlToolkit.Animation.createAnimation cannot add child animations to type \"{0}\" that does not derive from AjaxControlToolkit.Animation.ParentAnimation",
"PasswordStrength_RemainingSymbols":"{0} symbol characters",
"Service_not":"pas de",
"ExtenderBase_CannotSetClientStateField":"clientStateField can only be set before initialization",
"RTE_PreviewHTML":"Preview HTML",
"ModesPaiement":"Modes de paiements acceptés:",
"PriceFrom":"A partir de&nbsp;",
"PriceUnit":"€",
"ChildAgeFormat":"{0} {1} {2}",
"RTE_JustifyCenter":"Justify Center",
"PasswordStrength_RemainingUpperCase":"{0} more upper case characters",
"Animation_TargetNotFound":"AjaxControlToolkit.Animation.Animation.set_animationTarget requires the ID of a Sys.UI.DomElement or Sys.UI.Control.  No element or control could be found corresponding to \"{0}\"",
"RTE_FontColor":"Font Color",
"RTE_LabelColor":"Label Color",
"Common_InvalidBorderWidthUnit":"A unit type of \"{0}\"\u0027 is invalid for parseBorderWidth",
"Reservation":"Réservation",
"RTE_Heading":"Heading",
"Tabs_PropertySetBeforeInitialization":"{0} cannot be changed before initialization",
"RTE_OrderedList":"Ordered List",
"Tab_Map":"Carto.",
"ShowOtherOffers":"Offres complémentaires",
"NoDispo":"Aucune offre disponible.",
"ReorderList_DropWatcherBehavior_NoChild":"Could not find child of list with id \"{0}\"",
"CascadingDropDown_MethodTimeout":"[Method timeout]",
"RTE_Columns":"Columns",
"RTE_InsertImage":"Insert Image",
"RTE_InsertTable":"Insert Table",
"RTE_Values":"Values",
"RTE_OK":"OK",
"SCEA_Equipements":"Equipements",
"ExtenderBase_PageNotRegisteredForCallbacks":"This Page has not been registered for callbacks",
"Animation_NoDynamicPropertyFound":"AjaxControlToolkit.Animation.createAnimation found no property corresponding to \"{0}\" or \"{1}\"",
"SelectionModeMultiple":"Choix de la date d\u0027arrivée",
"Calendar_Days":"{0} jours",
"Animation_InvalidBaseType":"AjaxControlToolkit.Animation.registerAnimation can only register types that inherit from AjaxControlToolkit.Animation.Animation",
"RTE_UnorderedList":"Unordered List",
"ResizableControlBehavior_InvalidHandler":"{0} handler not a function, function name, or function text",
"OIS_SEJOUR":"Séjour",
"Animation_InvalidColor":"Color must be a 7-character hex representation (e.g. #246ACF), not \"{0}\"",
"RTE_CellColor":"Cell Color",
"PasswordStrength_RemainingMixedCase":"Mixed case characters",
"RTE_Italic":"Italic",
"CascadingDropDown_NoParentElement":"Failed to find parent element \"{0}\"",
"ResumeSearchPeriodeFormat":"du {0} au {1}.",
"ValidatorCallout_DefaultErrorMessage":"This control is invalid",
"RTE_Indent":"Indent",
"ReorderList_DropWatcherBehavior_CallbackError":"Reorder failed, see details below.\\r\\n\\r\\n{0}",
"PopupControl_NoDefaultProperty":"No default property supported for control \"{0}\" of type \"{1}\"",
"RTE_Normal":"Normal",
"DetSimple":"Lit simple",
"PopupExtender_NoParentElement":"Couldn\u0027t find parent element \"{0}\"",
"RTE_ViewValues":"View Values",
"RTE_Legend":"Legend",
"RTE_Labels":"Labels",
"RTE_CellSpacing":"Cell Spacing",
"OIS_LOCATIF":"Locatif",
"PasswordStrength_RemainingNumbers":"{0} more numbers",
"RTE_Border":"Border",
"RTE_Create":"Create",
"RTE_BackgroundColor":"Background Color",
"DetQueen":"Lit Queen size",
"RTE_Cancel":"Cancel",
"OIS_PATRIMOINE_CULTUREL":"Patrimoine culturel",
"RTE_JustifyFull":"Justify Full",
"RTE_JustifyLeft":"Justify Left",
"RTE_Cut":"Cut",
"SCEA_Activites":"Activités",
"OIS_PATRIMOINE_NATUREL":"Patrimoine naturel",
"ResizableControlBehavior_CannotChangeProperty":"Changes to {0} not supported",
"PanierItem_Delete":"Retirer",
"Tab_InfosSup":"Informations complémentaires",
"RTE_ViewSource":"View Source",
"DetKing":"Lit King size",
"Common_InvalidPaddingUnit":"A unit type of \"{0}\" is invalid for parsePadding",
"OIS_COMMERCE_SERVICE":"Commerce et service",
"OffreDureeFormat":"durée: {0} jour(s)",
"RTE_Paste":"Paste",
"ExtenderBase_ControlNotRegisteredForCallbacks":"This Control has not been registered for callbacks",
"DetDouble":"Lit double",
"Calendar_Night":", {0} nuit",
"Calendar_Today":"Aujourd\u0027hui: {0}",
"Common_DateTime_InvalidFormat":"Invalid format",
"ListSearch_DefaultPrompt":"Type to search",
"CollapsiblePanel_NoControlID":"Failed to find element \"{0}\"",
"RTE_ViewEditor":"View Editor",
"Calendar_Nights":", {0} nuits",
"RTE_BarColor":"Bar Color",
"Reservation_add":"Ajouter à la réservation",
"Reservation_del":"Retirer de la réservation",
"PasswordStrength_DefaultStrengthDescriptions":"NonExistent;Very Weak;Weak;Poor;Almost OK;Barely Acceptable;Average;Good;Strong;Excellent;Unbreakable!",
"SearchTypeText":"Nous rechercherons parmi",
"Age":"Age",
"OIS_ITINERAIRE":"Itinéraire",
"Child":"Enfant",
"Total":"Total",
"Tab_Services":"Services",
"Address":"Adresse :",
"RTE_Inserttexthere":"Insert text here",
"OIS_DEGUSTATION":"Dégustation",
"Animation_UknownAnimationName":"AjaxControlToolkit.Animation.createAnimation could not find an Animation corresponding to the name \"{0}\"",
"ExtenderBase_InvalidClientStateType":"saveClientState must return a value of type String",
"Rating_CallbackError":"An unhandled exception has occurred:\\r\\n{0}",
"Tabs_OwnerExpected":"owner must be set before initialize",
"DynamicPopulate_WebServiceTimeout":"Web service call timed out",
"PasswordStrength_RemainingLowerCase":"{0} more lower case characters",
"OIS_VILLAGEVACANCE":"Village vacance",
"OIS_RESTAURANT":"Restaurant",
"Panier_Total":"Total :",
"SCEA_Conforts":"Conforts",
"Animation_MissingAnimationName":"AjaxControlToolkit.Animation.createAnimation requires an object with an AnimationName property",
"RTE_JustifyRight":"Justify Right",
"Tabs_ActiveTabArgumentOutOfRange":"Argument is not a member of the tabs collection",
"RTE_CellPadding":"Cell Padding",
"OIS_HOTEL":"Hôtel",
"RTE_ClearFormatting":"Clear Formatting",
"AlwaysVisible_ElementRequired":"AjaxControlToolkit.AlwaysVisibleControlBehavior must have an element",
"OIS_LOISIR_SPORTIF":"Loisir sportif",
"Slider_NoSizeProvided":"Please set valid values for the height and width attributes in the slider\u0027s CSS classes",
"DynamicPopulate_WebServiceError":"Web Service call failed: {0}",
"PasswordStrength_StrengthPrompt":"Strength: ",
"PasswordStrength_RemainingCharacters":"{0} more characters",
"PasswordStrength_Satisfied":"Nothing more required",
"RTE_Hyperlink":"Hyperlink",
"ResumeSearchPrefixFormat":"Votre demande: {0}",
"Animation_NoPropertyFound":"AjaxControlToolkit.Animation.createAnimation found no property corresponding to \"{0}\"",
"PasswordStrength_InvalidStrengthDescriptionStyles":"Text Strength description style classes must match the number of text descriptions.",
"PasswordStrength_GetHelpRequirements":"Get help on password requirements",
"filterService8":"Animaux admis",
"filterService9":"Accès handicapés",
"filterService0":"Piscine",
"filterService1":"Salle de sports",
"filterService2":"Service en chambre",
"filterService3":"Parking",
"filterService4":"Climatisation",
"filterService5":"Accès Internet WIFI",
"filterService6":"Restaurant",
"filterService7":"Bar",
"DetExtraBed":"Lit supplémentaire",
"PasswordStrength_InvalidStrengthDescriptions":"Invalid number of text strength descriptions specified",
"RTE_Underline":"Underline",
"OIS_FETE_MANIFESTATION":"Fête et manifestation",
"Class_Chaines":"Chaines",
"Class_Handi":"Tourisme Handicap",
"ResumeSearchUniteEnfantsFormat":"et {0} enfant(s)",
"Tabs_PropertySetAfterInitialization":"{0} cannot be changed after initialization",
"RTE_Rows":"Rows",
"RTE_Redo":"Redo",
"RTE_Size":"Size",
"RTE_Undo":"Undo",
"RTE_Bold":"Bold",
"RTE_Copy":"Copy",
"RTE_Font":"Font",
"Lang_Accueil":"Langues parlées à l\u0027accueil",
"PlusDetails":"Plus de détails",
"CascadingDropDown_MethodError":"[Method error {0}]",
"SCEA_Services":"Services",
"RTE_BorderColor":"Border Color",
"filterService19":"Piscine chauffée",
"filterService18":"Club enfant",
"filterService11":"Chauffage",
"filterService10":"Discothèque",
"filterService13":"Garage",
"filterService12":"Cheminée",
"filterService15":"Salle de bain privée",
"filterService14":"Jardin",
"filterService17":"Baby Club",
"filterService16":"Commerce alimentaire",
"Class_Labels":"Labels",
"OIS_TRANSPORT":"Transport",
"Calendar_Day":"{0} jour",
"ResumeSearchUniteFormat":"{0} adulte(s)",
"RTE_Paragraph":"Paragraph",
"RTE_InsertHorizontalRule":"Insert Horizontal Rule",
"VoirOffres":"voir les offres",
"SCEA_Encadrements":"Encadrements",
"Common_UnitHasNoDigits":"No digits",
"RTE_Outdent":"Outdent",
"OIS_LOISIR_CULTUREL":"Loisir culturel",
"OIS_CAMPING":"Camping",
"Common_DateTime_InvalidTimeSpan":"\"{0}\" is not a valid TimeSpan format",
"weekabr":"sem.",
"Animation_CannotNestSequence":"AjaxControlToolkit.Animation.SequenceAnimation cannot be nested inside AjaxControlToolkit.Animation.ParallelAnimation",
"NoPrestaHebergement":"Aucun hébergement disponible",
"day1":"Lun",
"day0":"Dim",
"day3":"Mer",
"day2":"Mar",
"day5":"Ven",
"day4":"Jeu",
"day6":"Sam",
"week":"semaine",
"NoMoreDispo":"Plus de stock disponible",
"Shared_BrowserSecurityPreventsPaste":"Your browser security settings don\u0027t permit the automatic execution of paste operations. Please use the keyboard shortcut Ctrl+V instead.",
"AgeEnfant":"Age Enf."
};

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();