// JavaScript Document

function PopupFeature(id) {
	$E.onAvailable(id, this.handleOnAvailable, this); 
}

PopupFeature.prototype.cancelTimer = function(e) {
	var div = Event.findElement(e, 'div');
	if(this.nTimeoutId) window.clearTimeout(this.nTimeoutId);
	if(div.animDown && div.animDown.isAnimated() ) div.animDown.stop();
	if(div.animUp) div.animUp.animate(); 
};

PopupFeature.prototype.onButtonMouseOut = function(e) {
	var thisObj = this;
	this.cancelTimer(e);
	this.nTimeoutId = window.setTimeout(function(){ thisObj.featurePopup.animDown.animate(); }, 1000);
};

PopupFeature.prototype.handleOnAvailable = function(me) {   
	me.featurePopup = this;
	this.me = me;
	
	this.attributesUp = { height: { to: 80 } };
	this.attributesDown = { height: { to: 28 } };
	this.durationUp = 0.3; 
	this.durationDown = 0.5; 
	this.easingUp = YAHOO.util.Easing.backOut;
	this.easingDown = YAHOO.util.Easing.backIn;
	
	this.animUp = new $Anim(this, this.attributesUp, this.durationUp ,this. easingUp);
	this.animDown = new $Anim(this, this.attributesDown, this.durationDown , this.easingDown );
	$E.on(this, 'mouseover', this.animUp.animate, this.animUp, true);
	
	var children = this.childNodes;
	for (var i = 0; i < children.length; i++) {
		//if($E.nodeType == 3){continue;}
		$E.on(children[i], 'mouseover', me.cancelTimer, this, true);
	}

	$E.on(this, 'mouseover', me.cancelTimer, me, true);
	$E.on(me.featurePopup, 'mouseout', me.onButtonMouseOut, me, true);
	//$E.on(document, 'click', this.animDown.animate, this.animDown, true);
};