var Tips={tips:[],zIndex:1200,add:function(_1){this.tips.push(_1);},remove:function(_2){var _3=this.tips.find(function(t){return t.element==$(_2);});if(!_3){return;}this.tips=this.tips.reject(function(t){return t==_3;});_3.deactivate();if(_3.tooltip){_3.wrapper.remove();}if(_3.underlay){_3.underlay.remove();}}};var Tip=Class.create();Tip.prototype={initialize:function(_6,_7){this.element=$(_6);Tips.remove(this.element);this.content=_7;this.options=Object.extend({className:"tooltip",duration:0.3,effect:false,hook:false,offset:(arguments[2]&&arguments[2].hook)?{x:0,y:0}:{x:16,y:16},fixed:false,target:this.element,title:false,viewport:true},arguments[2]||{});this.target=$(this.options.target);if(this.options.hook){this.options.fixed=true;this.options.viewport=false;}if(this.options.effect){this.queue={position:"end",limit:1,scope:""};var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";for(var i=0;i<6;i++){var r=Math.floor(Math.random()*c.length);this.queue.scope+=c.substring(r,r+1);}}this.buildWrapper();Tips.add(this);this.activate();},activate:function(){this.eventShow=this.showTip.safeBind(this);this.eventHide=this.hideTip.safeBind(this);this.element.observe("mousemove",this.eventShow);this.element.observe("mouseout",this.eventHide);},deactivate:function(){this.element.stopObserving("mousemove",this.eventShow);this.element.stopObserving("mouseout",this.eventHide);},buildWrapper:function(){this.wrapper=document.createElement("div");Element.setStyle(this.wrapper,{position:"absolute",zIndex:Tips.zIndex+1,display:"none"});if(Prototype.Browser.IE){this.underlay=document.createElement("iframe");this.underlay.src="javascript:;";Element.setStyle(this.underlay,{position:"absolute",display:"none",border:0,margin:0,opacity:0.01,padding:0,background:"none",zIndex:Tips.zIndex});}},buildTip:function(){if(Prototype.Browser.IE){document.body.appendChild(this.underlay);}this.tooltip=this.wrapper.appendChild(document.createElement("div"));this.tooltip.className=this.options.className;this.tooltip.style.position="relative";if(this.options.title){this.title=this.tooltip.appendChild(document.createElement("div"));this.title.className="title";Element.update(this.title,this.options.title);}this.tip=this.tooltip.appendChild(document.createElement("div"));this.tip.className="content";Element.update(this.tip,this.content);document.body.appendChild(this.wrapper);var w=this.wrapper.getDimensions();this.wrapper.setStyle({width:w.width+"px",height:w.height+"px"});if(Prototype.Browser.IE){this.underlay.setStyle({width:w.width+"px",height:w.height+"px"});}Element.hide(this.tooltip);},showTip:function(_c){if(!this.tooltip){this.buildTip();}this.positionTip(_c);if(this.wrapper.visible()&&this.options.effect!="appear"){return;}if(Prototype.Browser.IE){this.underlay.show();}this.wrapper.show();if(!this.options.effect){this.tooltip.show();}else{if(this.activeEffect){Effect.Queues.get(this.queue.scope).remove(this.activeEffect);}this.activeEffect=Effect[Effect.PAIRS[this.options.effect][0]](this.tooltip,{duration:this.options.duration,queue:this.queue});}},hideTip:function(_d){if(!this.wrapper.visible()){return;}if(!this.options.effect){if(Prototype.Browser.IE){this.underlay.hide();}this.tooltip.hide();this.wrapper.hide();}else{if(this.activeEffect){Effect.Queues.get(this.queue.scope).remove(this.activeEffect);}this.activeEffect=Effect[Effect.PAIRS[this.options.effect][1]](this.tooltip,{duration:this.options.duration,queue:this.queue,afterFinish:function(){if(Prototype.Browser.IE){this.underlay.hide();}this.wrapper.hide();}.bind(this)});}},positionTip:function(_e){var _f={"left":this.options.offset.x,"top":this.options.offset.y};var _10=Position.cumulativeOffset(this.target);var _11=this.wrapper.getDimensions();var pos={"left":(this.options.fixed)?_10[0]:Event.pointerX(_e),"top":(this.options.fixed)?_10[1]:Event.pointerY(_e)};pos.left+=_f.left;pos.top+=_f.top;if(this.options.hook){var _13={"target":this.target.getDimensions(),"tip":_11};var _14={"target":Position.cumulativeOffset(this.target),"tip":Position.cumulativeOffset(this.target)};for(var z in _14){switch(this.options.hook[z]){case "topRight":_14[z][0]+=_13[z].width;break;case "bottomLeft":_14[z][1]+=_13[z].height;break;case "bottomRight":_14[z][0]+=_13[z].width;_14[z][1]+=_13[z].height;break;}}pos.left+=-1*(_14.tip[0]-_14.target[0]);pos.top+=-1*(_14.tip[1]-_14.target[1]);}if(!this.options.fixed&&this.element!==this.target){var _16=Position.cumulativeOffset(this.element);pos.left+=-1*(_16[0]-_10[0]);pos.top+=-1*(_16[1]-_10[1]);}if(!this.options.fixed&&this.options.viewport){var _17=this.getScrollOffsets();var _18=this.viewportSize();var _19={"left":"width","top":"height"};for(var z in _19){if((pos[z]+_11[_19[z]]-_17[z])>_18[_19[z]]){pos[z]=pos[z]-_11[_19[z]]-2*_f[z];}}}this.wrapper.setStyle({left:pos.left+"px",top:pos.top+"px"});if(Prototype.Browser.IE){this.underlay.setStyle({left:pos.left+"px",top:pos.top+"px"});}},viewportWidth:function(){if(Prototype.Browser.Opera){return document.body.clientWidth;}return document.documentElement.clientWidth;},viewportHeight:function(){if(Prototype.Browser.Opera){return document.body.clientHeight;}if(Prototype.Browser.WebKit){return this.innerHeight;}return document.documentElement.clientHeight;},viewportSize:function(){return {"height":this.viewportHeight(),"width":this.viewportWidth()};},getScrollLeft:function(){return this.pageXOffset||document.documentElement.scrollLeft;},getScrollTop:function(){return this.pageYOffset||document.documentElement.scrollTop;},getScrollOffsets:function(){return {"left":this.getScrollLeft(),"top":this.getScrollTop()};}};Function.prototype.safeBind=function(){var _1b=this,args=$A(arguments),object=args.shift();return function(){if(typeof $A=="function"){return _1b.apply(object,args.concat($A(arguments)));}};};