﻿Type.registerNamespace('BIT.WebControls');

BIT.WebControls.KillHtmlBehavior = function(element) 
{ 
	BIT.WebControls.KillHtmlBehavior.initializeBase(this, [element]);
	
	this._visibleBlock = false;
	this._timerId = null;
}

BIT.WebControls.KillHtmlBehavior.prototype =
{
    initialize: function() {
        BIT.WebControls.KillHtmlBehavior.callBaseMethod(this, 'initialize');

        var elm = this.get_element();
        $addHandlers(elm,
					{
					    'change': this._checkValue,
					    'blur': this._checkValue
					},
					this);
    },

    dispose: function() {
        $clearHandlers(this.get_element());

        BIT.WebControls.KillHtmlBehavior.callBaseMethod(this, 'dispose');
    },

    _checkValue: function() {
        var elm = this.get_element();

        if (elm) {
            if ((elm.value || '').length) {
                var re = new RegExp('<' + '[^><]*>|<.' + '[^><]*>', 'g');
                elm.value = elm.value.replace(re, '');
            }
        }

        elm = null;
    }
}

BIT.WebControls.KillHtmlBehavior.registerClass('BIT.WebControls.KillHtmlBehavior', Sys.UI.Behavior);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();