﻿Type.registerNamespace("Feratel.Website.Tosc");
var myPageEventHandler;
var myGlobalEventHandler;

// constructor
Feratel.Website.Tosc.GlobalEventHandler = function() {
    Feratel.Website.Tosc.GlobalEventHandler.initializeBase(this);
}

//class definition
Feratel.Website.Tosc.GlobalEventHandler.prototype = {
    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.Tosc.GlobalEventHandler.registerClass('Feratel.Website.Tosc.GlobalEventHandler', Sys.Component);

Feratel.Website.Tosc.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.Tosc.GlobalEventHandler();
    }
    return myGlobalEventHandler;
}

Feratel.Website.Tosc.GlobalEventHandler.getPageInstance = function() {
    if (myPageEventHandler == null) {
        myPageEventHandler = new Feratel.Website.Tosc.GlobalEventHandler();
    }
    return myPageEventHandler;
}
// Notify ScriptManager that this is the end of the script.
if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
