var Animation = Class.create({
	parent: null,
	timerOver: null,
	timerOut: null,
	timerValue: 200,
    activeElement: null,
    allowShow: true,
    allowHide: true,
    duration:0.4,
    
	init: function(parent) {
		this.parent = parent;
	    this.name = name;
	    
	    parent.select('.cell').each(function(item){
	    	item.observe('mouseover', this.onMouseover.bind(this));
	    }.bind(this));
	    
	    parent.observe('mouseout', this.onMouseout.bind(this));
	},
	
	onMouseover: function(e) {
		if (this.timerOut) {
			window.clearTimeout(this.timerOut);
		}
		var el = e.findElement('.cell');
		if (el.down('.sub') && this.activeElement != el.down('.sub') && this.allowShow) {
			
			if (this.timerOver) {
				window.clearTimeout(this.timerOver);
			}
			
			this.timerOver = window.setTimeout(function(){
	            if (this.activeElement) {
	                this.hideItem(this.activeElement);
	            }
	            this.showItem(el.down('.sub'));
	            this.activeElement = el.down('.sub');
			}.bind(this), this.timerValue)
			
		}
	},
	
	onMouseout: function(e) {
		this.timerOut = window.setTimeout(function(){
			if (this.activeElement) {
				this.hideItem(this.activeElement);
				this.activeElement = null;
			}
		}.bind(this), this.timerValue);
	},
	
	
	showItem: function(element) {
		this.allowShow = false;
		element.up('.cell').addClassName('active');
		element.up('tr').siblings().each(function(item){
			item.down('.cell').addClassName('short');
		});
	    Effect.BlindDown(element, {
	        duration: this.duration, 
	        afterFinish: function(){this.allowShow = true;}.bind(this),
	        queue: { position: 'end', scope: element.id}
	    });
		
	},
	
	hideItem: function(element, flag){
		element.up('.cell').removeClassName('active');
		element.up('tr').siblings().each(function(item){
			item.down('.cell').removeClassName('short');
		});
	    Effect.BlindUp(element, {
	        duration: this.duration, 
	        afterFinish: function(){}.bind(this),
	        queue: { position: 'end', scope: element.id}
	    });
	}
});
