﻿/// <reference name="MicrosoftAjax.js"/>

Type.registerNamespace("EitherorSolutions");

EitherorSolutions.ClientBehavior1 = function(element) {
    EitherorSolutions.ClientBehavior1.initializeBase(this, [element]);
    this._pagemouseoverDelegate = null;
    this._onMouseOverHandler = null;
}

EitherorSolutions.ClientBehavior1.prototype = {


    // Bind and unbind to hover event.
    add_pagemouseover: function(handler) {
        this.get_events().addHandler('pagemouseover', handler);
    },
    remove_pagemouseover: function(handler) {
        this.get_events().removeHandler('pagemouseover', handler);
    },
    initialize: function() {
        EitherorSolutions.ClientBehavior1.callBaseMethod(this, 'initialize');
        
        var element = this.get_element();   
        
        if (this._pagemouseoverDelegate === null) {
            this._pagemouseoverDelegate = Function.createDelegate(this, this._pagemouseoverHandler);
        }
        Sys.UI.DomEvent.addHandler(element, 'pagemouseover', this._pagemouseoverDelegate);
        
        // Add custom initialization here
        this._mouseOverHandler = Function.createDelegate(this, this._onMouseOver);
        
        //Attach the required event handlers     
     
        $addHandlers(element, {'click':this._mouseOverHandler},this); 
    
        
    },
    dispose: function() {        
        //Add custom dispose actions here
        $clearHandlers(this.get_element()); //Detach all event handlers 
        
        if (this._hoverDelegate) {
            Sys.UI.DomEvent.removeHandler(element, 'pagemouseover', this._pagemouseoverDelegate);
            delete this._pagemouseoverDelegate;
        }
        delete this._mouseOverHandler;

        EitherorSolutions.ClientBehavior1.callBaseMethod(this, 'dispose');
    },     
     
  _onMouseOver : function(e)     
  { 
  var h = this.get_events().getHandler('pagemouseover');
        if (h) h(this, Sys.EventArgs.Empty);     
  },
  _pagemouseoverHandler: function(event) {
        var h = this.get_events().getHandler('pagemouseover');
        if (h) h(this, Sys.EventArgs.Empty);
    }
}
EitherorSolutions.ClientBehavior1.registerClass('EitherorSolutions.ClientBehavior1', Sys.UI.Control);

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
