if there is no if statement to detect the exist of node, it causes an "object is null" error in IE 6,7,8
<p>i define a hideTip function below, and register an event handler, but if there is no if statement to detect the exist of node, it causes an "object is null" error in IE 6,7,8 .however, the result is fit my goal.</p>

<pre><code>var showT, hideT;
function getElementsByClassName(node, classname) {
    if(!document.getElementsByClassName) {
        var a = [];
        var re = new RegExp('\\b' + classname + '\\b');
        var els = node.getElementsByTagName("*");
        for(var i=0,j=els.length; i&lt;j; i++)
            if(re.test(els[i].className))a.push(els[i]);
        return a;
    }
    else {
        return node.getElementsByClassName(classname);
    }
}
function showTip() {
    clearTimeout(hideT);
    var obj = this,
        pos = getElementPosition(obj),
        tip;
    var id  = obj.id;
    id = id.substring(5);
    id = "adrz-tip-"+id;
    tip = document.getElementById(id);
    //in IE 6,7,8, if there is no if statement, it cause an "object is null" error.                            
    if(tip) {
        tip.onmouseover = function() {
            clearTimeout(hideT);
        }
        tip.onmouseout = function () {
            hideT = setTimeout(function() {
                tip.style.display = 'none';
            }, 100);
        }
        showT = setTimeout(function() {
            tip.style.top = (parseInt(pos.y)+5)+"px";
            tip.style.left = parseInt(pos.x)+"px";
            tip.style.display = "block";
        }, 100);
    }
}
function hideTip() {
    clearTimeout(showT);
    var obj = this,
        pos = getElementPosition(obj),
        tip;
    var id  = obj.id;
    id = id.substring(5);
    id = "adrz-tip-"+id;
    tip = document.getElementById(id);
    //in IE 6,7,8, if there is no if statement, it cause an "object is null" error.                            
    if(tip) {
        hideT = setTimeout(function() {
            tip.style.display = 'none';
        }, 100);
    }
}
function getElementPosition(e) {
    var x = 0 ,y = 0;
    while(e != null) {
        x += e.offsetLeft;
        y += e.offsetTop;
        e = e.offsetParent;
    }
    return {x:x,y:y};
} 
function addEvent(target, type, handler) {
    if(target.addEventListener) {
        target.addEventListener(type, handler, false);
    }
    else {
        target.attachEvent("on"+type, function(event) {
                return handler.call(target, event);
        });
    }
}
var button = getElementsByClassName(document,'adrz'),
    tip = getElementsByClassName(document,'adrz-tip');
for(var i = 0; i &lt; button.length; i++) {
    button[i].onmouseover = showTip;
    button[i].onmouseout  = hideTip;
}
</code></pre>
