
var currentBalloonClass;var balloonIsVisible
var balloonIsSticky;var balloonInvisibleSelects;var balloonIsSuppressed;var Balloon=function(){this.minWidth=150;this.maxWidth=600;this.balloonTextSize='90%';this.delayTime=500;this.allowFade=false;this.fadeIn=300;this.fadeOut=300;this.vOffset=10;this.padding=10;this.displayTime=10000;this.shadow=20;this.balloonImage='/images/balloons/balloon.png';this.ieImage='/images/balloons/balloon_ie.png';this.stem=true;this.stemHeight=32;this.stemOverlap=3;this.upLeftStem='/images/balloons/up_left.png';this.downLeftStem='/images/balloons/down_left.png';this.upRightStem='/images/balloons/up_right.png';this.downRightStem='/images/balloons/down_right.png';this.closeButton='/images/balloons/close.png';document.onmousemove=this.setActiveCoordinates;document.onscroll=Balloon.prototype.hideTooltip;window.onbeforeunload=function(){Balloon.prototype.hideTooltip(1);balloonIsSuppressed=true;};if(this.isIE()){this.suppress=true;}}
Balloon.prototype.showTooltip=function(evt,caption,sticky,width){if(this.isIE()&&document.readyState.match(/complete/i)){this.suppress=false;}
if(this.suppress||balloonIsSuppressed){return false;}
if(this.isKonqueror())this.allowFade=false;var mouseOver=evt.type.match('mouseover','i');if(!mouseOver){sticky=true;this.fadeOK=false;}
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.firingElement=el;if(sticky)this.hideTooltip(1);var closeBalloon=function(){var override=balloonIsSticky&&!balloonIsVisible;Balloon.prototype.hideTooltip(override)}
if(!mouseOver)el.onmouseup=function(){return false};el.onmouseout=closeBalloon;balloonIsSticky=sticky;this.width=width;this.hideTooltip();if(this.isOldIE()&&this.ieImage){this.balloonImage=this.ieImage;this.ieImage=null;}
if(caption.match(/^url:/)){var urlArray=caption.split(':');caption='';this.activeUrl=urlArray[1];}
else 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;}
else if(caption.match(/^(https?:|\/|ftp:)\S+$/i)){this.activeUrl=caption;caption='';}
this.currentHelpText=this.getContents(caption);this.loadedFromElement=false;if(!this.container){this.container=document.createElement('div');document.body.appendChild(this.container);this.setStyle(this.container,'position','absolute');this.setStyle(this.container,'top',-8888);this.setStyle(this.container,'display','inline');}
else{this.setStyle(this.container,'display','inline');}
this.container.innerHTML=unescape(this.currentHelpText);if(!this.images){this.images=document.createElement('div');document.body.appendChild(this.images);this.setStyle(this.images,'position','absolute');this.setStyle(this.images,'top',-8888);this.setStyle(this.images,'display','inline');if(this.upLeftStem)this.images.innerHTML='<img src='+this.upLeftStem+'>';if(this.upRightStem)this.images.innerHTML+='<img src='+this.upRightStem+'>';if(this.downLeftStem)this.images.innerHTML+='<img src='+this.downLeftStem+'>';if(this.downRightStem)this.images.innerHTML+='<img src='+this.downRightStem+'>';this.images.innerHTML+='<img src='+this.balloonImage+'>';this.images.innerHTML+='<img src='+this.closeButton+'>';}
else{this.setStyle(this.images,'display','none');}
currentBalloonClass=this;if(!mouseOver)this.setActiveCoordinates(evt);var delay=mouseOver?this.delayTime:1;this.timeoutTooltip=window.setTimeout(this.doShowTooltip,delay);}
Balloon.prototype.doShowTooltip=function(){var self=currentBalloonClass;if(balloonIsVisible)return false;window.clearTimeout(self.timeoutFade);self.setStyle('balloon','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);var vOrient=self.activeTop>pageMid?'up':'down';var hOrient=self.activeRight>pageCen?'left':'right';var helpText=self.container.innerHTML;self.contents.innerHTML=helpText;self.setBalloonStyle(vOrient,hOrient,pageWidth,pageLeft);if(balloonIsSticky){var topRight=document.getElementById('topRight');var margin=Math.round(self.padding/2);var top=margin+self.shadow;var marginLeft=16-margin;topRight.innerHTML='\
     <img src="'+self.closeButton+'" title="Close" \
          onclick="Balloon.prototype.hideTooltip(1)" \
          style="position:absolute;top:'+top+'px;left:0px;\
          margin-left:-'+marginLeft+'px;cursor:pointer;z-index:3">';}
balloonIsVisible=true;self.showHide();self.fade(0,95,self.fadeIn);}
Balloon.prototype.makeBalloon=function(){var self=currentBalloonClass;var balloon=document.getElementById('balloon');if(balloon)document.body.removeChild(balloon);balloon=document.createElement('div');balloon.setAttribute('id','balloon');document.body.appendChild(balloon);self.activeBalloon=balloon;self.parts=new Array(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')self.contents=child;self.parts.push(child);}
if(balloonIsSticky){self.setStyle('contents','margin-right',10);}
else 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;self.setStyle(balloon,'background','url('+self.balloonImage+') top left no-repeat');self.setStyle(balloon,'position','absolute');self.setStyle(balloon,'padding-top',fullPadding);self.setStyle(balloon,'padding-left',fullPadding);self.setStyle(balloon,'top',-9999);self.setStyle(balloon,'z-index',1);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(hOrient=='left'){var activeRight=pageWidth-self.activeLeft;self.setStyle(balloon,'right',activeRight);}
else{self.setStyle(balloon,'left',self.activeRight);}
if(!self.width){var width=self.getLoc('contents','width');if(self.isIE())width+=50;if(width>self.maxWidth)width=self.maxWidth+50;if(width<self.minWidth)width=self.minWidth;self.setStyle(balloon,'width',width);}
else{self.setStyle(balloon,'width',self.width);}
var balloonPad=self.padding+self.shadow;var balloonLeft=self.getLoc(balloon,'x1');var balloonRight=self.getLoc(balloon,'x2');if(hOrient=='left')balloonLeft+=balloonPad;if(hOrient=='right')balloonRight+=balloonPad;var pageRight=pageLeft+pageWidth;if(hOrient=='right'&&balloonRight>(pageRight-30)){self.setStyle(balloon,'width',(pageRight-balloonLeft)-50);}
else if(hOrient=='left'&&balloonLeft<(pageLeft+30)){self.setStyle(balloon,'width',(balloonRight-pageLeft)-50);}
var lineWidth=self.getLoc(balloon,'width');var lineHeight=self.getLoc(balloon,'height');self.setStyle('topRight','height',lineHeight);self.setStyle('bottomLeft','width',lineWidth);var vOverlap=self.isOverlap('topRight','bottomRight');var hOverlap=self.isOverlap('bottomLeft','bottomRight');if(vOverlap)self.setStyle('topRight','height',lineHeight-vOverlap[1]);if(hOverlap)self.setStyle('bottomLeft','width',lineWidth-hOverlap[0]);if(vOrient=='up'){var activeTop=self.activeTop-self.vOffset-self.stemHeight-lineHeight;self.setStyle(balloon,'top',activeTop);self.setStyle(balloon,'display','inline');}
else{var activeTop=self.activeTop+self.vOffset+self.stemHeight;self.setStyle(balloon,'top',activeTop);}
self.setStyle('contents','z-index',2);self.setOpacity(1);}
Balloon.prototype.fade=function(opacStart,opacEnd,millisec){var self=currentBalloonClass||new Balloon;var speed=Math.round(millisec/100);var timer=0;if(opacStart>opacEnd){if(self.fadeOK){for(o=opacStart;o>=opacEnd;o--){self.timeoutFade=setTimeout('Balloon.prototype.setOpacity('+o+')',(timer*speed));timer++;}
setTimeout("Balloon.prototype.setStyle('balloon','display','none')",millisec);}
else{self.setStyle('balloon','display','none')}}
else if(opacStart<opacEnd&&self.fadeOK){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||!self.fadeOK)return false;var o=parseFloat((opc||0)/100);var el=self.isIE()?'contents':'balloon';var b=document.getElementById(el);if(!b)return false;self.setStyle(b,'opacity',o);self.setStyle(b,'filter','alpha(opacity= '+opc+')');self.setStyle(b,'MozOpacity',o);self.setStyle(b,'KhtmlOpacity',o);}
Balloon.prototype.hideTooltip=function(override){if(override&&typeof override=='object')override=false;if(balloonIsSticky&&!override)return false;var self=currentBalloonClass;if(self){window.clearTimeout(self.timeoutTooltip);window.clearTimeout(self.timeoutAutoClose);}
if(balloonIsSticky&&self)self.currentElement=null;balloonIsVisible=false;balloonIsSticky=false;if(!self){var hideBalloon=document.getElementById('balloon');if(hideBalloon)Balloon.prototype.setStyle(hideBalloon,'display','none');}
else if(self.activeBalloon){if(!override&&self.fadeOK&&!self.isIE())self.fade(95,0,self.fadeOut);else self.setStyle(self.activeBalloon,'display','none');}
Balloon.prototype.showHide(1);}
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(event){var evt=event||window.event;var self=currentBalloonClass;if(!self)return false;var b=self.activeBalloon;var evt=event||window.event;var XY=self.eventXY(evt);self.activeTop=XY[1]-10;self.activeLeft=XY[0]-10;self.activeRight=self.activeLeft+20;self.activeBottom=self.activeTop+20;return true;}
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;return targ;}
Balloon.prototype.setStyle=function(el,att,val){if(!el)return false;if(val&&att.match(/left|top|bottom|right|width|height|padding|margin/))val+='px';if(typeof(el)!='object')el=document.getElementById(el);if(att=='z-index'){if(el.style){el.style.zIndex=parseInt(val);}}
else{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;}}
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);this.fadeOut=parseInt(this.fadeOut);}
Balloon.prototype.showHide=function(visible){var self=currentBalloonClass||new Balloon;if(self.isOldIE()){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(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.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.send(null);this.helpText=ajax.responseText||section;return this.helpText;}
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.indexOf('Konqueror')!=-1;}