//--------------------------------------------------------
// ttip.js - javascript routines for tooltips
// $id: ttip, $ver: 0.15, $last: 23.04.2003 14:10:59  Exp$
// $dsc: tooltips with border, follow-up and fade-in
// $auth: eugene yumatov, gene2109@mail.ru
//--------------------------------------------------------

dx=12
dy=20
dtype=0
var fade=1
var delay=300

var px=mybw.ns4||mybw.op?"":"px"

//constructor
function mktip(obj){
d=document
this.elm=d.getElementById?d.getElementById(obj):mybw.ie4?d.all[obj]:mybw.ns4?d.layers[obj]:0
this.css=mybw.ns4?this.elm:this.elm.style
this.wref=mybw.ns4?this.elm.document:this.elm
this.obj=obj+'mktip'; eval(this.obj+'=this')
this.w=mybw.ns4?this.elm.clip.width:this.elm.offsetWidth
this.h=mybw.ns4?this.elm.clip.height:this.elm.offsetHeight
}

mktip.prototype.calc=function(){
this.w=mybw.ns4?this.elm.clip.width:this.elm.offsetWidth
this.h=mybw.ns4?this.elm.clip.height:this.elm.offsetHeight
}

mktip.prototype.print=function(text){
if(mybw.ns4) {this.wref.write(text);this.wref.close()}
else this.wref.innerHTML=text
}

var mx=0,my=0,setX=0,setY=0

function micemove(e){
b=document.body
mx=(mybw.ns4up)?e.pageX:mybw.ie5up&&mybw.win?(event.clientX-2)+b.scrollLeft:event.clientX+b.scrollLeft
my=(mybw.ns4up)?e.pageY:mybw.ie5up&&mybw.win?(event.clientY-2)+b.scrollTop:event.clientY+b.scrollTop
if(yet && hover) place()
}

function place(){
if(dtype==1) setX=mx+dx+ttip.w>scrldw?scrldw-ttip.w:mx+dx
if(dtype==1) setY=my+dy+ttip.h>scrldh?scrldh-ttip.h:my+dy
if(dtype==0) setX=mx+dx+ttip.w>scrldw?mx-dx-ttip.w:mx+dx
if(dtype==0) setY=my+dy+ttip.h>scrldh?my-dy-ttip.h:my+dy
if(setX<0) setX=0
if(setY<0) setY=0
ttip.css.left=setX+px
ttip.css.top=setY+px
}

var hover=false,scrldw=0,scrldh=0

mktip.prototype.showtmr=null

function tip(msg){
if(yet){
if(msg==""){ttip.poptmr=setTimeout('dohide()',10)}
else{
clearTimeout(ttip.poptmr)
dohide()
if (mybw.ns4){
var text='<span class=ns4>'+msg+'</span>'
ttip.print(text)
}
if (!mybw.ns4) ttip.print(msg)

b=document.body
scrldw=scrw+(mybw.ie?b.scrollLeft:pageXOffset)
scrldh=scrh+(mybw.ie?b.scrollTop:pageYOffset)

hover=true

if (mybw.ie4) setTimeout('ttip.calc();place();',delay/2)
else { ttip.calc();place() }
if (fade) ttip.showtmr=setTimeout('ttip.blendIn()', delay)
if (!fade) ttip.showtmr=setTimeout('ttip.css.visibility="visible"', delay)
}
}
}//tip

mktip.prototype.poptmr=null

function dohide(){
hover=false
clearTimeout(ttip.showtmr)
ttip.css.visibility='hidden'
clearTimeout(ttip.fadetmr)
ttip.i=0
}

var scrbarw=mybw.ns6up&&mybw.win?14:mybw.ns6up&&!mybw.win?16:mybw.ns4?16:0

function sizes() {
b=document.body
ttip.css.top=0+px
ttip.css.left=0+px
scrw=(mybw.ie?b.clientWidth:innerWidth)-scrbarw
scrh=(mybw.ie?b.clientHeight:innerHeight)
// chain to previous "onResize" handler
if (oldresize!=null) oldresize()
}

mktip.prototype.blendIn=function(){
if (mybw.ie5up && mybw.win) {
this.css.filter='blendTrans(duration=0.4)'
this.elm.filters.blendTrans.apply()
this.css.visibility='visible'
this.elm.filters.blendTrans.play()
}
else {
this.css.visibility='visible'
if (mybw.ns6up) this.fadens6()
}
}

mktip.prototype.step=10
mktip.prototype.i=0
mktip.prototype.fadetmr=null

mktip.prototype.fadens6=function(){
this.i+=this.step
this.css.MozOpacity=this.i/100
if (this.i<100) this.fadetmr=setTimeout(this.obj+'.fadens6()',40)
else this.i=0
}

function popini(){
ttip=new mktip('divtooltip')
ttip.elm.onmouseover=function(){ clearTimeout(ttip.poptmr);if(mybw.ns4){setTimeout('clearTimeout(ttip.poptmr)',20)}; }
ttip.elm.onmouseout=dohide
if(mybw.ns4) d.captureEvents(Event.MOUSEMOVE)
d.onmousemove=micemove
sizes()
// + 23.04.2003 14:10:59 -> chain to prev handler
if (!mybw.ns4) { oldresize=eval(window.onresize); window.onresize=sizes; }
if (!mybw.ns4) ttip.elm.className='plain'
if (mybw.ie5up && mybw.win) ttip.css.filter='alpha(opacity=100)'
if (mybw.ns6up) delay=100
if (mybw.gecko) fade=0
yet=true
}

var oldresize=null
var yet=false
