/* Copyright (c) 2005,2006 ULP Multimédia. All rights reseved. */
2 	/*
3 	 * This file is part of liberscol.
4 	 *
5 	 * liberscol is free software; you can redistribute it and/or modify
6 	 * it under the terms of the GNU General Public License as published by
7 	 * the Free Software Foundation; either version 2 of the License, or
8 	 * (at your option) any later version.
9 	 *
10 	 * liberscol is distributed in the hope that it will be useful,
11 	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 	 * GNU General Public License for more details.
14 	 *
15 	 * You should have received a copy of the GNU General Public License
16 	 * along with liberscol; if not, write to the Free Software
17 	 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 	 */
19 	/*************************************************************************
20 	 
21 	  dw_tooltip.js
22 	  version date: Nov 2003
23 	  requires: dw_event.js and dw_viewport.js
24 	 
25 	  This code is from Dynamic Web Coding at http://www.dyn-web.com/
26 	  Copyright 2003 by Sharon Paine
27 	  See Terms of Use at http://www.dyn-web.com/bus/terms.html
28 	  regarding conditions under which you may use this code.
29 	  This notice must be retained in the code as is!
30 	
 	*************************************************************************/
	
 	var Tooltip = {
 	  followMouse: true,
 	  offX: 8,
 	  offY: 12,
 	 
 	  ready: false,
 	  t1: null,
 	  t2: null,
  tipID: "tipDiv",
	  tip: null,
 
	  init: function() {
    if ( document.createElement && document.body && typeof document.body.appendChild != "undefined" ) {
	      var el = document.createElement("DIV");
	      el.className = "tooltip";
 	      el.id = this.tipID;
	      document.body.appendChild(el);
 	      this.ready = true;
 	    }
	  },
 
	  show: function(e, msg, classType) {
 	    if (this.t1) clearTimeout(this.t1);
	        if (this.t2) clearTimeout(this.t2);
 	    this.tip = document.getElementById( this.tipID );
 	    this.tip.className  = classType;
	        // set up mousemove
	        if (this.followMouse)
 	      dw_event.add( document, "mousemove", this.trackMouse, true );
 	    this.writeTip("");  // for mac ie
 	    this.writeTip(msg);
 	    viewport.getAll();
    this.positionTip(e);
 	        this.t1 = setTimeout("document.getElementById('" + Tooltip.tipID + "').style.visibility = 'visible'",100);     
 	    },
	   
 	    writeTip: function(msg) {
 	      if ( this.tip && typeof this.tip.innerHTML != "undefined" ) this.tip.innerHTML = msg;
 	    },
 	   
	    positionTip: function(e) {
 	      var x = e.pageX? e.pageX: e.clientX + viewport.scrollX;
	      var y = e.pageY? e.pageY: e.clientY + viewport.scrollY;
 	
 	      if ( x + this.tip.offsetWidth + this.offX > viewport.width + viewport.scrollX )
	        x = x - this.tip.offsetWidth - this.offX;
 	      else x = x + this.offX;
 	   
 	      if ( y + this.tip.offsetHeight + this.offY > viewport.height + viewport.scrollY )
	        y = ( y - this.tip.offsetHeight - this.offY > viewport.scrollY )? y - this.tip.offsetHeight - this.offY : viewport.height + viewport.scrollY - this.tip.offsetHeight;
 	      else y = y + this.offY;
 	 
 	      this.tip.style.left = x + "px"; this.tip.style.top = y + "px";
 	    },
 	   
 	    hide: function() {
 	      if (this.t1) clearTimeout(this.t1);       
 	        if (this.t2) clearTimeout(this.t2);
 	      this.t2 = setTimeout("document.getElementById('" + this.tipID + "').style.visibility = 'hidden'",100);
 	        // release mousemove
 	        if (this.followMouse)
 	                dw_event.remove( document, "mousemove", this.trackMouse, true );
 	      this.tip = null;
 	    },
 	   
 	    trackMouse: function(e) {
 	        e = dw_event.DOMit(e);
 	        Tooltip.positionTip(e);
 	    }
 	
	}

	Tooltip.init();
