﻿Type.registerNamespace("Feratel.Website.HotelClient");
var myGlobalEventHandler;
// constructor
Feratel.Website.HotelClient.GlobalEventHandler = function() {
    this._events = new Sys.EventHandlerList();
    this.initialize();
}
//class definition
Feratel.Website.HotelClient.GlobalEventHandler.prototype = {
    initialize: function() {
    },
    get_events: function() {
        return this._events;
    },
    addHandler: function(event, handler) {
        this.get_events().addHandler(event, handler);
    },
    removeHandler: function(event, handler) {
    this.get_events().removeHandler(event, handler);
    },
    raiseEvent: function(event, eventArgs) {
        var handler = this.get_events().getHandler(event);
        if (handler) {
            if (!eventArgs) {
                eventArgs = Sys.EventArgs.Empty;
            }
            handler(this, eventArgs);
        }
    }
}
Feratel.Website.HotelClient.GlobalEventHandler.registerClass('Feratel.Website.HotelClient.GlobalEventHandler', null);

Feratel.Website.HotelClient.GlobalEventHandler.getInstance = function() {    
    if (myGlobalEventHandler == null) {
        // in case of lytebox
        try {
            if (window.parent.myGlobalEventHandler != null) {
                return window.parent.myGlobalEventHandler;
            }
        } catch (e) { };

        // in case of popup
        try {
            if (window.opener != null && window.opener.myGlobalEventHandler != null) {
                return window.opener.myGlobalEventHandler;
            }
        } catch (e) { };
        myGlobalEventHandler = new Feratel.Website.HotelClient.GlobalEventHandler();
    }
    return myGlobalEventHandler;
}

// Notify ScriptManager that this is the end of the script.
if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
