ChannelMenuHorizontal = function () {
	this._isInitialized = false;
	
	this.normalStyles = new Array();
	
	this.container = null;
	
	this._overAnimationSpeed = 200;
	this._outAnimationSpeed = 400;
	
	this.init = function (container) {
		if (this._isInitialized) {
			return;
		}
		
		this.container = container;
		
		this.container.children(".navElement").not(".active").each(jQuery.proxy(function (index, element) {
			var element = jQuery(element);
			var channelId = element.attr('_channelId');
			var prototype = this.container.children(".navElementHoverPrototype[_channelId = "+channelId+"]");
			
			element.css('backgroundColor', prototype.css('color'));
		}, this));
		
		this.container.children(".navElement").mouseenter(jQuery.proxy(function (ev) {
			var element = jQuery(ev.currentTarget);
			var channelId = element.attr('_channelId');
			
			var prototype = this.container.children(".navElementHoverPrototype[_channelId = "+channelId+"]");
				
			var oldCss = {
				backgroundColor: element.css('backgroundColor'),
				color: element.css('color')
			};

			if (!this.normalStyles[channelId]) {
				this.normalStyles[channelId] = oldCss;
			}

			var newCss = {
				backgroundColor: prototype.css('backgroundColor'),
				color: prototype.css('color')
			};

			element.clearQueue();
			element.stop();
			element.animate(newCss, this._overAnimationSpeed);
		}, this));

		this.container.children(".navElement").mouseleave(jQuery.proxy(function (ev) {
			var element = jQuery(ev.currentTarget);
			var channelId = element.attr('_channelId');
			
			if (this.normalStyles[channelId]) {
				element.animate(this.normalStyles[channelId], this._outAnimationSpeed);
			}
		}, this));
	};
};


ChannelMenuHorizontal._instance = null;
ChannelMenuHorizontal.getInstance = function () {
	if (!ChannelMenuHorizontal._instance) {
		ChannelMenuHorizontal._instance = new ChannelMenuHorizontal();
	}
	
	return ChannelMenuHorizontal._instance;
};
