Prototype.Browser={IE:!!(window.attachEvent&&!window.opera),Opera:!!window.opera,WebKit:navigator.userAgent.indexOf("AppleWebKit/")>-1,Gecko:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")==-1,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)};var FuckPosition={cumulativeOffset:function(b){var a=0,c=0;do{a+=b.offsetTop||0;c+=b.offsetLeft||0;b=b.offsetParent}while(b);return[c,a]}};var Tips={tips:[],zIndex:1200,add:function(a){this.tips.push(a)},remove:function(a){var b=this.tips.find(function(c){return c.element==$(a)});if(!b){return}this.tips=this.tips.reject(function(c){return c==b});b.deactivate();if(b.tooltip){b.wrapper.remove()}if(b.underlay){b.underlay.remove()}}};var Tip=Class.create();Tip.prototype={initialize:function(b,e){this.element=$(b);Tips.remove(this.element);this.content=e;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 f="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";for(var a=0;a<6;a++){var d=Math.floor(Math.random()*f.length);this.queue.scope+=f.substring(d,d+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"})},buildTip:function(){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 a=this.wrapper.getDimensions();this.wrapper.setStyle({width:a.width+"px",height:a.height+"px"});Element.hide(this.tooltip)},showTip:function(a){if(!this.tooltip){this.buildTip()}this.positionTip(a);if(this.wrapper.visible()&&this.options.effect!="appear"){return}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(a){if(!this.wrapper.visible()){return}if(!this.options.effect){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(){this.wrapper.hide()}.bind(this)})}},positionTip:function(a){var e={left:this.options.offset.x,top:this.options.offset.y};var f=FuckPosition.cumulativeOffset(this.target);var b=this.wrapper.getDimensions();var i={left:(this.options.fixed)?f[0]:Event.pointerX(a),top:(this.options.fixed)?f[1]:Event.pointerY(a)};i.left+=e.left;i.top+=e.top;if(this.options.hook){var k={target:this.target.getDimensions(),tip:b};var l={target:FuckPosition.cumulativeOffset(this.target),tip:FuckPosition.cumulativeOffset(this.target)};for(var h in l){switch(this.options.hook[h]){case"topRight":l[h][0]+=k[h].width;break;case"bottomLeft":l[h][1]+=k[h].height;break;case"bottomRight":l[h][0]+=k[h].width;l[h][1]+=k[h].height;break}}i.left+=-1*(l.tip[0]-l.target[0]);i.top+=-1*(l.tip[1]-l.target[1])}if(!this.options.fixed&&this.element!==this.target){var c=FuckPosition.cumulativeOffset(this.element);i.left+=-1*(c[0]-f[0]);i.top+=-1*(c[1]-f[1])}if(!this.options.fixed&&this.options.viewport){var j=this.getScrollOffsets();var g=this.viewportSize();var d={left:"width",top:"height"};for(var h in d){if((i[h]+b[d[h]]-j[h])>g[d[h]]){i[h]=i[h]-b[d[h]]-2*e[h]}}}this.wrapper.setStyle({left:i.left+"px",top:i.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 a=this,c=$A(arguments),b=c.shift();return function(){if(typeof $A=="function"){return a.apply(b,c.concat($A(arguments)))}}};