if(typeof Meetup==="undefined"){Meetup={}}Meetup.DiscreteBalloon=function(){return this.initialize(Meetup.DiscreteBalloon,this,arguments)};Meetup.DiscreteBalloon.prototype=new Meetup.DiscreteBase();Meetup.DiscreteBalloon.prototype.init=function(content,willKeep){this.objContent={};var div,tds,i,len,MDB=Meetup.DiscreteBalloon,EVENT_NAMES=MDB.EVENT_NAMES,MKD=MochiKit.DOM,G1=MKD.getFirstElementByTagAndClassName,ELMS=this.elements,root=this.elements.root;ELMS.head=G1("tr","top",root);ELMS.body=G1("tr","body",root);ELMS.foot=G1("tr","bot",root);tds=MKD.getElementsByTagAndClassName("td",undefined,root);ELMS["7"]=tds[0];ELMS["8"]=tds[1];ELMS["9"]=tds[2];ELMS["4"]=tds[3];ELMS["5"]=tds[4];ELMS["6"]=tds[5];ELMS["1"]=tds[6];ELMS["2"]=tds[7];ELMS["3"]=tds[8];ELMS.content=ELMS["5"];this.content(content);this.resetPosition();this.fixMSIE();this.bindEvents();this.bindedFunctions.actLoop=Meetup.DiscreteHelper.bind(this.actLoop,this);if(!willKeep){this.attach("onAfterHide",Meetup.DiscreteHelper.bind(this.discard,this))}};Meetup.DiscreteBalloon.prototype.NAME="Meetup.DiscreteBalloon";Meetup.DiscreteBalloon.prototype.ROOT_CLASS_NAME="J_discreteBalloon";Meetup.DiscreteBalloon.prototype.EVENT_NAMES=["onContentClick","onBeforeSetContent","onAfterSetContent","onBeforeShow","onAfterShow","onBeforeHide","onAfterHide"];Meetup.DiscreteBalloon.prototype.PUBLIC_METHODS=["attach","detach","discard","getRoot","hasDiscarded","hide","isShowing","show","content","dimension","opacity","offset","position","tipOrientation","zIndex"];Meetup.DiscreteBalloon.prototype.SERIALIZED_HTML='<table class="dbTable"><tbody class="dbBody"><tr class="top"><td class="left">&nbsp;</td><td class="center">&nbsp;</td><td class="right">&nbsp;</td></tr><tr class="body"><td class="left">&nbsp;</td><td class="center content"></td><td class="right">&nbsp;</td></tr><tr class="bot"><td class="left">&nbsp;</td><td class="center">&nbsp;</td><td class="right">&nbsp;</td></tr></tbody></table>';Meetup.DiscreteBalloon.prototype.DELTA=-20;Meetup.DiscreteBalloon.prototype.ORIENT_TYPE="y";Meetup.DiscreteBalloon.prototype.ORIENT_N=8;Meetup.DiscreteBalloon.prototype.ORIENT_NE=9;Meetup.DiscreteBalloon.prototype.ORIENT_E=6;Meetup.DiscreteBalloon.prototype.ORIENT_SE=3;Meetup.DiscreteBalloon.prototype.ORIENT_S=2;Meetup.DiscreteBalloon.prototype.ORIENT_SW=1;Meetup.DiscreteBalloon.prototype.ORIENT_W=4;Meetup.DiscreteBalloon.prototype.ORIENT_NW=7;Meetup.DiscreteBalloon.prototype.INT_INTERVAL=15;Meetup.DiscreteBalloon.prototype.objContent=null;Meetup.DiscreteBalloon.prototype.objOrientation=null;Meetup.DiscreteBalloon.prototype.viewState=0;Meetup.DiscreteBalloon.prototype.epochLast=false;Meetup.DiscreteBalloon.prototype.timerPointer=false;Meetup.DiscreteBalloon.prototype.hide=function(){--this.viewState;var e,interval=this.INT_INTERVAL;e=+new Date();this.epochLast=Math.floor(interval*2)+e;if(this.timerPointer===false){this.timerPointer=window.setInterval(this.bindedFunctions.actLoop,interval)}};Meetup.DiscreteBalloon.prototype.show=function(){++this.viewState;var e,interval=this.INT_INTERVAL;e=+new Date();this.epochLast=Math.floor(interval*2)+e;if(this.timerPointer===false){this.timerPointer=window.setInterval(this.bindedFunctions.actLoop,interval)}};Meetup.DiscreteBalloon.prototype.content=function(cnt){if(arguments.length!==0){if(Meetup.DiscreteHelper.isDOMNode(cnt)){this.elements.content.appendChild(cnt)}else{cnt=(cnt===undefined||cnt===null)?"":cnt.toString();this.elements.content.innerHTML=cnt}this.resetPosition()}return this.elements.content.innerHTML};Meetup.DiscreteBalloon.prototype.tipOrientation=function(orientation){if(typeof orientation!=="number"){orientation=this.ORIENT_S}switch(orientation){case 1:case 3:case 4:case 6:case 7:case 8:case 9:orientation=this.ORIENT_S;break;case 2:var image,matched,path,div,divstyle;this.objOrientation=orientation;image=Meetup.DiscreteHelper.getImageInfoFromCSS("div","discreteBalloonTip");matched=image.path.match(Meetup.DiscreteHelper.REGEX_CSS_IMAGE);if(matched===null){throw new Error("You should check your CSS")}path=matched[1];if(path.match(Meetup.DiscreteHelper.REGEX_ABSOLUTE_PATH)===null){path=this.getAbsolutePath(path)}div=MochiKit.DOM.createDOM("div",{});divstyle=div.style;divstyle.width=image.dimension.w+"px";divstyle.height=image.dimension.h+"px";divstyle.marginTop="0";divstyle.marginRight="auto";divstyle.marginBottom="0";divstyle.marginLeft="auto";divstyle.backgroundColor="transparent";divstyle.backgroundPosition="0";divstyle.backgroundRepeat="no-repeat";divstyle.backgroundAttachment="scroll";divstyle.backgroundImage="url("+path+")";Meetup.DiscreteHelper.clearChildElements(this.elements[2]);this.elements[2].appendChild(div);this.elements.tip=div;this.fixForTip(this.elements.tip);this.resetPosition();break}return this.objOrientation};Meetup.DiscreteBalloon.prototype.actHide=function(){if(this.tween!==null){this.tween.discard()}var i,len,opt,coord,afterFunc,self=this,before=this.events.onBeforeHide,after=this.events.onAfterHide,root=this.elements.root,rootStyle=root.style,time=this.SEC_FADE_IN,trans=this.TRANS_FADE_IN;this.boolShowing=false;if(before){for(i=0,len=before.length;i<len;++i){before[i]()}}afterFunc=function(){rootStyle.display="none";self.tween=null;self.opacity(0);if(after){for(var j=0,men=after.length;j<men;++j){after[j]()}}};if(this.boolHasTweener){coord=this.translateCoordinate(this.x,this.y,this.w,this.h,this.offsetX,this.offsetY);rootStyle.display="block";rootStyle.visibility="visible";opt={top:(coord[this.ORIENT_TYPE]+this.DELTA)+"px",opacity:0,transition:trans,time:time,onComplete:afterFunc};this.tween=Meetup.Tweener.addTween(root,opt)}else{afterFunc()}return true};Meetup.DiscreteBalloon.prototype.actLoop=function(){var e=+new Date();if(this.viewState<1&&this.boolShowing){this.actHide();this.actStopLoop()}else{if(this.viewState>0&&!this.boolShowing){this.actShow();this.actStopLoop()}else{if(this.epochLast<e){this.actStopLoop()}}}};Meetup.DiscreteBalloon.prototype.actShow=function(){if(this.objOrientation===null){this.tipOrientation(this.ORIENT_S)}if(this.tween!==null){this.tween.discard()}var i,len,opt,afterFunc,origY,coord,self=this,before=this.events.onBeforeShow,after=this.events.onAfterShow,root=this.elements.root,rootStyle=root.style,time=this.SEC_FADE_IN,trans=this.TRANS_FADE_IN;this.boolShowing=true;if(before){for(i=0,len=before.length;i<len;++i){before[i]()}}origY=this.y;this.y=(this.y-this.h/2);coord=this.translateCoordinate(this.x,this.y,this.w,this.h,this.offsetX,this.offsetY);afterFunc=function(){self.tween=null;self.opacity(1);self.y=origY;if(after){for(var j=0,men=after.length;j<men;++j){after[j]()}}};rootStyle.display="block";rootStyle.visibility="visible";if(this.boolHasTweener){if(this.ORIENT_TYPE=="x"){this.position(this.y,(this.x+this.DELTA));var prop="left";var val=coord.y}else{this.position(this.x,(this.y+this.DELTA));var prop="top";var val=coord.y}opt={opacity:1,transition:trans,time:time,onComplete:afterFunc};opt[prop]=val;this.tween=Meetup.Tweener.addTween(root,opt)}else{afterFunc()}return true};Meetup.DiscreteBalloon.prototype.actStopLoop=function(){this.epochLast=false;window.clearInterval(this.timerPointer);this.timerPointer=false};Meetup.DiscreteBalloon.prototype.fixForTip=function(elm){if(!(/msie/.test(navigator.userAgent.toLowerCase())&&!/opera/.test(navigator.userAgent.toLowerCase()))){return}var path=Meetup.DiscreteHelper.getBackgroundImagePathByElement(elm);Meetup.DiscreteHelper.swapBackgroundToFilter(elm,path)};Meetup.DiscreteBalloon.prototype.fixMSIE=function(){if(!(/msie/.test(navigator.userAgent.toLowerCase())&&!/opera/.test(navigator.userAgent.toLowerCase()))){return}var i,tag,path;for(i=1;i<10;++i){if(i===5){continue}tag=this.elements[i];path=Meetup.DiscreteHelper.getBackgroundImagePathByElement(tag);Meetup.DiscreteHelper.swapBackgroundToFilter(tag,path,((i%2)===0))}};Meetup.DiscreteBalloon.prototype.onContentClick=function(ev){var i,len,click=this.events.onContentClick;if(click){for(i=0,len=click.length;i<len;++i){click[i](ev)}}ev.stopPropagation()};Meetup.DiscreteBalloon.translateCoordinate=function(x,y,w,h,offsetX,offsetY){var left,top;if(offsetX===true){left=Math.floor(x-(w/2))}else{left=x+offsetX}if(offsetY===true){top=y-h}else{top=y+offsetY}return{x:left,y:top}};
