Meetup.DomDeco.CalendarQuickAdd=function(){bindMethods(this)};if(typeof(Meetup.QuickAddObjects)=="undefined"){Meetup.QuickAddObjects={}}if(typeof(Meetup.QuickAddHeight)=="undefined"){Meetup.QuickAddHeight=0}Meetup.DomDeco.CalendarQuickAdd.prototype={WIDTH:300,anchor:null,day:null,dateString:null,popup:null,form:null,cancel:null,titleField:null,descriptionField:null,allDayRadio:null,notallDayRadio:null,hourSelect:null,minuteSelect:null,amPmSelect:null,decorate:function(b){if(!b){LOG.error("no el passed into Meetup.DomDeco.CalendarQuickAdd");return false}b.href="javascript:void;";var c=b.id.substring("otherLink_".length);var a=c.split("-");this.day=new Date(a[0],a[1]-1,a[2]);this.dateString=getNodeAttribute(b,"dateString");connect(b,"onclick",this.showQuickAdd)},showQuickAdd:function(b){if($("quickAddDiv")){removeElement($("quickAddDiv"))}this.cancel=A({href:"javascript:"},Meetup.Copy.cancel);this.titleField=INPUT({type:"text",name:"title",style:"width: 100%;",maxLength:"80"});this.descriptionField=TEXTAREA({style:"width: 100%; height: 5em;",name:"description","class":"hasMaxLen maxChars5000"});this.allDayRadio=INPUT({type:"radio",id:"all_day",name:"all_day_toggle",value:"all_day",checked:"checked"});this.notallDayRadio=INPUT({type:"radio",id:"not_all_day",name:"all_day_toggle",value:"not_all_day"});var a=this.getDateTimeSelect();this.hourSelect=a[0];this.hourMinuteChar=a[1];this.minuteSelect=a[2];this.amPmSelect=a[3];this.form=FORM({method:"post"},P({style:"font-weight: bold;"},Meetup.Copy.titlePrompt),this.titleField,P({style:"font-weight: bold; padding-top: 1em;"},Meetup.Copy.descriptionPrompt),this.descriptionField,P({style:"font-weight: bold; padding-top: 0.75em;"},Meetup.Copy.timePrompt),TABLE({"class":"inputs",style:"width: 100%"},TBODY(null,TR(null,TD(null,this.allDayRadio),TD(null,LABEL({"for":"all_day"},Meetup.Copy.allDay))),TR(null,TD(null,this.notallDayRadio),TD(null,LABEL({"for":"not_all_day"},Meetup.Copy.startsAtPrompt),this.hourSelect,this.hourMinuteChar,this.minuteSelect,this.amPmSelect)))),DIV({"class":"footElement"},INPUT({type:"submit",style:"margin: .5em 0;","class":"D_submit",name:"submit",value:Meetup.Copy.submit}),P(null,this.cancel)));this.popup=DIV({id:"quickAddDiv"},H2({style:"font-size:1.3em;font-weight:bold;text-align:center;"},Meetup.Copy.addToCalendarPrompt+" "+this.dateString),this.form);connect(this.cancel,"onclick",this.closeThis);connect(this.form,"onsubmit",this.submitThis);connect(this.hourSelect,"onclick",this.selectTimeRadio);connect(this.minuteSelect,"onclick",this.selectTimeRadio);connect(this.amPmSelect,"onclick",this.selectTimeRadio);var c=new Meetup.DomDeco.CharCounter();c.decorate(this.descriptionField);Meetup.QuickAddObjects[b.target().id]=this;$("quickAddPopup").appendChild(this.popup);this.positionPopup(this,b)},positionPopup:function(c,g){var b=getViewportDimensions();if(Meetup.QuickAddHeight==0){Meetup.QuickAddHeight=elementDimensions(c.popup).h}var d=Meetup.QuickAddHeight>0?Meetup.QuickAddHeight:360;var a=g.mouse().page.y-g.mouse().client.y;var f=a+b.h;if(g.mouse().page.x>b.w-this.WIDTH){c.popup.style.left=b.w-this.WIDTH-100+"px"}else{c.popup.style.left=g.mouse().page.x-(this.WIDTH/2)+"px"}var h=g.mouse().page.y-d-15;if(h<a){if(g.mouse().page.y+d+15<f){h=g.mouse().page.y+15}else{h=a+15}}c.popup.style.top=h+"px";if(Meetup.UserAgent.isIE()){setTimeout(function(){c.titleField.focus()},500)}else{c.titleField.focus()}},submitThis:function(a){a.stop();var b=this.titleField.value;var g=this.descriptionField.value;var d=this.allDayRadio.checked?"true":"false";var c=this.day.getFullYear()+"-"+(this.day.getMonth()+1)+"-"+this.day.getDate()+" "+(1*this.hourSelect.value+(this.amPmSelect.value==1?12:0))+":"+this.minuteSelect.value+":00";if(b.replace(/^\s*|\s*$/g,"").length==0){alert(Meetup.Copy.errorTitleMissing);return}var f=doXHR(groupUrl+"api/",{method:"POST",sendContent:queryString({method:"quickCalendarAdd",arg_memberId:$("memberId").value,arg_date:c,arg_allDay:d,arg_title:b,arg_description:g}),headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});f.addCallbacks(this.addEventToCell,function(){alert(Meetup.Copy.genericError)});signal("quickAddPopup","dismiss");removeElement(this.popup)},closeThis:function(a){signal("quickAddPopup","dismiss");a.stop();removeElement(this.popup)},selectTimeRadio:function(){this.notallDayRadio.checked=true;this.allDayRadio.checked=false},getDateTimeSelect:function(){if(Meetup.Language=="en_US"){var b=SELECT({id:"eventhour",name:"event.hour12","class":"isRadioSelector"},map(this.getOption,[["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7","selected"],["8","8"],["9","9"],["10","10"],["11","11"],["0","12"]]));var a=":";var c=SELECT({id:"eventminute",name:"event.minute","class":"isRadioSelector"},map(this.getOption,[["0","00","selected"],["15","15"],["30","30"],["45","45"]]));var d=SELECT({id:"eventampm",name:"event.ampm","class":"isRadioSelector"},map(this.getOption,[["0","AM"],["1","PM","selected"]]));return[b,a,c,d]}else{var b=SELECT({id:"eventhour",name:"event.hour","class":"isRadioSelector"},map(this.getOption,[["0","00"],["1","01"],["2","02"],["3","03"],["4","04"],["5","05"],["6","06"],["7","07"],["8","08"],["9","09"],["10","10"],["11","11"],["12","12"],["13","13"],["14","14"],["15","15"],["16","16"],["17","17"],["18","18"],["19","19","selected"],["20","20"],["21","21"],["22","22"],["23","23"]]));var a=".";var c=SELECT({id:"eventminute",name:"event.minute","class":"isRadioSelector"},map(this.getOption,[["0","00","selected"],["15","15"],["30","30"],["45","45"]]));var d=SELECT({id:"eventampm",name:"event.ampm","class":"isRadioSelector",style:"display:none"},map(this.getOption,[["0","AM","selected"],["1","PM"]]));return[b,a,c,d]}},getOption:function(a){if(a.length==3){return OPTION({value:a[0],selected:"selected"},a[1])}else{return OPTION({value:a[0]},a[1])}},addEventToCell:function(j){var a=evalJSONRequest(j);var g=groupUrl+"calendar/"+a.eventId;var e=this.datetimeToDate(a.localTime);var c="";if(Meetup.Language=="en_US"){var h=(e.getHours()>12)?e.getHours()-12:e.getHours();if(h==0){h=12}c=h+":"+(e.getMinutes()<10?"0":"")+e.getMinutes()+(e.getHours()>=12?"PM":"AM")}else{c=e.getHours()+"."+(e.getMinutes()<10?"0":"")+e.getMinutes()}var i=LI({"class":"note niceToolTip",title:this.breakWords(a.descr?a.descr:a.title,25)},a.duration==1440?null:DIV({"class":"time"},c),DIV({"class":"eventContent"},DIV({"class":"eventName summary"},A({href:g,"class":"url levelUp level_2"},this.breakWords(a.title,12)))));var f="_"+e.getFullYear()+"-"+(e.getMonth()+1)+"-"+e.getDate();if($("cell"+f)){var d=getElementsByTagAndClassName("li",null,$("daydiv"+f));var b=DIV({"class":"events"},UL({id:"cell"+f},i,d));swapDOM(getElementsByTagAndClassName("div","events",$("daydiv"+f))[0],b)}else{$("daydiv"+f).appendChild(DIV({"class":"events"},UL({id:"cell"+f},i)))}this.clearDateFor(e);Meetup.DomDeco.applyDecorator(Meetup.DomDeco.BubbleTips,i)},clearDateFor:function(b){for(key in Meetup.QuickAddObjects){var a="otherLink_"+b.getFullYear()+"-"+(1*b.getMonth()+1)+"-"+b.getDate();if(key==a){Meetup.QuickAddObjects[key]=null}}},datetimeToDate:function(a){return new Date(a.substring(0,4),1*a.substring(5,7)-1,a.substring(8,10),a.substring(11,13),a.substring(14,16),a.substring(17,19))},breakWords:function(b,c){var a=new RegExp("([^\\s]{"+c+"})(?![^<>]*>)(?![\\w\\#]*;)","g");return b.replace(a,"$1 ")}};