var Prototip={Version:"1.1.0",REQUIRED_Prototype:"1.6.0",REQUIRED_Scriptaculous:"1.8.0",start:function(){
this.require("Prototype");
},require:function(_1){
if((typeof window[_1]=="undefined")||(this.convertVersionString(window[_1].Version)<this.convertVersionString(this["REQUIRED_"+_1]))){
throw ("Prototip requires "+_1+" >= "+this["REQUIRED_"+_1]);
}
},convertVersionString:function(_2){
var r=_2.split(".");
return parseInt(r[0])*100000+parseInt(r[1])*1000+parseInt(r[2]);
},viewport:{getDimensions:function(){
var _4={};
var B=Prototype.Browser;
$w("width height").each(function(d){
var D=d.capitalize();
if(B.Opera){
_4[d]=document.body["client"+D];
}else{
if(B.WebKit){
_4[d]=self["inner"+D];
}else{
_4[d]=document.documentElement["client"+D];
}
}
});
return _4;
}}};
Prototip.start();
var Tips={closeButtons:false,zIndex:1200,fixIE:(function(_8){
var _9=new RegExp("MSIE ([\\d.]+)").exec(_8);
return _9?(parseFloat(_9[1])<=6):false;
})(navigator.userAgent),tips:[],visible:[],add:function(_a){
this.tips.push(_a);
},remove:function(_b){
var _c=this.tips.find(function(t){
return t.element==$(_b);
});
if(_c){
_c.deactivate();
if(_c.tooltip){
_c.wrapper.remove();
if(Tips.fixIE){
_c.iframeShim.remove();
}
}
this.tips=this.tips.without(_c);
}
},zIndexRestore:1200,raise:function(_e){
var _f=this.zIndexHighest();
if(!_f){
_e.style.zIndex=this.zIndexRestore;
return;
}
var _10=(_e.style.zIndex!=_f)?_f+1:_f;
this.tips.pluck("wrapper").invoke("removeClassName","highest");
_e.setStyle({zIndex:_10}).addClassName("highest");
},zIndexHighest:function(){
var _11=this.visible.max(function(v){
return parseInt(v.style.zIndex);
});
return _11;
},addVisibile:function(tip){
this.removeVisible(tip);
this.visible.push(tip);
},removeVisible:function(tip){
this.visible=this.visible.without(tip);
}};
var Tip=Class.create({initialize:function(_15,_16){
this.element=$(_15);
Tips.remove(this.element);
this.content=_16;
var _17=(arguments[2]&&arguments[2].hook);
var _18=(arguments[2]&&arguments[2].showOn=="click");
this.options=Object.extend({className:"default",closeButton:Tips.closeButtons,delay:!_18?0.2:false,duration:0.3,effect:false,hideOn:"mouseout",hook:false,offset:_17?{x:0,y:0}:{x:16,y:16},fixed:_17?true:false,showOn:"mousemove",target:this.element,title:false,viewport:_17?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.zIndexRestore-1});
}
this.tip=new Element("div",{"class":"content"}).update(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:"javascript:;","class":"close"});
}
},build:function(){
if(Tips.fixIE){
document.body.appendChild(this.iframeShim).setOpacity(0);
}
var _19="wrapper";
if(this.options.effect){
this.effectWrapper=this.wrapper.appendChild(new Element("div",{"class":"effectWrapper"}));
_19="effectWrapper";
}
this.tooltip=this[_19].appendChild(new Element("div",{"class":"tooltip "+this.options.className}));
this.title=this.tooltip.appendChild(new Element("div",{"class":"title"}).update(" "));
this.tooltip.insert(this.tip);
this.footer=this.tooltip.appendChild(new Element("div",{"class":"footer"}).update(" "));
document.body.appendChild(this.wrapper);
var _1a=(this.options.effect)?[this.wrapper,this.effectWrapper]:[this.wrapper];
if(Tips.fixIE){
_1a.push(this.iframeShim);
}
var _1b=this.wrapper.getWidth();
_1a.invoke("setStyle",{width:_1b+"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 _1c=this.wrapper.getHeight();
_1a.invoke("setStyle",{width:_1b+"px",height:_1c+"px"});
this[this.options.effect?_19:"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);
}
this.hideElement=Object.isUndefined(this.options.hideOn.element)?"element":this.options.hideOn.element;
var _1d={"element":this.eventToggle?[]:[this.element],"target":this.eventToggle?[]:[this.target],"tip":this.eventToggle?[]:[this.wrapper],"closeButton":[],".close":this.tip.select(".close")};
this.hideTargets=_1d[this.hideElement];
if(this.element&&!this.eventToggle){
this.element.observe(this.options.showOn,this.eventShow);
}
this.hideAction=(this.options.hideOn.event||this.options.hideOn);
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);
}
if(this.closeButton){
this.closeButton.observe("click",this.eventHide);
}
if(this.options.showOn!="click"&&this.hideElement!="element"){
this.eventCheckDelay=this.checkDelay.bindAsEventListener(this);
this.element.observe("mouseout",this.eventCheckDelay);
}
this.wrapper.observe("mouseover",function(){
Tips.raise(this.wrapper);
}.bind(this));
},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);
this.hideTargets.invoke("stopObserving",this.hideAction,this.eventHide);
}
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();
},showDelayed:function(_1e){
if(!this.tooltip){
this.build();
}
this.position(_1e);
if(this.wrapper.visible()){
return;
}
this.checkDelay();
this.timer=this.show.bind(this).delay(this.options.delay);
},checkDelay:function(){
if(this.timer){
clearTimeout(this.timer);
this.timer=null;
}
},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});
}
},hide:function(){
this.checkDelay();
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(_1f){
if(this.wrapper&&this.wrapper.visible()){
this.hide(_1f);
}else{
this.showDelayed(_1f);
}
},position:function(_20){
if(!this.wrapper.hasClassName("highest")){
Tips.raise(this.wrapper);
}
var _21={left:this.options.offset.x,top:this.options.offset.y};
var _22=Position.cumulativeOffset(this.target);
var _23=this.wrapper.getDimensions();
var pos={left:(this.options.fixed)?_22[0]:Event.pointerX(_20),top:(this.options.fixed)?_22[1]:Event.pointerY(_20)};
pos.left+=_21.left;
pos.top+=_21.top;
if(this.options.hook){
var _25={target:this.target.getDimensions(),tip:_23};
var _26={target:Position.cumulativeOffset(this.target),tip:Position.cumulativeOffset(this.target)};
for(var z in _26){
switch(this.options.hook[z]){
case "topRight":
_26[z][0]+=_25[z].width;
break;
case "topMiddle":
_26[z][0]+=(_25[z].width/2);
break;
case "rightMiddle":
_26[z][0]+=_25[z].width;
_26[z][1]+=(_25[z].height/2);
break;
case "bottomLeft":
_26[z][1]+=_25[z].height;
break;
case "bottomRight":
_26[z][0]+=_25[z].width;
_26[z][1]+=_25[z].height;
break;
case "bottomMiddle":
_26[z][0]+=(_25[z].width/2);
_26[z][1]+=_25[z].height;
break;
case "leftMiddle":
_26[z][1]+=(_25[z].height/2);
break;
}
}
pos.left+=-1*(_26.tip[0]-_26.target[0]);
pos.top+=-1*(_26.tip[1]-_26.target[1]);
}
if(!this.options.fixed&&this.element!==this.target){
var _28=Position.cumulativeOffset(this.element);
pos.left+=-1*(_28[0]-_22[0]);
pos.top+=-1*(_28[1]-_22[1]);
}
if(!this.options.fixed&&this.options.viewport){
var _29=document.viewport.getScrollOffsets();
var _2a=Prototip.viewport.getDimensions();
var _2b={left:"width",top:"height"};
for(var z in _2b){
if((pos[z]+_23[_2b[z]]-_29[z])>_2a[_2b[z]]){
pos[z]=pos[z]-_23[_2b[z]]-2*_21[z];
}
}
}
var _2d={left:pos.left+"px",top:pos.top+"px"};
this.wrapper.setStyle(_2d);
if(Tips.fixIE){
this.iframeShim.setStyle(_2d);
}
}});


