var qTipTag="a,label,input,area,img,span,div,tr,td,th,li";
var qTipX=2;
var qTipY=16;
tooltip={name:"qTip",offsetX:qTipX,offsetY:qTipY,tip:null}
tooltip.init=function(){
var tipContainer=$("qTip")
if(!tipContainer){
tipContainer=document.createElement("div")
tipContainer.setAttribute("id","qTip")
document.getElementsByTagName("body").item(0).appendChild(tipContainer)
}
this.tip=$(this.name)
if(this.tip)document.onmousemove=function(evt){tooltip.move(evt)}
var a,sTitle,elements
var elementList=qTipTag.split(",")
for(var j=0;j<elementList.length;j++){
elements=document.getElementsByTagName(elementList[j])
if(elements){
for(var i=0;i<elements.length;i++){
a=elements[i]
sTitle=a.getAttribute("title")
if(sTitle!=null&&sTitle!=''){
a.setAttribute("tiptitle",sTitle)
a.removeAttribute("title")
a.onmouseover = function() {tooltip.show(this.getAttribute('tiptitle'))};
a.onmouseout = function() {tooltip.hide()};
}}}}}
tooltip.move=function(evt){
var x=0,y=0;
if (this.tip.style.display=="none") return;
if(document.all){
x=(document.documentElement&&document.documentElement.scrollLeft)?document.documentElement.scrollLeft:document.body.scrollLeft
y=(document.documentElement&&document.documentElement.scrollTop)?document.documentElement.scrollTop:document.body.scrollTop
x+=window.event.clientX
y+=window.event.clientY
}else{
x=evt.pageX
y=evt.pageY
}
//var w=document.body.clientWidth;
var w=(typeof(window.innerWidth)=='number')?window.innerWidth:document.documentElement.clientWidth
var h=(typeof(window.innerHeight)=='number')?window.innerHeight:document.documentElement.clientHeight

if (x < w/2){
	this.tip.style.left=(x+this.offsetX)+"px"
	this.tip.style.right=''
} else {
	this.tip.style.left=''
	this.tip.style.right=(w-x+this.offsetX/2)+"px"
}
if (y < h/2){
	this.tip.style.top=(y+this.offsetY)+"px"
	this.tip.style.bottom=''
} else {
	this.tip.style.top=''
	this.tip.style.bottom=(h-y+this.offsetY/2)+"px"
}
}
tooltip.show=function(text){
if(!this.tip)return
this.tip.innerHTML=text
this.tip.style.display="block"
}
tooltip.hide=function(){
if(!this.tip)return
this.tip.innerHTML=""
this.tip.style.display="none"
}
addEvt(window,'load',function(){tooltip.init()})

