/**
 * feedbackF
 */

var feedbackF = Class.create({
	initialize: function(element, tool_tip, mode) {	  
		this.element = $(element);
		this.tool_tip = $(tool_tip);
		this.mode = mode;
		this.tool_tip.hide();
		switch(this.mode){
		case 'static':
			this.eventMouseClick = this.showTooltip.bindAsEventListener(this);
			this.cBut = $('cBut');
			this.eventMouseClickClose = this.hideTooltip.bindAsEventListener(this);
			//this.eventMouseOut  = this.hideTooltip.bindAsEventListener(this);
			break;
		default:
			this.eventMouseOver = this.showTooltip.bindAsEventListener(this);
			this.eventMouseOut  = this.hideTooltip.bindAsEventListener(this);
			break;
		}
		this.registerEvents();
  	},
  	destroy: function() {
		Event.stopObserving(this.element, "mouseover", this.eventMouseOver);
		Event.stopObserving(this.element, "mouseout", this.eventMouseOut);
	},
	registerEvents: function() {
		switch(this.mode){
		case 'static':
			Event.observe(this.element, "click", this.eventMouseClick);
			Event.observe(this.cBut, "click", this.eventMouseClickClose);
			break;
		default:
			Event.observe(this.element, "mouseover", this.eventMouseOver);
			Event.observe(this.element, "mouseout", this.eventMouseOut);
			break;
		}
	},		
	showTooltip: function(event) {
		Event.stop(event);
		switch(this.mode){
		case 'static':
			this.tool_tip.setStyle({'position': 'relative'});
			this.element.blur();
			break;
		default:
			this.tool_tip.setStyle({'position': 'absolute'});
			break;
		}
		new Element.show(this.tool_tip);
	},
	hideTooltip: function(event){
		new Element.hide(this.tool_tip);
	}
});
