var ToolTip=Class.create();ToolTip.prototype={initialize:function(b){this.element=$(b);this.content=arguments[1]||"";this.options=Object.extend({dialog:"dialog",className:"tooltip",offsetX:20,offsetY:20,autoHide:true},arguments[2]||{});this.ajaxUrl=arguments[3]||"";this.outer=new Element("div",{style:"position:absolute; z-index:200;display:none;padding:0;margin:0;border:"});
this.outer.className=this.options.className;document.body.appendChild(this.outer);this.outerIframe=new Element("iframe",{style:"position:absolute; z-index:190;display:none;padding:0;margin:0;background:white;border:0",frameborder:"0",ulr:"/"});document.body.appendChild(this.outer);document.body.appendChild(this.outerIframe);
this.setup();this.dialog=$(this.options.dialog);},setup:function(){if(this.ajaxUrl!=""){(this.element).observe("mouseover",this.startTip.bindAsEventListener(this));}else{(this.element).observe("mouseover",this.startTip.bindAsEventListener(this));}(this.element).observe("mousemove",this.movingTip.bindAsEventListener(this));
(this.element).observe("mouseout",this.stopTip.bindAsEventListener(this));},startTip:function(b){this.setTip(b);if(this.ajaxUrl!=""){new Ajax.Request(this.ajaxUrl,{onSuccess:function(a){this.content=a.responseText;this.setTip();}.bindAsEventListener(this)});}else{this.setTip(b);}},movingTip:function(b){this.drawTip(b);
},stopTip:function(b){$(this.outer).hide();$(this.outerIframe).hide();},setTip:function(b){$(this.outer).update(this.content);this.tipWidth=$(this.outer).getWidth();this.tipHeight=$(this.outer).getHeight();$(this.outer).setStyle({width:this.tipWidth+"px"});$(this.outerIframe).setStyle({width:this.tipWidth+"px",height:this.tipHeight+"px"});
this.drawTip(b);},drawTip:function(b){this.getPosition(b);$(this.outerIframe).show();$(this.outer).show();},getPosition:function(l){var i=Event.pointerX(l)+this.options.offsetX;var j=Event.pointerY(l)+this.options.offsetY;var k=$(this.outer).getDimensions();var h=document.viewport.getScrollOffsets().top+document.viewport.getHeight();
var g=document.viewport.getScrollOffsets().left+document.viewport.getWidth();if((i+k.width)>g){i-=(k.width+2*this.options.offsetX);}if((j+k.height)>h){j=h-k.height;}i+="px";j+="px";this.options.X=i;this.options.Y=j;$(this.outerIframe).setStyle({top:j,left:i});$(this.outer).setStyle({top:j,left:i});},debug:function(b){$(this.dialog).update(b);
},debugProperties:function(){$(this.dialog).update("DEBUG: X = "+this.options.X+" Y = "+this.options.Y+" Height = "+this.outer.getHeight()+" Width = "+this.outer.getWidth());}};