﻿function getExplorerType(){
  var ua = navigator.userAgent.toLowerCase();
  if(window.ActiveXObject){
      return 1;
  }else if((ua.indexOf('firefox')>-1)){
      return 2;
    }else if((ua.indexOf('opera')>-1)){
      return 3;
    }
}   
var timeLazy;
var ell;
var thisObjj;
function showDiv(el,thisObj){
    if(timeLazy!=null){
        window.clearTimeout(timeLazy);
    }
    if(thisObj!=thisObjj&&thisObjj!=null){
        hiddenDiv();
    }
    var obj = document.getElementById(el);
    if(getExplorerType()==1){
        var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
        var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
        obj.style.top = thisObj.getBoundingClientRect().top+scrollTop+2+thisObj.scrollHeight-5+"px";
        obj.style.left = thisObj.getBoundingClientRect().left+scrollLeft-2+"px";
    }else{
        var pos = [thisObj.offsetLeft, thisObj.offsetTop];
        var parentNode = thisObj.offsetParent;
        if (parentNode != thisObj) {
            while (parentNode) {
                pos[0] += parentNode.offsetLeft;
                pos[1] += parentNode.offsetTop;
                parentNode = parentNode.offsetParent;
            }
        }
        if (thisObj.parentNode) { parentNode = thisObj.parentNode; }
        else { parentNode = null; }
        
        while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML') 
        { // account for any scrolled ancestors
            if (parentNode.style.display!= 'inline') { // work around opera inline scrollLeft/Top bug
                pos[0] -= parentNode.scrollLeft;
                pos[1] -= parentNode.scrollTop;
            }
                    
            if (parentNode.parentNode) {
                parentNode = parentNode.parentNode; 
            } else { parentNode = null; }
        }
        obj.style.top = pos[1]+2+thisObj.scrollHeight-5+"px";
        obj.style.left = pos[0]+"px";
    }
    
    thisObj.style.background="#f0f4ff";
    obj.style.position = "absolute";
    obj.style.display = "block";
}
function lazyHidden(el,thisObj){
    ell = el;
    thisObjj = thisObj;
    timeLazy = window.setTimeout(hiddenDiv,100);    
}
function hiddenDiv(){
    var obj = document.getElementById(ell);
    obj.style.display = "none";
    thisObjj.style.background = "";
}