var iex     = (document.all);
var nav     = (document.layers);
var old     = (navigator.appName=="Netscape" && !document.layers && !document.getElementById);
var n_6     = (window.sidebar);
var popup_id    = "popup";
var c_popup     = -1;
var last_obj    = 0;
var overpopup   = 0;

function getHeight() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function show_popup(e,obj,text,width,height) {
    c_popup = obj;
    var x = y = 0;
    var tag = obj;
    while (tag.tagName!="BODY") {
        y+=tag.offsetTop;
        x+=tag.offsetLeft;
        tag=tag.offsetParent;
    }

    if (!iex) {
        x=e.pageX;
        y=e.pageY;
        
        if (y-window.pageYOffset+height+20 > getHeight()) {
            y = getHeight() - height - 20;
        }
    } else {
        x=e.x;
        y= e.clientY;
        if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ){
            y = e.clientY + document.body.scrollTop;
        } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
            y = e.clientY + document.documentElement.scrollTop;
        }
        
        if (e.y+height+20 > getHeight()) {
            y = getHeight() - height - 20;
        }
    }

    var popup = document.getElementById(popup_id);
    y += 16;


    popup.innerHTML = '<div style="width:'+width+'px;'+((height!=0)?'height:'+height+'px;':'')+'" class="popup">'+text+'</div>';
    popup.style.top = y+'px';
    popup.style.left = x+'px';
    popup.style.visibility = "visible";
    obj.blur();
    last_obj = obj;
    e.cancelBubble=true;
    return true;
}

function hidepopup() {
    if (last_obj!=0) {
        last_obj.blur();
    }
    var popup = document.getElementById(popup_id);
    popup.style.visibility = "hidden";
    c_popup = -1;
    last_obj= 0;
    overpopup = 0;
    return true;
}
