var ab=null;var bb=0;var cb=1000;function Box(){this.has_shadow=true;this.shadow_size=5;this.classname="tooltip";this.width=0;this.height=0;this.x=0;this.y=0;this.content=null;this.id=bb++;this.dimmer=g("dim");this.clickaway_func=null;this.clickon_func=null;this.location=this.AUTO;this.box=null;this.shadow=null;this.relative_to_x=0;this.relative_to_y=0;this.centered_obj=null;this.is_visible=false;this.set_clickaway=function(db){this.clickaway_func=db;}
;this.set_clickon=function(db){this.clickon_func=db;}
;this.set_position_obj=function(eb,fb,gb,hb){if(!hb)hb=MIDDLE;if(!gb)gb=MIDDLE;this.location=eb;var ib=0,jb=0;var w=0,h=0;if(fb){var kb=lb(fb);ib=kb[0];jb=kb[1];w=fb.offsetWidth;h=fb.offsetHeight;}
else{w=Math.max(document.body.clientWidth,document.documentElement.clientWidth);h=Math.max(document.body.clientHeight,document.documentElement.clientHeight);}
ib+=(gb==MIDDLE)?(w/2):((gb==RIGHT)?w:0);jb+=(hb==MIDDLE)?(h/2):((hb==BOTTOM)?h:0);this.relative_to_x=ib;this.relative_to_y=jb;}
;this.set_position_point=function(eb,mb,nb){this.location=eb;this.relative_to_x=mb;this.relative_to_y=nb;}
;this.manifest=function(ob){var pb=typeof(this.content)=='string'?this.box:this.content;this.box=this.manifest_helper(pb);if(this.has_shadow){this.shadow=this.manifest_helper(this.shadow);this.shadow.className+="shadow";this.shadow.style.zIndex=cb++;}
this.box.style.zIndex=cb++;this.show(ob);}
;this.hide=function(){if(this.is_visible==false)return;if(this.clickaway_func){if(this==ab){ab=null;document.onclick=null;}
}
if(this.grab_keys)qb();this.box.style.display="none";if(this.has_shadow)this.shadow.style.display="none";if(this.dim_screen)this.dimmer.style.display="none";}
;this.show=function(ob){if(this.clickaway_func){this.add_clickaway();}
if(this.clickon_func){this.add_clickon();}
if(this.grab_keys)rb();if(!ob){this.box.style.visibility="hidden";this.box.style.left="0px";this.box.style.top="0px";if(this.shadow){this.shadow.style.visibility="hidden";this.shadow.style.left="0px";this.shadow.style.top="0px";}
}
this.box.style.display="block";if(this.has_shadow)this.shadow.style.display="block";if(this.dim_screen)this.dimmer.style.display="block";this.position();this.box.style.visibility="visible";if(this.shadow)this.shadow.style.visibility="visible";this.is_visible=true;}
;this.add_clickaway=function(){if(ab){ab.hide();}
ab=this;if(!this.clickon_func){this.box.onclick=function(e){if(!e)var e=window.event;if(e.stopPropagation)e.stopPropagation();e.cancelBubble=true;}
;}
var a=this.clickaway_func;var b=this;document.onclick=function(e){a(b);}
;}
;this.add_clickon=function(){var a=this.clickon_func;var b=this;this.box.onclick=function(e){if(!e)var e=window.event;if(e.stopPropagation)e.stopPropagation();e.cancelBubble=true;a(b);}
;}
;this.manifest_helper=function(sb){var b=sb?sb:document.createElement("div");b.className=this.classname;if(this.width)b.style.width=this.width+"px";if(this.height)b.style.height=this.height+"px";if(typeof(this.content)=='string')b.innerHTML=this.content;if(sb==null)document.body.appendChild(b);b.style.display="none";return b;}
;this.position=function(){var tb=this.shadow_size;var ub=this.relative_to_x;var vb=this.relative_to_y;var x=ub+this.x;var y=vb+this.y;var wb=this.box.offsetWidth;var xb=this.box.offsetHeight;if(this.location==AUTO){var yb=Math.max(document.body.clientWidth,document.documentElement.clientWidth)-10;var zb=Math.max(document.body.clientHeight,document.documentElement.clientHeight)-10;if(x+wb+tb>yb){x=ub-this.x-wb;if(x<10)x=10;}
if(y+xb+tb>zb){y=vb-this.y-xb;if(y<10)y=10;}
}
else if(this.location==CENTERED){x-=wb/2;y-=xb/2;}
this.box.style.left=x+"px";this.box.style.top=y+"px";if(this.has_shadow){this.shadow.style.left=(x+tb)+"px";this.shadow.style.top=(y+tb)+"px";this.shadow.style.width=(wb-4)+"px";this.shadow.style.height=(xb-4)+"px";}
}
;}
;