Type.registerNamespace("BMControls");

BMControls.ArticleGadget = function(element) {
	BMControls.ArticleGadget.initializeBase(this, [element]);
	this._articleCount = null;
}

BMControls.ArticleGadget.prototype = {
	initialize: function() {
		BMControls.ArticleGadget.callBaseMethod(this, 'initialize');

		this._onMouseOverHandler = Function.createDelegate(this, this._onMouseOver);
		this._onMouseOutHandler = Function.createDelegate(this, this._onMouseOut);

		var list = $get(this.get_id() + "_list").getElementsByTagName("li");

		for (var i = 0; i < list.length; i++) {
			var item = list[i];
			$addHandler(item, "mouseover", this._onMouseOverHandler);
			$addHandler(item, "mouseout", this._onMouseOutHandler);
		}
	},
	dispose: function() {
		$clearHandlers(this.get_element());
		BMControls.ArticleGadget.callBaseMethod(this, "dispose");
	},
	_onMouseOver: function(e) {
		this._clearHover();

		var target = e.target;

		while (target.nodeName != "LI") {
			target = target.parentNode;
		}
		
		Sys.UI.DomElement.addCssClass(target, "article-on");
	},
	_onMouseOut: function(e) {
		// Nothing to Do
	},
	_clearHover: function() {
		var list = $get(this.get_id() + "_list").getElementsByTagName("LI");
		for (var i = 0; i < list.length; i++) {
			Sys.UI.DomElement.removeCssClass(list[i], "article-on");
		}
	},
	get_articleCount: function() {
		return this._articleCount;
	},
	set_articleCount: function(value) {
		this._articleCount = value;
	}
}
BMControls.ArticleGadget.registerClass('BMControls.ArticleGadget', Sys.UI.Control);

if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();