/*
* (c) Felix Nagel for Paints Multimedia GmbH
* mofidied: 08.09.09
*/

var Tips = new Class({
	Implements: [Options, Events],

	options: {
		tips: [],
		hideDelay: 300
	},

	initialize: function(options){
		this.setOptions(options);
		var self = this;		
		
		var hideDelay = this.options.hideDelay;
		
		this.options.tips.each( function(el){
			var timeOut = null;	
			var div = el.getNext(".tip");
			var myFx = new Fx.Tween(div);
			
			el.addEvent('mouseenter', function(event){
				//div.setStyle("left", event.client.x-370);
				self.showTip(myFx);
				window.clearTimeout(timeOut);
			});
			el.addEvent('mouseleave', function(){		
				timeOut = window.setTimeout(function () { self.hideTip(myFx); }, hideDelay);
			});
			
			div.addEvent('mouseenter', function(){	
				window.clearTimeout(timeOut);
			});
			div.addEvent('mouseleave', function(){
				timeOut = window.setTimeout(function () { self.hideTip(myFx); }, hideDelay);				
			});			
		});

	},
	showTip: function(myFx){	
		myFx.cancel();
		myFx.start('opacity', '0', '1');
	},
	hideTip: function(myFx){
		myFx.cancel();
		myFx.start('opacity', '1', '0');
	}
});
