function getviewportheight() {
if (window.innerheight!=window.undefined) return window.innerheight;
if (document.compatmode=='css1compat') return document.documentelement.clientheight;
if (document.body) return document.body.clientheight;
return window.undefined;
}
function getviewportwidth() {
if (window.innerwidth!=window.undefined) return window.innerwidth;
if (document.compatmode=='css1compat') return document.documentelement.clientwidth;
if (document.body) return document.body.clientwidth;
return window.undefined;
}
/**
* gets the real scroll top
*/
function getscrolltop() {
if (self.pageyoffset) // all except explorer
{
return self.pageyoffset;
}
else if (document.documentelement && document.documentelement.scrolltop)
// explorer 6 strict
{
return document.documentelement.scrolltop;
}
else if (document.body) // all other explorers
{
return document.body.scrolltop;
}
}
function getscrollleft() {
if (self.pagexoffset) // all except explorer
{
return self.pagexoffset;
}
else if (document.documentelement && document.documentelement.scrollleft)
// explorer 6 strict
{
return document.documentelement.scrollleft;
}
else if (document.body) // all other explorers
{
return document.body.scrollleft;
}
}
/*
渐变的弹出图片
使用方法:
将tooltip.js包含在网页body的结束标签后
调用方法:
必须css样式
.trans_msg
{
filter:alpha(opacity=100,enabled=1) revealtrans(duration=.2,transition=1) blendtrans(duration=.2);
}
*/
//--初始化变量--
var rt=true;//允许图像过渡
var bt=true;//允许图像淡入淡出
var tw=150;//提示框宽度
var endaction=false;//结束动画
var ns4 = document.layers;
var ns6 = document.getelementbyid && !document.all;
var ie4 = document.all;
offsetx = 10;
offsety = 20;
var tooltipstyle="";
function inittooltips()
{
tempdiv = document.createelement("div");
tempdiv.id = "tooltiplayer";
tempdiv.style.position = "absolute";
tempdiv.style.display = "none";
document.body.appendchild(tempdiv);
if(ns4||ns6||ie4)
{
if(ns4) tooltipstyle = document.tooltiplayer;
else if(ns6) tooltipstyle = document.getelementbyid("tooltiplayer").style;
else if(ie4) tooltipstyle = document.all.tooltiplayer.style;
if(ns4) document.captureevents(event.mousemove);
else
{
tooltipstyle.visibility = "visible";
tooltipstyle.display = "none";
}
document.onmousemove = movetomouseloc;
}
}
function tooltip(msg, fg, bg)
{
try {
if(tooltip.arguments.length < 1) // hide
{
if(ns4)
{
tooltipstyle.visibility = "hidden";
}
else
{
//--图象过渡,淡出处理--
if (!endaction) {tooltipstyle.display = "none";}
if (rt) document.all("msg1").filters[1].apply();
if (bt) document.all("msg1").filters[2].apply();
document.all("msg1").filters[0].opacity=0;
if (rt) document.all("msg1").filters[1].play();
if (bt) document.all("msg1").filters[2].play();
if (rt){
if (document.all("msg1").filters[1].status==1 || document.all("msg1").filters[1].status==0){
tooltipstyle.display = "none";}
}
if (bt){
if (document.all("msg1").filters[2].status==1 || document.all("msg1").filters[2].status==0){
tooltipstyle.display = "none";}
}
if (!rt && !bt) tooltipstyle.display = "none";
//----------------------
}
}
else // show
{
if(!fg) fg = "#777777";
if(!bg) bg = "#eeeeee";
var content =
'
';
if(ns4)
{
tooltipstyle.document.write(content);
tooltipstyle.document.close();
tooltipstyle.visibility = "visible";
}
if(ns6)
{
document.getelementbyid("tooltiplayer").innerhtml = content;
tooltipstyle.display='block'
}
if(ie4)
{
document.all("tooltiplayer").innerhtml=content;
tooltipstyle.display='block'
//--图象过渡,淡入处理--
var cssopaction=document.all("msg1").filters[0].opacity
document.all("msg1").filters[0].opacity=0;
if (rt) document.all("msg1").filters[1].apply();
if (bt) document.all("msg1").filters[2].apply();
document.all("msg1").filters[0].opacity=cssopaction;
if (rt) document.all("msg1").filters[1].play();
if (bt) document.all("msg1").filters[2].play();
//----------------------
}
}
} catch(e) {}
}
function movetomouseloc(e)
{
var scrolltop = getscrolltop();
var scrollleft = getscrollleft();
if(ns4||ns6)
{
x = e.pagex + scrollleft;
y = e.pagey - scrolltop;
}
else
{
x = event.clientx + scrollleft;
y = event.clienty;
}
if (x-scrollleft > getviewportwidth() / 2) {
x = x - document.getelementbyid("tooltiplayer").offsetwidth - 2 * offsetx;
}
if ((y+document.getelementbyid("tooltiplayer").offsetheight+offsety)>getviewportheight()) {
y = getviewportheight()-document.getelementbyid("tooltiplayer").offsetheight-offsety;
}
tooltipstyle.left = (x + offsetx)+'px';
tooltipstyle.top = (y + offsety + scrolltop)+'px';
return true;
}
inittooltips();