var Prototip={Version:"1.2.0_pre1",REQUIRED_Prototype:"1.6.0",REQUIRED_Scriptaculous:"1.8.0",start:function(){this.require("Prototype");Tips.initialize();Element.observe(window,"unload",this.unload)},require:function(B){if((typeof window[B]=="undefined")||(this.convertVersionString(window[B].Version)<this.convertVersionString(this["REQUIRED_"+B]))){throw ("Prototip requires "+B+" >= "+this["REQUIRED_"+B])}},convertVersionString:function(C){var D=C.split(".");return parseInt(D[0])*100000+parseInt(D[1])*1000+parseInt(D[2])},viewport:{getDimensions:function(){var B={};var D=Prototype.Browser;$w("width height").each(function(A){var C=A.capitalize();B[A]=(D.WebKit&&!document.evaluate)?self["inner"+C]:(D.Opera)?document.body["client"+C]:document.documentElement["client"+C]});return B}},capture:function(B){if(!Prototype.Browser.IE){B=B.wrap(function(F,G){var H=G.relatedTarget,A=G.currentTarget;if(H&&H.nodeType==Node.TEXT_NODE){H=H.parentNode}if(H&&H!=A&&H.descendantOf&&!(H.descendantOf(A))){F(G)}})}return B},unload:function(){Tips.removeAll()}};var Tips={closeButtons:false,zIndex:1200,tips:[],visible:[],initialize:function(){this.zIndexTop=this.zIndex},useEvent:(function(B){return{mouseover:(B?"mouseenter":"mouseover"),mouseout:(B?"mouseleave":"mouseout"),mouseenter:(B?"mouseenter":"mouseover"),mouseleave:(B?"mouseleave":"mouseout")}})(Prototype.Browser.IE),fixIE:(function(D){var C=new RegExp("MSIE ([\\d.]+)").exec(D);return C?(parseFloat(C[1])<=6):false})(navigator.userAgent),add:function(B){this.tips.push(B)},remove:function(C){var D=this.tips.find(function(A){return A.element==$(C)});if(D){D.deactivate();if(D.tooltip){D.wrapper.remove();if(Tips.fixIE){D.iframeShim.remove()}}this.tips=this.tips.without(D)}},removeAll:function(){this.tips.each(function(B){this.remove(B.element)}.bind(this))},raise:function(D){if(D.highest){return }if(this.visible.length==0){this.zIndexTop=this.zIndex;for(var C=0;C<this.tips.length;C++){this.tips[C].wrapper.style.zIndex=this.zIndex}}D.style.zIndex=this.zIndexTop++;for(var C=0;C<this.tips.length;C++){this.tips[C].wrapper.highest=false}D.highest=true},addVisibile:function(B){this.removeVisible(B);this.visible.push(B)},removeVisible:function(B){this.visible=this.visible.without(B)}};Tips.initialize();var Tip=Class.create({initialize:function(E,H){this.element=$(E);Tips.remove(this.element);this.content=H;var F=(arguments[2]&&arguments[2].hook);var G=(arguments[2]&&arguments[2].showOn=="click");this.options=Object.extend({className:"default",closeButton:Tips.closeButtons,delay:!G?0.2:false,duration:0.3,effect:false,hideAfter:false,hideOn:"mouseleave",hook:false,offset:F?{x:0,y:0}:{x:16,y:16},fixed:F?true:false,showOn:"mousemove",target:this.element,title:false,viewport:F?false:true},arguments[2]||{});this.target=$(this.options.target);this.setup();if(this.options.effect){Prototip.require("Scriptaculous");this.queue={position:"end",limit:1,scope:this.wrapper.identify()}}Tips.add(this);this.activate()},setup:function(){this.wrapper=new Element("div",{"class":"prototip"}).setStyle({display:"none",zIndex:Tips.zIndex});this.wrapper.identify();if(Tips.fixIE){this.iframeShim=new Element("iframe",{"class":"iframeShim",src:"javascript:false;"}).setStyle({display:"none",zIndex:Tips.zIndex-1})}this.tip=new Element("div",{"class":"content"}).insert(this.content);this.tip.insert(new Element("div").setStyle({clear:"both"}));if(this.options.closeButton||(this.options.hideOn.element&&this.options.hideOn.element=="closeButton")){this.closeButton=new Element("a",{href:"#","class":"close"})}},build:function(){if(Tips.fixIE){document.body.appendChild(this.iframeShim).setOpacity(0)}var F="wrapper";if(this.options.effect){this.effectWrapper=this.wrapper.appendChild(new Element("div",{"class":"effectWrapper"}));F="effectWrapper"}this.tooltip=this[F].appendChild(new Element("div",{"class":"tooltip "+this.options.className}));if(this.options.title||this.options.closeButton){this.toolbar=this.tooltip.appendChild(new Element("div",{"class":"toolbar"}));this.title=this.toolbar.appendChild(new Element("div",{"class":"title"}).update(this.options.title||" "))}this.tooltip.insert(this.tip);document.body.appendChild(this.wrapper);var E=(this.options.effect)?[this.wrapper,this.effectWrapper]:[this.wrapper];if(Tips.fixIE){E.push(this.iframeShim)}var G=this.wrapper.getWidth();E.invoke("setStyle",{width:G+"px"});if(this.toolbar){this.wrapper.setStyle({visibility:"hidden"}).show();this.toolbar.setStyle({width:this.toolbar.getWidth()+"px"});this.wrapper.hide().setStyle({visibility:"visible"})}if(this.closeButton){this.title.insert({top:this.closeButton}).insert(new Element("div").setStyle({clear:"both"}))}var H=this.wrapper.getHeight();E.invoke("setStyle",{width:G+"px",height:H+"px"});this[this.options.effect?F:"tooltip"].hide()},activate:function(){this.eventShow=this.showDelayed.bindAsEventListener(this);this.eventHide=this.hide.bindAsEventListener(this);if(this.options.fixed&&this.options.showOn=="mousemove"){this.options.showOn="mouseover"}if(this.options.showOn==this.options.hideOn){this.eventToggle=this.toggle.bindAsEventListener(this);this.element.observe(this.options.showOn,this.eventToggle)}var G={element:this.eventToggle?[]:[this.element],target:this.eventToggle?[]:[this.target],tip:this.eventToggle?[]:[this.wrapper],closeButton:[],none:[]};var E=this.options.hideOn.element;this.hideElement=E||(!this.options.hideOn?"none":"element");this.hideTargets=G[this.hideElement];if(!this.hideTargets&&E&&Object.isString(E)){this.hideTargets=this.tip.select(E)}var F={mouseenter:"mouseover",mouseleave:"mouseout"};$w("show hide").each(function(A){var B=A.capitalize();var C=(this.options[A+"On"].event||this.options[A+"On"]);this[A+"Action"]=C;if(["mouseenter","mouseleave","mouseover","mouseout"].include(C)){this[A+"Action"]=(Tips.useEvent[C]||C);this["event"+B]=Prototip.capture(this["event"+B])}}.bind(this));if(!this.eventToggle){this.element.observe(this.options.showOn,this.eventShow)}if(this.hideTargets){this.hideTargets.invoke("observe",this.hideAction,this.eventHide)}if(!this.options.fixed&&this.options.showOn=="click"){this.eventPosition=this.position.bindAsEventListener(this);this.element.observe("mousemove",this.eventPosition)}this.buttonEvent=this.hide.wrap(function(A,B){B.stop();A(B)}).bindAsEventListener(this);if(this.closeButton){this.closeButton.observe("click",this.buttonEvent)}if(this.options.showOn!="click"&&(this.hideElement!="element")){this.eventCheckDelay=Prototip.capture(function(){this.clearTimer("show")}).bindAsEventListener(this);this.element.observe(Tips.useEvent.mouseout,this.eventCheckDelay)}var H=[this.element,this.wrapper];this.activityEnter=Prototip.capture(function(){Tips.raise(this.wrapper);this.cancelHideAfter()}).bindAsEventListener(this);this.activityLeave=Prototip.capture(this.hideAfter).bindAsEventListener(this);H.invoke("observe",Tips.useEvent.mouseover,this.activityEnter);H.invoke("observe",Tips.useEvent.mouseout,this.activityLeave)},deactivate:function(){if(this.options.showOn==this.options.hideOn){this.element.stopObserving(this.options.showOn,this.eventToggle)}else{this.element.stopObserving(this.options.showOn,this.eventShow);if(this.hideTargets){this.hideTargets.invoke("stopObserving")}}if(this.eventPosition){this.element.stopObserving("mousemove",this.eventPosition)}if(this.closeButton){this.closeButton.stopObserving()}if(this.eventCheckDelay){this.element.stopObserving("mouseout",this.eventCheckDelay)}this.wrapper.stopObserving();this.element.stopObserving(Tips.useEvent.mouseover,this.activityEnter);this.element.stopObserving(Tips.useEvent.mouseout,this.activityLeave)},showDelayed:function(B){if(!this.tooltip){this.build()}this.position(B);if(this.wrapper.visible()){return }this.clearTimer("show");this.showTimer=this.show.bind(this).delay(this.options.delay)},clearTimer:function(B){if(this[B+"Timer"]){clearTimeout(this[B+"Timer"])}},show:function(){if(this.wrapper.visible()&&this.options.effect!="appear"){return }if(Tips.fixIE){this.iframeShim.show()}Tips.addVisibile(this.wrapper);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.effectWrapper,{duration:this.options.duration,queue:this.queue})}},hideAfter:function(B){if(!this.options.hideAfter){return }this.cancelHideAfter();this.hideAfterTimer=this.hide.bind(this).delay(this.options.hideAfter)},cancelHideAfter:function(){if(this.options.hideAfter){this.clearTimer("hideAfter")}},hide:function(){this.clearTimer("show");if(!this.wrapper.visible()){return }if(!this.options.effect){if(Tips.fixIE){this.iframeShim.hide()}this.tooltip.hide();this.wrapper.hide();Tips.removeVisible(this.wrapper)}else{if(this.activeEffect){Effect.Queues.get(this.queue.scope).remove(this.activeEffect)}this.activeEffect=Effect[Effect.PAIRS[this.options.effect][1]](this.effectWrapper,{duration:this.options.duration,queue:this.queue,afterFinish:function(){if(Tips.fixIE){this.iframeShim.hide()}this.wrapper.hide();Tips.removeVisible(this.wrapper)}.bind(this)})}},toggle:function(B){if(this.wrapper&&this.wrapper.visible()){this.hide(B)}else{this.showDelayed(B)}},position:function(Q){Tips.raise(this.wrapper);var Z={left:this.options.offset.x,top:this.options.offset.y};var Y=Position.cumulativeOffset(this.target);var P=this.wrapper.getDimensions();var V={left:(this.options.fixed)?Y[0]:Event.pointerX(Q),top:(this.options.fixed)?Y[1]:Event.pointerY(Q)};V.left+=Z.left;V.top+=Z.top;if(this.options.hook){var T={target:this.target.getDimensions(),tip:P};var S={target:Position.cumulativeOffset(this.target),tip:Position.cumulativeOffset(this.target)};for(var W in S){switch(this.options.hook[W]){case"topRight":S[W][0]+=T[W].width;break;case"topMiddle":S[W][0]+=(T[W].width/2);break;case"rightMiddle":S[W][0]+=T[W].width;S[W][1]+=(T[W].height/2);break;case"bottomLeft":S[W][1]+=T[W].height;break;case"bottomRight":S[W][0]+=T[W].width;S[W][1]+=T[W].height;break;case"bottomMiddle":S[W][0]+=(T[W].width/2);S[W][1]+=T[W].height;break;case"leftMiddle":S[W][1]+=(T[W].height/2);break}}V.left+=-1*(S.tip[0]-S.target[0]);V.top+=-1*(S.tip[1]-S.target[1])}if(!this.options.fixed&&this.element!==this.target){var O=Position.cumulativeOffset(this.element);V.left+=-1*(O[0]-Y[0]);V.top+=-1*(O[1]-Y[1])}if(!this.options.fixed&&this.options.viewport){var U=document.viewport.getScrollOffsets();var X=Prototip.viewport.getDimensions();var N={left:"width",top:"height"};for(var W in N){if((V[W]+P[N[W]]-U[W])>X[N[W]]){V[W]=V[W]-P[N[W]]-2*Z[W]}}}var R={left:V.left+"px",top:V.top+"px"};this.wrapper.setStyle(R);if(Tips.fixIE){this.iframeShim.setStyle(R)}}});Prototip.start();
