/**
 * File: http://www.facilitywarehouse.com/gallery/js/Category.js
 */

var Category = new Class({
	
	state: 'off',
	
	initialize: function(obj) {
		this.target = obj;
		
		this.target.addEvent('mouseenter', this.changeState.bindWithEvent(this, 'hover'));
		this.target.addEvent('mouseleave', this.changeState.bindWithEvent(this, 'off'));
		
		this.setFauxEvents();
	},
	
	setFauxEvents: function() {
		$ES('.faux', this.target).each(function(obj) {
			obj.addEvent('click', function(evt) {
				new Event(evt).stopPropagation();
			});
		});
	},
	
	changeState: function(evt, state) {
		switch (state) {
			case 'hover' :
				this.target.addClass('hover');
				this.state = 'hover';
				break;
			case 'off' :
			default :
				this.target.removeClass('hover');
				this.state = 'off';
				break;
		}
	}
	
});