var currentBalloonClass;
var balloonIsVisible
var balloonIsSticky;
var balloonInvisibleSelects;


// If using this library from dynamically generated HTML in IE, such as
// CGI scripts, set this variable to false.50It will prevent
// balloons from firing until the page is fully loaded in IE.  
var balloonOK = false;
window.onload = function(){ balloonOK = true; }


var Balloon = function() {

  // Location of optional ajax handler that returns tooltip contents
  //this.helpUrl = '/cgi-bin/help.pl';

  // maxium allowed balloon width
  this.minWidth = 150;

  // minimum allowed balloon width
  this.maxWidth = 600;

  //this.height  = 400;
  
  // Default tooltip text size
  this.balloonTextSize = '90%';

  // Delay (milliseconds) before balloon is displayed
  this.delayTime = 50;
  this.hiddeDelayTime = 1000;

  // Vertical Distance from cursor location
  this.vOffset  = 1;
  this.hOffset  = -5;

  // text-padding within the balloon
  this.padding  = 10;

  // width of shadow (space aroung whole balloon)
  // This can be zero if there is no shadow and the
  // edges of the balloon are also the edges of the image
  this.shadow   = 20;

  // images of balloon body.  If the browser is IE < 7, png alpha
  // channels will not work.  An optional alternative image can be 
  // provided.  It should have the same dimensions as the default png image
  this.balloonImage  = '/content/images/balloons/balloon.png';    // with alpha channels
  this.ieImage       = '/content/images/balloons/balloon_ie.png'; // indexed color, transparent background

  // whether the balloon should have a stem
  this.stem          = true;

  // The height (px) of the stem and the extent to which the 
  // stem image should overlaps the balloon image.
  this.stemHeight  = 32;  

  this.stemOverlap = 3;
  
  // A stem for each of the four orientations
  this.upLeftStem    = '/content/images/balloons/up_left.png';
  this.downLeftStem  = '/content/images/balloons/down_left.png';
  this.upRightStem   = '/content/images/balloons/up_right.png';
  this.downRightStem = '/content/images/balloons/down_right.png';

  // A close button for sticky balloons
  this.closeButton   = '/content/images/balloons/close.png';
  
  this.stopDisplay = 0;
  
  this.centerDisplay = 1;
  
  
}



//////////////////////////////////////////////////////////////////////////
// This is the function that is called on mouseover.  It has a built-in //
// delay time to avoid balloons popping up on rapid mouseover events     //
//////////////////////////////////////////////////////////////////////////
Balloon.prototype.showTooltip = function(obj,evt,caption,sticky,width,height) {
	
  // Awful IE bug, page load aborts if the balloon is fired
  // before the page is fully loaded.
  Balloon.prototype.clearHiddeDeley();
  
  if (this.isIE() && !balloonOK) return false;

  //alert(obj.offsetLeft);
  //alert(obj.offsetWidth);
  
  // Check for mouseover (vs. mousedown or click)
  var mouseOver = evt.type.match('mouseover','i');  

  // Don't fire on mouseover if a non-sticky balloon is visible
  if (balloonIsVisible && !balloonIsSticky && mouseOver) return false;

  // Don't start a non-sticky balloon if a sticky one is visible
  if (balloonIsVisible && balloonIsSticky && !sticky) return false;
  
  // Ignore repeated firing of mouseover->mouseout events on 
  // the same element (Safari)
  var el = this.getEventTarget(evt);
  if (sticky && mouseOver && this.isSameElement(el,this.currentElement)) return false;
  this.firingElement = el;

  // A new sticky balloon can erase an old one
  if (sticky) this.hideTooltip(1);


  // attach a mouseout event handler to the target element
  var override = 0;
  var closeBalloon = function() { 

    var override = balloonIsSticky && !balloonIsVisible;
    Balloon.prototype.hideTooltip(override)
  }


  //el.onmouseout = closeBalloon;
  //el.onmouseout = Balloon.prototype.hideTooltipDeleyed(override);

  balloonIsSticky = sticky;

  // force balloon width and/or height if requested
  this.width  = width;
  this.height  = height;
  

  // Set the active mousover coordinates
  this.setActiveCoordinates(evt,obj);
  //this.setActiveCoordinates(obj);
  
  
  
  this.hideTooltip();


  
  // if this is IE < 7 use an alternative image if one is provided
  if (this.isOldIE() && this.ieImage) {
    this.balloonImage = this.ieImage;
    this.ieImage = null;
  }

  // look for a url in the balloon contents
  var match;
  if (match = caption.match(/^url:(\S+)/)) {
    caption = '';
    this.activeUrl = match[1];
  }
  // or if the contents are to be retrieved from an element
  else if (match = caption.match(/^load:(\S+)/)) {
    if (!document.getElementById(match[1])) alert ('problem locating element '+load[1]);
    caption = document.getElementById(match[1]).innerHTML;
  }
  // or if the text is a bare hyperlink
  else if (caption.match(/^(https?:|\/|ftp:)\S+$/i)) {
    this.activeUrl = caption;
    caption = '';
  }
  

  // create the balloon object
  currentBalloonClass = this;
  this.balloon = this.makeBalloon();


  // prepare the contents
  this.wrapper = this.wrapContents(caption);  
  

  // Balloon will be created after delayTime unless a mouseout happens first
  this.timeoutTooltip = window.setTimeout(this.doShowTooltip,this.delayTime);
  
  
  
}






// test for internet explorer
Balloon.prototype.isIE = function() {
  return document.all && !window.opera;
}

// test for internet explorer (but not IE7)
Balloon.prototype.isOldIE = function() {
  if (navigator.appVersion.indexOf("MSIE") == -1) return false;
  var temp=navigator.appVersion.split("MSIE");
  return parseFloat(temp[1]) < 7;
}


////
// event XY and getEventTarget Functions based on examples by Peter-Paul
// Koch http://www.quirksmode.org/js/events_properties.html
Balloon.prototype.eventXY = function(event) {
  var XY = new Array(2);
  var e = event || window.event;
  XY[0] = e.pageX || e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
  XY[1] = e.pageY || e.clientY + document.body.scrollTop  + document.documentElement.scrollTop;
  return XY;
}

Balloon.prototype.getEventTarget = function(event) {
  var targ;
  var e = event || window.event;
  if (e.target) targ = e.target;
  else if (e.srcElement) targ = e.srcElement;
  if (targ.nodeType == 3) targ = targ.parentNode; // Safari
  return targ;
}
////


Balloon.prototype.setStyle = function(el,att,val) {
  if (val && att.match(/left|top|bottom|right|width|height|padding|margin/)) val += 'px'; 
  if (el) YAHOO.util.Dom.setStyle(el,att,val);
}

// Coordinate-based test for the same element
Balloon.prototype.isSameElement = function(el1,el2) {
  if (!el1 || !el2) return false;
  var R1 = this.getLoc(el1,'region');
  var R2 = this.getLoc(el2,'region');
  var same = R1.contains(R2) && R2.contains(R1);
  return same ? true : false;
}







// IE select z-index bug
// improved method courtesy of Lincoln Stein
Balloon.prototype.showHideSelect = function(visible) {
  var bSelf = currentBalloonClass || new Balloon;
  if (!this.isOldIE()) return false;
  if (!visible) {
    var balloonSelects = document.getElementById('contents').getElementsByTagName('select');
    var myHash = new Object();
    for (var i=0; i<balloonSelects.length; i++) {
      var id = balloonSelects[i].id || balloonSelects[i].name;
      myHash[id] = 1;
    }
    balloonInvisibleSelects = new Array();
    var allSelects = document.getElementsByTagName('select');
    for (var i=0; i<allSelects.length; i++) {
      var id = allSelects[i].id || allSelects[i].name;
      if (bSelf.isOverlap(allSelects[i],bSelf.activeBalloon) && !myHash[id]) {
 	balloonInvisibleSelects.push(allSelects[i]);
 	bSelf.setStyle(allSelects[i],'visibility','hidden');
      }
    }
  }
  else if (balloonInvisibleSelects) {
    for (var i=0; i < balloonInvisibleSelects.length; i++) {
      var id = balloonInvisibleSelects[i].id || balloonInvisibleSelects[i].name;
      bSelf.setStyle(balloonInvisibleSelects[i],'visibility','visible');
    }
    balloonInvisibleSelects = null;
  }
}



// Set the active mouseover coordinates
Balloon.prototype.setActiveCoordinates = function(evt, obj) {

  //var el = this.getEventTarget(evt);
  //var XY = this.eventXY(evt);
	
  var el = Balloon.prototype.getEventTarget(evt);

  // is this an image map area?
  var area     = el.getAttribute('coords');
  var isImage  = el.tagName.match('img', 'i');
  var isTooBig = this.getLoc(el,'height') > 50;

  // prefer element vertical bounds if available
  // otherwise, use event's
  if (!area && !isImage && !isTooBig) {
    var objTop = this.getLoc(obj,'y1')+2;
	var objBottom = this.getLoc(obj,'y2');
  }
  else {
    var objTop = this.getLoc(el,'y1');
	var objBottom = this.getLoc(el,'y2');
  }
	
	
  var objLeft = this.getLoc(obj,'x1');
  var objRight = this.getLoc(obj,'x2');
 
  var t_objLeft = objLeft - document.body.scrollLeft - document.documentElement.scrollLeft;
  var t_objRight = objRight - document.body.scrollLeft - document.documentElement.scrollLeft;

  var t_objTop = objTop - document.body.scrollTop  - document.documentElement.scrollTop;
  var t_objBottom = objBottom - document.body.scrollTop  - document.documentElement.scrollTop;

  var pageWidth  = YAHOO.util.Dom.getViewportWidth();
  var pageCen    = Math.round(pageWidth/2) ;

  var pageHeight  = YAHOO.util.Dom.getViewportHeight();
  var pageMid    = Math.round(pageHeight/2) ;

  var spaceLeft = Math.abs(pageCen - t_objLeft);
  var spaceRight = Math.abs(pageCen - t_objRight);

  var spaceTop = Math.abs(pageMid - t_objTop);
  var spaceBottom = Math.abs(pageMid - t_objBottom);
  
  var activeCent = objLeft + (objRight - objLeft) / 2;
  
  if (spaceTop > spaceBottom) {
   this.activeTop = objBottom - 22
   this.vOrient = "down";
  }
  else{
   this.activeTop = objTop - 10;
   this.vOrient = "up";
  }
  
  this.hOrient = activeCent > pageCen ? 'left' : 'right';
  
  //alert("pageHeight:" + pageHeight + " spaceTop:" + spaceTop + " spaceBottom:" + spaceBottom + " t_objTop:" + t_objTop + " objTop:" + objTop + " objBottom:" + objBottom + " activeTop:" + this.activeTop + " t_height:" + t_height  );
  
 // this.activeLeft = spaceLeft > spaceRight ? objRight : objLeft;
  //this.activeRight = objRight;
  
  
  if (this.centerDisplay) {
    this.activeLeft = activeCent-1;
    this.activeRight = activeCent+1;
  }
  else {
    this.activeLeft = spaceLeft > spaceRight ? objRight : objLeft;
    this.activeRight = objRight;
  }
  
}



// Uses YAHOO's region class for element coordinates
Balloon.prototype.getLoc = function(el,request) {
  var region = YAHOO.util.Dom.getRegion(el);
  
  switch(request) {
    case ('y1') : return parseInt(region.top);
    case ('y2') : return parseInt(region.bottom);
    case ('x1') : return parseInt(region.left);
    case ('x2') : return parseInt(region.right);
    case ('width')  : return (parseInt(region.right) - parseInt(region.left));
    case ('height') : return (parseInt(region.bottom) - parseInt(region.top));
    case ('region') : return region; 
 }
}





///////////////////////////////////////////////////////
// Balloon contents from a URL get wrapped in an iframe
///////////////////////////////////////////////////////
Balloon.prototype.wrapContents = function(contents) {
  var wrapper = this.wrapper;
  if (!this.height) this.height = 400;
  
//  if (!balloonIsSticky) {
    args += ' scrolling="no"';
//  }

  if (this.activeUrl) {
    
    var args = 'height='+this.height+' width="100%"  frameborder=0 src="'+this.activeUrl+'"';
    contents = '<iframe name="bf" id="bf" '+args+' ></iframe>';

    // activeUrl is meant to be single-use only
    this.activeUrl = null;
  }

  wrapper.innerHTML = contents; 

  return wrapper;
}




/////////////////////////////////////////////////////////////////////
// Tooltip rendering function
/////////////////////////////////////////////////////////////////////
Balloon.prototype.doShowTooltip = function() {
  var bSelf = currentBalloonClass;
  var balloon = bSelf.balloon;

  //alert("doShowTooltip");
  
  // Stop firing if a balloon is already being displayed
  if (balloonIsVisible) return false;  


  if (balloon.stopDisplay) return false;  

  // record which element owns the balloon
  bSelf.currentElement = bSelf.firingElement;
  
  //bSelf.stopDisplay = 0;
  
  // make sure user-configured numbers are not strings
  bSelf.parseIntAll();

  // Hide the off-screen contents container
  bSelf.setStyle(this.container,'display','none');

  // window dimensions
  var pageWidth  = YAHOO.util.Dom.getViewportWidth();
  var pageCen    = Math.round(pageWidth/2) + document.body.scrollLeft + document.documentElement.scrollLeft;
  var pageHeight = YAHOO.util.Dom.getViewportHeight();
  var pageLeft   = YAHOO.util.Dom.getDocumentScrollLeft();
  var pageTop    = YAHOO.util.Dom.getDocumentScrollTop();
  var pageMid    = pageTop + Math.round(pageHeight/2);

  // balloon orientation
  //var vOrient = bSelf.activeTop > pageMid ? 'up' : 'down';
  //var hOrient = bSelf.activeCent > pageCen ? 'left' : 'right';
  var vOrient = bSelf.vOrient
  var hOrient = bSelf.hOrient;
  
  // sticky balloons need a close control
  if (balloonIsSticky) {
    var style = 
    'margin-right:-'+Math.round(bSelf.padding/2 - 1)+'px;float:right;'+
    'cursor:pointer;margin-top:-'+Math.round(bSelf.padding/2 - 1)+'px;float:right'; 
    //bSelf.wrapper.innerHTML = '<img onclick="Balloon.prototype.hideTooltip(1)" title="Close" '+ 'src="'+bSelf.closeButton+'" style="'+style+'"><br>'+bSelf.wrapper.innerHTML;
  }
 
  // how and where to draw the balloon
  //alert("vOrient: " + vOrient + " hOrient: " + hOrient + " pageWidth: " + pageWidth + " pageLeft:" + pageLeft)
  
  bSelf.setBalloonStyle(vOrient,hOrient,pageWidth,pageLeft);

  balloonIsVisible = true;
  
  //debugger;
  
  
  //balloon.onmouseout = function() { eval(Balloon.prototype.hideTooltipDeleyed()) };
  //balloon.onmouseover = function() { eval(Balloon.prototype.clearHiddeDeley()) };
  
  //debugger;
  
  // in IE < 7, hide <select> elements
  bSelf.showHideSelect();
}

// use a fresh object every time to make sure style 
// is not polluted
Balloon.prototype.makeBalloon = function() {
  var bSelf = currentBalloonClass;

  var balloon = document.getElementById('balloon');
  if (balloon) document.body.removeChild(balloon);

  balloon = document.createElement('div');
  balloon.setAttribute('id','balloon');

  //balloon.setAttribute('onMouseover','Balloon.prototype.clearHiddeDeley()');
  //balloon.setAttribute('onMouseout','Balloon.prototype.hideTooltipDeleyed()');
  
  balloon.onmouseout = function() { eval(Balloon.prototype.hideTooltipDeleyed()) };
  balloon.onmouseover = function() { eval(Balloon.prototype.clearHiddeDeley()) };

  
  //bSelf.setStyle(balloon,'top','-9999');
  //document.body.appendChild(balloon);
  
  var parts = new Array('contents','topRight','bottomRight','bottomLeft');
  for (var i=0;i<parts.length;i++) {
    var child = document.createElement('div');
    child.setAttribute('id',parts[i]);
    balloon.appendChild(child);
    if (parts[i] == 'contents') this.wrapper = child;
  }
  bSelf.activeBalloon = balloon;
  return balloon;
}




// We don't know if numbers are overridden with strings
// so play it safe
Balloon.prototype.parseIntAll = function() {
    this.padding     = parseInt(this.padding);
    this.shadow      = parseInt(this.shadow);
    this.stemHeight  = parseInt(this.stemHeight);
    this.stemOverlap = parseInt(this.stemOverlap);
    this.vOffset     = parseInt(this.vOffset);
    this.hOffset     = parseInt(this.hOffset);
    this.delayTime   = parseInt(this.delayTime);
    this.width       = parseInt(this.width);
    this.maxWidth    = parseInt(this.maxWidth);
    this.minWidth    = parseInt(this.minWidth);
}





Balloon.prototype.setBalloonStyle = function(vOrient,hOrient,pageWidth,pageLeft) {

  var bSelf = currentBalloonClass;
  var balloon = bSelf.activeBalloon;

  if (typeof(bSelf.shadow) != 'number') bSelf.shadow = 0;
  if (!bSelf.stem) bSelf.stemHeight = 0;

  var fullPadding   = bSelf.padding + bSelf.shadow;
  var insidePadding = bSelf.padding;

  bSelf.setStyle(balloon,'background','url('+bSelf.balloonImage+') top left no-repeat');
  bSelf.setStyle(balloon,'position','absolute');
  bSelf.setStyle(balloon,'padding-top',fullPadding);
  bSelf.setStyle(balloon,'padding-left',fullPadding);
  bSelf.setStyle(balloon,'top',-9999);
  document.body.appendChild(balloon);

  // hopefully, on top of everything
  bSelf.setStyle(balloon,'z-index',999999);


  bSelf.setStyle('bottomRight','background','url('+bSelf.balloonImage+') bottom right no-repeat');
  bSelf.setStyle('bottomRight','position','absolute');
  bSelf.setStyle('bottomRight','right',0-fullPadding);
  bSelf.setStyle('bottomRight','bottom',0-fullPadding);
  bSelf.setStyle('bottomRight','height',fullPadding);
  bSelf.setStyle('bottomRight','width',fullPadding);

  bSelf.setStyle('topRight','background','url('+bSelf.balloonImage+') top right no-repeat');
  bSelf.setStyle('topRight','position','absolute');
  bSelf.setStyle('topRight','right',0-fullPadding);
  bSelf.setStyle('topRight','top',0);
  bSelf.setStyle('topRight','width',fullPadding);
  bSelf.setStyle('topRight','z-index',-1);

  bSelf.setStyle('bottomLeft','background','url('+bSelf.balloonImage+') bottom left no-repeat');
  bSelf.setStyle('bottomLeft','position','absolute');
  bSelf.setStyle('bottomLeft','left',0);
  bSelf.setStyle('bottomLeft','bottom',0-fullPadding);
  bSelf.setStyle('bottomLeft','height',fullPadding);
  bSelf.setStyle('bottomLeft','z-index',-1); //IE

  if (this.stem) {
    var stem = document.createElement('img');
    bSelf.setStyle(stem,'position','absolute');
    balloon.appendChild(stem);    

    if (vOrient == 'up' && hOrient == 'left') {  
      stem.src = bSelf.upLeftStem;
      var height = bSelf.stemHeight + insidePadding - bSelf.stemOverlap;
      bSelf.setStyle(stem,'bottom',0-height);
      bSelf.setStyle(stem,'right',0);             
    }
    else if (vOrient == 'down' && hOrient == 'left') {
      stem.src = bSelf.downLeftStem;
      var height = bSelf.stemHeight - (bSelf.shadow + bSelf.stemOverlap);
      bSelf.setStyle(stem,'top',0-height);
      bSelf.setStyle(stem,'right',0);
    }
    else if (vOrient == 'up' && hOrient == 'right') {
      stem.src = bSelf.upRightStem;
      var height = bSelf.stemHeight + insidePadding - bSelf.stemOverlap;
      bSelf.setStyle(stem,'bottom',0-height);
      bSelf.setStyle(stem,'left',bSelf.shadow);
    }
    else if (vOrient == 'down' && hOrient == 'right') {
      stem.src = bSelf.downRightStem;
      var height = bSelf.stemHeight - (bSelf.shadow + bSelf.stemOverlap);
      bSelf.setStyle(stem,'top',0-height);
      bSelf.setStyle(stem,'left',bSelf.shadow);
    }

  }

  // flip left or right, as required
  if (hOrient == 'left') {
    var activeRight = pageWidth - bSelf.activeLeft + bSelf.hOffset;
    bSelf.setStyle(balloon,'right',activeRight);
  }
  else {
    bSelf.setStyle(balloon,'left',bSelf.activeRight - 18 + bSelf.hOffset) ;
  }
  
  

  if (!bSelf.width) {
    var width = bSelf.getLoc(balloon,'width');
    if (width > bSelf.maxWidth) width = bSelf.maxWidth + 50;
    if (width < bSelf.minWidth) width = bSelf.minWidth;
    bSelf.setStyle(balloon,'width',width);
  }
  else {
    bSelf.setStyle(balloon,'width',bSelf.width);
  }

  // Make sure the balloon is not offscreen
  var balloonPad   = bSelf.padding + bSelf.shadow;
  var balloonLeft  = bSelf.getLoc(balloon,'x1');
  var balloonRight = bSelf.getLoc(balloon,'x2');
  if (hOrient == 'left')  balloonLeft  += balloonPad;
  if (hOrient == 'right') balloonRight += balloonPad;
  var pageRight    = pageLeft + pageWidth;

  if (hOrient == 'right' && balloonRight > (pageRight-30)) {
    bSelf.setStyle(balloon,'width',(pageRight - balloonLeft) - 50);
  }
  else if (hOrient == 'left' && balloonLeft < (pageLeft+30)) {
    bSelf.setStyle(balloon,'width',(balloonRight - pageLeft) - 50);
  }

  // Set the width/height for the right and bottom outlines
  var lineWidth  = bSelf.getLoc(balloon,'width');
  var lineHeight = bSelf.getLoc(balloon,'height');

  bSelf.setStyle('topRight','height',lineHeight);
  bSelf.setStyle('bottomLeft','width',lineWidth);

  // IE7 quirk -- look for unwanted overlap cause by an off by 1px error
  var vOverlap = bSelf.isOverlap('topRight','bottomRight');
  var hOverlap = bSelf.isOverlap('bottomLeft','bottomRight');
  if (vOverlap) bSelf.setStyle('topRight','height',lineHeight-vOverlap[1]);
  if (hOverlap) bSelf.setStyle('bottomLeft','width',lineWidth-hOverlap[0]);

  if (vOrient == 'up') {
    var activeTop = bSelf.activeTop - bSelf.vOffset - bSelf.stemHeight - lineHeight;
    bSelf.setStyle(balloon,'top',activeTop);
    bSelf.setStyle(balloon,'display','inline');
	//alert("activeTop:" + activeTop + " vOffset:" + bSelf.vOffset + " stemHeight:" + bSelf.stemHeight + " lineHeight:" + lineHeight)
  }
  else {
    var activeTop = bSelf.activeTop + bSelf.vOffset + bSelf.stemHeight;
    bSelf.setStyle(balloon,'top',activeTop);
  }

}



// Try to find overlap 
Balloon.prototype.isOverlap = function(el1,el2) {
  if (!el1 || !el2) return false;
  var R1 = this.getLoc(el1,'region');
  var R2 = this.getLoc(el2,'region');
  if (!R1 || !R2) return false; 
 
  // being conservative; make the balloon area a bit bigger
  if (el2.id == 'balloon') {
    R2.top = R2.top - 30;
    R2.left = R2.left - 30;
    R2.right = R2.right + 30;
    R2.bottom = R2.bottom + 30;
  }

  var intersect = R1.intersect(R2);
  if (intersect) {
    // extent of overlap;
    intersect = new Array((intersect.right - intersect.left),(intersect.bottom - intersect.top));
  }
  return intersect;
}



// this function is meant to be called externally to clear
// any open balloons
hideAllTooltips = function() {
  var bSelf = currentBalloonClass;
  if (!bSelf) return;
  window.clearTimeout(bSelf.timeoutTooltip);
  if (bSelf.activeBalloon) bSelf.setStyle(bSelf.activeBalloon,'display','none');
  balloonIsVisible    = false;
  balloonIsSticky     = false;
  currentBalloonClass = null;
}




Balloon.prototype.hideTooltipDeleyed = function() {
  var bSelf = currentBalloonClass;
  if (bSelf) {
     var balloon = bSelf.activeBalloon;
	 balloon.stopDisplay = 1;
  	 bSelf.delayHide = window.setTimeout("Balloon.prototype.hideTooltipCheck()", bSelf.hiddeDelayTime);
  }
}

Balloon.prototype.hideTooltipCheck = function() {
  var bSelf = currentBalloonClass;
  if (bSelf){
  	// pruefen, ob Balloon noch aktive
	Balloon.prototype.hideTooltip(1);
  }
}

Balloon.prototype.clearHiddeDeley = function() {
  var bSelf = currentBalloonClass;
  if (bSelf) window.clearTimeout(bSelf.delayHide);
}



Balloon.prototype.hideTooltip = function(override) {
  // some browsers pass the event object == we don't want it
  if (override && typeof override == 'object') override = false;
  //if (balloonIsSticky && !override) return false;
  
  var bSelf = currentBalloonClass;
  currentBalloonClass = null;

  if (bSelf) window.clearTimeout(bSelf.timeoutTooltip);

  if (balloonIsSticky && bSelf) bSelf.currentElement = null;

  balloonIsVisible = false;
  //balloonIsSticky  = false;

  if (!bSelf) {
    var hideBalloon  = document.getElementById('balloon');
    if (hideBalloon) Balloon.prototype.setStyle(hideBalloon,'display','none');
  }
  else if (bSelf.activeBalloon) {
    bSelf.setStyle(bSelf.activeBalloon,'display','none');
  }
  
  Balloon.prototype.showHideSelect(1);
}

