/* tooltip.js */
/*prompt(1,function(p,a,c,k,e,d){

e=function(c){

return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))}
;if(!''.replace(/^/,String)){

while(c--){

d[e(c)]=k[c]||e(c)}
k=[function(e){

return d[e]}
];e=function(){

return'\\w+'}
;c=1}
;while(c--){

if(k[c]){

	p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}
}
return p}
('i O=4 1k({
1i:n(e,12,7){
3.1b({
1d:1h,1u:13.1s.1r,1n:v,U:\'1m-5\',P:\'1t\',6:1q,J:\'1p\',V:\'1a\',G:0}
,7);3.q=v;3.e=$(e);3.e.19(3.18());3.5=4 9(\'a\',{
\'8\':3.7.U,\'f\':{
\'u\':\'1w\',\'d\':0,\'j\':0,\'z-1v\':10,\'1l\':\'1x\',\'6\':3.7.6}
}
).1c(1f.1j);3.Q=4 9(\'a\',{
\'8\':3.7.P}
).c(3.5);3.s=4 9(\'a\',{
\'8\':\'5-1g\',\'f\':{
\'6\':3.7.6}
}
).c(3.Q);3.S=4 9(\'a\',{
\'8\':\'5-1e\'}
).c(3.s);3.1o=4 9(\'a\',{
\'8\':\'5-t\',\'f\':{
\'K\':15}
}
).c(3.S);3.B=4 9(\'a\',{
\'8\':\'5-l\',\'f\':{
\'6\':3.7.6}
}
).W(3.s);3.X=4 9(\'a\',{
\'8\':\'5-r\'}
).c(3.B);3.1J=4 9(\'a\',{
\'8\':\'5-m\'}
).c(3.X).1K(12);3.Y=4 9(\'a\',{
\'8\':\'5-1L\',\'f\':{
\'6\':3.7.6}
}
).W(3.B);3.Z=4 9(\'a\',{
\'8\':\'5-1M\'}
).c(3.Y);3.T=4 9(\'a\',{
\'8\':\'5-b\'}
).c(3.Z);3.1H=4 9(\'a\',{
\'8\':\'5-1B\',\'f\':{
\'K\':1I}
}
).c(3.T);o(3.7.G){
3.A=4 9(\'a\',{
\'8\':\'5-A\'}
).c(3.s)}
3.E=4 13.1A(3.5,3.7);3.e.w(\'11\',3.14.C(3));o(3.7.G){
3.A.w(\'11\',3.D.C(3))}
1C{
3.e.w(\'1D\',3.D.C(3))}
}
,14:n(g){
o(!3.q){
3.k=3.u(g);3.5.19({
\'F\':0,\'d\':3.k.d+\'p\',\'j\':3.k.j+\'p\'}
);3.E.17({
\'F\':1,\'d\':(3.k.d-10)+\'p\'}
);3.q=1G}
}
,D:n(g){
3.E.17({
\'F\':0,\'d\':(3.k.d-1F)+\'p\'}
);3.q=v}
,u:n(g){
i h=3.e.I();i L=3.5.I();o(3.7.V==\'1a\'){
i g=4 1E(g);h=$M(h,{
\'d\':g.16.y,\'j\':g.16.x,\'6\':0}
)}
H{
\'d\':h.d-(L.K),\'j\':h.j-(L.6/2)+(h.6/2)}
}
,18:n(){
i f={
\'J\':3.7.J}
;o(!3.e.R())H f;i N=3.e.R().I();H $M(f,{
\'6\':N.6}
)}
}
);O.1y(4 1z);',62,111,'|||this|new|tooltip|width|options|class|Element|div||injectInside|top|trigger|styles|event|trg|var|left|pos|||function|if|px|open||tooltip_tl||position|false|addEvent||||close|tooltip_l|bindWithEvent|hide|fx|opacity|sticky|return|getCoordinates|display|height|tip|extend|first|ToolTip|style|tooltip_style|getFirst|tooltip_tr|tooltip_b|tooltipClass|mode|injectAfter|tooltip_r|tooltip_bl|tooltip_br||mouseenter|content|Fx|show||page|start|triggerstyles|setStyles|cursor|setOptions|injectTop|duration|tr|document|tl|300|initialize|body|Class|visibility|yoo|wait|tooltip_t|inline|250|linear|Transitions|default|transition|index|absolute|hidden|implement|Options|Styles|arrow|else|mouseleave|Event|20|true|tooltip_arrow|23|tooltip_m|setHTML|bl|br'.split('|'),0,{
}
))
*/
var openToolTip = "";
var ToolTip=new Class({
					  
	initialize:function(trigger,content,options){
		this.setOptions({
			duration:300,
			transition:Fx.Transitions.linear,
			wait:false,
			tooltipClass:'yoo-tooltip',
			style:'default',
			width:250,
			display:'inline',
			mode:'cursor',
			sticky:0
		},options);

		this.open = false;
		this.trigger = $(trigger);
		this.trigger.setStyles( this.triggerstyles() );
		
		/* borders */
		this.tooltip=new Element('div',{			'class':this.options.tooltipClass,'styles':{			'position':'absolute','top':0,'left':0,'z-index':10,'visibility':'hidden','width':this.options.width}		}		).injectTop(document.body);
		this.tooltip_style=new Element('div',{		'class':this.options.style}		).injectInside(this.tooltip);
		this.tooltip_tl=new Element('div',{		'class':'tooltip-tl','styles':{		'width':this.options.width}		}		).injectInside(this.tooltip_style);
		this.tooltip_tr=new Element('div',{		'class':'tooltip-tr'}		).injectInside(this.tooltip_tl);
		this.tooltip_t=new Element('div',{		'class':'tooltip-t','styles':{		'height':15}		}		).injectInside(this.tooltip_tr);
		this.tooltip_l=new Element('div',{		'class':'tooltip-l','styles':{		'width':this.options.width}		}		).injectAfter(this.tooltip_tl);
		this.tooltip_r=new Element('div',{'class':'tooltip-r'}		).injectInside(this.tooltip_l);
		this.tooltip_m=new Element('div',{		'class':'tooltip-m'}		).injectInside(this.tooltip_r).setHTML(content);
		this.tooltip_bl=new Element('div',{'class':'tooltip-bl','styles':{'width':this.options.width}}).injectAfter(this.tooltip_l);
		this.tooltip_br=new Element('div',{'class':'tooltip-br'}).injectInside(this.tooltip_bl);
		this.tooltip_b=new Element('div',{'class':'tooltip-b'}).injectInside(this.tooltip_br);
		this.tooltip_arrow=new Element('div',{'class':'tooltip-arrow','styles':{'height':23} }
									   
	).injectInside(this.tooltip_b);

	if(this.options.sticky){
		this.close=new Element('div',{		'class':'tooltip-close'}		).injectInside(this.tooltip_tl)}
		this.fx=new Fx.Styles(this.tooltip,this.options);this.trigger.addEvent('mouseenter',this.show.bindWithEvent(this));if(this.options.sticky){
		this.close.addEvent('mouseenter',this.hide.bindWithEvent(this))
	} else {
		this.trigger.addEvent('mouseleave',this.hide.bindWithEvent(this))}
	}
	
	,show:function(event){
		if(!this.open){
			if (openToolTip != "") {
				openToolTip.hide();
			}
			openToolTip = this;
			this.pos=this.position(event);
			this.tooltip.setStyles({'opacity':0,'top':this.pos.top+'px','left':this.pos.left+'px'});
			this.fx.start({'opacity':1,'top':(this.pos.top-10)+'px'});
			this.open=true
		}
	}
	,hide:function(event){
		this.fx.start({	'opacity':0,'top':(this.pos.top-20)+'px'});
		this.open=false;
		openToolTip = "";
	}
	,position:function(event){
		var trg=this.trigger.getCoordinates();
		var tip=this.tooltip.getCoordinates();
		if(this.options.mode=='cursor'){
			var event=new Event(event);trg=$extend(trg,{'top':event.page.y,'left':event.page.x,'width':0})
		}
		return{'top':trg.top-(tip.height),'left':trg.left-(tip.width/2)+(trg.width/2)}
	}
	,triggerstyles:function(){
		var styles={'display':this.options.display};
		if(!this.trigger.getFirst())
			return styles;
			
		var first=this.trigger.getFirst().getCoordinates();
		return $extend(styles,{'width':first.width})
	}
});

ToolTip.implement(new Options);