<script type="text/javascript">
var Common = {
getItself: function(id) {
return "string" == typeof id ? document.getElementById(id) : id;
},
getTextSize: function(text) {
var span = document.createElement("span");
var result = {};
result.width = span.offsetWidth;
result.height = span.offsetWidth;
span.style.visibility = "hidden";
document.body.appendChild(span);
if (typeof span.textContent != "undefined") span.textContent = text;
else span.innerText = text;
result.width = span.offsetWidth - result.width;
result.height = span.offsetHeight - result.height;
span.parentNode.removeChild(span);
return result;
}
}
var TitleTip = {
showTitleTip: function(param, linkObj, e) {
var div;
if (document.getElementById("TitleTipDiv")) {
document.body.removeChild(document.getElementById("TitleTipDiv"));
}
div = document.createElement("div");
div.id = "TitleTipDiv";
div.innerHTML = linkObj.tip;
document.body.appendChild(div);
if (param && param.width) {
if (Common.getTextSize(div.innerHTML).width < param.width) {
div.style.maxWidth = param.width + "px";
} else {
div.style.width = param.width + "px";
}
}
div.style.display = "";
div.style.top = linkObj.offsetTop + linkObj.offsetHeight + 8 + "px";
div.style.left = linkObj.offsetLeft + linkObj.offsetWidth/2 + "px";
if (param && param.time) {
setTimeout(this.hidTitleTip, param.time);
}
},
hidTitleTip: function() {
if (document.getElementById("TitleTipDiv")) {
document.getElementById("TitleTipDiv").style.display = "none";
}
},
addTips: function(param) {
var linkArr = document.getElementsByTagName("a");
if (!linkArr) {
return false;
}
for (i = 0; i < linkArr.length; i++) {
if (linkArr[i].className == "TitleTip") {
linkArr[i].tip = linkArr[i].title;
var tipObj = this;
linkArr[i].onmouseover = function(e) {
tipObj.showTitleTip(param, this, e);
}
linkArr[i].onmouseout = tipObj.hidTitleTip;
if (param && param.moveable == true) {
linkArr[i].onmousemove = function(e) {
tipObj.showTitleTip(param, this, e);
}
}
linkArr[i].title = "";
}
}
}
}
window.onload = function() {
TitleTip.addTips({
width: 200
});
}
</script>