/*
Custom Tooltip plugin. V0.1 for mootools framwork.
Created by Mic
mic@goldencomm.com
*/

var tip = new Class({
 
		
			
		options: {
				title: null,
				content: null,
				speed: 500
		},
		
		initialize: function(options) {
			this.setOptions(options);
			this.title = options['title'];
			this.content = options['content'];
			this.speed = options['speed'];
			this.parent = options['parent'];
			
			this.TipContainer = new Element('div', {id: 'Tip'});
			this.TipTitle = new Element('h3', {id:'TipTitle'});	
			this.TipContent = new Element('p', {id:'TipContent'});
			
			this.TipTitle.appendText(this.title);
			this.TipContent.appendText(this.content);
			
			this.TipTitle.inject(this.TipContainer);
			this.TipContent.inject(this.TipContainer);	
			

			if ($(this.parent)) {
			$(this.parent).addEvent('mouseenter', this.Show.bindWithEvent(this));
			$(this.parent).addEvent('mouseleave', this.Hide.bindWithEvent(this));
			$(this.parent).addEvent('mousemove', this.Drag.bindWithEvent(this));
			}
			
		},
		
		
		Show: function(){
			
			this.TipContainer.inject($('body'),'end');
		},
		
		Hide: function() {
			
			this.TipContainer.remove();
			
		},
		
		Drag: function(event) {
			var e = new Event(event);
			this.TipContainer.setStyle('left', (e.page.x-20)+'px');
			this.TipContainer.setStyle('top', (e.page.y+10)+'px');
		}
		
		

});


tip.implement(new Options, new Events);

