var baseObjString = "showPopInfoDiv";
var showObj = null;
var x, y;

function endPopInfo() {
  if (showObj != null) {
    showObj.style.display = "none";
    showObj.innerHTML = "leeg";
  }
  document.onmousemove = null;

  return true;
}

function startPopInfo(id, width) {
  //if (window.Event) {
    //document.captureEvents(Event.MOUSEMOVE);
  //}
  var text = document.getElementById(id);
  if (text != null) {
    document.onmousemove = getXY;
    showObj = document.getElementById(baseObjString);
    showObj.innerHTML = text.innerHTML;
    showObj.style.display = "block";
    var version;      
    version = parseFloat(navigator.appVersion.split("MSIE")[1]);
    //alert(showObj.innerHTML.width);
    if(version == 6){
      var length = showObj.innerHTML.length;
      if(length > 60){
         showObj.style.width = 400;
      }else{
        showObj.style.width = length * 6.8;
      }
    }else{
      showObj.style.width = width;
    }
    
  }
  return true;
}

function getXY(evt) {
  
  x = (evt && evt.clientX ? evt.clientX : event.clientX ? event.clientX : null) + (window.pageXOffset ? window.pageXOffset : document.body.scrollLeft ? document.body.scrollLeft : document.documentElement.scrollLeft ? document.documentElement.scrollLeft : null);
  y = (evt && evt.clientY ? evt.clientY : event.clientY ? event.clientY : null) + (window.pageYOffset ? window.pageYOffset : document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop ? document.documentElement.scrollTop  : null);
  z = 0;
  
  x = x - 210;
  y = y - 110;
  ((x+250) >= getWinWidth())?x-=255:x+=10; 

  //y += 10;

  var scrollTop =    parseInt(document.body.scrollTop)>parseInt(document.documentElement.scrollTop)?parseInt(document.body.scrollTop):parseInt(document.documentElement.scrollTop);
  var clientHeight = parseInt(document.body.clientHeight)>parseInt(document.documentElement.clientHeight)?parseInt(document.body.clientHeight):parseInt(document.documentElement.clientHeight);
  scrollBottom = clientHeight+scrollTop;
  ((y+100) > scrollBottom)?(y=scrollBottom-100):(y+=10);

  if (showObj != null) {
    showObj.style.left = x+"px";
    showObj.style.top = y+"px";
  }
  
  status = x + "::" + y; 
}

function getClient() {
  // convert all characters to lowercase to simplify testing
  var agt=navigator.userAgent.toLowerCase()
  var apv=navigator.appVersion.toLowerCase()
  this.major = parseInt(navigator.appVersion)
  this.minor = parseFloat(navigator.appVersion)
  // browserversion
  this.opera = (agt.indexOf('opera')!=-1);
  this.ns  = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1)))
  this.ns4 = (this.ns && (this.minor >= 4.03) && (this.major < 5))
  this.ns6 = (this.ns && (this.major == 5) || this.opera)
  this.gecko = (this.ns && (this.major >= 5))
  this.ie   = (agt.indexOf("msie") != -1)
  this.ie4  = (this.ie && (this.major == 3))
  this.ie45 = (agt.indexOf('msie 4.5') != -1);
  this.ie5  = (this.ie && (this.major == 4))
  this.ie6  = (agt.indexOf('msie 6') != -1)
  this.ie7  = (agt.indexOf('msie 7') != -1)
  // platform
  this.mac = (apv.indexOf("macintosh")>0);
  this.win = (apv.indexOf("win")>0);
  // compatible browsers
  this.ie4comp = ((this.ie4 && !this.mac) || this.ie45 || this.ie5)
  this.ns4comp = (this.ns4);
  this.ns6comp = (this.gecko || this.ns6);
  this.comp = (this.ie4comp || this.ns4comp || this.ns6comp);
  return (this)
}

var is = new getClient();


function getWinWidth()
{ if (is.ns4comp) return(window.innerWidth);
  else if (is.ie4comp) return(document.body.clientWidth);
  else if (is.ns6comp) return(window.innerWidth);
}