var currentBalloonClass;
var balloonIsVisible;
var balloonIsSticky;
var balloonInvisibleSelects;
var balloonIsSuppressed;
var tooltipIsSuppressed;
var Balloon = function () {

 this.trackCursor = true;
 document.onmousemove = this.setActiveCoordinates;
 var myObject = this.isIE() ? window : document;
 myObject.onscroll = function(){Balloon.prototype.nukeTooltip()};
 window.onbeforeunload = function(){
 Balloon.prototype.nukeTooltip();
 balloonIsSuppressed = true;
 };
 if (this.isIE()) {
 this.suppress = true;
 }

 return this;
}
Balloon.prototype.showTooltip = function(evt,caption,sticky,width,height) {
 if (!this.configured) {
 BalloonConfig(this,'GBubble');
 }

 this.stopTrackingX = this.trackCursor ? 100 : 10;
 this.stopTrackingY = this.trackCursor ? 50 : 10;
 if (this.isIE() && document.readyState.match(/complete/i)) {
 this.suppress = false;
 }
 if (this.suppress || balloonIsSuppressed) {
 return false;
 }
 if (tooltipIsSuppressed && !sticky) {
 return false;
 }
 if (this.opacity && this.opacity < 1) {
 this.opacity = parseInt(parseFloat(this.opacity) * 100);
 }
 else if (this.opacity && this.opacity == 1) {
 this.opacity = 100;
 }
 else if (!this.opacity) {
 this.opacity == 100;
 }
 if (this.isKonqueror()) {
 this.allowFade = false;
 this.opacity = 100;
 }
 if (this.isIE() && this.allowFade) {
 this.opacity = 100;
 }
 var mouseOver = evt.type.match('mouseover','i');
 if (!mouseOver) {
 sticky = true;
 this.fadeOK = false;
 if (balloonIsVisible) {
 this.hideTooltip();
 }
 }
 else {
 this.fadeOK = this.allowFade;
 }
 if (balloonIsVisible && !balloonIsSticky && mouseOver) {
 return false;
 }
 if (balloonIsVisible && balloonIsSticky && !sticky) {
 return false;
 }
 var el = this.getEventTarget(evt);
 if (sticky && mouseOver && this.isSameElement(el,this.currentElement)) {
 return false;
 } 
 this.currentElement = el;
 this.elCoords = this.getLoc(el,'region');
 if (!sticky) {
 var mouseoutFunc = el.onmouseout;
 var closeBalloon = function() { 
 Balloon.prototype.hideTooltip();
 if (mouseoutFunc) {
 mouseoutFunc();
 }
 }
 if (!mouseOver) {
 el.onmouseup = function() {return false};
 }
 el.onmouseout = closeBalloon;
 } 
 
 balloonIsSticky = sticky;

 this.hideTooltip();
 this.currentHelpText = this.getAndCheckContents(caption);
 if (!this.currentHelpText) {
 return false;
 }

 this.width = width;
 this.height = height;
 this.actualWidth = null;
 this.hideTooltip();
 this.container = document.createElement('div');
 this.container.id = 'balloonPreloadContainer';
 document.body.appendChild(this.container);
 this.setStyle(this.container,'position','absolute');
 this.setStyle(this.container,'top',-8888);
 this.setStyle(this.container,'font-family',this.fontFamily);
 this.setStyle(this.container,'font-size',this.fontSize);
 this.currentHelpText = this.currentHelpText.replace(/\&/g, '&amp');
 this.container.innerHTML = unescape(this.currentHelpText);
 if (this.images) {
 this.balloonImage = this.balloonImage ? this.images +'/'+ this.balloonImage : false;
 this.ieImage = this.ieImage ? this.images +'/'+ this.ieImage : false;
 this.upLeftStem = this.upLeftStem ? this.images +'/'+ this.upLeftStem : false;
 this.upRightStem = this.upRightStem ? this.images +'/'+ this.upRightStem : false;
 this.downLeftStem = this.downLeftStem ? this.images +'/'+ this.downLeftStem : false;
 this.downRightStem = this.downRightStem ? this.images +'/'+ this.downRightStem : false;

 this.closeButton = this.closeButton ? this.images +'/'+ this.closeButton : false;

 this.images = false;
 }
 if (this.ieImage && (this.isIE() || this.isChrome())) {
 if (this.isOldIE() || this.opacity || this.allowFade) { 
 this.balloonImage = this.ieImage;
 }
 }
 if (!this.preloadedImages) {
 var images = new Array(this.balloonImage, this.closeButton);
 if (this.ieImage) {
 images.push(this.ieImage);
 }
 if (this.stem) {
 images.push(this.upLeftStem,this.upRightStem,this.downLeftStem,this.downRightStem);
 }
 var len = images.length;
 for (var i=0;i<len;i++) {
 if ( images[i] ) {
 this.preload(images[i]);
 }
 }
 this.preloadedImages = true;
 }

 currentBalloonClass = this;
 if (!mouseOver) {
 this.setActiveCoordinates(evt);
 }
 this.currentEvent = evt;
 evt.cancelBubble = true;
 var delay = mouseOver ? this.delayTime : 1;
 this.timeoutTooltip = window.setTimeout(this.doShowTooltip,delay);
 this.pending = true;
}
Balloon.prototype.preload = function(src) {
 var i = new Image;
 i.src = src;
 this.setStyle(i,'position','absolute');
 this.setStyle(i,'top',-8000);
 document.body.appendChild(i);
 document.body.removeChild(i);
}
Balloon.prototype.doShowTooltip = function() {
 var self = currentBalloonClass;
 if (balloonIsVisible) {
 return false; 
 }
 
 if (!self.parent) {
 if (self.parentID) {
 self.parent = document.getElementById(self.parentID);
 }
 else {
 self.parent = document.body;
 }
 self.xOffset = self.getLoc(self.parent, 'x1');
 self.yOffset = self.getLoc(self.parent, 'y1');
 }
 window.clearTimeout(self.timeoutFade);
 if (!balloonIsSticky) {
 self.setStyle('visibleBalloonElement','display','none');
 }
 self.parseIntAll();
 var balloon = self.makeBalloon();
 var pageWidth = YAHOO.util.Dom.getViewportWidth();
 var pageCen = Math.round(pageWidth/2);
 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);
 self.pageBottom = pageTop + pageHeight;
 self.pageTop = pageTop;
 self.pageLeft = pageLeft;
 self.pageRight = pageLeft + pageWidth;
 var vOrient = self.activeTop > pageMid ? 'up' : 'down';
 var hOrient = self.activeRight > pageCen ? 'left' : 'right';
 var helpText = self.container.innerHTML;
 self.actualWidth = self.getLoc(self.container,'width');
 if (!isNaN(self.actualWidth)) {
 self.actualWidth += 10;
 }
 self.parent.removeChild(self.container);
 var wrapper = document.createElement('div');
 wrapper.id = 'contentWrapper';
 self.contents.appendChild(wrapper);
 wrapper.innerHTML = helpText;
 self.setBalloonStyle(vOrient,hOrient,pageWidth,pageLeft);
 if (balloonIsSticky) {
 self.addCloseButton();
 }

 balloonIsVisible = true;
 self.pending = false;
 self.showHide();

 self.startX = self.activeLeft;
 self.startY = self.activeTop;

 self.fade(0,self.opacity,self.fadeIn);
}

Balloon.prototype.addCloseButton = function () {
 var self = currentBalloonClass;
 var margin = Math.round(self.padding/2);
 var closeWidth = self.closeButtonWidth || 16;
 var balloonTop = self.getLoc('visibleBalloonElement','y1') + margin + self.shadow;
 var BalloonLeft = self.getLoc('topRight','x2') - self.closeButtonWidth - self.shadow - margin;
 var closeButton = document.getElementById('closeButton');

 if (!closeButton) {
 closeButton = new Image;
 closeButton.setAttribute('id','closeButton');
 closeButton.setAttribute('src',self.closeButton);
 closeButton.onclick = function() {
 Balloon.prototype.nukeTooltip();
 };
 self.setStyle(closeButton,'position','absolute');
 document.body.appendChild(closeButton);
 }
 if (self.isIE()) {
 BalloonLeft = BalloonLeft - 5;
 }

 self.setStyle(closeButton,'top',balloonTop);
 self.setStyle(closeButton,'left',BalloonLeft);
 self.setStyle(closeButton,'display','inline');
 self.setStyle(closeButton,'cursor','pointer');
 self.setStyle(closeButton,'z-index',999999999);
}
Balloon.prototype.makeBalloon = function() {
 var self = currentBalloonClass;

 var balloon = document.getElementById('visibleBalloonElement');
 if (balloon) {
 self.hideTooltip();
 }

 balloon = document.createElement('div');
 balloon.setAttribute('id','visibleBalloonElement');
 self.parent.appendChild(balloon);
 self.activeBalloon = balloon;

 self.parts = new Array();
 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') self.contents = child;
 self.parts.push(child);
 }

 if (self.displayTime) {
 self.timeoutAutoClose = window.setTimeout(this.hideTooltip,self.displayTime);
 }
 return balloon;
}

Balloon.prototype.setBalloonStyle = function(vOrient,hOrient,pageWidth,pageLeft) {
 var self = currentBalloonClass;
 var balloon = self.activeBalloon;

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

 var fullPadding = self.padding + self.shadow;
 var insidePadding = self.padding;
 var outerWidth = self.actualWidth + fullPadding;
 var innerWidth = self.actualWidth; 

 self.setStyle(balloon,'position','absolute');
 self.setStyle(balloon,'top',-9999);
 self.setStyle(balloon,'z-index',1000000);

 if (self.height) {
 self.setStyle('contentWrapper','height',self.height-fullPadding);
 }

 if (self.width) {
 self.setStyle(balloon,'width',self.width); 
 innerWidth = self.width - fullPadding;
 if (balloonIsSticky) {
 innerWidth -= self.closeButtonWidth;
 }
 self.setStyle('contentWrapper','width',innerWidth);
 }
 else {
 self.setStyle(balloon,'width',outerWidth);
 self.setStyle('contentWrapper','width',innerWidth);
 }
 if (!self.width && self.maxWidth && outerWidth > self.maxWidth) {
 self.setStyle(balloon,'width',self.maxWidth);
 self.setStyle('contentWrapper','width',self.maxWidth-fullPadding);
 }
 if (!self.width && self.minWidth && outerWidth < self.minWidth) {
 self.setStyle(balloon,'width',self.minWidth);
 self.setStyle('contentWrapper','width',self.minWidth-fullPadding);
 }

 self.setStyle('contents','z-index',2);
 self.setStyle('contents','color',self.fontColor);
 self.setStyle('contents','font-family',self.fontFamily);
 self.setStyle('contents','font-size',self.fontSize);
 self.setStyle('contents','background','url('+self.balloonImage+') top left no-repeat');
 self.setStyle('contents','padding-top',fullPadding);
 self.setStyle('contents','padding-left',fullPadding);

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

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

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

 if (this.stem) {
 var stem = document.createElement('img');
 self.setStyle(stem,'position','absolute');
 balloon.appendChild(stem);
 
 if (vOrient == 'up' && hOrient == 'left') { 
 stem.src = self.upLeftStem;
 var height = self.stemHeight + insidePadding - self.stemOverlap;
 self.setStyle(stem,'bottom',0-height);
 self.setStyle(stem,'right',0); 
 }
 else if (vOrient == 'down' && hOrient == 'left') {
 stem.src = self.downLeftStem;
 var height = self.stemHeight - (self.shadow + self.stemOverlap);
 self.setStyle(stem,'top',0-height);
 self.setStyle(stem,'right',0);
 }
 else if (vOrient == 'up' && hOrient == 'right') {
 stem.src = self.upRightStem;
 var height = self.stemHeight + insidePadding - self.stemOverlap;
 self.setStyle(stem,'bottom',0-height);
 self.setStyle(stem,'left',self.shadow);
 }
 else if (vOrient == 'down' && hOrient == 'right') {
 stem.src = self.downRightStem;
 var height = self.stemHeight - (self.shadow + self.stemOverlap);
 self.setStyle(stem,'top',0-height);
 self.setStyle(stem,'left',self.shadow);
 }
 if (self.fadeOK && self.isIE()) {
 self.parts.push(stem);
 }
 }

 if (self.allowFade) {
 self.setOpacity(1);
 }
 else if (self.opacity) {
 self.setOpacity(self.opacity);
 }
 if (hOrient == 'left') {
 var pageWidth = self.pageRight - self.pageLeft;
 var activeRight = pageWidth - self.activeLeft;
 self.setStyle(balloon,'right',activeRight);
 }
 else {
 var activeLeft = self.activeRight - self.xOffset;
 self.setStyle(balloon,'left',activeLeft);
 }
 var overflow = balloonIsSticky ? 'auto' : 'hidden';
 self.setStyle('contentWrapper','overflow',overflow);
 if (balloonIsSticky) {
 self.setStyle('contentWrapper','margin-right',self.closeButtonWidth);
 }
 var balloonLeft = self.getLoc(balloon,'x1');
 var balloonRight = self.getLoc(balloon,'x2');
 var scrollBar = 20;

 if (hOrient == 'right' && balloonRight > (self.pageRight - fullPadding)) {
 var width = (self.pageRight - balloonLeft) - fullPadding - scrollBar;
 self.setStyle(balloon,'width',width);
 self.setStyle('contentWrapper','width',width-fullPadding);
 }
 else if (hOrient == 'left' && balloonLeft < (self.pageLeft + fullPadding)) {
 var width = (balloonRight - self.pageLeft) - fullPadding;
 self.setStyle(balloon,'width',width);
 self.setStyle('contentWrapper','width',width-fullPadding);
 }
 var balloonWidth = self.getLoc(balloon,'width');
 var balloonHeight = self.getLoc(balloon,'height');
 var vOverlap = self.isOverlap('topRight','bottomRight');
 var hOverlap = self.isOverlap('bottomLeft','bottomRight');
 if (vOverlap) {
 self.setStyle('topRight','height',balloonHeight-vOverlap[1]);
 }
 if (hOverlap) {
 self.setStyle('bottomLeft','width',balloonWidth-hOverlap[0]);
 }
 if (vOrient == 'up') {
 var activeTop = self.activeTop - balloonHeight;
 self.setStyle(balloon,'top',activeTop);
 }
 else {
 var activeTop = self.activeBottom;
 self.setStyle(balloon,'top',activeTop);
 }
 var balloonTop = self.getLoc(balloon,'y1');
 var balloonBottom = self.height ? balloonTop + self.height : self.getLoc(balloon,'y2');
 var deltaTop = balloonTop < self.pageTop ? self.pageTop - balloonTop : 0;
 var deltaBottom = balloonBottom > self.pageBottom ? balloonBottom - self.pageBottom : 0;

 if (vOrient == 'up' && deltaTop) {
 var newHeight = balloonHeight - deltaTop;
 if (newHeight > (self.padding*2)) {
 self.setStyle('contentWrapper','height',newHeight-fullPadding);
 self.setStyle(balloon,'top',self.pageTop+self.padding);
 self.setStyle(balloon,'height',newHeight);
 }
 }
 if (vOrient == 'down' && deltaBottom) {
 var newHeight = balloonHeight - deltaBottom - scrollBar;
 if (newHeight > (self.padding*2) + scrollBar) {
 self.setStyle('contentWrapper','height',newHeight-fullPadding);
 self.setStyle(balloon,'height',newHeight);
 }
 }
 var iframe = balloon.getElementsByTagName('iframe');
 if (iframe[0]) {
 iframe = iframe[0];
 var w = self.getLoc('contentWrapper','width');
 if (balloonIsSticky && !this.isIE()) {
 w -= self.closeButtonWidth;
 }
 var h = self.getLoc('contentWrapper','height');
 self.setStyle(iframe,'width',w);
 self.setStyle(iframe,'height',h);
 self.setStyle('contentWrapper','overflow','hidden');
 }
 self.setStyle('topRight','height', self.getLoc(balloon,'height'));
 self.setStyle('bottomLeft','width', self.getLoc(balloon,'width'));

 self.hOrient = hOrient;
 self.vOrient = vOrient;
}
Balloon.prototype.fade = function(opacStart, opacEnd, millisec) {
 var self = currentBalloonClass || new Balloon;
 if (!millisec || !self.allowFade) {
 return false;
 }

 opacEnd = opacEnd || 100;
 var speed = Math.round(millisec / 100);
 var timer = 0;
 for(o = opacStart; o <= opacEnd; o++) {
 self.timeoutFade = setTimeout('Balloon.prototype.setOpacity('+o+')',(timer*speed));
 timer++;
 }
}

Balloon.prototype.setOpacity = function(opc) {
 var self = currentBalloonClass;
 if (!self || !opc) return false;

 var o = parseFloat(opc/100);
 var parts = self.isIE() ? self.parts : [self.activeBalloon];

 var len = parts.length;
 for (var i=0;i<len;i++) {
 self.doOpacity(o,opc,parts[i]);
 }
}

Balloon.prototype.doOpacity = function(op,opc,el) {
 var self = currentBalloonClass;
 if (!el) return false;
 self.setStyle(el,'opacity',op);
 self.setStyle(el,'filter','alpha(opacity='+opc+')');
 self.setStyle(el,'MozOpacity',op);
 self.setStyle(el,'KhtmlOpacity',op);
}
Balloon.prototype.nukeTooltip = function() {
 this.hideTooltip(1);
}
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 self = currentBalloonClass;
 Balloon.prototype.showHide(1);
 Balloon.prototype.cleanup();

 if (self) {
 window.clearTimeout(self.timeoutTooltip);
 window.clearTimeout(self.timeoutFade);
 window.clearTimeout(self.timeoutAutoClose);
 if (balloonIsSticky) {
 self.currentElement = null;
 }
 self.startX = 0;
 self.startY = 0;
 }

 balloonIsVisible = false;
 balloonIsSticky = false;
}
Balloon.prototype.cleanup = function() {
 var self = currentBalloonClass;
 var body;
 if (self) {
 body = self.parent ? self.parent 
 : self.parentID ? document.getElementById(self.parentID) || document.body
 : document.body;
 }
 else {
 body = document.body;
 }

 var bubble = document.getElementById('visibleBalloonElement');
 var close = document.getElementById('closeButton');
 var cont = document.getElementById('balloonPreloadContainer');
 if (bubble) { body.removeChild(bubble) } 
 if (close) { body.removeChild(close) }
 if (cont) { body.removeChild(cont) }
}
hideAllTooltips = function() {
 var self = currentBalloonClass;
 if (!self) return;
 window.clearTimeout(self.timeoutTooltip);
 if (self.activeBalloon) self.setStyle(self.activeBalloon,'display','none');
 balloonIsVisible = false;
 balloonIsSticky = false;
 currentBalloonClass = null;
}
Balloon.prototype.setActiveCoordinates = function(evt) {
 var self = currentBalloonClass;
 if (!self) {
 return true;
 }

 var evt = evt || window.event || self.currentEvent;
 if (!evt) {
 return true;
 }
 
 self.currentEvent = {};
 for (var i in evt) {
 self.currentEvent[i] = evt[i];
 }
 self.hOffset = self.hOffset || 1;
 self.vOffset = self.vOffset || 1;
 self.stemHeight = self.stem && self.stemHeight ? (self.stemHeight|| 0) : 0;

 var scrollTop = 0;
 var scrollLeft = 0;

 var XY = self.eventXY(evt);
 adjustment = self.hOffset < 20 ? 10 : 0;
 self.activeTop = scrollTop + XY[1] - adjustment - self.vOffset - self.stemHeight;
 self.activeLeft = scrollLeft + XY[0] - adjustment - self.hOffset;
 self.activeRight = scrollLeft + XY[0];
 self.activeBottom = scrollTop + XY[1] + self.vOffset + 2*adjustment;
 if (balloonIsVisible && !balloonIsSticky) {
 var deltaX = Math.abs(self.activeLeft - self.startX);
 var deltaY = Math.abs(self.activeTop - self.startY);
 if ( XY[0] < self.elCoords.left || XY[0] > self.elCoords.right
 || XY[1] < self.elCoords.top || XY[1] > self.elCoords.bottom ) {
 self.hideTooltip();
 }
 if (deltaX > self.stopTrackingX || deltaY > self.stopTrackingY) {
 self.hideTooltip();
 }
 else if (self.trackCursor) {
 var b = self.activeBalloon;
 var bwidth = self.getLoc(b,'width');
 var bheight = self.getLoc(b,'height');
 var btop = self.getLoc(b,'y1');
 var bleft = self.getLoc(b,'x1');

 if (self.hOrient == 'right') {
 self.setStyle(b,'left',self.activeRight);
 }
 else if (self.hOrient == 'left') {
 self.setStyle(b,'right',null);
 var newLeft = self.activeLeft - bwidth;
 self.setStyle(b,'left',newLeft);
 }

 if (self.vOrient == 'up') {
 self.setStyle(b,'top',self.activeTop - bheight);
 }
 else if (self.vOrient == 'down') {
 self.setStyle(b,'top',self.activeBottom);
 }
 }
 }

 return true;
}
Balloon.prototype.eventXY = function(event) {
 var XY = new Array(2);
 var e = event || window.event;
 if (!e) {
 return false;
 }
 if (e.pageX || e.pageY) {
 XY[0] = e.pageX;
 XY[1] = e.pageY;
 return XY;
 }
 else if ( e.clientX || e.clientY ) {
 XY[0] = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
 XY[1] = 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 (!el) { 
 return false;
 }
 if (typeof(el) != 'object') {
 el = document.getElementById(el);
 }
 if (!el) {
 return false;
 }
 
 var v = val;

 if (val && att.match(/left|top|bottom|right|width|height|padding|margin/)) {
 val = new String(val);
 if (!val.match(/auto/)) {
 val += 'px';
 }
 }
 if (att == 'z-index') {
 if (el.style) {
 el.style.zIndex = parseInt(val);
 }
 }
 else {

 if (this.isIE() && att.match(/^left|right|top|bottom$/) && !parseInt(val) && val != 0) {
 val = null;
 }

 YAHOO.util.Dom.setStyle(el,att,val);
 }
}

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; 
 }

 return region;
}

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.delayTime = parseInt(this.delayTime);
 this.width = parseInt(this.width);
 this.maxWidth = parseInt(this.maxWidth);
 this.minWidth = parseInt(this.minWidth);
 this.fadeIn = parseInt(this.fadeIn) || 1000;
}
Balloon.prototype.showHide = function(visible) {
 var self = currentBalloonClass || new Balloon;

 if (self.isOldIE()) {
 var balloonContents = document.getElementById('contentWrapper');
 if (!visible && balloonContents) {
 var balloonSelects = balloonContents.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 (self.isOverlap(allSelects[i],self.activeBalloon) && !myHash[id]) {
 balloonInvisibleSelects.push(allSelects[i]);
 self.setStyle(allSelects[i],'visibility','hidden');
 }
 }
 }
 else if (balloonInvisibleSelects) {
 for (var i=0; i < balloonInvisibleSelects.length; i++) {
 var id = balloonInvisibleSelects[i].id || balloonInvisibleSelects[i].name;
 self.setStyle(balloonInvisibleSelects[i],'visibility','visible');
 }
 balloonInvisibleSelects = null;
 }
 }
 if (self.hide) {
 var display = visible ? 'inline' : 'none';
 for (var n=0;n<self.hide.length;n++) {
 if (self.isOverlap(self.activeBalloon,self.hide[n])) {
 self.setStyle(self.hide[n],'display',display);
 }
 }
 }
}
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;
 var intersect = R1.intersect(R2);
 if (intersect) {
 intersect = new Array((intersect.right - intersect.left),(intersect.bottom - intersect.top));
 }
 return intersect;
}
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;
}
Balloon.prototype.getAndCheckContents = function(caption) {
 var originalCaption = caption;
 var notAllowed = 'are not allowed in popup balloons in this web site. \
Please contact the site administrator for assistance.';
 var notSupported = 'AJAX is not supported for popup balloons in this web site. \
Please contact the site administrator for assistance.';
 if (this.helpUrl && !this.allowAJAX) {
 alert('Sorry, you have specified help URL '+this.helpUrl+' but '+notSupported);
 return null;
 }
 if (caption.match(/^url:/)) {
 this.activeUrl = caption.replace(/^url:/,'');
 caption = '';
 }
 else if (caption.match(/^(https?:|\/|ftp:)\S+$/i)) {
 this.activeUrl = caption;
 caption = '';
 }
 if (this.activeUrl && !this.allowAJAX) {
 alert('Sorry, you asked for '+originalCaption+' but '+notSupported);
 return null;
 }
 if (caption.match(/^load:/)) {
 var load = caption.split(':');
 if (!document.getElementById(load[1])) alert ('problem locating element '+load[1]);
 caption = document.getElementById(load[1]).innerHTML;
 this.loadedFromElement = true;
 }
 if (caption.match(/\<\s*iframe/i) && !this.allowIframes) {
 alert('Sorry: iframe elements '+notAllowed);
 return null;
 }
 if (caption.match(/\bon(load|mouse|click|unload|before)[^=]*=/i) && !this.allowEventHandlers) {
 alert('Sorry: JavaScript event handlers '+notAllowed);
 return null;
 }
 if (caption.match(/\<\s*script/i) && !this.allowScripts) {
 alert('Sorry: <script> elements '+notAllowed);
 return null;
 }
 this.currentHelpText = this.getContents(caption);
 this.loadedFromElement = false;
 
 return this.currentHelpText;;
}
Balloon.prototype.getContents = function(section) {
 if (!this.helpUrl && !this.activeUrl) return section;
 if (this.loadedFromElement) return section;
 var url = this.activeUrl || this.helpUrl;
 url += this.activeUrl ? '' : '?section='+section;
 this.activeUrl = null;

 var ajax;
 if (window.XMLHttpRequest) {
 ajax = new XMLHttpRequest();
 } else {
 ajax = new ActiveXObject("Microsoft.XMLHTTP");
 }

 if (ajax) {
 ajax.open("GET", url, false);
 ajax.onreadystatechange=function() {
 };
 try {
 ajax.send(null);
 }
 catch (e) {
 }
 var txt = this.escapeHTML ? escape(ajax.responseText) : ajax.responseText;
 return txt || section;
 }
 else {
 return section;
 }
}
Balloon.prototype.isIE = function() {
 return document.all && !window.opera;
}
Balloon.prototype.isOldIE = function() {
 if (navigator.appVersion.indexOf("MSIE") == -1) return false;
 var temp=navigator.appVersion.split("MSIE");
 return parseFloat(temp[1]) < 7;
}
Balloon.prototype.isKonqueror = function() {
 return navigator.userAgent.toLowerCase().indexOf( 'konqueror' ) != -1;
}
Balloon.prototype.isChrome = function() {
 return navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
}