Meetup.DomDeco.GrowPdfs=function(){bindMethods(this)};Meetup.DomDeco.GrowPdfs.prototype={decorate:function(el){if(!el){LOG.error("no element passed in to Meetup.DomDeco.GrowPdfs.decorate()");return}this.base_el=el;this.form=$tagClass("form","pdfForm",this.base_el)[0];this.baseUrl=""+this.form.action;this.submitArea=$tagClass(null,"submitArea",this.base_el)[0];this.container=$tagClass(null,"container",this.base_el)[0];this.fileFormDiv=$tagClass(null,"fileForm",this.base_el)[0];this.pdfFrame=$tagClass(null,"pdfIframe",this.base_el)[0];this.pdfDiv=$tagClass(null,"pdfDiv",this.base_el)[0];this.saveForm=$tagClass("form","saveForm",this.base_el)[0];this.formSubmit=$("formSubmit");if(!acrobat.installed||IS_MAC){this.base_el.appendChild(this.fileFormDiv);this.fileFormDiv.style.display="block";this.form.target="_blank"}else{this.formSubmit.value=Meetup.Copy.view;$("printInstruct").style.display="none";this.form.target=this.pdfFrame.name;connect(this.form,"onsubmit",this.doSubmit);var loadMsgFontSize=20;var loadMsgTop=(this.pdfFrame.height/2)-(this.loadMsgFontSize/2);this.loadingMsg=DIV(null,{color:"#c00",position:"absolute",fontSize:loadMsgFontSize+"px",top:loadMsgTop+"px",textAlign:"center",width:"100%"});this.loadingMsg.innerHTML=this.getLoadingMsg();this.pdfDiv.insertBefore(this.loadingMsg,this.pdfFrame)}connect(this.saveForm,"onsubmit",this.saveToFiles);var renameInput=$tagClass(null,"renameInput",this.saveForm)[0];renameInput.value=this.getUniqueFilename()},doSubmit:function(){if(this.container.parentNode!=this.submitArea){this.submitArea.appendChild(this.container);this.base_el.appendChild(this.fileFormDiv);this.container.style.display="block";this.fileFormDiv.style.display="block"}this.pdfFrame.style.visibility="hidden";this.loadingMsg.style.visibility="visible";if(this.pdfFrame.contentWindow){this.lastLoc=""+this.pdfFrame.contentWindow.location}else{this.lastLoc=""+this.pdfFrame.contentDocument.location}window.setTimeout(this.checkIframe,this.POLL_TIME);setPageHeight();document.location="#previewArea";return true},checkIframe:function(){var doc=null;try{doc=this.pdfFrame.contentDocument}catch(er){}var win=doc?null:this.pdfFrame.contentWindow;if(!doc&&win&&typeof(win.document)!="unknown"){doc=win.document}if(doc&&doc.links.length>0){this.form.target="_top";this.form.submit()}else{if((doc&&doc.location==this.lastLoc)||(win&&win.location==this.lastLoc)){window.setTimeout(this.checkIframe,this.POLL_TIME);this.loadingMsg.innerHTML=this.getLoadingMsg()}else{var s=this.form.action;if(this.loadingMsg.style.visibility!="hidden"){this.form.action=(s.indexOf("#")==-1)?s+"#":s.substring(0,s.length-1)}this.loadingMsg.style.visibility="hidden";this.pdfFrame.style.visibility="visible"}}},saveToFiles:function(){var i,len,elems=$tagClass("input",null,this.form);for(i=0,len=elems.length;i<len;++i){if(elems[i].type=="text"||elems[i].type=="hidden"||(elems[i].type=="checkbox"||elems[i].type=="radio")&&elems[i].checked){this.saveForm.appendChild(INPUT({type:"hidden",name:elems[i].name,value:elems[i].value}))}}elems=$tagClass("textarea",null,this.form);for(i=0,len=elems.length;i<len;++i){this.saveForm.appendChild(INPUT({type:"hidden",name:elems[i].name,value:elems[i].value}))}return true},getUniqueFilename:function(){var basename=$tagClass(null,"defaultFilename",this.base_el)[0].value+" - "+$tagClass(null,"memberName",this.base_el)[0].value;basename=basename.replace(/[\\\/:*?\"<>|]/g,"");var filelistArr=($tagClass(null,"filelist",this.base_el)[0]).value.split("/");var foundDup=true;var filename=basename;var version=0;while(foundDup){foundDup=false;for(var i=0;i<filelistArr.length;i+=2){if(filelistArr[i]==filename.toLowerCase()+".pdf"){version=version+1;filename=basename+" ("+version+")";foundDup=true}}}return filename},msgs:["...","..",".",""],getLoadingMsg:function(){if(this.lmI==this.msgs.length){lmI=0}return"Loading, please wait<p style='font-size: 0.65em;'>(This may take a minute or two)</p>"+this.msgs[this.lmI++]},base_el:null,baseUrl:null,submitArea:null,formSubmit:null,container:null,fileFormDiv:null,pdfFrame:null,filenameInput:null,loadingMsg:null,lastLoc:null,POLL_TIME:2000,lmI:0};Meetup.DOMReady.ready(function(){Meetup.DomDeco.applyByTagAndClass("div","flyerMagic",Meetup.DomDeco.GrowPdfs)});