var currentBalloonClass;var balloonIsVisible;var balloonIsSticky;var balloonInvisibleSelects;var balloonOK=true;var Balloon=function(){this.minWidth=60;this.maxWidth=300;this.balloonTextSize="4%";this.delayTime=500;this.vOffset=10;this.padding=10;this.shadow=20;this.balloonImage="/img/balloons/balloon.png";this.ieImage="/img/balloons/balloon_ie.png";this.stem=true;this.stemHeight=32;this.stemOverlap=3;this.upLeftStem="/img/balloons/up_left.gif";this.downLeftStem="/img/balloons/down_left.gif";this.upRightStem="/img/balloons/up_right.gif";this.downRightStem="/img/balloons/down_right.gif"};Balloon.prototype.showTooltip=function(a,g,c,d){if(this.isIE()&&!balloonOK){return false}var b=a.type.match("mouseover","i");if(balloonIsVisible&&!balloonIsSticky&&b){return false}if(balloonIsVisible&&balloonIsSticky&&!c){return false}var e=this.getEventTarget(a);if(c&&b&&this.isSameElement(e,this.currentElement)){return false}this.firingElement=e;if(c){this.hideTooltip(1)}balloonIsSticky=c;this.width=d;this.setActiveCoordinates(a);this.hideTooltip();if(this.isOldIE()&&this.ieImage){this.balloonImage=this.ieImage;this.ieImage=null}var f;if(f=g.match(/^url:(\S+)/)){g="";this.activeUrl=f[1]}else{if(f=g.match(/^load:(\S+)/)){if(!document.getElementById(f[1])){alert("problem locating element "+load[1])}g=document.getElementById(f[1]).innerHTML}else{if(g.match(/^(https?:|\/|ftp:)\S+$/i)){this.activeUrl=g;g=""}}}currentBalloonClass=this;this.balloon=this.makeBalloon();this.wrapper=this.wrapContents(g);this.timeoutTooltip=window.setTimeout(this.doShowTooltip,this.delayTime)};Balloon.prototype.doShowTooltip=function(){var k=currentBalloonClass;var f=k.balloon;if(balloonIsVisible){return false}var e=jQuery(window);k.currentElement=k.firingElement;k.parseIntAll();k.setStyle(this.container,"display","none");var i=e.width();var j=Math.round(i/2);var a=e.height();var h=e.scrollLeft();var g=e.scrollTop();var d=g+Math.round(a/2);var l=k.activeTop>d?"up":"down";var b=k.activeRight>j?"left":"right";if(balloonIsSticky){var c="margin-right:-"+Math.round(k.padding/2-1)+"px;float:right;cursor:pointer;margin-top:-"+Math.round(k.padding/2-1)+"px;float:right"}k.setBalloonStyle(l,b,i,h);balloonIsVisible=true;k.showHideSelect()};Balloon.prototype.makeBalloon=function(){var e=currentBalloonClass;var d=document.getElementById("balloon");if(d){document.body.removeChild(d)}d=document.createElement("div");d.setAttribute("id","balloon");var c=new Array("contents","topRight","bottomRight","bottomLeft");for(var a=0;a<c.length;a++){var b=document.createElement("div");b.setAttribute("id",c[a]);d.appendChild(b);if(c[a]=="contents"){this.wrapper=b}}e.activeBalloon=d;return d};Balloon.prototype.setBalloonStyle=function(d,p,b,i){var n=currentBalloonClass;var t=n.activeBalloon;if(typeof(n.shadow)!="number"){n.shadow=0}if(!n.stem){n.stemHeight=0}var a=n.padding+n.shadow;var g=n.padding;n.setStyle(t,"background","url("+n.balloonImage+") top left no-repeat");n.setStyle(t,"position","absolute");n.setStyle(t,"padding-top",a);n.setStyle(t,"padding-left",a);n.setStyle(t,"top",-9999);document.body.appendChild(t);n.setStyle(t,"z-index",999999);n.setStyle("bottomRight","background","url("+n.balloonImage+") bottom right no-repeat");n.setStyle("bottomRight","position","absolute");n.setStyle("bottomRight","right",0-a);n.setStyle("bottomRight","bottom",0-a);n.setStyle("bottomRight","height",a);n.setStyle("bottomRight","width",a);n.setStyle("topRight","background","url("+n.balloonImage+") top right no-repeat");n.setStyle("topRight","position","absolute");n.setStyle("topRight","right",0-a);n.setStyle("topRight","top",0);n.setStyle("topRight","width",a);n.setStyle("topRight","z-index",-1);n.setStyle("bottomLeft","background","url("+n.balloonImage+") bottom left no-repeat");n.setStyle("bottomLeft","position","absolute");n.setStyle("bottomLeft","left",0);n.setStyle("bottomLeft","bottom",0-a);n.setStyle("bottomLeft","height",a);n.setStyle("bottomLeft","z-index",-1);if(this.stem){var l=document.createElement("img");n.setStyle(l,"position","absolute");t.appendChild(l);if(d=="up"&&p=="left"){l.src=n.upLeftStem;var h=n.stemHeight+g-n.stemOverlap;n.setStyle(l,"bottom",0-h);n.setStyle(l,"right",0)}else{if(d=="down"&&p=="left"){l.src=n.downLeftStem;var h=n.stemHeight-(n.shadow+n.stemOverlap);n.setStyle(l,"top",0-h);n.setStyle(l,"right",0)}else{if(d=="up"&&p=="right"){l.src=n.upRightStem;var h=n.stemHeight+g-n.stemOverlap;n.setStyle(l,"bottom",0-h);n.setStyle(l,"left",n.shadow)}else{if(d=="down"&&p=="right"){l.src=n.downRightStem;var h=n.stemHeight-(n.shadow+n.stemOverlap);n.setStyle(l,"top",0-h);n.setStyle(l,"left",n.shadow)}}}}}if(p=="left"){var m=b-n.activeLeft;n.setStyle(t,"right",m)}else{n.setStyle(t,"left",n.activeRight)}if(!n.width){var e=n.getLoc(t,"width");if(e>n.maxWidth){e=n.maxWidth+50}if(e<n.minWidth){e=n.minWidth}n.setStyle(t,"width",e)}else{n.setStyle(t,"width",n.width)}var c=n.padding+n.shadow;var o=n.getLoc(t,"x1");var s=n.getLoc(t,"x2");if(p=="left"){o+=c}if(p=="right"){s+=c}var q=i+b;if(p=="right"&&s>(q-30)){n.setStyle(t,"width",(q-o)-50)}else{if(p=="left"&&o<(i+30)){n.setStyle(t,"width",(s-i)-50)}}var u=n.getLoc(t,"width");var r=n.getLoc(t,"height");n.setStyle("topRight","height",r);n.setStyle("bottomLeft","width",u);var k=n.isOverlap("topRight","bottomRight");var j=n.isOverlap("bottomLeft","bottomRight");if(k){n.setStyle("topRight","height",r-k[1])}if(j){n.setStyle("bottomLeft","width",u-j[0])}if(d=="up"){var f=n.activeTop-n.vOffset-n.stemHeight-r;n.setStyle(t,"top",f);n.setStyle(t,"display","inline")}else{var f=n.activeTop+n.vOffset+n.stemHeight;n.setStyle(t,"top",f)}};Balloon.prototype.hideTooltip=function(b){if(b&&typeof b=="object"){b=false}if(balloonIsSticky&&!b){return false}var c=currentBalloonClass;currentBalloonClass=null;if(c){window.clearTimeout(c.timeoutTooltip)}if(balloonIsSticky&&c){c.currentElement=null}balloonIsVisible=false;balloonIsSticky=false;if(!c){var a=document.getElementById("balloon");if(a){Balloon.prototype.setStyle(a,"display","none")}}else{if(c.activeBalloon){c.setStyle(c.activeBalloon,"display","none")}}Balloon.prototype.showHideSelect(1)};hideAllTooltips=function(){var a=currentBalloonClass;if(!a){return}window.clearTimeout(a.timeoutTooltip);if(a.activeBalloon){a.setStyle(a.activeBalloon,"display","none")}balloonIsVisible=false;balloonIsSticky=false;currentBalloonClass=null};Balloon.prototype.setActiveCoordinates=function(a){var e=this.getEventTarget(a);var c=this.eventXY(a);var d=e.getAttribute("coords");var b=e.tagName.match("img","i");var f=this.getLoc(e,"height")>50;if(!d&&!b&&!f){this.activeTop=this.getLoc(e,"y1")-10}else{this.activeTop=c[1]-10}this.activeLeft=c[0]-10;this.activeRight=this.activeLeft+20;this.activeBottom=!d&&this.getLoc(e,"y2");if(this.activeBottom){this.activeBottom+=10}else{this.activeBottom=this.activeTop+20}};Balloon.prototype.eventXY=function(a){var b=new Array(2);var c=a||window.event;b[0]=c.pageX||c.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;b[1]=c.pageY||c.clientY+document.body.scrollTop+document.documentElement.scrollTop;return b};Balloon.prototype.getEventTarget=function(c){var a;var b=c||window.event;if(b.target){a=b.target}else{if(b.srcElement){a=b.srcElement}}if(a.nodeType==3){a=a.parentNode}return a};Balloon.prototype.setStyle=function(d,b,c){if(c&&b.match(/left|top|bottom|right|width|height|padding|margin/)){c+="px"}if(d){var a=typeof d=="string"?"#"+d:d;jQuery(a).css(b,c)}};Balloon.prototype.getLoc=function(a,c){var b=Region.getRegion(a);switch(c){case ("y1"):return parseInt(b.top);case ("y2"):return parseInt(b.bottom);case ("x1"):return parseInt(b.left);case ("x2"):return parseInt(b.right);case ("width"):return(parseInt(b.right)-parseInt(b.left))+50;case ("height"):return(parseInt(b.bottom)-parseInt(b.top))+50;case ("region"):return b}};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)};Balloon.prototype.showHideSelect=function(c){var e=currentBalloonClass||new Balloon;if(!this.isOldIE()){return false}if(!c){var g=document.getElementById("contents").getElementsByTagName("select");var d=new Object();for(var f=0;f<g.length;f++){var b=g[f].id||g[f].name;d[b]=1}balloonInvisibleSelects=new Array();var a=document.getElementsByTagName("select");for(var f=0;f<a.length;f++){var b=a[f].id||a[f].name;if(e.isOverlap(a[f],e.activeBalloon)&&!d[b]){balloonInvisibleSelects.push(a[f]);e.setStyle(a[f],"visibility","hidden")}}}else{if(balloonInvisibleSelects){for(var f=0;f<balloonInvisibleSelects.length;f++){var b=balloonInvisibleSelects[f].id||balloonInvisibleSelects[f].name;e.setStyle(balloonInvisibleSelects[f],"visibility","visible")}balloonInvisibleSelects=null}}};Balloon.prototype.isOverlap=function(b,d){if(!b||!d){return false}var c=this.getLoc(b,"region");var e=this.getLoc(d,"region");if(!c||!e){return false}if(d.id=="balloon"){e.top=e.top-30;e.left=e.left-30;e.right=e.right+30;e.bottom=e.bottom+30}var a=c.intersect(e);if(a){a=new Array((a.right-a.left),(a.bottom-a.top))}return a};Balloon.prototype.isSameElement=function(c,e){if(!c||!e){return false}var d=this.getLoc(c,"region");var a=this.getLoc(e,"region");var b=d.contains(a)&&a.contains(d);return b?true:false};Balloon.prototype.wrapContents=function(c){var b=this.wrapper;if(!this.height){this.height=400}a+=' scrolling="no"';if(this.activeUrl){var a="height="+this.height+' width="100%" frameborder=0 src="'+this.activeUrl+'"';c='<iframe name="bf" id="bf" '+a+"></iframe>";this.activeUrl=null}b.innerHTML=c;return b};Balloon.prototype.isIE=function(){return document.all&&!window.opera};Balloon.prototype.isOldIE=function(){if(navigator.appVersion.indexOf("MSIE")==-1){return false}var a=navigator.appVersion.split("MSIE");return parseFloat(a[1])<7};Region=function(d,e,a,c){this.top=d;this.y=d;this[1]=d;this.right=e;this.bottom=a;this.left=c;this.x=c;this[0]=c;this.width=this.right-this.left;this.height=this.bottom-this.top};Region.prototype.contains=function(a){return(a.left>=this.left&&a.right<=this.right&&a.top>=this.top&&a.bottom<=this.bottom)};Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left))};Region.prototype.intersect=function(f){var d=Math.max(this.top,f.top),e=Math.min(this.right,f.right),a=Math.min(this.bottom,f.bottom),c=Math.max(this.left,f.left);if(a>=d&&e>=c){return new Region(d,e,a,c)}else{return null}};Region.prototype.union=function(f){var d=Math.min(this.top,f.top),e=Math.max(this.right,f.right),a=Math.max(this.bottom,f.bottom),c=Math.min(this.left,f.left);return new Region(d,e,a,c)};Region.prototype.toString=function(){return("Region {top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+", height: "+this.height+", width: "+this.width+"}")};Region.getRegion=function(e){var g=typeof e=="string"?"#"+e:e;var j=jQuery(g);var d=j.is(":hidden");if(d){j.show()}var c=j.offset(),i=c.top,a=c.left+j.width(),h=c.top+j.height(),f=c.left;if(d){j.hide()}return new Region(i,a,h,f)};
