if(window.PlotJax.Balloon==null){registerNS("PlotJax.Balloon");PlotJax.Balloon=function(a,b,c){this.balloonid=a+"_balloon";this.centered=false;this.isIE=(window.G_vmlCanvasManager!=null);if((b==null)||(b<100)){b=100}if((c==null)||(c<100)){c=100}this.maxw=b;this.maxh=c;this.balloondiv=document.createElement('div');this.balloondiv.setAttribute('id',this.balloonid);this.balloondiv.style.visibility='hidden';this.balloondiv.style.position='absolute';this.balloondiv.style.left='0';this.balloondiv.style.top='0';this.balloondiv.style.width=b+"px";this.balloondiv.style.height=c+"px";document.body.appendChild(this.balloondiv);this.balloondiv=document.getElementById(this.balloonid);var d=document.createElement("canvas");d.setAttribute("width",b);d.setAttribute("height",c);d.setAttribute("id",this.balloonid+"_canvas");d.style.position="absolute";d.style.left="0";d.style.top="0";d.style.zIndex=1;this.balloondiv.appendChild(d);if(this.isIE){G_vmlCanvasManager.initElement(d)}var e=document.createElement('div');e.setAttribute('id',this.balloonid+"_button");this.balloondiv.appendChild(e);e.style.position='absolute';e.style.right='16';e.style.top='0';e.style.width="16px";e.style.height="16px";e.style.zIndex=2;e.balloonid=this.balloonid;e.onclick=function(){document.getElementById(this.balloonid).closeBalloon()};var f=document.createElement('div');f.setAttribute('id',this.balloonid+"_content");f.style.position='absolute';f.style.left='10';f.style.top='16';f.style.width=(b-30-75)+"px";f.style.maxWidth=(b-20-75)+"px";f.style.maxHeight=(c-60)+"px";f.style.zIndex=2;if(this.isIE){f.style.height=(c-60)+"px";f.style.overflowY="scroll"}else{f.style.height="auto";f.style.overflow="auto"}this.balloondiv.appendChild(f);this.canvas=document.getElementById(this.balloonid+'_canvas');this.ctx=this.canvas.getContext('2d');this.closebtn=document.getElementById(this.balloonid+'_button');this.contentdiv=document.getElementById(this.balloonid+'_content');this.balloondiv.balloon=this;this.balloondiv.closeBalloon=function(){this.balloon.closeBalloon()}};PlotJax.Balloon.SHADOW_COLOR="rgba(100,100,100,0.3)";PlotJax.Balloon.SHADOW_SIZE=8;PlotJax.Balloon.FILL_COLOR="white";PlotJax.Balloon.CENTER_FILL_COLOR="rgba(255,255,255,0.8)";PlotJax.Balloon.BORDER_SIZE=2;PlotJax.Balloon.prototype={centerBalloon:function(){this.centered=true;this.contentdiv.style.width=(this.maxw-30)+"px";this.contentdiv.style.maxWidth=(this.maxw-20)+"px"},offsetBalloon:function(){this.centered=false;this.contentdiv.style.width=(this.maxw-30-75)+"px";this.contentdiv.style.maxWidth=(this.maxw-20-75)+"px"},drawCenteredBalloon:function(w,h,a,b,c){var d=this.ctx;var e=2;var f=5;var g=w+16;var i=f+h+a;d.fillStyle=PlotJax.Balloon.SHADOW_COLOR;this.centeredBalloon(e+PlotJax.Balloon.SHADOW_SIZE,f+PlotJax.Balloon.SHADOW_SIZE,g+PlotJax.Balloon.SHADOW_SIZE,i+PlotJax.Balloon.SHADOW_SIZE);d.fill();d.fillStyle=PlotJax.Balloon.FILL_COLOR;this.centeredBalloon(e,f,g,i);d.fill();d.strokeStyle='black';d.lineWidth=PlotJax.Balloon.BORDER_SIZE;this.centeredBalloon(e,f,g,i);d.stroke();return this},drawLowLeftBalloon:function(w,h,a,b,c){var d=this.ctx;var e=2;var f=5;var g=w+16;var i=f+h+a;d.fillStyle=PlotJax.Balloon.SHADOW_COLOR;this.lowerLeftBalloon(e+PlotJax.Balloon.SHADOW_SIZE,f+PlotJax.Balloon.SHADOW_SIZE,g+PlotJax.Balloon.SHADOW_SIZE,i+PlotJax.Balloon.SHADOW_SIZE);d.fill();d.fillStyle=PlotJax.Balloon.FILL_COLOR;this.lowerLeftBalloon(e,f,g,i);d.fill();d.strokeStyle='black';d.lineWidth=PlotJax.Balloon.BORDER_SIZE;this.lowerLeftBalloon(e,f,g,i);d.stroke();return this},drawLowRightBalloon:function(w,h,a,b,c){var d=this.ctx;var e=75;var f=5;var g=e+w+16;var i=f+h+a;d.fillStyle=PlotJax.Balloon.SHADOW_COLOR;this.lowerRightBalloon(e+PlotJax.Balloon.SHADOW_SIZE,f+PlotJax.Balloon.SHADOW_SIZE,g+PlotJax.Balloon.SHADOW_SIZE,i+PlotJax.Balloon.SHADOW_SIZE);d.fill();d.fillStyle=PlotJax.Balloon.FILL_COLOR;this.lowerRightBalloon(e,f,g,i);d.fill();d.strokeStyle='black';d.lineWidth=PlotJax.Balloon.BORDER_SIZE;this.lowerRightBalloon(e,f,g,i);d.stroke();return this},drawUpLeftBalloon:function(w,h,a,b,c){var d=this.ctx;var e=2;var f=5;var g=w+16;var i=f+h+a;d.fillStyle=PlotJax.Balloon.SHADOW_COLOR;this.upperLeftBalloon(e+PlotJax.Balloon.SHADOW_SIZE,f+PlotJax.Balloon.SHADOW_SIZE,g+PlotJax.Balloon.SHADOW_SIZE,i+PlotJax.Balloon.SHADOW_SIZE);d.fill();d.fillStyle=PlotJax.Balloon.FILL_COLOR;this.upperLeftBalloon(e,f,g,i);d.fill();d.strokeStyle='black';d.lineWidth=PlotJax.Balloon.BORDER_SIZE;this.upperLeftBalloon(e,f,g,i);d.stroke();return this},drawUpRightBalloon:function(w,h,a,b,c){var d=this.ctx;var e=75;var f=5;var g=e+w+16;var i=f+h+a;d.fillStyle=PlotJax.Balloon.SHADOW_COLOR;this.upperRightBalloon(e+PlotJax.Balloon.SHADOW_SIZE,f+PlotJax.Balloon.SHADOW_SIZE,g+PlotJax.Balloon.SHADOW_SIZE,i+PlotJax.Balloon.SHADOW_SIZE);d.fill();d.fillStyle=PlotJax.Balloon.FILL_COLOR;this.upperRightBalloon(e,f,g,i);d.fill();d.closePath();d.strokeStyle='black';d.lineWidth=PlotJax.Balloon.BORDER_SIZE;this.upperRightBalloon(e,f,g,i);d.stroke();return this},centeredBalloon:function(a,b,c,d){var e=this.ctx;e.beginPath();e.moveTo(a+10,b);e.quadraticCurveTo(a,b,a,b+10);e.lineTo(a,d-10);e.quadraticCurveTo(a,d,a+10,d);e.lineTo(c-10,d);e.quadraticCurveTo(c,d,c,d-10);e.lineTo(c,b+10);e.quadraticCurveTo(c,b,c-10,b);e.lineTo(a+10,b)},lowerLeftBalloon:function(a,b,c,d){var e=this.ctx;e.beginPath();e.moveTo(a+10,b);e.quadraticCurveTo(a,b,a,b+10);e.lineTo(a,d-10);e.quadraticCurveTo(a,d,a+10,d);e.lineTo(c-10,d);e.quadraticCurveTo(c,d,c,d-10);e.lineTo(c,b+60);e.lineTo(c+75,b+5);e.lineTo(c,b+27);e.lineTo(c,b+10);e.quadraticCurveTo(c,b,c-10,b);e.lineTo(a+10,b)},lowerRightBalloon:function(a,b,c,d){var e=this.ctx;e.beginPath();e.moveTo(a+10,b);e.quadraticCurveTo(a,b,a,b+10);e.lineTo(a,b+27);e.lineTo(a-75,b+5);e.lineTo(a,b+60);e.lineTo(a,d-10);e.quadraticCurveTo(a,d,a+10,d);e.lineTo(c-10,d);e.quadraticCurveTo(c,d,c,d-10);e.lineTo(c,b+10);e.quadraticCurveTo(c,b,c-10,b);e.lineTo(a+10,b)},closeBalloon:function(){if(this.balloondiv.style.visibility!='hidden'){this.balloondiv.style.visibility='hidden';this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);if(this.iframe!=null){if(this.isIE){this.iframe.balloon=null}this.balloondiv.removeChild(this.iframe);this.iframe=null}this.contentdiv.innerHTML='';this.contentdiv.style.width=this.centered?(this.balloondiv.offsetWidth-30)+"px":(this.balloondiv.offsetWidth-30-75)+"px";if(this.isIE){this.contentdiv.style.height=(this.maxh-60)+"px"}else{this.contentdiv.style.height="auto"}}},openBalloon:function(x,y,b){this.closeBalloon();if(b.substr(0,4)=='url:'){var c=document.createElement("IFRAME");this.iframe=c;c.setAttribute("id","balloon_iframe");if(this.isIE){c.balloon=this;c.readycount=0;this.my_x=x;this.my_y=y;c.onreadystatechange=function(){this.readycount++;if(this.readycount==1){this.balloon.finishBalloon(this.balloon.my_x,this.balloon.my_y)}}}else{c.onreadystatechange=function(a,x,y){a.finishBalloon(x,y)}(this,x,y)}var w=this.centered?this.balloondiv.offsetWidth-30:this.balloondiv.offsetWidth-30-75;c.setAttribute("width",w);c.setAttribute("height",this.balloondiv.offsetHeight-70);c.setAttribute("frameborder",0);c.setAttribute("frameBorder",0);c.setAttribute("scrolling","auto");c.style.zIndex=4;c.style.position='absolute';this.balloondiv.appendChild(c);c.src=b.substr(4);return this}else if(b.substr(0,3)=='id:'){this.contentdiv.innerHTML=document.getElementById(b.substr(3)).innerHTML}else{this.contentdiv.innerHTML=b}return this.finishBalloon(x,y)},finishBalloon:function(x,y){var a=(this.iframe!=null)?this.iframe:this.contentdiv;var w=this.centered?30:30+75;var b=(this.iframe!=null)?this.balloondiv.offsetWidth-w:a.offsetWidth;var c=(this.iframe!=null)?this.balloondiv.offsetHeight-70:a.offsetHeight;var d=this.balloondiv.offsetWidth-w;var e=this.balloondiv.offsetHeight-30;var f=x;var g=document.body.clientWidth-x;if((!this.centered)&&(this.iframe!=null)&&(f<this.balloondiv.offsetWidth)){g=Math.max(g,this.balloondiv.offsetWidth+10)}var h=y;var i=document.body.clientHeight-y;var j=this.centered?'c':(g>f)?'r':'l';var k=(j=='c')?document.body.clientWidth:(j=='r')?g:f;var l=this.centered?'c':(h>i)?'u':'d';var m=(j=='c')?document.body.clientHeight:(l=='u')?h:i;if(!this.centered){k-=75}if(b<100){b=100}else if(b>d){b=d}if(k<b){b=k-10;if(this.iframe!=null){a.setAttribute("width",b-10)}else{c=a.offsetHeight}}if(c<75){c=75}else if(c>e){c=e}if(m<c){c=m-10;if(this.iframe!=null){a.setAttribute("height",m-this.closebtn.offsetHeight-25)}else{a.style.height=(m-this.closebtn.offsetHeight-25)+"px"}}var n=this.balloondiv.offsetWidth;var o=this.balloondiv.offsetHeight;var p=10+this.closebtn.offsetHeight;var q=(j=='c')?this.drawCenteredBalloon(b,c,p,n,o):(j=='l')?((l=='u')?this.drawUpLeftBalloon(b,c,p,n,o):this.drawLowLeftBalloon(b,c,p,n,o)):((l=='u')?this.drawUpRightBalloon(b,c,p,n,o):this.drawLowRightBalloon(b,c,p,n,o));a.style.left=(j=='r')?87:9;a.style.top=p;this.closebtn.style.left=b+((j=='r')?67:-8);this.closebtn.style.top=10;this.closebtn.style.zIndex=10;this.drawCloseButton(b+((j=='r')?67:-8),10);if(this.centered){x-=(n>>1);y-=(o>>1);if(x<3){x=3}else if((x+n)>document.body.clientWidth){x=document.body.clientWidth-n}if(y<3){y=3}else if((y+o)>document.body.clientHeight){y=document.body.clientHeight-o}this.balloondiv.style.left=x;this.balloondiv.style.top=y}else{this.balloondiv.style.left=(j=='r')?x:x-85-b;this.balloondiv.style.top=(l=='d')?y-10:y-(c+p-15)}this.balloondiv.style.visibility="visible";this.balloondiv.style.zIndex=20},upperLeftBalloon:function(a,b,c,d){var e=this.ctx;e.beginPath();e.moveTo(a+10,b);e.quadraticCurveTo(a,b,a,b+10);e.lineTo(a,d-10);e.quadraticCurveTo(a,d,a+10,d);e.lineTo(c-10,d);e.quadraticCurveTo(c,d,c,d-10);e.lineTo(c,d-27);e.lineTo(c+75,d-15);e.lineTo(c,d-60);e.lineTo(c,b+10);e.quadraticCurveTo(c,b,c-10,b);e.lineTo(a+10,b)},upperRightBalloon:function(a,b,c,d){var e=this.ctx;e.beginPath();e.moveTo(a+10,b);e.quadraticCurveTo(a,b,a,b+10);e.lineTo(a,d-60);e.lineTo(a-75,d-15);e.lineTo(a,d-27);e.lineTo(a,d-10);e.quadraticCurveTo(a,d,a+10,d);e.lineTo(c-10,d);e.quadraticCurveTo(c,d,c,d-10);e.lineTo(c,b+10);e.quadraticCurveTo(c,b,c-10,b);e.lineTo(a+10,b)},drawCloseButton:function(a,b){var c=this.ctx;c.lineWidth=1;c.fillStyle="rgb(160,160,160)";c.fillRect(a,b,14,14);c.strokeStyle="rgb(200,200,200)";c.beginPath();c.moveTo(a+13,b);c.lineTo(a,b);c.lineTo(a,b+13);c.closePath();c.stroke();c.strokeStyle="rgb(40,40,40)";c.beginPath();c.moveTo(a+13,b);c.lineTo(a+13,b+13);c.lineTo(a,b+13);c.closePath();c.stroke();c.strokeStyle="rgb(0,0,0)";c.beginPath();c.moveTo(a+11,b+2);c.lineTo(a+2,b+11);c.closePath();c.stroke();c.beginPath();c.moveTo(a+2,b+2);c.lineTo(a+11,b+11);c.closePath();c.stroke()}}}