var $A=Array.from=function(d){if(!d){return[]}if(d.toArray){return d.toArray()}else{var b=[];for(var a=0,c=d.length;a<c;a++){b.push(d[a])}return b}};Function.prototype.bind=function(){var a=this,c=$A(arguments),b=c.shift();return function(){return a.apply(b,c.concat($A(arguments)))}};String.prototype.endsWith=function(a){var b=this.length-a.length;return b>=0&&this.lastIndexOf(a)===b};Ext.form.MultiUploader=Ext.extend(Ext.form.Field,{iconPath:"images/icons",addIcon:"add.png",deleteIcon:"delete.png",uploadIcon:"arrow_up.png",stopIcon:"control_stop.png",editIcon:"page_edit.png",successIcon:"accept.png",failureIcon:"exclamation.png",pgInfo:{totalBytes:0,doneBytes:0,lastBytes:0},flashColor:"#000000",flashWidth:"1px",flashHeight:"1px",maxNameLength:15,buttonWidth:78,sizeText:"Size",errorText:"Error",pgSizeText:"Size/Total",pgSpeedText:"Speed",pgSpeedAvgText:"Avg. speed",pgEtaText:"Rem. time",pgEnabled:true,fileCls:"file",showUploadBtn:false,showClearBtn:false,files:[],abortUpload:false,initComponent:function(){Ext.form.MultiUploader.superclass.initComponent.call(this);this.addEvents("afterfilerowcreated","filerowremoved","beforefilerowcreated","fileuploaded","queuecomplete","queuestarted","queuestopped","beforequeuestarted","error")},onRender:function(b,a){Ext.form.MultiUploader.superclass.onRender.call(this,b,a);this.removeOld();this.wrap=this.el.wrap({cls:"x-multiuploader-wrap"});this.el=this.wrap;this.uploadBtnEl=this.el.insertFirst({cls:"upload-btn"});this.createInstance()},removeOld:function(){this.el.addClass("x-hidden");this.el.dom.style.border="0 none";this.el.dom.setAttribute("tabIndex",-1);this.el.addClass("x-hidden");if(Ext.isIE){this.el.applyStyles("margin-top:-1px;margin-bottom:-1px;")}},createInstance:function(){if(!this.iconPath.endsWith("/")){this.iconPath+="/"}this.flash=new SWFUpload({flash_url:"libraries/swfupload/Flash/swfupload.swf",upload_url:pm.util.url("flash_upload"),post_params:Ext.apply(this.uploadParams,{PHPSESSID:pm.services.sessionID}),file_size_limit:"100 MB",file_types:"*.*",file_types_description:"All Files",file_upload_limit:100,file_queue_limit:0,custom_settings:{progressTarget:"fsUploadProgress",cancelButtonId:"btnCancel"},debug:false,button_image_url:"images/XPButtonUploadText_61x22.png",button_placeholder_id:this.uploadBtnEl.id,button_width:61,button_height:22,flash_ready_handler:this.onFlashReady.bind(this),file_queued_handler:this.onFileQueued.bind(this),upload_progress_handler:this.onProgress.bind(this),upload_error_handler:this.onFileError.bind(this),upload_success_handler:this.onFileUploadComplete.bind(this),queue_complete_handler:this.onQueueComplete.bind(this),});if(this.renderFirst){this.renderQueueForm()}},renderQueueForm:function(){this.queueFormRendered=true;this.el=this.el.createChild({cls:"queue-wrap"});this.createQueueTable();this.createProgressInfo();this.createButtons()},ensureRendered:function(){this.show();if(!this.queueFormRendered){this.renderQueueForm()}},getTotalFileCount:function(){return this.files.length},destroy:function(){if(this.flash){$(this.flash.movieElement).remove();this.flash=null}this.purgeListeners()},upload:function(){if(this.files.length==0){return}this.fireEvent("beforequeuestarted",{sender:this});if(this.flash&&!this.abortUpload){this.uploadBtn.disable();this.flash.startUpload();this.fireEvent("queuestarted")}},cancelFile:function(a){if(this.flash){this.flash.cancelUpload(a,false)}var c=Ext.fly("fir_"+a);c.remove();var d=Ext.fly("fpr_"+a);d.remove();this.fireEvent("filerowremoved",{table:this.tbody,id:a});var b=this.getFileById(a);this.pgInfo.totalBytes-=b.size;this.updateProgress(0);this.files.remove(b);this.uploadBtn.enable()},getFileById:function(a){for(var c in this.files){var b=this.files[c];if(typeof b=="object"){if(a==this.files[c].id){return b}}}},clearQueue:function(){this.cancelQueue()},cancelQueue:function(){if(this.flash){this.flash.cancelQueue();this.fireEvent("queuestopped")}var a;if(this.tbody){while(this.tbody.dom.rows.length>1){this.tbody.dom.deleteRow(1)}}this.pgInfo.totalBytes=0;this.pgInfo.doneBytes=0;this.pgInfo.lastBytes=0;this.updateProgress(0)},onFlashReady:function(a){this.flashReady=true;this.cancelQueue.defer(100,this)},onFileQueued:function(a,b){this.ensureRendered();this.appendRow(a,b);this.pgInfo.totalBytes+=a.size;this.updateProgress(0);this.files.push(a)},onFileUploadComplete:function(a){this.pgInfo.doneBytes+=a.size-this.pgInfo.lastBytes;this.pgInfo.lastBytes=0;var b=Ext.get("icn_"+a.id);if(b){b.update('<img src="'+this.iconPath+this.successIcon+'">')}this.updateFileProgress(a,1);this.updateProgress();this.uploadBtn.enable();this.fireEvent("fileuploaded",{sender:this,file:a})},onProgress:function(a,c,b){this.pgInfo.doneBytes+=c-this.pgInfo.lastBytes;this.pgInfo.lastBytes=c;this.updateProgress();this.updateFileProgress(a,c/b)},onFileError:function(b,c,e){var a;switch(b){case -10:break;case -20:break;case -30:break;case -40:break;case -50:a=this.formatBytes(c.size);e+="\n\nThe maximum acceptable upload size is: "+Ext.util.Format.fileSize(this.fileSizeLimit*1000)+".";e+="\n\nThis file is "+a[0]+" "+a[1]+".";break}Ext.Msg.alert(this.errorText,e,function(){this.fireEvent("error")}.bind(this));var d=Ext.get("icn_"+c.id);if(d){d.update('<img src="'+this.iconPath+this.failureIcon+'"qtip="'+e+'"qclass="x-form-invalid-tip"ext:width="200">')}this.cancelFile(c.id)},onQueueComplete:function(){this.pgInfo.doneBytes=this.pgInfo.totalBytes;this.pgInfo.lastBytes=0;this.updateProgress(1);this.fireEvent("queuecomplete",{sender:this,files:this.files});this.files.clear()},getFlashVars:function(){var b,a=[];for(b in this.fv){a.push(b+"="+this.fv[b])}return a.join("&")},createButtons:function(){var a=Ext.DomHelper.append(this.el.dom,{tag:"div",cls:"x-uf-buttons-ct",children:[{tag:"div",cls:"x-uf-input-ct",children:[{tag:"div",cls:"x-uf-bbtn-ct"},{tag:"div",cls:"x-uf-input-wrap"}]},{tag:"div",cls:"x-uf-wait"},{tag:"div",cls:"x-uf-ubtn-ct"},{tag:"div",cls:"x-uf-cbtn-ct"}]},true);this.buttonsWrap=a;this.inputWrap=a.select("div.x-uf-input-wrap").item(0);this.addBtnCt=a.select("div.x-uf-input-ct").item(0);var c=a.select("div.x-uf-bbtn-ct").item(0);if(this.showUploadBtn){var d=a.select("div.x-uf-ubtn-ct").item(0);this.ubtnCt=d;this.uploadBtn=new Ext.Button({text:"Upload",renderTo:d,icon:this.iconPath+this.uploadIcon,cls:"x-btn-text-icon",tooltip:"<b>Upload</b><br />Begins uploading of the queued files",scope:this,handler:this.upload})}if(this.showClearBtn){var b=a.select("div.x-uf-cbtn-ct").item(0);this.cbtnCt=b;this.clearBtn=new Ext.Button({icon:this.iconPath+this.deleteIcon,renderTo:b,text:"Clear All",cls:"x-btn-text-icon",ctCls:"x-uf-cbtn-ct",tooltip:"<b>Clear All</b><br />Clears all files from the queue",scope:this,handler:this.cancelQueue})}this.waitIcon=a.select("div.x-uf-wait").item(0)},createProgressInfo:function(){var b;if(this.pgCfg&&true===this.pgCfg.progressBar){b=Ext.DomHelper.append(this.el.dom,{tag:"div",cls:"x-uf-progress-wrap",children:[{tag:"div",cls:"x-uf-progress",children:[{tag:"div",cls:"x-uf-progress-bar"}]}]},true);this.progressBar=b.select("div.x-uf-progress-bar").item(0)}var c,a;if(this.pgCfg){c={tag:"div",cls:"x-uf-pginfo-ct"};a=this.pgCfg.progressTarget;a=("above"===a&&!b)?"under":a;if(this.pgCfg&&this.pgCfg.progressTarget&&!this.progressTarget){switch(a){case"under":case"below":this.progressTarget=Ext.DomHelper.append(this.el.dom,c,true);break;case"above":this.progressTarget=Ext.DomHelper.insertBefore(b,c,true);break}}}this.updateProgress(0)},createQueueTable:function(){Ext.DomHelper.append(this.el.dom,{tag:"div",cls:"title",html:"Upload Queue"});this.table=Ext.DomHelper.append(this.el.dom,{tag:"table",cls:"x-uf-table",children:[{tag:"tbody"}]},true);this.tbody=this.table.select("tbody").item(0);Ext.DomHelper.append(this.tbody,{tag:"tr",cls:"header-row",children:[{tag:"th",cls:"x-form-item",style:"display:table-cell",html:"Filename"},{tag:"th",cls:"x-form-item",style:"display:table-cell",html:"Delete"}]},true);this.table.on({click:{scope:this,fn:this.onDeleteFile,delegate:"a",preventDefault:true}})},appendRow:function(d,h){var b=this.formatBytes(d.size);var f={id:d.id,fileCls:this.getFileCls(d.name),fileName:Ext.util.Format.ellipsis(d.name.split(/[\/\\]/).pop(),this.maxNameLength),fileQtip:d.name,fileSize:b[0],fileSizeUnit:b[1],displayName:Ext.util.Format.capitalize(Ext.util.Format.substr(d.name,0,d.name.lastIndexOf("."))).replace("_"," "),fileIcon:pm.nodes.getFileIcon({filename:d.name})};var a=new Ext.Template(['<tr class="x-uf-filerow" id="fir_{id}">','<td class="x-unselectable {fileCls} x-tree-node-leaf">','<img class="x-uf-icon" src="{fileIcon}">','<span class="x-uf-filename" unselectable="on"',' qtip="<h3>{fileQtip}</h3>'+this.sizeText+': {fileSize} {fileSizeUnit}"',">{fileName}</span>","</td>",'<td id="icn_{id}" class="x-uf-filedelete"><a id="lnk_{id}" href="#"><img src="'+this.iconPath+this.deleteIcon+'"></a>',"</td>","</tr>"]);try{this.fireEvent("beforefilerowcreated",{table:this.tbody,id:f.id})}catch(c){}a.append(this.tbody,f,true);var g=new Ext.Template(['<tr id="fpr_{id}">','<td colspan="2">','<div id="fpb_{id}" class="hide x-uf-filepb"></div>',"</td>","</tr>"]);g.append(this.tbody,{id:d.id});var e=(new Date().getTime());this.flash.addFileParam(d.id,"clientid",e);this.fireEvent("afterfilerocreated",{table:this.tbody,id:f.id,clientid:e})},getFileCls:function(a){var b=a.split(".");if(1===b.length){return this.fileCls}else{return this.fileCls+"-"+b.pop()}},formatBytes:function(a){if(isNaN(a)){return["",""]}var b,c;if(999>a){b="B";c=a}else{if(999999>a){b="kB";c=Math.round(a/1000)}else{if(999999999>a){b="MB";c=Math.round(a/100000)/10}else{if(999999999999>a){b="GB";c=Math.round(a/100000000)/10}else{b="TB";c=Math.round(a/100000000000)/10}}}}return[c,b]},formatTime:function(d){var c=0;var a=0;var b=0;if(3599<d){b=parseInt(d/3600,10);d-=b*3600}if(59<d){a=parseInt(d/60,10);d-=a*60}a=String.leftPad(a,2,0);b=String.leftPad(b,2,0);c=String.leftPad(d,2,0);return("00"!==b?b+":":"")+a+":"+c},onDeleteFile:function(c,b){var a=b.id.substr(4);this.cancelFile(a);if(!this.files[0]){this.hide()}},updateProgress:function(b){var c={bytes_uploaded:0,bytes_total:this.pgInfo.totalBytes,speed_last:0,speed_average:0,est_sec:0};if(1===b){c.bytes_uploaded=c.bytes_total;c.est_sec=0}c.bytes_uploaded=this.pgInfo.doneBytes;b=c.bytes_total?c.bytes_uploaded/c.bytes_total:0;var a;if(this.progressBar){a=Ext.get(this.progressBar.dom.parentNode);this.progressBar.setWidth(Math.floor(b*a.dom.offsetWidth))}if(this.progressTarget){this.getProgressTemplate().overwrite(this.progressTarget,this.formatProgress(c))}else{if(this.pgCfg&&"qtip"===this.pgCfg.progressTarget&&this.progressBar){Ext.QuickTips.tips({target:this.progressBar,title:"Upload progress",text:this.getProgressTemplate().apply(this.formatProgress(c)),width:160,autoHide:true});Ext.QuickTips.enable()}}},updateFileProgress:function(b,d){var a=Ext.get("fpb_"+b.id);var c;if(a){c=a.dom.parentNode.offsetWidth;a.setWidth(Math.floor(d*c))}if(d>0){a.removeClass("hide")}},formatProgress:function(d){var c={};var b=this.formatBytes(d.bytes_uploaded);c.bytes_uploaded=b[0]+" "+b[1];b=this.formatBytes(d.bytes_total);c.bytes_total=b[0]+" "+b[1];b=this.formatBytes(d.speed_last);c.speed_last=b[0]+" "+b[1]+"/s";b=this.formatBytes(d.speed_average);c.speed_average=b[0]+" "+b[1]+"/s";c.est_sec=this.formatTime(d.est_sec);return(c)},getProgressTemplate:function(){var a=new Ext.Template('<table class="x-uf-pginfo-table"><tbody>',"<tr>",'<td class="x-uf-pginfo-label">'+this.pgSizeText+":</td>",'<td class="x-uf-pginfo-value">{bytes_uploaded}/{bytes_total}</td>',"</tr>","<tr>",'<td class="x-uf-pginfo-label">'+this.pgSpeedText+":</td>",'<td class="x-uf-pginfo-value">{speed_last}</td>',"</tr>","<tr>",'<td class="x-uf-pginfo-label">'+this.pgSpeedAvgText+":</td>",'<td class="x-uf-pginfo-value">{speed_average}</td>',"</tr>","<tr>",'<td class="x-uf-pginfo-label">'+this.pgEtaText+":</td>",'<td class="x-uf-pginfo-value">{est_sec}</td>',"</tr>","</tbody></table>");a.compile();return a}});Ext.reg("multiuploader",Ext.form.MultiUploader);Ext.ux.TableLayout=Ext.extend(Ext.layout.ContainerLayout,{monitorResize:false,setContainer:function(a){Ext.ux.TableLayout.superclass.setContainer.call(this,a);this.currentRow=0;this.currentColumn=0;this.spanCells=[]},onLayout:function(d,f){var e=d.items.items,a=e.length,g,b;if(!this.table){f.addClass("x-table-layout-ct");this.table=f.createChild({tag:"table",cls:"x-table-layout-fixed",cellspacing:0,cn:{tag:"tbody"}},null,true);this.renderAll(d,f)}},getRow:function(a){var b=this.table.tBodies[0].childNodes[a];if(!b){b=document.createElement("tr");this.table.tBodies[0].appendChild(b)}return b},getNextCell:function(g){var e=document.createElement("td"),k,i;if(!this.columns){k=this.getRow(0)}else{i=this.currentColumn;if(i!==0&&(i%this.columns===0)){this.currentRow++;i=(g.colspan||1)}else{i+=(g.colspan||1)}var j=this.getNextNonSpan(i,this.currentRow);this.currentColumn=j[0];if(j[1]!=this.currentRow){this.currentRow=j[1];if(g.colspan){this.currentColumn+=g.colspan-1}}k=this.getRow(this.currentRow)}var f="";if(g.colspan){f="width-"+(g.colspan/this.columns)*100;e.colSpan=g.colspan}else{f="width-"+(1/this.columns)*100}e.className="x-table-layout-cell "+f;if(g.rowspan){e.rowSpan=g.rowspan;var h=this.currentRow,d=g.colspan||1;for(var a=h+1;a<h+g.rowspan;a++){for(var b=this.currentColumn-d+1;b<=this.currentColumn;b++){if(!this.spanCells[b]){this.spanCells[b]=[]}this.spanCells[b][a]=1}}}k.appendChild(e);return e},getNextNonSpan:function(a,f){var e=(a<=this.columns?a:this.columns),d=f;for(var b=e;b<=this.columns;b++){if(this.spanCells[b]&&this.spanCells[b][d]){if(++e>this.columns){return this.getNextNonSpan(1,++d)}}else{break}}return[e,d]},renderItem:function(d,a,b){if(d&&!d.rendered){d.render(this.getNextCell(d))}},isValidParent:function(b,a){return true}});Ext.Container.LAYOUTS.fixedtable=Ext.ux.TableLayout;Ext.namespace("Ext.ux.form");Ext.ux.form.DateTime=Ext.extend(Ext.form.Field,{defaultAutoCreate:{tag:"input",type:"hidden"},dateWidth:135,timeWidth:100,dtSeparator:" ",hiddenFormat:"Y-m-d H:i:s",otherToNow:true,timePosition:"right",initComponent:function(){Ext.ux.form.DateTime.superclass.initComponent.call(this);var b=Ext.apply({},{id:this.id+"-date",format:this.dateFormat,width:this.dateWidth,listeners:{blur:{scope:this,fn:this.onBlur},focus:{scope:this,fn:this.onFocus}}},this.dateConfig);this.df=new Ext.form.DateField(b);delete (this.dateFormat);var a=Ext.apply({},{id:this.id+"-time",format:this.timeFormat,width:this.timeWidth,listeners:{blur:{scope:this,fn:this.onBlur},focus:{scope:this,fn:this.onFocus}}},this.timeConfig);this.tf=new Ext.form.TimeField(a);delete (this.timeFormat);this.relayEvents(this.df,["focus","specialkey","invalid","valid"]);this.relayEvents(this.tf,["focus","specialkey","invalid","valid"])},onRender:function(c,a){if(this.isRendered){return}Ext.ux.form.DateTime.superclass.onRender.call(this,c,a);if("below"===this.timePosition){var b=Ext.DomHelper.append(c,{tag:"table",style:"border-collapse:collapse",children:[{tag:"tr",children:[{tag:"td",style:"padding-bottom:1px",cls:"ux-datetime-date"}]},{tag:"tr",children:[{tag:"td",cls:"ux-datetime-time"}]}]},true)}else{var b=Ext.DomHelper.append(c,{tag:"table",style:"border-collapse:collapse",children:[{tag:"tr",children:[{tag:"td",style:"padding-right:4px",cls:"ux-datetime-date"},{tag:"td",cls:"ux-datetime-time"}]}]},true)}this.tableEl=b;this.wrap=b.wrap({cls:"x-form-field-wrap"});this.wrap.on("mousedown",this.onMouseDown,this,{delay:10});this.df.render(b.child("td.ux-datetime-date"));this.tf.render(b.child("td.ux-datetime-time"));if(Ext.isIE&&Ext.isStrict){b.select("input").applyStyles({top:0})}this.on("specialkey",this.onSpecialKey,this);this.df.el.swallowEvent(["keydown","keypress"]);this.tf.el.swallowEvent(["keydown","keypress"]);if("side"===this.msgTarget){var d=this.el.findParent(".x-form-element",10,true);this.errorIcon=d.createChild({cls:"x-form-invalid-icon"});this.df.errorIcon=this.errorIcon;this.tf.errorIcon=this.errorIcon}this.isRendered=true},getPositionEl:function(){return this.wrap},getResizeEl:function(){return this.wrap},adjustSize:Ext.BoxComponent.prototype.adjustSize,alignErrorIcon:function(){this.errorIcon.alignTo(this.wrap,"tl-tr",[2,0])},onSpecialKey:function(a,b){if(b.getKey()==b.TAB){if(a===this.df&&!b.shiftKey){b.stopEvent();this.tf.focus()}if(a===this.tf&&b.shiftKey){b.stopEvent();this.df.focus()}}},setSize:function(a,b){if(!a){return}if("below"==this.timePosition){this.df.setSize(a,b);this.tf.setSize(a,b);if(Ext.isIE){this.df.el.up("td").setWidth(a);this.tf.el.up("td").setWidth(a)}}else{this.df.setSize(a-this.timeWidth-4,b);this.tf.setSize(this.timeWidth,b);if(Ext.isIE){this.df.el.up("td").setWidth(a-this.timeWidth-4);this.tf.el.up("td").setWidth(this.timeWidth)}}},setValue:function(c){if(!c){this.setDate("");this.setTime("");this.updateValue();return}c=new Date(c.getTime());var a,b;if(Ext.isDate(c)){this.setDate(c);this.setTime(c);this.dateValue=new Date(c)}else{a=c.split(this.dtSeparator);this.setDate(a[0]);if(a[1]){this.setTime(a[1])}}this.updateValue()},getValue:function(){return this.dateValue?new Date(this.dateValue):""},onMouseDown:function(a){this.wrapClick="td"===a.target.nodeName.toLowerCase()},onFocus:function(){if(!this.hasFocus){this.hasFocus=true;this.startValue=this.getValue();this.fireEvent("focus",this)}},onBlur:function(a){if(this.wrapClick){a.focus();this.wrapClick=false}if(a===this.df){this.updateDate()}else{this.updateTime()}this.updateHidden();(function(){if(!this.df.hasFocus&&!this.tf.hasFocus){var b=this.getValue();if(String(b)!==String(this.startValue)){this.fireEvent("change",this,b,this.startValue)}this.hasFocus=false;this.fireEvent("blur",this)}}).defer(100,this)},updateDate:function(){var a=this.df.getValue();if(a){if(!Ext.isDate(this.dateValue)){this.initDateValue();if(!this.tf.getValue()){this.setTime(this.dateValue)}}this.dateValue.setFullYear(a.getFullYear());this.dateValue.setMonth(a.getMonth());this.dateValue.setDate(a.getDate())}else{this.dateValue="";this.setTime("")}},updateTime:function(){var a=this.tf.getValue();if(a&&!Ext.isDate(a)){a=Date.parseDate(a,this.tf.format)}if(a&&!this.df.getValue()){this.initDateValue();this.setDate(this.dateValue)}if(Ext.isDate(this.dateValue)){if(a){this.dateValue.setHours(a.getHours());this.dateValue.setMinutes(a.getMinutes());this.dateValue.setSeconds(a.getSeconds())}else{this.dateValue.setHours(0);this.dateValue.setMinutes(0);this.dateValue.setSeconds(0)}}},initDateValue:function(){this.dateValue=this.otherToNow?new Date():new Date(1970,0,1,0,0,0)},updateHidden:function(){pm.log("updateHidden");if(this.isRendered){pm.log("is rendered");var a=Ext.isDate(this.dateValue)?this.dateValue.format(this.hiddenFormat):"";this.el.dom.value=a}},updateValue:function(){pm.log("updateValue");this.updateDate();this.updateTime();this.updateHidden();return},setDate:function(a){this.df.setValue(a)},setTime:function(a){this.tf.setValue(a)},isValid:function(){return this.df.isValid()&&this.tf.isValid()},validate:function(){return this.df.validate()&&this.tf.validate()},focus:function(){this.df.focus()},onDisable:function(){if(this.rendered){this.df.disable();this.tf.disable()}},onEnable:function(){if(this.rendered){this.df.enable();this.tf.enable()}},disableTime:function(){if(this.rendered){this.tf.disable()}},enableTime:function(){if(this.rendered){this.tf.enable()}}});Ext.reg("xdatetime",Ext.ux.form.DateTime);Ext.namespace("Ext.ux");Ext.ux.RadioGroup=Ext.extend(Ext.form.Field,{focusClass:undefined,fieldClass:"x-form-field",checked:false,defaultAutoCreate:{tag:"input",type:"radio",autocomplete:"off"},getId:function(){if(this.radios&&this.radios instanceof Array){if(this.radios.length){var a=this.radios[0];this.value=a.value;this.boxLabel=a.boxLabel;this.checked=a.checked||false;this.readOnly=a.readOnly||false;this.disabled=a.disabled||false;this.tabIndex=a.tabIndex;this.cls=a.cls;this.listeners=a.listeners;this.style=a.style;this.bodyStyle=a.bodyStyle;this.hideParent=a.hideParent;this.hidden=a.hidden}}Ext.ux.RadioGroup.superclass.getId.call(this)},initComponent:function(){Ext.ux.RadioGroup.superclass.initComponent.call(this);this.addEvents("check")},onResize:function(){Ext.ux.RadioGroup.superclass.onResize.apply(this,arguments);if(!this.boxLabel){this.el.alignTo(this.wrap,"c-c")}},initEvents:function(){Ext.ux.RadioGroup.superclass.initEvents.call(this);this.el.on("click",this.onClick,this);this.el.on("change",this.onClick,this)},getResizeEl:function(){return this.wrap},getPositionEl:function(){return this.wrap},markInvalid:Ext.emptyFn,clearInvalid:Ext.emptyFn,onRender:function(c,a){Ext.ux.RadioGroup.superclass.onRender.call(this,c,a);this.wrap=this.el.wrap({cls:"x-form-check-wrap"});if(this.boxLabel){this.wrap.createChild({tag:"label",htmlFor:this.el.id,cls:"x-form-cb-label",html:this.boxLabel})}if(!this.isInGroup){this.wrap.applyStyles({"padding-top":"2px"})}if(this.checked){this.setChecked(true)}else{this.checked=this.el.dom.checked}if(this.radios&&this.radios instanceof Array){this.els=new Array();this.els[0]=this.el;for(var b=1;b<this.radios.length;b++){var d=this.radios[b];this.els[b]=new Ext.ux.RadioGroup({renderTo:this.wrap,hideLabel:true,boxLabel:d.boxLabel,checked:d.checked||false,value:d.value,name:this.name||this.id,readOnly:d.readOnly||false,disabled:d.disabled||false,tabIndex:d.tabIndex,cls:d.cls,listeners:d.listeners,style:d.style,bodyStyle:d.bodyStyle,hideParent:d.hideParent,hidden:d.hidden,isInGroup:true});if(this.horizontal){this.els[b].el.up("div.x-form-check-wrap").applyStyles({display:"inline","padding-left":"5px"})}}if(this.hidden){this.hide()}}},initValue:function(){if(this.value!==undefined){this.el.dom.value=this.value}else{if(this.el.dom.value.length>0){this.value=this.el.dom.value}}},onDestroy:function(){if(this.radios&&this.radios instanceof Array){var b=this.radios.length;for(var a=1;a<b;a++){this.els[a].destroy()}}if(this.wrap){this.wrap.remove()}Ext.ux.RadioGroup.superclass.onDestroy.call(this)},setChecked:function(a){if(this.el&&this.el.dom){var b=false;if(a!=this.checked){b=true}this.checked=a;this.el.dom.checked=this.checked;this.el.dom.defaultChecked=this.checked;if(b){this.fireEvent("check",this,this.checked)}}},getValue:function(){if(!this.rendered){return this.value}var a=this.el.up("form");if(!a){a=Ext.getBody()}var b=a.child("input[name="+this.el.dom.name+"]:checked",true);return(b)?b.value:this.value},onClick:function(){if(this.el.dom.checked!=this.checked){var b=this.el.up("form");if(!b){b=Ext.getBody()}var a=b.select("input[name="+this.el.dom.name+"]");a.each(function(c){if(c.dom.id==this.id){this.setChecked(true)}else{var d=Ext.getCmp(c.dom.id);d.setChecked.apply(d,[false])}},this)}},setValue:function(a){if(!this.rendered){this.value=a;return}var c=this.el.up("form");if(!c){c=Ext.getBody()}var b=c.child("input[name="+this.el.dom.name+"][value="+a+"]",true);if(b){b.checked=true}}});Ext.reg("ux-radiogroup",Ext.ux.RadioGroup);Ext.form.ComboBoxMulti=function(a){Ext.apply(a);this.typeAhead=false;this.minChars=2;this.hideTrigger=true;this.defaultAutoCreate={tag:"textarea",autocomplete:"off"};Ext.form.ComboBoxMulti.superclass.constructor.call(this,a)};Ext.form.ComboBoxMulti=Ext.extend(Ext.form.ComboBoxMulti,Ext.form.ComboBox,{getPosition:function(){pm.log("getPosition");if(document.selection){var a=document.selection.createRange();var b=a.duplicate();b.moveToElementText(this.el.dom);b.setEndPoint("EndToEnd",a);return b.text.length}else{return this.el.dom.selectionEnd}},getActiveRange:function(){pm.log("getActiveRange");var b=this.sep;var d=this.getPosition();var a=this.getRawValue();var c=d;while(c>0&&a.charAt(c)!=b){--c}if(c>0){c++}return{left:c,right:d}},getActiveEntry:function(){pm.log("getActiveEntry");var a=this.getActiveRange();return this.getRawValue().substring(a.left,a.right).replace(/^s+|s+$/g,"")},replaceActiveEntry:function(c){pm.log("replaceActiveEntry");var b=this.getActiveRange();var a=this.getRawValue();if(this.preventDuplicates&&a.indexOf(c)>=0){return}var e=(this.sep==" "?"":" ");this.setValue(a.substring(0,b.left)+(b.left>0?e:"")+c+this.sep+e+a.substring(b.right));var d=b.left+c.length+2+e.length;this.selectText.defer(200,this,[d,d])},onSelect:function(a,b){pm.log("onSelect");if(this.fireEvent("beforeselect",this,a,b)!==false){var c=a.data[this.valueField||this.displayField];if(this.sep){this.replaceActiveEntry(c)}else{this.setValue(c)}this.collapse();this.fireEvent("select",this,a,b)}},initQuery:function(){pm.log("initQuery");this.doQuery(this.sep?this.getActiveEntry():this.getRawValue())}});Ext.reg("combomulti",Ext.form.ComboBoxMulti);Ext.ux.Multiselect=Ext.extend(Ext.form.Field,{store:null,dataFields:[],data:[],width:100,height:100,displayField:0,valueField:1,allowBlank:true,minLength:0,maxLength:Number.MAX_VALUE,blankText:Ext.form.TextField.prototype.blankText,minLengthText:"Minimum {0} item(s) required",maxLengthText:"Maximum {0} item(s) allowed",copy:false,allowDup:false,allowTrash:false,legend:null,focusClass:undefined,delimiter:",",view:null,dragGroup:null,dropGroup:null,tbar:null,appendOnly:false,sortField:null,sortDir:"ASC",defaultAutoCreate:{tag:"div"},initComponent:function(){Ext.ux.Multiselect.superclass.initComponent.call(this);this.addEvents({dblclick:true,click:true,change:true,drop:true})},onRender:function(e,b){var a,c,d;Ext.ux.Multiselect.superclass.onRender.call(this,e,b);c="ux-mselect";a=new Ext.form.FieldSet({renderTo:this.el,title:this.legend,height:this.height,width:this.width,style:"padding:1px;",tbar:this.tbar});a.body.addClass(c);d='<tpl for="."><div class="'+c+"-item";if(Ext.isIE||Ext.isIE7){d+='" unselectable=on'}else{d+=' x-unselectable"'}d+=">{"+this.displayField+"}</div></tpl>";if(!this.store){this.store=new Ext.data.SimpleStore({fields:this.dataFields,data:this.data})}this.view=new Ext.ux.DDView({multiSelect:true,store:this.store,selectedClass:c+"-selected",tpl:d,allowDup:this.allowDup,copy:this.copy,allowTrash:this.allowTrash,dragGroup:this.dragGroup,dropGroup:this.dropGroup,itemSelector:"."+c+"-item",isFormField:false,applyTo:a.body,appendOnly:this.appendOnly,sortField:this.sortField,sortDir:this.sortDir});a.add(this.view);this.view.on("click",this.onViewClick,this);this.view.on("beforeClick",this.onViewBeforeClick,this);this.view.on("dblclick",this.onViewDblClick,this);this.view.on("drop",function(h,k,g,j,i){return this.fireEvent("drop",h,k,g,j,i)},this);this.hiddenName=this.name;var f={tag:"input",type:"hidden",value:"",name:this.name};if(this.isFormField){this.hiddenField=this.el.createChild(f)}else{this.hiddenField=Ext.get(document.body).createChild(f)}a.doLayout()},initValue:Ext.emptyFn,onViewClick:function(d,b,c,f){var a=this.preClickSelections.indexOf(b);if(a!=-1){this.preClickSelections.splice(a,1);this.view.clearSelections(true);this.view.select(this.preClickSelections)}this.fireEvent("change",this,this.getValue(),this.hiddenField.dom.value);this.hiddenField.dom.value=this.getValue();this.fireEvent("click",this,f);this.validate()},onViewBeforeClick:function(c,a,b,d){this.preClickSelections=this.view.getSelectedIndexes();if(this.disabled){return false}},onViewDblClick:function(c,a,b,d){return this.fireEvent("dblclick",c,a,b,d)},getValue:function(a){var d=[];var c=this.view.getSelectedIndexes();if(c.length==0){return""}for(var b=0;b<c.length;b++){d.push(this.store.getAt(c[b]).get(((a!=null)?a:this.valueField)))}return d.join(this.delimiter)},setValue:function(a){var b;var d=[];this.view.clearSelections();this.hiddenField.dom.value="";if(!a||(a=="")){return}if(!(a instanceof Array)){a=a.split(this.delimiter)}for(var c=0;c<a.length;c++){b=this.view.store.indexOf(this.view.store.query(this.valueField,new RegExp("^"+a[c]+"$","i")).itemAt(0));d.push(b)}this.view.select(d);this.hiddenField.dom.value=this.getValue();this.validate()},reset:function(){this.setValue("")},getRawValue:function(a){var b=this.getValue(a);if(b.length){b=b.split(this.delimiter)}else{b=[]}return b},setRawValue:function(a){setValue(a)},validateValue:function(a){if(a.length<1){if(this.allowBlank){this.clearInvalid();return true}else{this.markInvalid(this.blankText);return false}}if(a.length<this.minLength){this.markInvalid(String.format(this.minLengthText,this.minLength));return false}if(a.length>this.maxLength){this.markInvalid(String.format(this.maxLengthText,this.maxLength));return false}return true}});Ext.reg("multiselect",Ext.ux.Multiselect);Ext.ux.ItemSelector=Ext.extend(Ext.form.Field,{msWidth:200,msHeight:300,hideNavIcons:false,imagePath:"",iconUp:"up2.gif",iconDown:"down2.gif",iconLeft:"left2.gif",iconRight:"right2.gif",iconTop:"top2.gif",iconBottom:"bottom2.gif",drawUpIcon:true,drawDownIcon:true,drawLeftIcon:true,drawRightIcon:true,drawTopIcon:true,drawBotIcon:true,fromStore:null,toStore:null,fromData:null,toData:null,displayField:0,valueField:1,switchToFrom:false,allowDup:false,focusClass:undefined,delimiter:",",readOnly:false,toLegend:null,fromLegend:null,toSortField:null,fromSortField:null,toSortDir:"ASC",fromSortDir:"ASC",toTBar:null,fromTBar:null,bodyStyle:null,border:false,defaultAutoCreate:{tag:"div"},initComponent:function(){Ext.ux.ItemSelector.superclass.initComponent.call(this);this.addEvents({rowdblclick:true,change:true})},onRender:function(d,a){Ext.ux.ItemSelector.superclass.onRender.call(this,d,a);this.fromMultiselect=new Ext.ux.Multiselect({legend:this.fromLegend,delimiter:this.delimiter,allowDup:this.allowDup,copy:this.allowDup,allowTrash:this.allowDup,dragGroup:this.readOnly?null:"drop2-"+this.el.dom.id,dropGroup:this.readOnly?null:"drop1-"+this.el.dom.id,width:this.msWidth,height:this.msHeight,dataFields:this.dataFields,data:this.fromData,displayField:this.displayField,valueField:this.valueField,store:this.fromStore,isFormField:false,tbar:this.fromTBar,appendOnly:true,sortField:this.fromSortField,sortDir:this.fromSortDir});this.fromMultiselect.on("dblclick",this.onRowDblClick,this);if(!this.toStore){this.toStore=new Ext.data.SimpleStore({fields:this.dataFields,data:this.toData})}this.toStore.on("add",this.valueChanged,this);this.toStore.on("remove",this.valueChanged,this);this.toStore.on("load",this.valueChanged,this);this.toMultiselect=new Ext.ux.Multiselect({legend:this.toLegend,delimiter:this.delimiter,allowDup:this.allowDup,dragGroup:this.readOnly?null:"drop1-"+this.el.dom.id,dropGroup:this.readOnly?null:"drop2-"+this.el.dom.id+",drop1-"+this.el.dom.id,width:this.msWidth,height:this.msHeight,displayField:this.displayField,valueField:this.valueField,store:this.toStore,isFormField:false,tbar:this.toTBar,sortField:this.toSortField,sortDir:this.toSortDir});this.toMultiselect.on("dblclick",this.onRowDblClick,this);var g=new Ext.Panel({bodyStyle:this.bodyStyle,border:this.border,layout:"table",layoutConfig:{columns:3}});g.add(this.switchToFrom?this.toMultiselect:this.fromMultiselect);var c=new Ext.Panel({header:false});g.add(c);g.add(this.switchToFrom?this.fromMultiselect:this.toMultiselect);g.render(this.el);c.el.down("."+c.bwrapCls).remove();if(this.imagePath!=""&&this.imagePath.charAt(this.imagePath.length-1)!="/"){this.imagePath+="/"}this.iconUp=this.imagePath+(this.iconUp||"up2.gif");this.iconDown=this.imagePath+(this.iconDown||"down2.gif");this.iconLeft=this.imagePath+(this.iconLeft||"left2.gif");this.iconRight=this.imagePath+(this.iconRight||"right2.gif");this.iconTop=this.imagePath+(this.iconTop||"top2.gif");this.iconBottom=this.imagePath+(this.iconBottom||"bottom2.gif");var f=c.getEl();if(!this.toSortField){this.toTopIcon=f.createChild({tag:"img",src:this.iconTop,style:{cursor:"pointer",margin:"2px"}});f.createChild({tag:"br"});this.upIcon=f.createChild({tag:"img",src:this.iconUp,style:{cursor:"pointer",margin:"2px"}});f.createChild({tag:"br"})}this.addIcon=f.createChild({tag:"img",src:this.switchToFrom?this.iconLeft:this.iconRight,style:{cursor:"pointer",margin:"2px"}});f.createChild({tag:"br"});this.removeIcon=f.createChild({tag:"img",src:this.switchToFrom?this.iconRight:this.iconLeft,style:{cursor:"pointer",margin:"2px"}});f.createChild({tag:"br"});if(!this.toSortField){this.downIcon=f.createChild({tag:"img",src:this.iconDown,style:{cursor:"pointer",margin:"2px"}});f.createChild({tag:"br"});this.toBottomIcon=f.createChild({tag:"img",src:this.iconBottom,style:{cursor:"pointer",margin:"2px"}})}if(!this.readOnly){if(!this.toSortField){this.toTopIcon.on("click",this.toTop,this);this.upIcon.on("click",this.up,this);this.downIcon.on("click",this.down,this);this.toBottomIcon.on("click",this.toBottom,this)}this.addIcon.on("click",this.fromTo,this);this.removeIcon.on("click",this.toFrom,this)}if(!this.drawUpIcon||this.hideNavIcons){this.upIcon.dom.style.display="none"}if(!this.drawDownIcon||this.hideNavIcons){this.downIcon.dom.style.display="none"}if(!this.drawLeftIcon||this.hideNavIcons){this.addIcon.dom.style.display="none"}if(!this.drawRightIcon||this.hideNavIcons){this.removeIcon.dom.style.display="none"}if(!this.drawTopIcon||this.hideNavIcons){this.toTopIcon.dom.style.display="none"}if(!this.drawBotIcon||this.hideNavIcons){this.toBottomIcon.dom.style.display="none"}var b=g.body.first();this.el.setWidth(g.body.first().getWidth());g.body.removeClass();this.hiddenName=this.name;var e={tag:"input",type:"hidden",value:"",name:this.name};this.hiddenField=this.el.createChild(e);this.valueChanged(this.toStore)},initValue:Ext.emptyFn,toTop:function(){var c=this.toMultiselect.view.getSelectedIndexes();var a=[];if(c.length>0){c.sort();for(var b=0;b<c.length;b++){record=this.toMultiselect.view.store.getAt(c[b]);a.push(record)}c=[];for(var b=a.length-1;b>-1;b--){record=a[b];this.toMultiselect.view.store.remove(record);this.toMultiselect.view.store.insert(0,record);c.push(((a.length-1)-b))}}this.toMultiselect.view.refresh();this.toMultiselect.view.select(c)},toBottom:function(){var c=this.toMultiselect.view.getSelectedIndexes();var a=[];if(c.length>0){c.sort();for(var b=0;b<c.length;b++){record=this.toMultiselect.view.store.getAt(c[b]);a.push(record)}c=[];for(var b=0;b<a.length;b++){record=a[b];this.toMultiselect.view.store.remove(record);this.toMultiselect.view.store.add(record);c.push((this.toMultiselect.view.store.getCount())-(a.length-b))}}this.toMultiselect.view.refresh();this.toMultiselect.view.select(c)},up:function(){var a=null;var c=this.toMultiselect.view.getSelectedIndexes();c.sort();var d=[];if(c.length>0){for(var b=0;b<c.length;b++){a=this.toMultiselect.view.store.getAt(c[b]);if((c[b]-1)>=0){this.toMultiselect.view.store.remove(a);this.toMultiselect.view.store.insert(c[b]-1,a);d.push(c[b]-1)}}this.toMultiselect.view.refresh();this.toMultiselect.view.select(d)}},down:function(){var a=null;var c=this.toMultiselect.view.getSelectedIndexes();c.sort();c.reverse();var d=[];if(c.length>0){for(var b=0;b<c.length;b++){a=this.toMultiselect.view.store.getAt(c[b]);if((c[b]+1)<this.toMultiselect.view.store.getCount()){this.toMultiselect.view.store.remove(a);this.toMultiselect.view.store.insert(c[b]+1,a);d.push(c[b]+1)}}this.toMultiselect.view.refresh();this.toMultiselect.view.select(d)}},fromTo:function(){var d=this.fromMultiselect.view.getSelectedIndexes();var b=[];if(d.length>0){for(var c=0;c<d.length;c++){record=this.fromMultiselect.view.store.getAt(d[c]);b.push(record)}if(!this.allowDup){d=[]}for(var c=0;c<b.length;c++){record=b[c];if(this.allowDup){var a=new Ext.data.Record();record.id=a.id;delete a;this.toMultiselect.view.store.add(record)}else{this.fromMultiselect.view.store.remove(record);this.toMultiselect.view.store.add(record);d.push((this.toMultiselect.view.store.getCount()-1))}}}this.toMultiselect.view.refresh();this.fromMultiselect.view.refresh();if(this.toSortField){this.toMultiselect.store.sort(this.toSortField,this.toSortDir)}if(this.allowDup){this.fromMultiselect.view.select(d)}else{this.toMultiselect.view.select(d)}},toFrom:function(){var c=this.toMultiselect.view.getSelectedIndexes();var a=[];if(c.length>0){for(var b=0;b<c.length;b++){record=this.toMultiselect.view.store.getAt(c[b]);a.push(record)}c=[];for(var b=0;b<a.length;b++){record=a[b];this.toMultiselect.view.store.remove(record);if(!this.allowDup){this.fromMultiselect.view.store.add(record);c.push((this.fromMultiselect.view.store.getCount()-1))}}}this.fromMultiselect.view.refresh();this.toMultiselect.view.refresh();if(this.fromSortField){this.fromMultiselect.store.sort(this.fromSortField,this.fromSortDir)}this.fromMultiselect.view.select(c)},valueChanged:function(c){var a=null;var b=[];for(var d=0;d<c.getCount();d++){a=c.getAt(d);b.push(a.get(this.valueField))}this.hiddenField.dom.value=b.join(this.delimiter);this.fireEvent("change",this,this.getValue(),this.hiddenField.dom.value)},getValue:function(){return this.hiddenField.dom.value},onRowDblClick:function(c,a,b,d){return this.fireEvent("rowdblclick",c,a,b,d)},reset:function(){range=this.toMultiselect.store.getRange();this.toMultiselect.store.removeAll();if(!this.allowDup){this.fromMultiselect.store.add(range);this.fromMultiselect.store.sort(this.displayField,"ASC")}this.valueChanged(this.toMultiselect.store)}});Ext.reg("itemselector",Ext.ux.ItemSelector);Array.prototype.contains=function(a){return this.indexOf(a)!==-1};Ext.namespace("Ext.ux");Ext.ux.DDView=function(b){if(!b.itemSelector){var a=b.tpl;if(this.classRe.test(a)){b.tpl=a.replace(this.classRe,"class=$1x-combo-list-item $2$1")}else{b.tpl=a.replace(this.tagRe,'$1 class="x-combo-list-item" $2')}b.itemSelector=".x-combo-list-item"}Ext.ux.DDView.superclass.constructor.call(this,Ext.apply(b,{border:false}))};Ext.extend(Ext.ux.DDView,Ext.DataView,{sortDir:"ASC",isFormField:true,classRe:/class=(['"])(.*)\1/,tagRe:/(<\w*)(.*?>)/,reset:Ext.emptyFn,clearInvalid:Ext.form.Field.prototype.clearInvalid,msgTarget:"qtip",afterRender:function(){Ext.ux.DDView.superclass.afterRender.call(this);if(this.dragGroup){this.setDraggable(this.dragGroup.split(","))}if(this.dropGroup){this.setDroppable(this.dropGroup.split(","))}if(this.deletable){this.setDeletable()}this.isDirtyFlag=false;this.addEvents("drop")},validate:function(){return true},destroy:function(){this.purgeListeners();this.getEl().removeAllListeners();this.getEl().remove();if(this.dragZone){if(this.dragZone.destroy){this.dragZone.destroy()}}if(this.dropZone){if(this.dropZone.destroy){this.dropZone.destroy()}}},getName:function(){return this.name},setValue:function(a){if(!this.store){throw"DDView.setValue(). DDView must be constructed with a valid Store"}var b={};b[this.store.reader.meta.root]=a?[].concat(a):[];this.store.proxy=new Ext.data.MemoryProxy(b);this.store.load()},getValue:function(){var a="(";this.store.each(function(b){a+=b.id+","});return a.substr(0,a.length-1)+")"},getIds:function(){var b=0,a=new Array(this.store.getCount());this.store.each(function(c){a[b++]=c.id});return a},isDirty:function(){return this.isDirtyFlag},getTargetFromEvent:function(b){var a=b.getTarget();while((a!==null)&&(a.parentNode!=this.el.dom)){a=a.parentNode}if(!a){a=this.el.dom.lastChild||this.el.dom}return a},getDragData:function(d){var c=this.findItemFromChild(d.getTarget());if(c){if(!this.isSelected(c)){delete this.ignoreNextClick;this.onItemClick(c,this.indexOf(c),d);this.ignoreNextClick=true}var b={sourceView:this,viewNodes:[],records:[],copy:this.copy||(this.allowCopy&&d.ctrlKey)};if(this.getSelectionCount()==1){var a=this.getSelectedIndexes()[0];var f=this.getNode(a);b.viewNodes.push(b.ddel=f);b.records.push(this.store.getAt(a));b.repairXY=Ext.fly(f).getXY()}else{b.ddel=document.createElement("div");b.ddel.className="multi-proxy";this.collectSelection(b)}return b}return false},getRepairXY:function(a){return this.dragData.repairXY},collectSelection:function(b){b.repairXY=Ext.fly(this.getSelectedNodes()[0]).getXY();if(this.preserveSelectionOrder===true){Ext.each(this.getSelectedIndexes(),function(c){var e=this.getNode(c);var d=e.cloneNode(true);d.id=Ext.id();b.ddel.appendChild(d);b.records.push(this.store.getAt(c));b.viewNodes.push(e)},this)}else{var a=0;this.store.each(function(d){if(this.isSelected(a)){var e=this.getNode(a);var c=e.cloneNode(true);c.id=Ext.id();b.ddel.appendChild(c);b.records.push(this.store.getAt(a));b.viewNodes.push(e)}a++},this)}},setDraggable:function(a){if(a instanceof Array){Ext.each(a,this.setDraggable,this);return}if(this.dragZone){this.dragZone.addToGroup(a)}else{this.dragZone=new Ext.dd.DragZone(this.getEl(),{containerScroll:true,ddGroup:a});if(!this.multiSelect){this.singleSelect=true}this.dragZone.getDragData=this.getDragData.createDelegate(this);this.dragZone.getRepairXY=this.getRepairXY;this.dragZone.onEndDrag=this.onEndDrag}},setDroppable:function(a){if(a instanceof Array){Ext.each(a,this.setDroppable,this);return}if(this.dropZone){this.dropZone.addToGroup(a)}else{this.dropZone=new Ext.dd.DropZone(this.getEl(),{owningView:this,containerScroll:true,ddGroup:a});this.dropZone.getTargetFromEvent=this.getTargetFromEvent.createDelegate(this);this.dropZone.onNodeEnter=this.onNodeEnter.createDelegate(this);this.dropZone.onNodeOver=this.onNodeOver.createDelegate(this);this.dropZone.onNodeOut=this.onNodeOut.createDelegate(this);this.dropZone.onNodeDrop=this.onNodeDrop.createDelegate(this)}},getDropPoint:function(g,j,d){if(j==this.el.dom){return"above"}var f=Ext.lib.Dom.getY(j),a=f+j.offsetHeight;var i=f+(a-f)/2;var h=Ext.lib.Event.getPageY(g);if(h<=i){return"above"}else{return"below"}},isValidDropPoint:function(b,e,a){if(!a.viewNodes||(a.viewNodes.length!=1)){return true}var c=a.viewNodes[0];if(c==e){return false}if((b=="below")&&(e.nextSibling==c)){return false}if((b=="above")&&(e.previousSibling==c)){return false}return true},onNodeEnter:function(d,a,c,b){if(this.highlightColor&&(b.sourceView!=this)){this.el.highlight(this.highlightColor)}return false},onNodeOver:function(h,a,g,d){var b=this.dropNotAllowed;var f=this.getDropPoint(g,h,a);if(this.isValidDropPoint(f,h,d)){if(this.appendOnly||this.sortField){return"x-tree-drop-ok-below"}if(f){var c;if(f=="above"){b=h.previousSibling?"x-tree-drop-ok-between":"x-tree-drop-ok-above";c="x-view-drag-insert-above"}else{b=h.nextSibling?"x-tree-drop-ok-between":"x-tree-drop-ok-below";c="x-view-drag-insert-below"}if(this.lastInsertClass!=c){Ext.fly(h).replaceClass(this.lastInsertClass,c);this.lastInsertClass=c}}}return b},onNodeOut:function(d,a,c,b){this.removeDropIndicators(d)},onNodeDrop:function(c,k,h,f){if(this.fireEvent("drop",this,c,k,h,f)===false){return false}var l=this.getDropPoint(h,c,k);var d=(this.appendOnly||(c==this.el.dom))?this.store.getCount():c.viewIndex;if(l=="below"){d++}if(f.sourceView==this){if(l=="below"){if(f.viewNodes[0]==c){f.viewNodes.shift()}}else{if(f.viewNodes[f.viewNodes.length-1]==c){f.viewNodes.pop()}}if(!f.viewNodes.length){return false}if(d>this.store.indexOf(f.records[0])){d--}}if(f.node instanceof Ext.tree.TreeNode){var a=f.node.getOwnerTree().recordFromNode(f.node);if(a){f.records=[a]}}if(!f.records){alert("Programming problem. Drag data contained no Records");return false}for(var g=0;g<f.records.length;g++){var a=f.records[g];var b=this.store.getById(a.id);if(b&&(k!=this.dragZone)){if(!this.allowDup&&!this.allowTrash){Ext.fly(this.getNode(this.store.indexOf(b))).frame("red",1);return true}var j=new Ext.data.Record();a.id=j.id;delete j}if(f.copy){this.store.insert(d++,a.copy())}else{if(f.sourceView){f.sourceView.isDirtyFlag=true;f.sourceView.store.remove(a)}if(!this.allowTrash){this.store.insert(d++,a)}}if(this.sortField){this.store.sort(this.sortField,this.sortDir)}this.isDirtyFlag=true}this.dragZone.cachedTarget=null;return true},onEndDrag:function(a,b){var c=Ext.get(this.dragData.ddel);if(c&&c.hasClass("multi-proxy")){c.remove()}},removeDropIndicators:function(a){if(a){Ext.fly(a).removeClass(["x-view-drag-insert-above","x-view-drag-insert-left","x-view-drag-insert-right","x-view-drag-insert-below"]);this.lastInsertClass="_noclass"}},setDeletable:function(a){if(!this.singleSelect&&!this.multiSelect){this.singleSelect=true}var b=this.getContextMenu();this.contextMenu.on("itemclick",function(c){switch(c.id){case"delete":this.remove(this.getSelectedIndexes());break}},this);this.contextMenu.add({icon:a||AU.resolveUrl("/images/delete.gif"),id:"delete",text:AU.getMessage("deleteItem")})},getContextMenu:function(){if(!this.contextMenu){this.contextMenu=new Ext.menu.Menu({id:this.id+"-contextmenu"});this.el.on("contextmenu",this.showContextMenu,this)}return this.contextMenu},disableContextMenu:function(){if(this.contextMenu){this.el.un("contextmenu",this.showContextMenu,this)}},showContextMenu:function(b,a){a=this.findItemFromChild(b.getTarget());if(a){b.stopEvent();this.select(this.getNode(a),this.multiSelect&&b.ctrlKey,true);this.contextMenu.showAt(b.getXY())}},remove:function(b){b=[].concat(b);for(var a=0;a<b.length;a++){var c=this.store.getAt(b[a]);this.store.remove(c)}},onDblClick:function(f){var d=this.findItemFromChild(f.getTarget());if(d){if(this.fireEvent("dblclick",this,this.indexOf(d),d,f)===false){return false}if(this.dragGroup){var a=Ext.dd.DragDropMgr.getRelated(this.dragZone,true);while(a.contains(this.dropZone)){a.remove(this.dropZone)}if((a.length==1)&&(a[0].owningView)){this.dragZone.cachedTarget=null;var b=Ext.get(a[0].getEl());var c=b.getBox(true);a[0].onNodeDrop(b.dom,{target:b.dom,xy:[c.x,c.y+c.height-1]},null,this.getDragData(f))}}}},onItemClick:function(b,a,c){if(this.ignoreNextClick){delete this.ignoreNextClick;return}if(this.fireEvent("beforeclick",this,a,b,c)===false){return false}if(this.multiSelect||this.singleSelect){if(this.multiSelect&&c.shiftKey&&this.lastSelection){this.select(this.getNodes(this.indexOf(this.lastSelection),a),false)}else{if(this.isSelected(b)&&c.ctrlKey){this.deselect(b)}else{this.deselect(b);this.select(b,this.multiSelect&&c.ctrlKey);this.lastSelection=b}}c.preventDefault()}return true}});Ext.ux.TreeGroup=Ext.extend(Ext.Panel,{baseCls:"x-group",titleCollapse:true,collapseFirst:false,initComponent:function(){Ext.ux.TreeGroup.superclass.initComponent.call(this);this.animCollapse=false},render:function(a){Ext.ux.TreeGroup.superclass.render.call(this,a)},afterCollapse:function(){Ext.ux.TreeGroup.superclass.afterCollapse.call(this);this.removeLoadingIndicator()},afterExpand:function(){Ext.ux.TreeGroup.superclass.afterExpand.call(this);if(this.loadingIndicator){this.el.addClass("x-panel-loading")}},removeLoadingIndicator:function(){this.el.removeClass("x-panel-loading")}});Ext.reg("treegroup",Ext.ux.TreeGroup);Ext.ux.TreePanel=Ext.extend(Ext.Panel,{animate:Ext.enableFx,hlDrop:Ext.enableFx,pathSeparator:"/",initComponent:function(){Ext.ux.TreePanel.superclass.initComponent.call(this);this.eventModel=new Ext.ux.TreeEventModel(this);this.nodeHash={};if(this.root){this.setRootNode(this.root)}this.loader=new Ext.ux.TreeLoaderHTTP({ot:this,baseParams:this.baseParams,nodeParams:this.nodeParams,idField:this.idField,titleField:this.titleField,dataUrl:this.dataUrl,onNodeInit:this.onNodeInit,onNodeLoad:this.onNodeLoad});this.addEvents("append","remove","movenode","insert","beforeappend","beforeremove","beforemovenode","beforeinsert","beforeload","load","textchange","beforeexpandnode","beforecollapsenode","expandnode","disabledchange","collapsenode","beforeclick","click","beforechildrenrendered","onCount");this.root.on("beforechildrenrendered",function(){this.childCount=this.childNodes.length;this.fireEvent("onCount",this.childCount)});if(this.singleExpand){this.on("beforeexpandnode",this.restrictExpand,this)}},proxyNodeEvent:function(c,b,a,g,f,e,d){if(c=="collapse"||c=="expand"||c=="beforecollapse"||c=="beforeexpand"||c=="move"||c=="beforemove"){c=c+"node"}return this.fireEvent(c,b,a,g,f,e,d)},getRootNode:function(){return this.root},reload:function(){this.root.reload()},setRootNode:function(a){this.root=a;a.ownerTree=this;a.isRoot=true;this.registerNode(a);a.ui=new Ext.ux.RootTreeNodeUI(a);return a},getNodeById:function(a){return this.nodeHash[a]},registerNode:function(a){this.nodeHash[a.id]=a},unregisterNode:function(a){delete this.nodeHash[a.id]},toString:function(){return"[Tree"+(this.id?" "+this.id:"")+"]"},restrictExpand:function(a){var b=a.parentNode;if(b){if(b.expandedChild&&b.expandedChild.parentNode==b){b.expandedChild.collapse()}b.expandedChild=a}},getEl:function(){return this.el},getLoader:function(){return this.loader},expandAll:function(){this.root.expand(true)},collapseAll:function(){this.root.collapse(true)},getSelectionModel:function(){if(!this.selModel){this.selModel=new Ext.tree.DefaultSelectionModel()}return this.selModel},expandPath:function(g,a,h){a=a||"id";var d=g.split(this.pathSeparator);var c=this.root;if(c.attributes[a]!=d[0]){if(h){h(false,null)}return}var b=0;var e=function(){if(++b==d.length){if(h){h(true,c)}return}var f=c.findChild(a,d[b]);if(!f){if(h){h(false,c)}return}c=f;f.expand(false,false,e)};c.expand(false,false,e)},selectPath:function(e,a,g){a=a||"id";var c=e.split(this.pathSeparator);var b=c.pop();if(c.length>0){var d=function(h,f){if(h&&f){var i=f.findChild(a,b);if(i){i.select();if(g){g(true,i)}}else{if(g){g(false,i)}}}else{if(g){g(false,i)}}};this.expandPath(c.join(this.pathSeparator),a,d)}else{this.root.select();if(g){g(true,this.root)}}},getTreeEl:function(){return this.body},onRender:function(b,a){Ext.ux.TreePanel.superclass.onRender.call(this,b,a);this.el.addClass("x-tree");this.innerCt=this.body.createChild({tag:"div",cls:"x-tree-root-ct"})},initEvents:function(){Ext.ux.TreePanel.superclass.initEvents.call(this);this.getSelectionModel().init(this)},afterRender:function(){Ext.ux.TreePanel.superclass.afterRender.call(this);this.root.render(this.innerCt.dom);if(!this.root.childrenRendered){this.root.renderChildren()}},onDestroy:function(){if(this.rendered){this.body.removeAllListeners()}this.root.destroy();this.nodeHash=null;Ext.ux.TreePanel.superclass.onDestroy.call(this)}});Ext.reg("treepanelx",Ext.ux.TreePanel);Ext.ux.TreeNode=function(a){a=a||{};if(typeof a=="string"){a={text:a}}this.childrenRendered=false;this.rendered=false;Ext.ux.TreeNode.superclass.constructor.call(this,a);this.expanded=a.expanded===true;this.isTarget=a.isTarget!==false;this.draggable=a.draggable!==false&&a.allowDrag!==false;this.allowChildren=a.allowChildren!==false&&a.allowDrop!==false;this.title=a.title;this.disabled=a.disabled===true;this.addEvents("titlechange","teaserchange","beforeexpand","beforecollapse","expand","disabledchange","collapse","beforeclick","click","beforechildrenrendered");this.ui=new Ext.ux.TreeNodeUI(this)};Ext.extend(Ext.ux.TreeNode,Ext.data.Node,{preventHScroll:true,isExpanded:function(){return this.expanded},getUI:function(){return this.ui},setFirstChild:function(a){var b=this.firstChild;Ext.ux.TreeNode.superclass.setFirstChild.call(this,a)},setLastChild:function(b){var a=this.lastChild;Ext.ux.TreeNode.superclass.setLastChild.call(this,b)},appendChild:function(){var a=Ext.ux.TreeNode.superclass.appendChild.apply(this,arguments);if(a&&this.childrenRendered){a.render()}this.ui.updateExpandIcon();return a},insertBefore:function(c,a){var b=Ext.ux.TreeNode.superclass.insertBefore.apply(this,arguments);if(b&&a&&this.childrenRendered){c.render()}this.ui.updateExpandIcon();return b},setTitle:function(a){this.title=a;this.attributes.title=a;if(this.rendered){this.ui.onChangeTitle(a)}this.fireEvent("titlechange",a)},setTeaser:function(a){this.teaser=a;this.attributes.teaser=a;if(this.rendered){this.ui.onChangeTeaser(a)}this.fireEvent("teaserchange",a)},select:function(){this.getOwnerTree().getSelectionModel().select(this)},unselect:function(){this.getOwnerTree().getSelectionModel().unselect(this)},isSelected:function(){return this.getOwnerTree().getSelectionModel().isSelected(this)},expandParentGroups:function(a){if(a&&a.instance){if(a.parent){this.expandParentGroups(a.parent)}a.instance.expand()}},expand:function(a,b,c){if(!this.expanded){if(this.fireEvent("beforeexpand",this,a,b)===false){return}if(!this.childrenRendered){this.renderChildren()}this.expanded=true;if(!this.isHiddenRoot()&&(this.getOwnerTree().animate&&b!==false)||b){this.ui.animExpand(function(){this.fireEvent("expand",this);if(typeof c=="function"){c(this)}if(a===true){this.expandChildNodes(true)}}.createDelegate(this));return}else{this.ui.expand();this.fireEvent("expand",this);if(typeof c=="function"){c(this)}}}else{if(typeof c=="function"){c(this)}}if(a===true){this.expandChildNodes(true)}},isHiddenRoot:function(){return this.isRoot&&!this.getOwnerTree().rootVisible},clearChildren:function(){for(var b=0,a=this.childNodes.length;b<a;b++){this.childNodes[b].destroy()}this.childNodes=[];this.ui.clearChildren()},collapse:function(b,e){if(this.expanded&&!this.isHiddenRoot()){if(this.fireEvent("beforecollapse",this,b,e)===false){return}this.expanded=false;if((this.getOwnerTree().animate&&e!==false)||e){this.ui.animCollapse(function(){this.fireEvent("collapse",this);if(b===true){this.collapseChildNodes(true)}}.createDelegate(this));return}else{this.ui.collapse();this.fireEvent("collapse",this)}}if(b===true){var d=this.childNodes;for(var c=0,a=d.length;c<a;c++){d[c].collapse(true,false)}}},delayedExpand:function(a){if(!this.expandProcId){this.expandProcId=this.expand.defer(a,this)}},cancelExpand:function(){if(this.expandProcId){clearTimeout(this.expandProcId)}this.expandProcId=false},toggle:function(){if(this.expanded){this.collapse()}else{this.expand()}},ensureVisible:function(b){var a=this.getOwnerTree();a.expandPath(this.parentNode.getPath(),false,function(){a.getTreeEl().scrollChildIntoView(this.ui.anchor);Ext.callback(b)}.createDelegate(this))},expandChildNodes:function(b){var d=this.childNodes;for(var c=0,a=d.length;c<a;c++){d[c].expand(b)}},collapseChildNodes:function(b){var d=this.childNodes;for(var c=0,a=d.length;c<a;c++){d[c].collapse(b)}},disable:function(){this.disabled=true;this.unselect();if(this.rendered&&this.ui.onDisableChange){this.ui.onDisableChange(this,true)}this.fireEvent("disabledchange",this,true)},enable:function(){this.disabled=false;if(this.rendered&&this.ui.onDisableChange){this.ui.onDisableChange(this,false)}this.fireEvent("disabledchange",this,false)},sort:function(e,d){Ext.ux.TreeNode.superclass.sort.apply(this,arguments);if(this.childrenRendered){var c=this.childNodes;for(var b=0,a=c.length;b<a;b++){c[b].render(true)}}},getTarget:function(){if(!this.targetNode){if(this.parentNode){this.targetNode=this.parentNode.ui.getContainer()}else{this.targetNode=this.ownerTree.innerCt.dom}}var a=Ext.get(this.targetNode);return this.targetNode},markAsRead:function(){var a=this.attributes.mark;this.attributes.mark="";if(a=="new"){var c=-1}else{var b=-1}this.ui.updateMarks();this.changeParentMarks(c,b)},changeParentMarks:function(b,a){if(b||a){this.bubble(function(){var c=this.attributes;if(b){c.num_descend_new+=b}if(a){c.num_descend_updated+=a}this.ui.updateMarks()})}},updateMarks:function(d){var b=this.attributes;var f={};if(d.num_descend_new!=b.num_descend_new){var e=d.num_descend_new-b.num_descend_new}else{if(d.num_descend_updated!=b.num_descend_updated){var c=d.num_descend_updated-b.num_descend_updated}}if(e||c){this.changeParentMarks(e,c)}},render:function(a,b){if(b){this.targetNode=b}else{this.getTarget()}this.ui.render(a);if(!this.rendered){this.getOwnerTree().registerNode(this);this.rendered=true;if(this.expanded){this.expanded=false;this.expand(false,false)}}},renderChildren:function(b){this.childrenRendered=true;if(b!==false){this.fireEvent("beforechildrenrendered",this)}if(this.ui.ctNode){this.groupChildren();if(this.childGroups&&this.childGroups.length>0){var f=this.buildGroupConfig(this.ui.ctNode,this.childGroups);f.render(this.ui.ctNode);var e=this;f.cascade(function(){var j=this.body.dom;if(this.queue){for(var h=0,g=this.queue.length;h<g;h++){this.queue[h].render(true,j)}delete this.queue}})}else{if(this.childNodes&&this.childNodes.length>0){var d=this.childNodes;for(var c=0,a=d.length;c<a;c++){d[c].render(true)}}else{}}}},sortNodes:function(b,e,d){var a=b.length;if(a>0){var f=d?function(){return e.apply(d,arguments)}:e;b.sort(f);for(var c=0;c<a;c++){var g=b[c];g.previousSibling=b[c-1];g.nextSibling=b[c+1];if(c==0){this.setFirstChild(g)}if(c==a-1){this.setLastChild(g)}}}},sortItems:function(b,d,c){var a=b.length;if(a>1){var e=c?function(){return d.apply(c,arguments)}:d;b.sort(e)}},buildGroupConfig:function(b,k,o,d){if(!d){d=new Ext.ux.TreeGroup(Ext.apply({title:"",collapsible:false,frame:false,border:false},this.getOwnerTree().grouping));o=d}if(k.length>1){this.sortTree(k,o)}for(var e=0,j=k.length;e<j;e++){var p=k[e];if(p.title){if(p.addCount&&p.child_items){var h=" ("+p.child_items.length+")"}else{var h=""}if(p.optional&&j==1){var g=Ext.apply({collapsible:false,frame:false,border:false},p);g.collapsed=false;g.title="";var m=new Ext.ux.TreeGroup(g)}else{var m=new Ext.ux.TreeGroup(Ext.apply(p,{title:p.title+h,collapsible:true,iconCls:p.iconCls,frame:false,border:false,titleCollapse:true,bodyStyle:"padding-left: 20px",cls:"x-group-padded"}))}o.add(m);if(p.child_items){this.buildGroupConfig(null,p.child_items,m,d)}}else{var f=p;if(this.childNodes[f]){var c=this.childNodes[f],l=c.attributes;if(o.add){if(!o.queue){o.queue=[]}if(o.nodeConfig){o.nodeConfig(c)}o.queue.push(c)}else{c.targetNode=b;c.render(true)}}else{pm.log("Child node not found!")}}}return d},beginUpdate:function(){this.childrenRendered=false},endUpdate:function(){if(this.expanded){this.renderChildren()}},loadData:function(){},refresh:function(){this.reload()},removeChildren:function(){for(var b=0,a=this.childNodes.length;b<a;b++){var c=this.childNodes[b];this.removeChild(c);c.destroy()}this.childNodes=[];delete this.childGroups;delete this.firstChild;delete this.lastChild},removeChild:function(a){this.ownerTree.getSelectionModel().unselect(a);Ext.ux.TreeNode.superclass.removeChild.apply(this,arguments);if(this.childrenRendered){a.ui.remove()}this.getOwnerTree().unregisterNode(a);return a},destroy:function(){for(var b=0,a=this.childNodes.length;b<a;b++){this.childNodes[b].destroy()}this.childNodes=null;if(this.ui.destroy){this.ui.destroy()}this.getOwnerTree().unregisterNode(this)},groupChildren:function(){this.childGroups=this.groupTree(this.getOwnerTree().grouping)},groupTree:function(q,d){var c=this.childNodes;if(!c){return[]}var l=[];var p=[];q=(q)?q:{};d=(d)?d:[];if(q.groupConfig){var h=(d.length>0)?d:c;for(var g=0;g<h.length;g++){var k=(d.length>0)?h[g]:g;var e=c[k];var m=e.attributes;if(q.groupConfig){var b=q.groupConfig(m);var o=b.key;if(typeof p[o]=="number"){var f=p[o]}else{if(!b.title){b.title="Other"}b.child_items=[];l.push(b);var f=p[o]=l.length-1}l[f].child_items.push(k)}}for(var g=0;g<l.length;g++){if(l[g].groupConfig){l[g].child_items=this.groupTree(l[g],l[g].child_items)}}}return(l)?l:(d)?d:[]},sortTree:function(a,b){this.sortItems(a,function(g,e){var l=(typeof g=="object")?true:false;var k=(typeof e=="object")?true:false;if(l&&!k){return -1}else{if(!l&&k){return 1}else{if(l&&k){if(b.groupOrder){var d=b.groupOrder;var h=g;var f=e;if(d.sticky){var c=pm.util.which_first(d.sticky,g.key,e.key);if(c==0){var c=pm.util.which_first(d.sticky,g.title,e.title)}if(c==1){return -1}else{if(c==2){return 1}}}}}else{if(b.nodeOrder){var d=b.nodeOrder;var h=this.childNodes[g].attributes;var f=this.childNodes[e].attributes}}}}if(d&&h&&f){if(d.field){var j=h[d.field],i=f[d.field];if(d.method=="numeric"){if(d.order=="desc"){return i-j}else{return j-i}}else{if(j==i){return 0}if(d.order=="desc"){return(j<i)?1:-1}else{return(j<i)?-1:1}}}}return -1},this)}});Ext.ux.TreeNodeUI=function(a){this.node=a;this.rendered=false;this.animating=false;this.wasLeaf=true;this.ecc="pm-tree-ec-icon pm-tree";this.emptyIcon=Ext.BLANK_IMAGE_URL};Ext.ux.TreeNodeUI.prototype={beforeLoad:function(){this.addClass("pm-tree-node-loading")},afterLoad:function(){this.removeClass("pm-tree-node-loading")},onChangeTitle:function(a){if(this.rendered&&this.textNode){this.textNode.nodeValue=a}},onChangeTeaser:function(e){if(this.rendered){if(!this.teaserEl){this.teaserEl=Ext.get(this.ctNode).createChild({cls:"pm-tree-node-details"});this.teaserEl.enableDisplayMode()}var c=this.node.getOwnerTree();var a=c.getLinks(this.node);var b=new Ext.XTemplate('<tpl for="links">','<tpl if="xindex &gt; 1">'," | ","</tpl>",'<span class="a action">{title}</span>',"</tpl>");var d=b.applyTemplate({links:a});e='<span class="actions" style="float: right">'+d+"</span>"+e;this.teaserEl.update(e)}},setEditMode:function(a){if(this.editMode){this.endEditMode()}this.editMode=true;switch(a.mode){case"edit":this.teaserEl.hide();this.formEl=this.ctEl.insertFirst({cls:"pm-tree-form-ct"});break;case"reply":this.formEl=this.ctEl.createChild({cls:"pm-tree-form-ct"},this.ctEl.dom.childNodes[1]);break;default:pm.log("Unrecognized edit mode")}},endEditMode:function(){if(this.teaserEl){this.teaserEl.show()}this.formEl.hide();this.formEl.remove();delete this.formEl;this.editMode=false},onDisableChange:function(a,b){this.disabled=b;if(b){this.addClass("pm-tree-node-disabled")}else{this.removeClass("pm-tree-node-disabled")}},onSelectedChange:function(a){if(a){this.focus()}else{this.blur()}},addClass:function(a){if(this.elNode){Ext.fly(this.elNode).addClass(a)}},removeClass:function(a){if(this.elNode){Ext.fly(this.elNode).removeClass(a)}},remove:function(){if(this.rendered){this.destroy()}},clear:function(){if(this.teaserEl){this.teaserEl.remove();delete this.teaserEl}if(this.ctEl){this.ctEl.update()}},fireEvent:function(){return this.node.fireEvent.apply(this.node,arguments)},initEvents:function(){if(this.node.disabled){this.addClass("pm-tree-node-disabled")}if(this.node.hidden){this.hide()}},hide:function(){this.node.hidden=true;if(this.wrap){this.wrap.style.display="none"}},show:function(){this.node.hidden=false;if(this.wrap){this.wrap.style.display=""}},onClick:function(d){if(this.fireEvent("beforeclick",this.node,d)!==false){d.preventDefault();if(this.disabled){return}var a=d.getTarget("span.b",3,true);if(a){var c=this.linkHash[a.id];if(c.handler){c.handler.call(c.scope||this,this.node,d);this.fireEvent("click",this.node,d);return}}var b=this.node.getOwnerTree();if(b.onClickNode){if(b.onClickNode(this.node,d)){this.fireEvent("click",this.node,d);return}}if(!this.node.attributes.leaf){this.node.toggle();this.node.markAsRead()}this.fireEvent("click",this.node,d)}else{d.stopEvent()}},onDetailsClick:function(d){var c=this.node.getOwnerTree();var b=d.getTarget("span.a",1,true);if(b){if(b.is(".action")){c.onClickLink(this.node,b.dom);this.fireEvent("click",this.node,d);return}else{pm.state.navigate(pm.state.parseLink(b.dom.id))}}else{if(c.onClickText){c.onClickText(this.node)}}},onOver:function(a){this.addClass("pm-tree-node-over")},onOut:function(a){this.removeClass("pm-tree-node-over")},ecClick:function(a){if(!this.animating&&(this.node.hasChildNodes()||!this.node.attributes.leaf)){this.node.toggle()}},expand:function(){this.updateExpandIcon();this.ctNode.style.display=""},updateMarks:function(d){if(this.rendered){var e=this.node,b=e.attributes;var c=[];if(b.mark=="new"){c.push("new")}if(b.mark=="updated"){c.push("updated")}if(b.num_descend_new>0){c.push(b.num_descend_new+" new")}if(b.num_descend_updated>0){c.push(b.num_descend_updated+" updated")}Ext.select(".mark",false,this.anchor).remove();if(c.length>0){if(d){if(!(e.parentNode&&e.parentNode.parentNode)){e.expand()}}if(!pm.tpl.treeNodeMarks){pm.tpl.treeNodeMarks=new Ext.XTemplate('<tpl for="marks">','<span class="mark">{.}</span>',"</tpl>");pm.tpl.treeNodeMarks.compile()}pm.tpl.treeNodeMarks.append(this.anchor,{marks:c})}}},focus:function(){if(!this.node.preventHScroll){try{this.anchor.focus()}catch(c){}}else{if(!Ext.isIE){try{var b=this.node.getOwnerTree().getTreeEl().dom;var a=b.scrollLeft;this.anchor.focus();b.scrollLeft=a}catch(c){}}}},blur:function(){try{this.anchor.blur()}catch(a){}},animExpand:function(b){var a=Ext.get(this.ctNode);a.stopFx();if(!this.node.hasChildNodes()){this.updateExpandIcon();this.ctNode.style.display="";Ext.callback(b);return}this.animating=true;this.updateExpandIcon();a.slideIn("t",{callback:function(){this.animating=false;Ext.callback(b)},scope:this,duration:this.node.ownerTree.duration||0.25})},highlight:function(){var a=this.node.getOwnerTree();Ext.fly(this.wrap).highlight(a.hlColor||"C3DAF9",{endColor:a.hlBaseColor})},collapse:function(){this.updateExpandIcon();this.ctNode.style.display="none"},animCollapse:function(a){ctEl.enableDisplayMode("block");ctEl.stopFx();this.animating=true;this.updateExpandIcon();ctEl.slideOut("t",{callback:function(){this.animating=false;Ext.callback(a)},scope:this,duration:this.node.ownerTree.duration||0.25})},getContainer:function(){return this.ctNode},getEl:function(){return this.wrap},onRender:function(){this.render()},render:function(c){var d=this.node,b=d.attributes;if(!this.rendered){this.rendered=true;this.renderElements(d,b,d.targetNode,c);if(b.qtip){if(this.textNode.setAttributeNS){this.textNode.setAttributeNS("ext","qtip",b.qtip);if(b.qtipTitle){this.textNode.setAttributeNS("ext","qtitle",b.qtipTitle)}}else{this.textNode.setAttribute("ext:qtip",b.qtip);if(b.qtipTitle){this.textNode.setAttribute("ext:qtitle",b.qtipTitle)}}}else{if(b.qtipCfg){b.qtipCfg.target=Ext.id(this.textNode);Ext.QuickTips.register(b.qtipCfg)}}this.initEvents();if(!this.node.expanded){this.updateExpandIcon(true)}}},renderElements:function(c,l,j,o){if(!pm.tpl.treeNode){pm.tpl.treeNode=new Ext.XTemplate('<div class="pm-tree-node">','<div class="pm-tree-node-el" ext:tree-node-id="{id}">','<span style="position: absolute;">','<tpl if="expandable">','<img src="',this.emptyIcon,'" class="pm-tree-ec-icon" />',"</tpl>",'<tpl if="icon">','<img src="{icon}" class="pm-tree-node-icon" />',"</tpl>","</span>",'<div class="pm-tree-node-header">','<span class="links">{links}</span>','<div class="title" ext:qtip="{tip}">{title}</div>',"</div>","</div>",'<div class="pm-tree-node-ct" style="display: none"></div>',"</div>");pm.tpl.treeNode.compile()}var d=this.node.getOwnerTree();var p=[];if(d.nodeLinks){if(typeof d.nodeLinks=="function"){p=d.nodeLinks.call(d.scope||this,this.node)}else{p=d.nodeLinks}}if(d.showReadMore!==false){p.push({text:'<span class="a">read more</span>',tip:"Expand this item to read more"})}var e="";this.linkHash=[];for(var f=0,h=p.length;f<h;f++){var k=p[f];k.id=pm.app.id();this.linkHash[k.id]=k;e+='<span title="'+k.tip+'" class="b" id="'+k.id+'">'+k.text+"</span>"}var m={id:c.id,title:pm.util.breakPlainText(l.title,d.maxTitleLen||25,true),tip:l.title,icon:l.icon,links:e,expandable:(l.leaf)?false:true};var b;if(o!==true&&c.nextSibling&&(b=c.nextSibling.ui.getEl())){this.wrap=pm.tpl.treeNode.insertBefore(b,m)}else{this.wrap=pm.tpl.treeNode.append(j,m)}this.elNode=this.wrap.childNodes[0];this.ctNode=this.wrap.childNodes[1];this.elEl=this.wrap.childNodes[0];this.ctEl=Ext.get(this.ctNode);var g=this.elNode.childNodes;this.ecNode=Ext.fly(g[0]).child(".pm-tree-ec-icon",true);this.iconNode=Ext.fly(g[0]).child(".pm-tree-node-icon",true);this.anchor=g[1].childNodes[1];this.textNode=this.anchor.firstChild;this.updateMarks(true)},getAnchor:function(){return this.anchor},getTextEl:function(){return this.textNode},getIconEl:function(){return this.iconNode},updateExpandIcon:function(){if(this.rendered&&this.ecNode){var f=this.node,d,c;var a="pm-tree";var e=f.hasChildNodes();if(f.expanded){a+="-minus";d="pm-tree-node-collapsed";c="pm-tree-node-expanded"}else{a+="-plus";d="pm-tree-node-expanded";c="pm-tree-node-collapsed"}if(this.wasLeaf){this.removeClass("pm-tree-node-leaf");this.wasLeaf=false}if(this.c1!=d||this.c2!=c){Ext.fly(this.elNode).replaceClass(d,c);this.c1=d;this.c2=c}var b="pm-tree-ec-icon "+a;if(this.ecc!=b){this.ecNode.className=b;this.ecc=b}}},getChildIndent:function(){if(!this.childIndent){var a=[];var b=this.node;while(b){if(!b.isRoot){if(!b.isLast()){a.unshift('<img src="'+this.emptyIcon+'" class="pm-tree-line" />')}else{a.unshift('<img src="'+this.emptyIcon+'" class="pm-tree-icon" />')}}b=b.parentNode}this.childIndent=a.join("")}return this.childIndent},destroy:function(){delete this.elNode;delete this.ctNode;delete this.ecNode;delete this.iconNode;delete this.anchor;delete this.textNode;if(this.teaserEl){this.teaserEl.remove();delete this.teaserEl}Ext.removeNode(this.wrap);this.node=null}};Ext.ux.RootTreeNodeUI=Ext.extend(Ext.ux.TreeNodeUI,{render:function(){if(!this.rendered){this.rendered=true;var a=this.node.ownerTree.innerCt.dom;this.node.expanded=true;a.innerHTML='<div class="pm-tree-root-node"></div>';this.wrap=this.ctNode=a.firstChild;this.ctEl=Ext.get(this.ctNode)}},collapse:Ext.emptyFn,expand:Ext.emptyFn});Ext.ux.AsyncTreeNode=function(a){this.loaded=false;this.loading=false;Ext.ux.AsyncTreeNode.superclass.constructor.apply(this,arguments);this.addEvents("beforeload","load")};Ext.extend(Ext.ux.AsyncTreeNode,Ext.ux.TreeNode,{expand:function(b,d,g){if(this.loading){var e;var c=function(){if(!this.loading){clearInterval(e);this.expand(b,d,g)}}.createDelegate(this);e=setInterval(c,200);return}if(!this.loaded){if(this.fireEvent("beforeload",this)===false){return}this.loading=true;this.ui.beforeLoad(this);var a=this.loader||this.attributes.loader||this.getOwnerTree().getLoader();if(a){a.load(this,this.loadComplete.createDelegate(this,[b,d,g]));return}}Ext.ux.AsyncTreeNode.superclass.expand.call(this,b,d,g)},isLoading:function(){return this.loading},loadComplete:function(a,b,c){this.loading=false;this.loaded=true;this.ui.afterLoad(this);this.fireEvent("load",this);this.expand(a,b,c)},isLoaded:function(){return this.loaded},hasChildNodes:function(){if(!this.isLeaf()&&!this.loaded){return true}else{return Ext.ux.AsyncTreeNode.superclass.hasChildNodes.call(this)}},reload:function(b){var a=this.expanded;this.collapse(false,false);while(this.firstChild){this.removeChild(this.firstChild)}delete this.attributes.children;this.childrenRendered=false;this.ui.clear();this.loaded=false;if(a){this.expand(false,false,b)}}});Ext.ux.TreeLoader=function(a){Ext.apply(this,a);this.addEvents("beforeload","load","loadexception");Ext.ux.TreeLoader.superclass.constructor.call(this)};Ext.extend(Ext.ux.TreeLoader,Ext.util.Observable,{clearOnLoad:true,doPreload:function(d,e){this.onNodeLoad(d,e);if(this.ot.filters){if(d.isRoot||!this.ot.filterRootOnly){this.filterChildren(d)}}if(d.attributes.children){if(d.childNodes.length<1){var c=d.attributes.children;d.beginUpdate();for(var b=0,a=c.length;b<a;b++){var g=this.createNode(c[b]);var f=d.appendChild(g);if(this.preloadChildren){this.doPreload(f)}}d.endUpdate()}return true}else{return false}},filterChildren:function(c){var h=[],e=this.ot;var b=c.attributes.children;if(!e.filters){return}if(!b){return}for(var f=0,j=b.length;f<j;f++){var g=true;var a=b[f];for(var d in e.filters){var k=e.filters[d];switch(typeof k){case"object":if(pm.util.inArray(a[d],k)==-1){g=false}break;case"number":case"string":if(k!=a[d]){g=false}break}}if(g){h.push(a)}}c.attributes.children=h},createNode:function(a){if(this.baseAttrs){Ext.applyif(a,this.baseAttrs)}if(this.applyLoader!==false){a.loader=this}if(this.idField){a.id=a[this.idField]}if(this.titleField){a.title=a[this.titleField]}if(this.onNodeInit){this.onNodeInit(a)}return(a.leaf?new Ext.ux.TreeNode(a):new Ext.ux.AsyncTreeNode(a))}});Ext.ux.TreeLoaderHTTP=function(a){this.baseParams={};this.requestMethod="GET";Ext.ux.TreeLoaderHTTP.superclass.constructor.call(this,a)};Ext.extend(Ext.ux.TreeLoaderHTTP,Ext.ux.TreeLoader,{load:function(a,b){if(this.clearOnLoad){while(a.firstChild){a.removeChild(a.firstChild)}}if(this.doPreload(a)){if(typeof b=="function"){b()}}else{if(this.dataUrl||this.url){this.requestData(a,b)}}},getParams:function(d){var a=[],c=this.baseParams,e=this.nodeParams(d);for(var b in c){if(typeof c[b]!="function"){a.push(encodeURIComponent(b),"=",encodeURIComponent(c[b]),"&")}}for(var b in e){if(typeof e[b]!="function"){a.push(encodeURIComponent(b),"=",encodeURIComponent(e[b]),"&")}}return a.join("")},requestData:function(a,b){if(this.fireEvent("beforeload",this,a,b)!==false){this.transId=Ext.Ajax.request({method:this.requestMethod,url:this.dataUrl||this.url,success:this.handleResponse,failure:this.handleFailure,scope:this,argument:{callback:b,node:a},params:this.getParams(a)})}else{if(typeof b=="function"){b()}}},isLoading:function(){return this.transId?true:false},abort:function(){if(this.isLoading()){Ext.Ajax.abort(this.transId)}},processResponse:function(response,node,callback){var json=response.responseText;var o=eval("("+json+")");node.attributes.children=o.records;this.doPreload(node,o);if(typeof callback=="function"){callback(this,node)}},handleResponse:function(c){this.transId=false;var b=c.argument;this.processResponse(c,b.node,b.callback);this.fireEvent("load",this,b.node,c)},handleFailure:function(c){this.transId=false;var b=c.argument;this.fireEvent("loadexception",this,b.node,c);if(typeof b.callback=="function"){b.callback(this,b.node)}}});Ext.ux.TreeEventModel=function(a){this.tree=a;this.tree.on("render",this.initEvents,this)};Ext.ux.TreeEventModel.prototype={initEvents:function(){var a=this.tree.getTreeEl();a.on("click",this.delegateClick,this);a.on("mouseover",this.delegateOver,this);a.on("mouseout",this.delegateOut,this)},getNode:function(b){var a;if(a=b.getTarget(".pm-tree-node-el",10)){var c=Ext.fly(a,"_treeEvents").getAttributeNS("ext","tree-node-id");if(c){return this.tree.getNodeById(c)}}return null},getNodeFromEl:function(a){if(a.is(".pm-tree-node-el")){var b=Ext.fly(a,"_treeEvents").getAttributeNS("ext","tree-node-id");if(b){return this.tree.getNodeById(b)}}return null},getNodeTarget:function(b){var a=b.getTarget(".pm-tree-node-icon",1);if(!a){a=b.getTarget(".pm-tree-node-el",6)}return a},delegateOut:function(b,a){if(!this.beforeEvent(b)){return}a=this.getNodeTarget(b);if(a&&!b.within(a,true)){this.onNodeOut(b,this.getNode(b))}},delegateOver:function(b,a){if(!this.beforeEvent(b)){return}a=this.getNodeTarget(b);if(a){this.onNodeOver(b,this.getNode(b))}},delegateClick:function(d,b){if(!this.beforeEvent(d)){return}var c;if(d.getTarget("input[type=checkbox]",1)){this.onCheckboxClick(d,this.getNode(d))}else{if(d.getTarget(".pm-tree-ec-icon",1)){this.onIconClick(d,this.getNode(d))}else{if(this.getNodeTarget(d)){this.onNodeClick(d,this.getNode(d))}else{if(c=d.getTarget(".pm-tree-node-details",3,true)){var a=c.parent().prev();this.onDetailsClick(d,this.getNodeFromEl(a))}}}}},onDetailsClick:function(b,a){a.ui.onDetailsClick(b)},onNodeClick:function(b,a){a.ui.onClick(b)},onNodeOver:function(b,a){a.ui.onOver(b)},onNodeOut:function(b,a){a.ui.onOut(b)},onIconClick:function(b,a){a.ui.ecClick(b)},beforeEvent:function(a){if(this.disabled){a.stopEvent();return false}return true},disable:function(){this.disabled=true},enable:function(){this.disabled=false}};Ext.namespace("pm");Ext.namespace("Ext.ux");pm.app=function(){var a=0;return{enableUserWidgets:false,disableSingleFileUploads:true,disableMultiFileUploader:false,tabForms:false,predictiveLoading:false,useHistoryMgr:true,submitUsingGET:false,consoleLogging:true,isDebugging:false,state:{},currentUser:{},pageDefs:{},nodeDefs:{},widgetDefs:{},pages:[],nodes:[],widgets:[],modules:["nodes","dashboard","contacts","projects","tasks","events","documents","inventory","emails","widgets","finances","search"],systemPath:window.location.protocol+"//"+window.location.host+window.location.pathname.replace(/[A-Za-z0-9]*.html/,""),loadingIndicator:'<div class="loading-indicator">Loading...</div>',icons:{add:"famfamfam/add.png",edit:"famfamfam/pencil.png",del:"famfamfam/delete.png",subscribe:"famfamfam/transmit_add.png",unsubscribe:"famfamfam/transmit_delete.png",comment:"famfamfam/comment.png",commentAdd:"famfamfam/comment_add.png",commentEdit:"famfamfam/comment_edit.png",commentDel:"famfamfam/comment_delete.png",completed:"famfamfam/tick.png",progress:"famfamfam/cog.png",delegation:"famfamfam/folder_go.png",fileUnknown:"famfamfam/page_white.png",fileText:"famfamfam/page_white_text.png",fileWord:"famfamfam/page_white_word.png",filePDF:"famfamfam/page_white_acrobat.png",fileImage:"famfamfam/page_white_camera.png",fileExcel:"famfamfam/page_white_excel.png",filePPT:"famfamfam/page_white_office.png",fileAudio:"famfamfam/sound.png",fileVideo:"famfamfam/film.png",fileAttach:"famfamfam/page_white_link.png",bulletDel:"famfamfam/bullet_delete.png",trash:"famfamfam/bin_closed.png",promoteImage:"famfamfam/picture_go.png",arrowUp:"up.gif",arrowDown:"down.gif",arrowLeft:"left.gif",arrowRight:"right.gif",finances:"famfamfam/calculator.png",financesAdd:"famfamfam/calculator_add.png",financesEdit:"famfamfam/calculator_edit.png",financesDel:"famfamfam/calculator_delete.png",time:"famfamfam/clock.png",timeAdd:"famfamfam/clock_add.png",timeEdit:"famfamfam/clock_edit.png",timeDel:"famfamfam/clock_delete.png",save:"famfamfam/disk.png",saveMultiple:"famfamfam/disk_multiple.png",cancel:"famfamfam/cancel.png",check:"famfamfam/tick.png",error:"famfamfam/error.png",info:"famfamfam/information.png",exclamation:"famfamfam/exclamation.png",close:"close.gif",bigError:"icon-error.gif",bigInfo:"icon-info.gif",bigQuestion:"icon-question.gif",bigWarning:"icon-warning.gif"},init:function(){this.iconPath=this.systemPath+"images/icons/";pm.icons=this.icons;pm.tpl={};Ext.BLANK_IMAGE_URL="libraries/ext-2.0/resources/images/default/s.gif";Ext.QuickTips.init();Ext.apply(Ext.QuickTips.getQuickTip(),{showDelay:50,trackMouse:true});Ext.Ajax.on({beforerequest:{fn:pm.util.showLoader},requestcomplete:{fn:pm.util.hideLoader},requestexception:{fn:pm.util.hideLoader}});if(window.vortex){vortex.offline.init("Productive Pro",{},[this.systemPath+"index.html"])}this.events=new pm.SystemEventsMgr();this.events.on("historyEnabled",function(){this.historyReady=true;this.init3()},this);this.events.on("nodeEvent",function(d){if(d.action=="load"){this.nodes[d.node.data.nid]=d.node}},this);this.numModulesEnabled=0;for(var c=0;c<this.modules.length;c++){var b=this.modules[c];if(b&&pm[b]){pm[b].init({scope:this,callback:function(){this.numModulesEnabled++;if(this.numModulesEnabled==this.modules.length){this.init2()}}})}}},init2:function(){pm.services.get({method:"users.getCurrentUser",scope:this,success:function(b){this.currentUser=new pm.NodeObj({data:b.node,isCurrentUser:true});this.init3()},failure:function(b){this.initLogin()}});this.loginPage=Ext.get("login");this.systemPage=Ext.get("page");this.loginPage.enableDisplayMode();this.systemPage.enableDisplayMode()},init3:function(){if(this.currentUser.nid&&this.historyReady&&!this.systemReady){this.systemReady=true;this.loginPage.hide();this.systemPage.show();this.state=new pm.StateMgr();pm.state=this.state;this.contentArea=new pm.ContentArea({stateMgr:this.state,renderTo:"content"});pm.state.on({navigate:{scope:this,fn:function(c,b){Ext.select("#navigation a").removeClass("active");var d=c.path[0];var e=Ext.get(d+"-btn");if(e){e.select("a",true).elements[0].addClass("active")}}}});this.searchBox=new pm.SearchBar({stateMgr:this.state,renderTo:"breadcrumbs"});this.init4.defer(10,pm.app)}},init4:function(){this.numModulesEnabled=0;for(var c=0;c<this.modules.length;c++){var b=this.modules[c];if(b&&pm[b]&&pm[b].load){pm[b].load({scope:this,callback:function(){this.numModulesEnabled++;if(this.numModulesEnabled==this.modules.length){this.init5()}}})}else{this.numModulesEnabled++;if(this.numModulesEnabled==this.modules.length){this.init5()}}}},init5:function(){pm.state.onNavigate(YAHOO.util.History.getCurrentState("app"));var c=new pm.WidgetMgr({panelID:"pm",regionID:"left",uid:pm.app.currentUser.data.account.uid,renderTo:"sidebar-widgets"});var b=Ext.get("system-links");b.dom.innerHTML='<a href="#" id="my-profile-link">My Profile</a> | <a href="#" id="emails-link">Emails</a> | <a href="#" id="logout-link">Logout</a> | <a href="services/admin" target="_blank">Administer</a>';Ext.get("my-profile-link").on("click",function(){pm.state.navigate({path:["contacts","individuals","view"],nid:pm.app.currentUser.data.nid})},this,{preventDefault:true});Ext.get("emails-link").on("click",function(){pm.state.navigate({path:["emails","list"]})},this,{preventDefault:true});Ext.get("logout-link").on("click",function(){pm.services.get({method:"users.logout",scope:this,success:function(d){window.location.reload()},failure:function(d){Ext.MessageBox.alert("Error","Unable to logout: "+d.message)}},this)},this,{preventDefault:true})},initLogin:function(){this.loginPage.show();if(!this.loginInit){this.loginInit=true;Ext.get("user-login-form").on("submit",function(){var c=Ext.get("edit-name").getValue();var b=Ext.get("edit-pass").getValue();pm.services.post({method:"users.login",params:{username:c,password:b},scope:this,success:function(d){this.currentUser=new pm.NodeObj({data:d.node});this.init3()},failure:function(d){Ext.MessageBox.alert("Error","Unable to login: "+d.message)}})},this,{preventDefault:true})}},id:function(b){b=b||"pm-";var c=b+(++a);return c},initActionLinks:function(e,b,f){for(var d=0;d<b.length;d++){var g=b[d];if(g.id=="subscription"){g.activeMode=(g.subscription.subscribed)?1:0}else{}}var c=new pm.ActionLinks({items:b,fnScope:f,renderTo:e});return c}}}();Ext.form.LabelField=function(a){Ext.form.LabelField.superclass.constructor.call(this,a)};Ext.extend(Ext.form.LabelField,Ext.form.Field,{defaultAutoCreate:{tag:"span"},value:"",setValue:function(a){if(this.rendered){this.el.update(a)}}});pm.log=function(a){if(pm.app.consoleLogging&&window.console&&window.console.log){window.console.log(a)}};pm.console={debug:function(){if(pm.app.consoleLogging&&window.console){window.console.debug.apply(this,arguments)}},info:function(){if(pm.app.consoleLogging&&window.console){window.console.info.apply(this,arguments)}}};pm.util=function(){return{apply:function(d,e,b){if(b){Ext.apply(d,b)}if(d&&e&&typeof e=="object"){for(var a in e){if(d[a]){d[a]=pm.util.apply(d[a],e[a])}else{d[a]=e[a]}}}return d},formatTerms:function(d){if(d){var b=[];if(d.length){for(var c=0,a=d.length;c<a;c++){b.push(pm.state.navLink({text:d[c].name,state:{path:["category"],tid:d[c].tid}}))}}else{if(d.name){b.push(pm.state.navLink({text:d.name,state:{path:["category"],tid:d.tid}}))}}if(b){d=b.join(", ");return d}}return""},formatForDateField:function(a){if(a){return a.month+"/"+a.day+"/"+a.year}},formatForTimeField:function(a){if(a){if(a.hour&&a.min&&a.ampm){return(a.hour*1)+":"+a.min+" "+a.ampm}else{return"12:00 AM"}}},formatDate:function(e,b){if(!e){return}var a=(e.month*1)+"/"+(e.day*1)+"/"+e.year.substr(2);if(e.hour){var c=(e.hour*1)+":"+e.min+e.ampm.toLowerCase();return a+" at "+c}else{return a}},usMoney:function(a,e){a=(Math.round((a-0)*100))/100;if(e){a=Math.round(a)}else{a=(a==Math.floor(a))?a+".00":((a*10==Math.floor(a*10))?a+"0":a)}a=String(a);var f=a.split(".");var d=f[0];if(e){var b=""}else{var b=f[1]?"."+f[1]:".00"}var c=/(\d+)(\d{3})/;while(c.test(d)){d=d.replace(c,"$1,$2")}a=d+b;if(a.charAt(0)=="-"){return"-$"+a.substr(1)}return"$"+a},whatChanged:function(e,b){var d=[];if(e){for(var c in b){if(typeof b[c]!="function"){if(typeof b[c]=="object"){var a=pm.util.whatChanged(e[c],b[c]);if(a.length>0){d.push(c)}}else{if(e[c]!=b[c]){d.push(c)}}}}}return d},isChanged:function(d,c,b){if(b&&b.length){for(var a=0;a<b.length;a++){if(d[b[a]]!=c[b[a]]){return true}}}return false},callWhen:function(b){if(this.loading){var c;var a=function(){if(!this.loading){clearInterval(c);b.callback.apply(b.scope,b.args)}}.createDelegate(this);c=setInterval(a,200);return}if(!this.loaded){if(this.load){this.load({scope:this,callback:function(){b.callback.apply(b.scope,b.args)}})}else{Ext.MessageBox.alert("Error","Load function not defined!")}return}b.callback.apply(b.scope,b.args)},removeNonAlphaNum:function(a){if(typeof a=="string"){return a.replace(/[^A-Za-z0-9]/g,"")}},which_first:function(b,e,d){for(var c=0,a=b.length;c<a;c++){if(b[c]===e){return 1}else{if(b[c]==d){return 2}}}return 0},in_array:function(b,a){var c=b.length;if(c>0){do{if(b[c]===a){return true}}while(c--)}return false},flatten:function(d,c){var e={};if(!c||typeof c!="string"){var c=""}for(var a in d){var b=d[a];switch(typeof b){case"string":e[c+a]=b;break;case"object":Ext.apply(e,this.flatten(b,c+a+"_"));break}}return e},callIf:function(c,g){var h="";var e=false;for(var f=0,a=c.length;f<a;f++){if(h){h=h+"."+c[f]}else{h=c[f]}if(!e){if(b){b=b[c[f]]}else{var b=c[f]}if(!b){var e=true}}}if(b){if(g){var d=[];for(f=2,a=arguments.length;f<a;f++){d.push(arguments[f])}return b.apply(g,d)}else{pm.log("Scope not found for function "+h+" (substituting 'this' object)");return b.call(this,arguments)}}else{}},getIf:function(g,c){var f="";var d=false;for(var e=0,a=g.length;e<a;e++){if(f){f=f+"."+g[e]}else{f=g[e]}if(!d){if(b){b=b[g[e]]}else{var b=g[e]}if(!b){var d=true}}}if(b){return b}else{pm.log("Value not found: "+f);return c}},convertURLs:function(b){if(typeof b!="string"){return}var a=new RegExp("((http://|https://|ftp://|mailto:|smb://|afp://|file://|gopher://|news://|ssl://|sslv2://|sslv3://|tls://|tcp://|udp://)([a-zA-Z0-9@:%_+*~#?&=.,/;-]*[a-zA-Z0-9@:%_+*~#&=/;-]))([.,?!]*?)(?=(</p>|</li>|<brs*/?>|[ \n\r\t)]))","g");b=b.replace(a,'<a href="$1" target="_blank">$1</a>');return b},getJSDate:function(g,f){if(!g){if(f){return new Date()}else{return}}var h=g.month*1-1;var e=g.year*1;var b=g.day*1;var a=g.hour*1;var d=g.min*1;var c=g.ampm;if(c=="PM"){var a=a+12}return new Date(e,h,b,a,d)},dateFormatTimeAgo:function(b){var a=new Date();var c=(a.getTime()-b.getTime())/1000;if(c<60){return"just a moment ago"}else{if(c<3600){return Math.floor(c/60)+" minutes ago"}else{if(c<86400){return Math.floor(c/3600)+" hours ago"}else{return Ext.util.Format.date(b,"F n, Y \\a\\t g:ia")}}}},inArray:function(c,d){for(var e=0,f=d.length;e<f;e++){if(d[e]==c){return e}}return -1},clone:function(d,e){if(!e){e=1}if(e>4){return}if(d==null||typeof(d)!="object"){return d}if(d.constructor==Array){var a=[];for(var c=0;c<d.length;c++){if(typeof(d[c])=="object"){a.push(pm.util.clone(d[c],e+1))}else{a.push(d[c])}}return a}var a={};for(var b in d){a[b]=pm.util.clone(d[b],e+1)}return a},isEqual:function(d,c){if(Ext.type(d)!=Ext.type(c)){return false}switch(Ext.type(d)){case"string":case"number":case"boolean":if(d==c){return true}break;case"array":return pm.util.areArraysEqual(d,c);case"object":break}return false},areArraysEqual:function(d,c){var a=new Array();if((!d[0])||(!c[0])){return false}if(d.length!=c.length){return false}for(var b=0;b<d.length;b++){key=(typeof d[b])+"~"+d[b];if(a[key]){a[key]++}else{a[key]=1}}for(var b=0;b<c.length;b++){key=(typeof c[b])+"~"+c[b];if(a[key]){if(a[key]==0){return false}else{a[key]--}}else{return false}}return true},isChanged:function(d,c,b){if(b&&b.length){for(var a=0;a<b.length;a++){if(d[b[a]]!=c[b[a]]){return true}}}return false},breakPlainText:function(g,b,f){var c=b||40;if(g){var a=g.split(" ");for(var d=0,b=a.length;d<b;d++){var e=a[d];if(e.length>c){if(f){a[d]=Ext.util.Format.ellipsis(e,c)}else{a[d]=e.substr(0,c)+" "+pm.util.breakPlainText(e.substr(c),c)}}}g=a.join(" ")}return g},breakHTMLText:function(j,b){var c=b||40;if(j){var f=new RegExp("(<[/]?[a-zA-Z0-9]+[^>]*>)","g");var a=j.split(f);for(var e=0,b=a.length;e<b;e++){var h=a[e];if(h.charAt(0)!="<"&&h.length>0){a[e]=pm.util.breakPlainText(h,c,true);var g=1}}j=a.join("")}return j},processText:function(a){a=pm.util.convertURLs(a);a=pm.util.nl2br(a);a=pm.util.breakHTMLText(a);a=pm.util.limitBreaks(a);return a},limitBreaks:function(b){var a=new RegExp("(<br( /)?>){3,}","g");return b.replace(a,"<br /><br />")},nl2br:function(c){if(!c){return""}c=escape(c);var a="";if(c.indexOf("%0D%0A")>-1){a=/%0D%0A/g}else{if(c.indexOf("%0A")>-1){a=/%0A/g}else{if(c.indexOf("%0D")>-1){a=/%0D/g}}}if(a){var b=unescape(c.replace(a,"<br />"));return pm.util.nl2br(b)}else{return unescape(c)}},showLoader:function(){Ext.get("loader").show()},hideLoader:function(){Ext.get("loader").hide()},url:function(d,c,a){c=c?c:"";a=a?a:"";var b=pm.app.systemPath+"services/";if(!pm.settings.cleanurls){if(c){return b+"?q="+d+"&"+c+a}else{return b+"?q="+d+"&"+a}}else{if(c){return b+d+"?"+c+a}else{return b+d+a}}},formatFileSize:function(a){if(a>1000000000){return Math.round(a/1000000000)+" GB"}else{if(a>1000000){return Math.round(a/1000000)+" MB"}else{if(a>1000){return Math.round(a/1000)+" KB"}else{return a+" Bytes"}}}},setCheckbox:function(b,a){if(!b){return}if(b.dom){b=b.dom}var c=(a===true||a==="true"||a=="1"||String(a).toLowerCase()=="on");b.checked=c;b.defaultChecked=c},toggleCheckbox:function(a){if(!a){return}if(a.dom){a=a.dom}a.checked=!a.checked;a.defaultChecked=!a.defaultChecked}}}();pm.StateMgr=function(a){this.current={};this.current.params={};this.history=[];this.pagesAccessed=[];this.destroyOld=0;Ext.apply(this,a);this.addEvents({init:true,beforenavigate:true,navigate:true,beforechange:true,change:true,setTitle:true});pm.StateMgr.superclass.constructor.call(this)};Ext.extend(pm.StateMgr,Ext.util.Observable,{navUrl:function(b,a){var c={};if(a){Ext.apply(c,this.current.params)}else{if(!b.path){c.path=[];Ext.apply(c.path,this.current.params.path)}}Ext.apply(c,b);return this.yuiEncode(c)},navLink:function(b){var a=this.navUrl(b.state,b.append);a=a.replace(/\+/g,"_");if(!this.linkID){this.linkID=0}this.linkID++;if(!pm.tpl.link){pm.tpl.link=new Ext.Template('<span class="a" id="{id}" {attributes}>{text}</span>');pm.tpl.link.compile()}return pm.tpl.link.applyTemplate({id:a+"-"+this.linkID,attributes:(b.title)?'ext:qtip="'+b.tip+'"':"",text:Ext.util.Format.trim(b.text)})},parseLink:function(a){a=a.replace(/-[0-9]*$/,"");a=a.replace(/_/g,"+");return this.yuiDecode(a)},navigate:function(c,a,b,d){if(pm.app.useHistoryMgr){}if(b!==false){window.scrollTo(0,0)}if(this.fireEvent("beforenavigate",c)!==false){if(!pm.app.useHistoryMgr||d){this.onNavigate(this.navUrl(c,a))}else{YAHOO.util.History.navigate("app",this.navUrl(c,a))}}},navigate2:function(d){var c=d.state;var a=d.append;var b=d.scrollUp;var e=d.skipHistoryMgr;if(b!==false){window.scrollTo(0,0)}if(this.fireEvent("beforenavigate",c)!==false){if(e){this.onNavigate(this.navUrl(c,a))}else{YAHOO.util.History.navigate("app",this.navUrl(c,a))}}},onNavigate:function(c){var b={};b.params=this.yuiDecode(c);this.current=b;this.addHistory(this.current);var a=this.getDefinition(this.current);this.fireEvent("navigate",this.current.params,a)},navigateBack:function(l){var o=false;if(l){var k=this.history[this.currentHistoryID];var g=["path"];var b=this.getDefinition(k);if(b.required){g.push(b.required)}var c;for(var e=this.currentHistoryID-1;e>=0;e--){if(c=pm.state.history[e]){for(var d=0,f=g.length;d<f;d++){var n=g[d];var m=c.params[n];var a=k.params[n];if(!pm.util.isEqual(m,a)){o=true;break}}}if(o){var h=e;break}}}else{var h=this.currentHistoryID-1;if(h>=0){o=true}}if(o){this.navigateToHistory(h);return true}else{return false}},navigateNext:function(){this.navigateToHistory(this.currentHistoryID+1)},navigateToHistory:function(a){var b=this.history[a];if(b){this.navigate(Ext.apply(b.params,{historyID:a}))}},reload:function(){var a=this.loadPage({state:this.current,historyID:this.history.length-1})},preload:function(c){var b={};b.params=c;var a=this.loadPage({state:b})},getDefinition:function(d){var b=pm.app.pageDefs;for(var c=0;c<d.params.path.length;c++){var a=d.params.path[c];if(b&&b[a]){b=b[a]}else{b=null;pm.log("Definition Not Found!")}}return b},getRequired:function(c,d){var b={};if(c&&d){if(typeof d=="string"){d=[d]}for(var a=0;a<d.length;a++){if(c[d[a]]){b[d[a]]=c[d[a]]}}}return b},yuiEncode:function(b){if(typeof b.path=="object"){b.path=b.path.join(".")}var a=Ext.urlEncode(b);a=a.replace(/=/g,"-");return a.replace(/&/g,"+")},yuiDecode:function(b){var a=b.replace(/-(?!-)/g,"=");a=a.replace(/\+/g,"&");a=Ext.urlDecode(a);a.path=a.path.split(".");return a},addHistory:function(a){if(this.history[a.params.historyID]){this.history[a.params.historyID]=a;this.currentHistoryID=a.params.historyID;pm.log("Back to existing ID: "+this.currentHistoryID)}else{if(this.currentHistoryID<(this.history.length-1)){this.history[this.currentHistoryID+1]=a;this.currentHistoryID++;pm.log("Forward to new rewritten ID: "+this.currentHistoryID)}else{this.history.push(a);this.currentHistoryID=this.history.length-1;pm.log("Forward to new History ID: "+this.currentHistoryID)}}},setTitle:function(b,a){if(!b){b=""}if(b&&a&&(a!=this.currentHistoryID)){this.history[a].title=b}else{this.history[this.currentHistoryID].title=b;if(b){document.title=b+" - Productive Pro"}else{document.title="Productive Pro"}}this.fireEvent("setTitle",b)}});pm.ContentArea=Ext.extend(Ext.Container,{initComponent:function(){pm.ContentArea.superclass.initComponent.call(this);this.addEvents({init:true,beforenavigate:true,navigate:true,beforechange:true,change:true,setTitle:true});this.stateMgr.on({navigate:{scope:this,fn:this.onNavigate},preload:{scope:this,fn:this.preload}});this.setLayout(new Ext.layout.CardLayout({deferredRender:true}));this.add({id:"loading",border:false,html:'<div class="loading-indicator">Loading...</div>'});this.activePage=0},render:function(a){pm.ContentArea.superclass.render.call(this,a);if(this.activePage!==undefined){var b=this.activePage;delete this.activePage;this.setActivePage(b)}},onRender:function(b,a){pm.ContentArea.superclass.onRender.call(this,b,a);this.el=b.createChild({id:"content-area"},a)},onNavigate:function(f,b){this.state=f;var e=this.getPathID(f,b);pm.log("Navigate to Path ID: "+e);var c=this.findById(e);if(!c){if(!b.handler){b.handler=pm.ErrorPage;if(!b.params){b.params={}}b.params.error=404}var a=new b.handler(Ext.apply({id:e,state:f},b.params));a.on({setTitle:{scope:this,fn:function(h,g){if(g&&g.isActive){this.setTitle(h)}}}});a.load();var c=this.add(a)}if(c.title){this.setTitle(c.title)}else{this.setTitle()}var d=this.items.indexOf(c);this.setActivePage(d)},setActivePage:function(a){a=this.getComponent(a);if(!this.rendered){this.activePage=a;return}if(this.activePage!=a){if(this.activePage){if(this.activePage.deaktivieren){this.activePage.deaktivieren()}}this.activePage=a;this.layout.setActiveItem(a)}if(this.activePage.aktivieren){this.activePage.aktivieren(this.state)}},getPathID:function(d,b){var e=d.path;var a="";for(var c=0;c<e.length;c++){a+=e[c]}if(b.required){a+="-"+b.required+d[b.required]}return a},setTitle:function(a){this.fireEvent("setTitle",a,this);this.stateMgr.setTitle(a)}});pm.SystemEventsMgr=function(a){this.listeners={};this.addEvents({nodeEvent:true,userEvent:true,subscriptionEvent:true,relatedContentEvent:true});this.idSeed=0};Ext.extend(pm.SystemEventsMgr,Ext.util.Observable,{listen:function(a){if(a.id){this.listeners[a.id]=a;this.doAction(this.listeners[a.id],"on")}},stopListening:function(a){if(this.listeners[a]){this.doAction(this.listeners[a],"un");delete this.listeners[a]}},doAction:function(a,e){if(e!="un"){e="on"}for(var b=0;b<a.listeners.length;b++){var d=a.listeners[b];var c=(d.scope)?d.scope:this;pm.app.events[e](d.type,d.fn,c)}},id:function(){return"events-"+(++this.idSeed)}});pm.SystemProxy=function(a){pm.SystemProxy.superclass.constructor.call(this);Ext.apply(this,a)};Ext.extend(pm.SystemProxy,Ext.data.DataProxy,{load:function(e,b,f,d,a){var c=new Ext.data.HttpProxy({url:pm.services.url(this.method),method:(this.op)?this.op:"GET",timeout:this.timeout||30000});c.load(e,b,f,d,a)}});pm.Block=Ext.extend(Ext.Panel,{baseCls:"pm-block",titleCollapse:true,collapseFirst:false,elements:"body",initComponent:function(){pm.Block.superclass.initComponent.call(this);this.animCollapse=false},onRender:function(b,a){pm.Block.superclass.onRender.call(this,b,a)},reset:function(){}});Ext.reg("block",pm.Block);pm.Pager=Ext.extend(Ext.Component,{initComponent:function(){pm.Pager.superclass.initComponent.call(this);if(!this.state){this.state={}}if(!this.limit){this.limit=10}if(!this.page){this.page=1}this.addEvents({next:true,previous:true,change:true});this.ds.on("beforeload",function(){this.getCurrentState();this.ds.baseParams.limit=this.limit;this.ds.baseParams.page=this.page;this.ds.baseParams.start=(this.page-1)*this.limit},this);this.ds.on("load",function(){this.loaded=true;this.total=this.ds.getTotalCount();this.onUpdate()},this)},getCurrentState:function(){if(this.stateVars){this.page=this.state[this.stateVars.page]||1;this.limit=this.state[this.stateVars.limit]||10}},onRender:function(b,a){pm.Pager.superclass.onRender.call(this,b,a);var c=this.el=b.createChild({cls:"pager-ct"},a);this.el.on("click",function(g,f){var h=g.getTarget("span.a",2,true);if(h){if(isNaN(this.page)){this.page=1}if(h.is(".previous")){this.page--;this.fireEvent("change",this)}else{if(h.is(".first")){this.page=1;this.fireEvent("change",this)}else{if(h.is(".next")){this.page++;this.fireEvent("change",this)}else{if(h.is(".last")){this.page=this.numPages;this.fireEvent("change",this)}else{if(h.is(".all")){this.page=1;this.limit=0;this.fireEvent("change",this)}else{this.page=h.dom.innerHTML;this.fireEvent("change",this)}}}}}var d={};d[this.stateVars.page]=this.page;d[this.stateVars.limit]=this.limit;pm.state.navigate(d,true,false)}},this,{preventDefault:true});if(this.loaded){this.onUpdate()}},update:function(){},onUpdate:function(){if(!this.rendered){return}if(!this.page||isNaN(this.page)||this.page<1){this.page=1}if(this.limit==0){this.numPages=1}else{if(!(this.limit>0)){this.limit=10}this.numPages=Math.ceil(this.total/this.limit)}if(this.numPages<2){this.el.update("");return}this.hasNext=(this.page<this.numPages)?true:false;this.hasPrevious=(this.page>1)?true:false;if(this.showNums){var b=[];for(var a=1;a<=this.numPages;a++){b.push(a)}}if(!pm.tpl.pager){pm.tpl.pager=new Ext.XTemplate('<div class="pager">','<tpl if="hasPrevious == true">','<span class="a first">First</span> | <span class="a previous">Previous</span>',"</tpl>",'<tpl if="hasPrevious != true">','<span class="first">First</span> | <span class="previous">Previous</span>',"</tpl>",'<tpl for="pages">','<tpl if="xindex &gt; 1">'," | ","</tpl>",'<tpl if="parent.page == xindex">','<span class="current-page">{.}</span>',"</tpl>",'<tpl if="parent.page != xindex">','<span class="a page-num">{.}</span>',"</tpl>","</tpl>",'<tpl if="hasNext == true">',' | <span class="a next">Next</span> | <span class="a last">Last</span>',"</tpl>",'<tpl if="hasNext != true">',' | <span class="next">Next</span> | <span class="last">Last</span>',"</tpl>",'<tpl if="enableShowAll == 1">','<tpl if="parent.limit == 0">',' | <span class="all">View All</span>',"</tpl>",'<tpl if="parent.limit != 0">',' | <span class="a all">View All</span>',"</tpl>","</tpl>"," (Page {page} of {numPages})","</div>")}pm.tpl.pager.overwrite(this.el,{hasPrevious:this.hasPrevious,hasNext:this.hasNext,page:this.page,numPages:this.numPages,limit:this.limit,pages:(this.showNums)?b:[],enableShowAll:(this.enableShowAll===false)?0:1})}});pm.SearchBar=Ext.extend(Ext.Component,{initComponent:function(){pm.SearchBar.superclass.initComponent.call(this);this.stateMgr.on({navigate:{scope:this,fn:function(c,a){if(this.rendered){var b=pm.state.history[pm.state.currentHistoryID-1];if(b){this.backLinkEl.show()}else{this.backLinkEl.hide()}if(c.path[0]=="search"){this.searchBox.dom.value=pm.util.getIf([c,"keywords"])}}}}})},onRender:function(b,a){pm.SearchBar.superclass.onRender.call(this,b,a);this.el=b.createChild();if(!this.navTpl){this.navTpl=new Ext.XTemplate('<div class="nav-menu">','<table width="100%">',"<tr>",'<td class="links">','<span class="back ai" id="back"><img class="back-btn" src="{backIcon}" /> <span class="text">Back</span></span>',"</td>",'<td valign="middle" align="right" class="search">System Search: <input id="search-box" type="text" name="searchtext" value="" /><input id="search-button" name="searchbtn" value="Go" type="button" /></td>',"</tr>","</table>","</div>");this.navTpl.overwrite(this.el,{backIcon:pm.app.iconPath+pm.app.icons.arrowLeft,nextIcon:pm.app.iconPath+pm.app.icons.arrowRight});this.backLinkEl=this.el.child("span.back");this.backTextEl=this.backLinkEl.child("span.text");this.searchBox=Ext.get("search-box");this.searchBtn=Ext.get("search-button");this.searchBox.on(Ext.isIE?"keydown":"keypress",this.onKeyDownInSearchBox,this);this.el.on("click",function(f,c){var d=f.getTarget("span.ai");if(d){if(d.id=="back"){pm.state.navigateBack()}else{if(d.id=="next"){pm.state.navigateNext()}}}var d=f.getTarget();if(d){if(d.id=="search-button"){this.searchNow()}}},this)}},onKeyDownInSearchBox:function(b,a){if(b.keyCode==13){this.searchNow()}},searchNow:function(){pm.state.navigate2({state:{path:["search"],keywords:this.searchBox.getValue()}})}});pm.Subscription=function(a){Ext.apply(this,a);this.addEvents({subscribe:true,unsubscribe:true});pm.Subscription.superclass.constructor.call(this)};Ext.extend(pm.Subscription,Ext.util.Observable,{isSubscribed:function(){return this.subscribed},subscribe:function(){this.doAction("subscribe")},unsubscribe:function(){this.doAction("unsubscribe")}});pm.Subscription.prototype.doAction=function(a){if(!this.uid){this.uid=pm.app.currentUser.data.account.uid}pm.services.post({method:"subscriptions."+a,scope:this,params:{uid:this.uid,stype:this.stype,sid:this.sid},success:function(b){this.subscribed=(a=="subscribe")?true:false;this.fireEvent(a,this);pm.app.events.fireEvent("subscriptionEvent",{action:a,subscription:this})},failure:function(b){Ext.MessageBox.alert("Failed","Unable to perform action: "+b.message)}})};pm.ActionLinks=function(c){Ext.apply(this,c);if(!this.items){this.items=[]}var b=[];if(this.items){for(var d=0,a=this.items.length;d<a;d++){var e=this.getActive(this.items[d]);b.push([e.id,e.title,e.icon])}}this.ds=new Ext.data.SimpleStore({data:b,fields:["id","title","icon"],id:0});if(!pm.tpl.actionLinks){pm.tpl.actionLinks=new Ext.XTemplate('<tpl for=".">','<div class="link">','<span class="icon"><img src="{icon}" alt=""></span>','<span class="title">{title}</span>',"</div>","</tpl>");pm.tpl.actionLinks.compile()}this.view=new Ext.DataView({tpl:pm.tpl.actionLinks,singleSelect:false,store:this.ds,cls:"action-links",overClass:"over",itemSelector:"div.link",emptyText:"No buttons to display",loadingText:"Loading buttons..."});this.view.prepareData=function(f){f.icon=pm.app.iconPath+f.icon;return f};this.view.on("click",function(f,h,j,k){var g=this.items[h];if(g.callback){g.callback.call(this.fnScope||this,g,j)}var l=12},this,{preventDefault:true});pm.ActionLinks.superclass.constructor.call(this);if(this.renderTo){this.render(this.renderTo)}};Ext.extend(pm.ActionLinks,Ext.util.Observable,{setText:function(c,f,b){var a=Ext.fly(c);var e=1},getActive:function(b){if(b.id=="spacer"){}else{var c=(typeof b.title=="string")?b.title:b.title[b.activeMode];if(b.icon){var a=(typeof b.icon=="string")?b.icon:b.icon[b.activeMode]}else{var a=""}}return{id:b.id,title:c,icon:a}},render:function(a){this.view.render(a)},add:function(b){var a=new pm.ActionLinksItem(this,b);this.addItem(a);return a},addItem:function(a){this.items[a.id]=a;this.items.push(a)},getCount:function(){return this.items.length}});pm.ActionLinksItem=function(a,d){this.actionLinks=a;Ext.apply(this,d);if(this.id=="spacer"){var e=(typeof this.title=="string")?this.title:"";var b=a.createSpacer(a.el.dom,e)}else{var e=(typeof this.title=="string")?this.title:this.title[this.activeMode];if(this.icon){var c=(typeof this.icon=="string")?this.icon:this.icon[this.activeMode]}else{var c=""}var b=a.createActionLink(a.el.dom,e,c,this.indent)}this.el=Ext.get(b,true);this.titleEl=this.el.select(".title",true);this.iconEl=this.el.select(".icon img",true);pm.ActionLinksItem.superclass.constructor.call(this)};Ext.extend(pm.ActionLinksItem,Ext.util.Observable,{setMode:function(c){this.activeMode=c;var b=(typeof this.title=="string")?this.title:this.title[this.activeMode];var a=(typeof this.icon=="string")?this.icon:this.icon[this.activeMode];this.titleEl.update(b);this.iconEl.elements[0].dom.src=pm.app.iconPath+a}});pm.ActionLinks.prototype.createActionLink=function(b,e,d,a){if(!pm.tpl.actionLink){pm.tpl.actionLink=new Ext.XTemplate('<div class="link {[values.indent === true ? "link-indent" : ""]}">','<span class="icon"><img src="{icon}" alt=""></span>','<span class="title">{title}</span>',"</div>");pm.tpl.actionLink.compile()}var c=pm.tpl.actionLink.append(b,{title:e,icon:pm.app.iconPath+d,indent:a});return c};pm.ActionLinks.prototype.createSpacer=function(a,c){if(!pm.tpl.actionLinkSpacer){pm.tpl.actionLinkSpacer=new Ext.XTemplate('<div class="spacer">','<tpl if="values.title">','<div class="title">{title}</div>',"</tpl>","</div>");pm.tpl.actionLinkSpacer.compile()}var b=pm.tpl.actionLinkSpacer.append(a,{title:c});return b};pm.FieldGroup=Ext.extend(Ext.Component,{initComponent:function(){pm.FieldGroup.superclass.initComponent.call(this);this.addEvents("beforeclick","click","containerclick");this.all=new Ext.CompositeElementLite();this.itemSelector="tr.field";this.allFields=[]},onRender:function(b,a){pm.FieldGroup.superclass.onRender.call(this,b,a);var c=this.el=b.createChild({},a);this.getRender();this.all.fill(Ext.query(this.itemSelector,this.el.dom))},getRender:function(){return this.renderFields({renderTo:this.el,scope:this,items:this.items})},renderFields:function(b){var e=b.items;var a=[];for(var c=0,d=e.length;c<d;c++){var h=e[c];if(h){if(h.title&&h.items){this.renderFields({items:h.items,group:h,renderTo:b.renderTo})}else{var g=this.compileFieldData(h);if(g.values){this.allFields.push(g);a.push(g)}}}}if(a.length>0){if(b.renderTo&&b.group){var f=b.group;var j=new Ext.ux.TreeGroup({collapsible:true,collapsed:f.collapsed||false,title:f.title,renderTo:b.renderTo});this.renderFieldData({data:a,renderTo:j.body.dom})}else{if(b.renderTo){this.renderFieldData({data:a,renderTo:b.renderTo})}else{return this.renderFieldData({data:a})}}}},renderFieldData:function(b){if(!b.data){return}if(!pm.tpl.fields){pm.tpl.fields=new Ext.XTemplate('<table width="100%" class="fields {[values.clickable == 1 ? "clickable" : ""]}" >','<tpl for=".">','<tr class="field {cls}">','<tpl if="label">','<td><div class="label">{label}: </div></td>',"</tpl>",'<td width="100%" colspan="{[values.label ? "1" : "2"]}">','<div class="items">','<tpl for="values">','<div class="item" ext:qtip="{parent.tip}">{.}</div>',"</tpl>","</div>","</td>","</tr>","</tpl>","</table>");pm.tpl.fields.compile()}if(b.renderTo){var a=pm.tpl.fields.append(b.renderTo,b.data);Ext.fly(a).on("click",function(h,f){var d=h.getTarget(this.itemSelector,this.el);if(d){var c=this.indexOf(d);var g=this.allFields[c];if(this.onFieldClick(g,c,h)!==false){this.fireEvent("click",this,g,c,h)}}else{if(this.fireEvent("containerclick",this,h)!==false){}}},this)}else{return pm.tpl.fields.applyTemplate(b.data)}},onFieldClick:function(d,a,c){if(this.fireEvent("beforeclick",this,d,a,c)===false){return false}if(d.onClick){d.onClick.call(this,d,a,c)}else{var b=c.getTarget("span.a",1);if(b){pm.state.navigate(pm.state.parseLink(b.id))}}return true},indexOf:function(a){a=this.getNode(a);if(typeof a.viewIndex=="number"){return a.viewIndex}return this.all.indexOf(a)},getNode:function(a){if(typeof a=="string"){return document.getElementById(a)}else{if(typeof a=="number"){return this.all.elements[a]}}return a},compileFieldData:function(e){var d=e.label;var g=e.value;var a=e.values;var f=e.tip;if(!a){a=[]}if(g){a.push(g)}if(a){var h=[];for(var c=0;c<a.length;c++){if(a[c]){if(e.format=="date"){if(a[c]>0){var b=new Date(a[c]*1000);a[c]=Ext.util.Format.date(b,"D, M j, Y");h.push(a[c])}}else{if(e.multiline){a[c]=pm.util.processText(a[c])}h.push(a[c])}}}if(h.length){return{label:d,tip:f,values:h,cls:e.cls||""}}}return[]}});pm.FieldGroup2=Ext.extend(Ext.Component,{initComponent:function(){pm.FieldGroup2.superclass.initComponent.call(this);this.addEvents("beforeclick","click","containerclick");this.all=new Ext.CompositeElementLite();this.itemSelector="tr.field";this.allFields=[]},onRender:function(b,a){pm.FieldGroup2.superclass.onRender.call(this,b,a);var c=this.el=b.createChild({},a);this.getRender();this.all.fill(Ext.query(this.itemSelector,this.el.dom))},getRender:function(){return this.renderFields({renderTo:this.el,scope:this,items:this.items})},renderFields:function(b){var e=b.items;var a=[];for(var c=0,d=e.length;c<d;c++){var h=e[c];if(h){if(h.title&&h.items){this.renderFields({items:h.items,group:h,renderTo:b.renderTo})}else{var g=this.compileFieldData(h);if(g.values){this.allFields.push(g);a.push(g)}}}}if(a.length>0){if(b.renderTo&&b.group){var f=b.group;var j=new Ext.ux.TreeGroup({collapsible:true,collapsed:f.collapsed||false,title:f.title,renderTo:b.renderTo});this.renderFieldData({data:a,renderTo:j.body.dom})}else{if(b.renderTo){this.renderFieldData({data:a,renderTo:b.renderTo})}else{return this.renderFieldData({data:a})}}}},renderFieldData:function(b){if(!b.data){return}if(!pm.tpl.fields){pm.tpl.fields=new Ext.XTemplate('<table width="100%" class="fields {[values.clickable == 1 ? "clickable" : ""]}" >','<tpl for=".">','<tr class="field {cls}">','<tpl if="label">','<td class="label-cell">','<div class="label" ext:qtip="Click to edit...">{label}: </div>',"</td>","</tpl>",'<td class="value-cell" width="100%" colspan="{[values.label ? "1" : "2"]}">','<div class="items">','<tpl for="values">','<div class="item" ext:qtip="{parent.tip}">{.}</div>',"</tpl>","</div>","</td>","</tr>","</tpl>","</table>");pm.tpl.fields.compile()}if(b.renderTo){var a=pm.tpl.fields.append(b.renderTo,b.data);Ext.fly(a).on({click:{fn:this.onClick,scope:this},mouseover:{fn:this.onMouseOver,scope:this},mouseout:{fn:this.onMouseOut,scope:this}})}else{return pm.tpl.fields.applyTemplate(b.data)}},onMouseOver:function(b,a){var c=b.getTarget("tr.field",10,true);c.addClass("over")},onMouseOut:function(b,a){var c=b.getTarget("tr.field",10,true);c.removeClass("over")},onClick:function(f,c){var b=f.getTarget(this.itemSelector,10,true);if(b){var a=this.indexOf(b);var d=this.allFields[a];if(this.onFieldClick(d,a,f)!==false){this.fireEvent("click",this,d,a,f)}}else{if(this.fireEvent("containerclick",this,f)!==false){}}},onFieldClick:function(d,a,c){if(this.fireEvent("beforeclick",this,d,a,c)===false){return false}if(d.onClick){d.onClick.call(this,d,a,c)}else{var b=c.getTarget("span.a",1);if(b){pm.state.navigate(pm.state.parseLink(b.id));return false}}return true},indexOf:function(a){a=this.getNode(a);if(typeof a.viewIndex=="number"){return a.viewIndex}return this.all.indexOf(a)},getNode:function(a){if(typeof a=="string"){return document.getElementById(a)}else{if(typeof a=="number"){return this.all.elements[a]}}return a},compileFieldData:function(e){var d=e.label;var g=e.value;var a=e.values;var f=e.tip;if(!a){a=[]}if(g){a.push(g)}if(a){var h=[];for(var c=0;c<a.length;c++){if(a[c]){if(e.format=="date"){if(a[c]>0){var b=new Date(a[c]*1000);a[c]=Ext.util.Format.date(b,"D, M j, Y");h.push(a[c])}}else{if(e.multiline){a[c]=pm.util.processText(a[c])}h.push(a[c])}}}if(h.length){return{label:d,tip:f,values:h,cls:e.cls||""}}}return[]}});pm.PieMenu=Ext.extend(Ext.Panel,{minWidth:40,maxWidth:300,autoRender:true,frame:false,hidden:true,baseCls:"x-piemenu",floating:{shadow:false,shim:false,useDisplay:true,constrain:false},autoHeight:true,initComponent:function(){pm.PieMenu.superclass.initComponent.call(this)},afterRender:function(){pm.PieMenu.superclass.afterRender.call(this);var a=new Ext.Template('<div class="pie-menu"></div>');this.menuEl=a.overwrite(this.body,{},true);this.body.on({mousemove:{fn:this.onMouseMove,scope:this},mouseout:{fn:function(e,d,f){this.hide.defer(100,this)},scope:this},click:{fn:this.onClick,scope:this}})},onClick:function(c,b){var d=this.getRelativeXY(c);var a=this.getBtn(d);if(a){if(a.fn){this.hide();a.fn.call(a.scope||this,this)}}},onMouseMove:function(c,b){var d=this.getRelativeXY(c);var a=this.getBtn(d);if(a){this.removeClasses(a.cls);this.menuEl.addClass(a.cls);this.menuEl.addClass("clickable")}else{this.removeClasses();this.menuEl.removeClass("clickable")}},removeClasses:function(c){for(var b=0,a=this.btns.length;b<a;b++){if(this.btns[b].cls!=c){this.menuEl.removeClass(this.btns[b].cls)}}},getRelativeXY:function(a){var b=a.getXY();return[b[0]-this.pageX,b[1]-this.pageY]},getBtn:function(d){for(var c=0,a=this.btns.length;c<a;c++){var b=this.btns[c];if(this.inBox(d,b.coords)){return b}}return false},inBox:function(b,a){if((b[0]<a[0][0])||(b[0]>a[1][0])){return false}if((b[1]<a[0][1])||(b[1]>a[1][1])){return false}return true},showAt:function(a){pm.PieMenu.superclass.show.call(this);this.setPagePosition(a[0],a[1])}});pm.NodeObj=function(a){Ext.apply(this,a);if(!this.data){this.data={}}this.lastData={};this.addEvents({load:true,save:true,"delete":true,setProfileImage:true});pm.NodeObj.superclass.constructor.call(this);this.on("load",function(){pm.app.events.fireEvent("nodeEvent",{action:"load",node:this})},this);this.on("save",function(c){c=c||{};pm.app.events.fireEvent("nodeEvent",{action:"save",node:this});var d=(this.lastData.nid)?"changed":"added";var b=pm.util.whatChanged(this.lastData,this.data);pm.app.events.fireEvent("nodeEvent",{action:d,whatChanged:b,node:this});if(!c.noAlert){pm.alerts.add({msg:this.nodeDef.name+" saved: "+pm.state.navLink({text:this.data.title,state:{path:this.nodeDef.paths.view,nid:this.data.nid}}),icon:pm.app.iconPath+this.nodeDef.icons.view})}},this);this.on("delete",function(){pm.app.events.fireEvent("nodeEvent",{action:"deleted",node:this});pm.alerts.add({msg:this.nodeDef.name+" deleted: "+this.data.title,icon:pm.app.iconPath+this.nodeDef.icons.view})},this);if(this.data.nid){this.processData(this.data,true)}else{if(this.nodeDef){this.data.type=this.nodeDef.nodeType}}};Ext.extend(pm.NodeObj,Ext.util.Observable,{load:function(a){if(!a){a={}}if(this.nid&&(a.reload||!this.loaded)){pm.services.get({method:"nodes.getNode",params:{nid:this.nid,loadChildren:this.loadChildren||0,loadFinancialSummary:this.loadFinancialSummary||0,loadFinancialRecords:this.loadFinancialsRecords||0},scope:this,success:function(b){this.processData(b.node,true);if(a.callback){a.callback.call(a.scope||this)}},failure:function(b){Ext.MessageBox.alert("Failed","Unable to load: "+b.message)}})}else{this.fireEvent("load",this);if(a.callback){a.callback.call(a.scope||this)}}},loadMore:function(a){if(!a){a={}}if(!this.loadingAttr){this.loadingAttr=[]}if(!this.loadedAttr){this.loadedAttr=[]}if(this.loadingAttr[a.attr]){var c;var b=function(){if(!this.loadingAttr[a.attr]){clearInterval(c);a.callback.call(a.scope||this)}}.createDelegate(this);c=setInterval(b,200);return}if(!this.loadedAttr[a.attr]){this.doLoadMore(a);return}if(a.callback){a.callback.call(a.scope||this)}},doLoadMore:function(a){this.loadingAttr[a.attr]=true;this.loadedAttr[a.attr]=false;if(a.data){this.data[a.attr]=a.data;this.loadingAttr[a.attr]=false;this.loadedAttr[a.attr]=true;if(a.callback&&a.scope){a.callback.call(a.scope)}}else{if(a.method){pm.services.get({method:a.method,params:Ext.apply({nid:this.nid},a.params),scope:this,success:function(b){this.data[a.attr]=b.records;this.loadingAttr[a.attr]=false;this.loadedAttr[a.attr]=true;if(a.callback&&a.scope){a.callback.call(a.scope)}},failure:function(b){Ext.MessageBox.alert("Failed","Unable to load: "+b.message)}})}else{Ext.MessageBox.alert("Failed","Unable to load: method not specified")}}},processData:function(b,a){this.lastData=pm.util.clone(this.data);if(a){this.data={}}Ext.apply(this.data,b);this.nid=this.data.nid;this.subscription=new pm.Subscription({subscribed:this.data.subscribed,uid:pm.util.getIf([pm.app.currentUser,"data","account","uid"]),stype:"node",sid:this.data.nid,node:this});if(this.isCurrentUser){this.title="My Profile"}else{this.title=this.data.title}this.nodeDef=pm.nodes.getDef(this.data.type);this.loaded=true;this.fireEvent("load",this)},destroy:function(){},save:function(a){pm.services.get({method:"nodes.saveNode",params:pm.util.flatten(this.data),scope:this,success:function(b){this.processData(b.node,true);this.fireEvent("save");if(a.success){a.success.call(a.scope||this,b)}},failure:function(b){Ext.MessageBox.alert("Failed","Unable to save: "+b.message)}})},deleteNode:function(a){pm.services.post({method:"nodes.deleteNode",params:{nid:this.data.nid},scope:this,success:function(b){this.fireEvent("delete");if(typeof a.success=="function"){a.success.call(a.scope||this)}},failure:function(b){Ext.MessageBox.alert("Failed","Unable to delete: "+b.message)}})},deleteConfirm:function(a){if(!a){a={}}Ext.MessageBox.show({title:"Confirm Delete",msg:"Are you sure you want to delete this "+this.nodeDef.name.toLowerCase()+"? There is no undo.",buttons:Ext.MessageBox.YESNO,animEl:a.animEl||"",scope:this,fn:function(b){if(b=="yes"){this.deleteNode({scope:a.scope,success:a.success})}}})},gotoNodeList:function(){if(this.nodeDef.paths&&this.nodeDef.paths.list){pm.state.navigate({path:this.nodeDef.paths.list})}},setProfileFile:function(a){pm.services.post({method:"nodes.setProfileImage",params:{fid:a.fid},scope:this,success:function(b){this.processData(b.node,true);this.fireEvent("save",{noAlert:true});if(a.success){a.success.call(a.scope||this,result)}},failure:function(b){Ext.MessageBox.alert("Failed","Unable to make this the default image: "+b.message)}})}});pm.NodeMiniEditUI=Ext.extend(Ext.Component,{initComponent:function(){pm.NodeMiniEditUI.superclass.initComponent.call(this);this.addEvents({load:true,save:true,close:true});if(this.nodeObj&&!this.nodeDef){this.nodeDef=this.nodeObj.nodeDef}else{if(!this.nodeObj&&this.nodeDef){this.nodeObj=new pm.NodeObj({nodeDef:this.nodeDef})}else{if(!this.nodeObj&&!this.nodeDef){pm.log("Neither a nodeObj or a nodeDef were passed to NodeMiniEditUI!")}}}},initForm:Ext.emptyFn,onRender:function(b,a){pm.NodeMiniEditUI.superclass.onRender.call(this,b,a);this.el=b.createChild({cls:"mini-form"},a);this.titleEl=this.el.createChild({cls:"form-title",html:this.title});this.initForm({scope:this,callback:function(){this.renderNow.defer(10,this)}},this.nodeObj.data)},renderNow:function(){if(this.form&&!this.formReady){this.formReady=true;this.form.render(this.el);this.form.getForm().findField(0).focus(true)}},onClose:function(){this.fireEvent("close")},onSave:function(){if(this.form.getForm().isValid()){pm.services.submitForm(this.form.getForm(),{method:"nodes.saveNode",params:{form_id:this.form_id,nid:this.nodeObj.data.nid,type:this.nodeObj.data.type,parent_nid:pm.util.getIf([this.nodeObj.data,"parent","nid"])},scope:this,success:function(a){this.nodeObj.processData(a.node,true);this.nodeObj.fireEvent("save")},failure:function(a){Ext.MessageBox.alert("Failed","Unable to save: "+a.message)}})}else{Ext.MessageBox.alert("Errors","Please fix the errors noted.")}},onDestroy:function(){pm.NodeMiniEditUI.superclass.onDestroy.call(this);this.form.destroy()}});pm.NodeListHelper=function(a){pm.NodeListHelper.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.NodeListHelper,Ext.util.Observable,{getButtons:function(a){if(!this.nodeDef){return[]}return[{text:"New "+this.nodeDef.name,icon:pm.app.iconPath+(this.nodeDef.icons.add||pm.icons.add),cls:"x-btn-text-icon",scope:this,handler:function(){pm.state.navigate({path:this.nodeDef.paths.create})}}]}});pm.NodeTeaserUI=function(a){Ext.apply(this,a)};Ext.extend(pm.NodeTeaserUI,Ext.util.Observable,{getPostedBy:function(){var b=pm.state.navLink({text:pm.util.getIf([this.nodeObj.data,"user","title"],"unknown user"),state:{path:pm.nodes.getDef("individual").paths.view,nid:pm.util.getIf([this.nodeObj.data,"user","nid"])}});var a="";if(this.nodeObj.data.created.timestamp!=this.nodeObj.data.changed.timestamp){a='<span class="updated">Edited: '+this.nodeObj.data.changed.formatted.date+" at "+this.nodeObj.data.changed.formatted.time+"</span>"}return'<div class="posted-by">Posted by '+b+" on "+this.nodeObj.data.created.formatted.date+" at "+this.nodeObj.data.created.formatted.time+a+"</div>"}});pm.ContactMgr=function(a){pm.ContactMgr.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.ContactMgr,Ext.util.Observable,{getButtons:function(a){return[{text:"New Organization",icon:pm.app.iconPath+(pm.app.nodeDefs.organization.icons.add||pm.icons.add),cls:"x-btn-text-icon",scope:this,handler:function(e,d,f){pm.state.navigate({path:["contacts","organizations","create"]})}},{text:"New Individual Contact",icon:pm.app.iconPath+(pm.app.nodeDefs.individual.icons.add||pm.icons.add),cls:"x-btn-text-icon",scope:this,handler:function(e,d,f){pm.state.navigate({path:["contacts","individuals","create"]})}}]}});pm.IndividualViewUI=function(a){pm.IndividualViewUI.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.IndividualViewUI,Ext.util.Observable,{getFieldGroups:function(){var c=[];var j=[];var k=[];k.push({label:"Nick Name",value:this.nodeObj.data.nick_name});k.push({label:"Job Title",value:this.nodeObj.data.job_title});k.push({label:"Hire Date",value:pm.util.formatDate(this.nodeObj.data.hire_date)});if(this.nodeObj.data.phone_numbers){this.nodeObj.data.phone_numbers.sort(function(p,i){if(i.label.toUpperCase()=="FAX"){return -1}else{if(p.label.toUpperCase()=="OFFICE"){return -1}else{return 0}}});for(var e=0;e<this.nodeObj.data.phone_numbers.length;e++){var g=this.nodeObj.data.phone_numbers[e];j.push({label:g.label,value:g.number})}}if(this.nodeObj.data.email_addresses){for(var e=0;e<this.nodeObj.data.email_addresses.length;e++){var h=this.nodeObj.data.email_addresses[e];var b=(h["default"]=="1")?" (default)":"";var l=(h.label)?" ("+h.label+")":"";j.push({label:"E-Mail"+l,value:'<a href="mailto:'+h.email+'" target="_blank">'+h.email+"</a>"})}}if(this.nodeObj.data.websites){for(var e=0;e<this.nodeObj.data.websites.length;e++){var a=this.nodeObj.data.websites[e];var l=(a.label)?" ("+a.label+")":"";j.push({label:"Website"+l,value:'<a href="'+a.url+'" target="_blank">'+a.url+"</a>"})}}k.push({label:"DISC Profile",value:this.nodeObj.data.discprofile});k.push({label:"Myers-Briggs Type",value:this.nodeObj.data.myerbriggs});k.push({label:"Keirsey Temperament",value:this.nodeObj.data.keirsey});k.push({label:"FexEx #",value:this.nodeObj.data.fedex_number});c.push({title:"Contact Information",collapsed:false,items:j});if(this.nodeObj.data.addresses){var j=[];for(var e=0;e<this.nodeObj.data.addresses.length;e++){var o=[];var n=this.nodeObj.data.addresses[e];if(n.address1){o.push(n.address1)}if(n.address_line_2){o.push(n.address_line_2)}var m=n.city;if(n.city&&n.state){m+=", "}m+=n.state;if(m&&n.zip){m+=" "}m+=n.zip;o.push(m);var f=o.join(", ");var d=Ext.urlEncode({q:f});o.push('<a href="http://maps.google.com/maps?f=q&hl=en&'+d+'" target="_blank">Google Map</a>');j.push({label:(n.label)?n.label:"Address",values:o})}c.push({title:(this.nodeObj.data.addresses.length>1)?"Addresses":"Address",collapsed:true,items:j})}c.push({title:"More Information",collapsed:true,items:k});c.push({title:"Notes",collapsed:true,items:[{value:this.nodeObj.data.body,multiline:true}]});return new pm.FieldGroup2({items:c})}});pm.IndividualEditUI=function(a){pm.IndividualEditUI.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.IndividualEditUI,Ext.util.Observable,{initForm:function(a,b){this.orgDS=new Ext.data.Store({proxy:new pm.SystemProxy({method:"nodes.getList"}),reader:new Ext.data.JsonReader({root:"records",totalProperty:"count",successProperty:"success",id:"nid"},[{name:"nid"},{name:"title"}]),baseParams:{type:"organization",limit:0,"fields[]":["nid","title"]}});this.orgDS.load({scope:this,callback:function(c,d,e){if(e){this.initForm2(a,b)}else{Ext.MessageBox.alert("Error","Unable to load organizations list")}}})},initForm2:function(b,e){pm.contacts.initFormFields();var f={};var c={};var i={};this.employmentTypeDS=new Ext.data.SimpleStore({data:[["staff","Staff"],["freelance","Freelance"],["temporary","Temporary"],["intern","Intern"]],fields:["key","value"],id:0});this.employmentStatusDS=new Ext.data.SimpleStore({data:[["fulltime","Full-Time"],["parttime","Part-Time"]],fields:["key","value"],id:0});this.genderDS=new Ext.data.SimpleStore({data:[[" "],["Male"],["Female"]],fields:["value"],id:0});var j=new Ext.data.SimpleStore({data:[["ISTJ"],["ISFJ"],["INFJ"],["INTJ"],["ISTP"],["ISFP"],["INFP"],["INTP"],["ESTP"],["ESFP"],["ENFP"],["ENTP"],["ESTJ"],["ESFJ"],["ENFJ"],["ENTJ"]],fields:["value"],id:0});var g=new Ext.data.SimpleStore({data:[["Artisan"],["Guardian"],["Rational"],["Idealist"]],fields:["value"],id:0});var a=new Ext.data.SimpleStore({data:[["0","Never"],["1","Daily"],["2","Hourly"]],fields:["key","value"],id:0});i.individual={xtype:"treegroup",title:"Individual",layout:"form",border:false,items:[{xtype:"textfield",fieldLabel:"First Name",name:"first_name",allowBlank:false,value:e.first_name,anchor:"-30"},{xtype:"textfield",fieldLabel:"Last Name",name:"last_name",allowBlank:false,value:e.last_name,anchor:"-30"},{xtype:"textfield",fieldLabel:"Nick Name",name:"nick_name",value:e.nick_name,anchor:"-30"},{xtype:"combo",fieldLabel:"Gender",name:"gender",store:this.genderDS,displayField:"value",forceSelection:true,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,value:e.gender,anchor:"-30"},{xtype:"panel",html:"Gender is an optional field, but it is useful for properly formatting log messages such as 'User X updated her profile'",border:false,bodyStyle:"padding: 0 0 10px 95px; font-size: 10px;"},{xtype:"combo",fieldLabel:"Organization",name:"parent_title",store:this.orgDS,displayField:"title",valueField:"nid",typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,value:pm.util.getIf([e,"parent","nid"]),anchor:"-30"},{xtype:"textfield",fieldLabel:"Job Title",name:"job_title",value:e.job_title,anchor:"-30"},{xtype:"datefield",fieldLabel:"Hire Date",name:"hire_date",value:e.hire_date,width:100},{xtype:"panel",html:"Hire date can be entered in any common date format, such as MM/DD/YY",border:false,bodyStyle:"padding: 0 0 10px 95px; font-size: 10px;"},{xtype:"textarea",fieldLabel:"Notes",name:"body",anchor:"-30",height:"125",value:e.body}]};i.temperament={xtype:"treegroup",title:"Temperament",layout:"form",border:false,labelWidth:140,items:[{xtype:"textfield",fieldLabel:"DISC Profile",name:"discprofile",value:e.discprofile,anchor:"-30"},{xtype:"combo",fieldLabel:"Myers-Briggs Type",name:"myerbriggs",store:j,displayField:"value",forceSelection:true,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,value:e.myerbriggs,anchor:"-30"},{xtype:"combo",fieldLabel:"Keirsey Temperament",name:"keirsey",store:g,displayField:"value",forceSelection:true,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,value:e.keirsey,anchor:"-30"}]};var k="";if(pm.util.getIf([e,"account","username"])){k="12345678901234567890"}var d=false;if(pm.util.getIf([e,"account","disabled"])){d=true}i.account={xtype:"treegroup",title:"Account",layout:"form",border:false,labelWidth:120,items:[{xtype:"panel",html:"If this individual should be able to log into the system you can specify his or her login credentials and settings here.",border:false,bodyStyle:"padding-bottom: 15px"},{xtype:"textfield",fieldLabel:"Account username",name:"account_username",value:pm.util.getIf([e,"account","username"]),width:200},{xtype:"textfield",fieldLabel:"Password",name:"account_password1",inputType:"password",selectOnFocus:true,value:k,width:200},{xtype:"textfield",fieldLabel:"Confirm Password",name:"account_password2",inputType:"password",selectOnFocus:true,value:k,width:200},{xtype:"checkbox",fieldLabel:"Disable account?",name:"account_disabled",checked:(d)?true:false,inputValue:"disabled"}]};var h=pm.util.getIf([e,"account","notification_level"]);i.settings={xtype:"treegroup",title:"Settings",layout:"form",border:false,labelWidth:120,items:[{xtype:"panel",border:false,bodyStyle:"padding: 0 0 10px 0",html:"Receive email notifications when select pieces of content change?"},{xtype:"radio",name:"account_notification_level",checked:(h=="Hourly")?true:false,hideLabel:true,inputValue:"Hourly",boxLabel:"Hourly"},{xtype:"panel",layout:"table",layoutConfig:{columns:2},border:false,items:[{xtype:"radio",name:"account_notification_level",checked:(h=="Daily")?true:false,hideLabel:true,inputValue:"Daily",boxLabel:"Daily at&nbsp;&nbsp;"},{xtype:"timefield",hideLabel:true,name:"account_notification_hour",minValue:"5:00am",maxValue:"11:00pm",increment:60,value:pm.util.getIf([e,"account","notification_hour"],"9:00 AM"),width:100}]}]};this.formCfg={labelAlign:"left",labelWidth:90};this.formItems=[];if(e.nid){this.formItems.push(pm.contacts.getTypeSelector(e,this))}this.formItems.push(i.individual);this.formItems.push(pm.contacts.getPhoneTab(e));this.formItems.push(pm.contacts.getInternetTab(e));this.formItems.push(pm.contacts.getAddressTab(e));this.formItems.push(pm.contacts.getShippingTab(e));this.formItems.push(i.temperament);this.formItems.push(i.settings);if(b.callback){b.callback.call(b.scope,{formItems:this.formItems,formCfg:this.formCfg})}}});pm.OrganizationViewUI=function(a){pm.OrganizationViewUI.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.OrganizationViewUI,Ext.util.Observable,{getFieldGroups:function(){var d=[];var l=[],f=[];var b=pm.util.getIf([this.nodeObj.data.category,"name"]);if(b){b=pm.state.navLink({text:b,state:{path:["category"],tid:this.nodeObj.data.category.tid}})}l.push({label:"Category",value:b});f.push({label:"Abbreviation",value:this.nodeObj.data.abbrev});if(this.nodeObj.data.shipping){for(var g=0;g<this.nodeObj.data.shipping.length;g++){var q=this.nodeObj.data.shipping[g];f.push({label:q.label+" #",value:q.number})}}if(this.nodeObj.data.phone_numbers){this.nodeObj.data.phone_numbers.sort(function(r,i){if(i.label.toUpperCase()=="FAX"){return -1}else{if(r.label.toUpperCase()=="OFFICE"){return -1}else{return 0}}});for(var g=0;g<this.nodeObj.data.phone_numbers.length;g++){var j=this.nodeObj.data.phone_numbers[g];l.push({label:j.label,value:j.number})}}if(this.nodeObj.data.email_addresses){for(var g=0;g<this.nodeObj.data.email_addresses.length;g++){var k=this.nodeObj.data.email_addresses[g];var c=(k["default"]=="1")?" (default)":"";var m=(k.label)?" ("+k.label+")":"";l.push({label:"E-Mail"+m,value:'<a href="mailto:'+k.email+'" target="_blank">'+k.email+"</a>"})}}if(this.nodeObj.data.websites){for(var g=0;g<this.nodeObj.data.websites.length;g++){var a=this.nodeObj.data.websites[g];var m=(a.label)?" ("+a.label+")":"";l.push({label:"Website"+m,value:'<a href="'+a.url+'" target="_blank">'+a.url+"</a>"})}}d.push({title:"Contact Information",collapsed:false,items:l});if(this.nodeObj.data.addresses){var l=[];for(var g=0;g<this.nodeObj.data.addresses.length;g++){var p=[];var o=this.nodeObj.data.addresses[g];if(o.address1){p.push(o.address1)}if(o.address_line_2){p.push(o.address_line_2)}var n=o.city;if(o.city&&o.state){n+=", "}n+=o.state;if(n&&o.zip){n+=" "}n+=o.zip;p.push(n);var h=p.join(", ");var e=Ext.urlEncode({q:h});p.push('<a href="http://maps.google.com/maps?f=q&hl=en&'+e+'" target="_blank">Google Map</a>');l.push({label:(o.label)?o.label:"Address",values:p})}d.push({title:(this.nodeObj.data.addresses.length>1)?"Addresses":"Address",collapsed:true,items:l})}d.push({title:"More Information",collapsed:true,items:f});d.push({title:"Notes",collapsed:true,items:[{value:this.nodeObj.data.body,multiline:true}]});return new pm.FieldGroup2({items:d})}});pm.OrganizationEditUI=function(a){pm.OrganizationEditUI.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.OrganizationEditUI,Ext.util.Observable,{initForm:function(a,b){pm.data.getCategoriesDS({name:"Contact Types",scope:this,callback:function(c){this.categoriesDS=c;this.initForm2(a,b)}})},initForm2:function(c,e){pm.contacts.initFormFields();var b={};var a={};var d={};b.title={xtype:"textfield",fieldLabel:"Organization",name:"title",anchor:"-20",value:e.title};b.category={xtype:"combo",fieldLabel:"Category",name:"category",store:this.categoriesDS,displayField:"name",valueField:"tid",forceSelection:false,typeAhead:true,mode:"local",triggerAction:"all",anchor:"-20",value:pm.util.getIf([e,"category","tid"])};b.notes={xtype:"textarea",fieldLabel:"Notes",name:"body",anchor:"-20",height:"125",value:e.body};b.abbrev={xtype:"textfield",fieldLabel:"Abbreviation",name:"abbrev",anchor:"-20",value:e.abbrev};d.organization={xtype:"treegroup",title:"Organization",layout:"form",border:false,items:[b.title,b.notes,b.abbrev,b.category]};this.formCfg={labelAlign:"left",labelWidth:90};this.formItems=[];if(e.nid){this.formItems.push(pm.contacts.getTypeSelector(e,this))}this.formItems.push(d.organization);this.formItems.push(pm.contacts.getPhoneTab(e));this.formItems.push(pm.contacts.getInternetTab(e));this.formItems.push(pm.contacts.getAddressTab(e));this.formItems.push(pm.contacts.getShippingTab(e));if(c.callback){c.callback.call(c.scope,{formItems:this.formItems,formCfg:this.formCfg})}}});pm.ProjectMgr=function(a){pm.ProjectMgr.superclass.constructor.call(this,a)};Ext.extend(pm.ProjectMgr,pm.NodeListHelper,{prepareData:function(a){a.details="";a.right=pm.util.formatTerms(a.project_type);return a}});pm.ProjectViewUI=function(a){pm.ProjectViewUI.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.ProjectViewUI,Ext.util.Observable,{renderTags:function(a){if(!pm.tpl.nodeTags){pm.tpl.nodeTags=new Ext.Template('<div class="tags">{tags}</div>');pm.tpl.nodeTags.compile()}pm.tpl.nodeTags.append(a,{tags:pm.state.navLink({text:this.nodeObj.data.project_type.name,state:{path:["projects","by","type"],id:this.nodeObj.data.project_type.id}})});a.on("click",function(b,d){var c=Ext.get(d);if(c.is("span.a")){pm.state.navigate(pm.state.parseLink(d.id))}},this)},getFieldGroups:function(){this.tipCfg={title:"Click to edit"};var e=pm.util.getIf([this.nodeObj.data.project_type,"name"]);if(e){e=pm.state.navLink({text:e,state:{path:["category"],tid:this.nodeObj.data.project_type.tid}})}var f=pm.util.getIf([this.nodeObj.data.project_progress,"name"]);if(f){f=pm.state.navLink({text:f,state:{path:["category"],tid:this.nodeObj.data.project_progress.tid}})}var b=this.nodeObj.data.delivery_formats;if(b&&b.length){var c=[];for(var d=0,a=b.length;d<a;d++){c.push(b[d])}if(c){b=c.join(", ")}}return new pm.FieldGroup2({scope:this,items:[{title:"Project Information",items:[{label:"Project #",value:this.nodeObj.data.project_number},{label:"Project Type",value:e},{label:"Status",value:f},{label:"Deadline",value:pm.util.formatDate(this.nodeObj.data.deadline)}]},{title:"More Information",collapsed:true,items:[{label:"Creative Summary",value:this.nodeObj.data.creative_summary,multiline:true},{label:"Delivery Formats",value:b},{label:"Master Tape Number",value:this.nodeObj.data.master_tape_number},{label:"Stock Footage Details",value:this.nodeObj.data.stock_footage_details,multiline:true},{label:"Music Track Details",value:this.nodeObj.data.music_track_details,multiline:true},{label:"Post Production",value:this.nodeObj.data.post_production,multiline:true},{label:"Production Shooting Description",value:this.nodeObj.data.production_shooting_descr,multiline:true},{label:"Client Supplied Elements",value:this.nodeObj.data.client_supplied_elements,multiline:true}]}]})}});pm.ProjectTeaserUI=function(a){pm.ProjectTeaserUI.superclass.constructor.call(this,a)};Ext.extend(pm.ProjectTeaserUI,pm.NodeTeaserUI,{getTeaser:function(){var a='<div class="fields">';a+=this.getPostedBy();var b=new pm.FieldGroup({items:[{label:"Project #",value:this.nodeObj.data.project_number},{label:"Project Type",value:pm.util.getIf([this.nodeObj.data.project_type,"name"])},{label:"Status",value:pm.util.getIf([this.nodeObj.data.project_progress,"name"])}]});a+=b.getRender();a+="</div>";return a}});pm.ProjectEditUI=function(a){pm.ProjectEditUI.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.ProjectEditUI,Ext.util.Observable,{initForm:function(a,b){this.deliveryDS=new Ext.data.SimpleStore({data:[["VHS"],["HD"],["MiniDV"],["IMX"],["DVCPro"],["DigiBeta"],["Beta SP"],["DVD"]],fields:["value"],id:0});pm.data.getCategoriesDS({name:"Project Types",scope:this,callback:function(c){this.projectTypesDS=c;this.initForm2(a,b)}})},initFormFields:function(d,g){this.data={};this.fields={};this.tabs={};var f=pm.projects.progressDefs;var c=[];if(f){for(var e=0,a=f.length;e<a;e++){c.push([f[e].id,f[e].namePlural])}}this.progressDS=new Ext.data.SimpleStore({data:c,fields:["key","value"],id:0});this.fields.title={xtype:"textfield",fieldLabel:"Title",name:"title",allowBlank:false,anchor:"-30",value:g.title};this.fields.projectNumber={xtype:"textfield",fieldLabel:"Project #",name:"project_number",width:100,value:g.project_number};this.fields.projectProgress={xtype:"combo",fieldLabel:"Progress",name:"project_progress",store:this.progressDS,displayField:"value",forceSelection:true,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,width:250,value:pm.util.getIf([g,"project_progress","name"])};this.fields.projectType={xtype:"combo",fieldLabel:"Project Type",name:"project_type",store:this.projectTypesDS,displayField:"name",valueField:"tid",forceSelection:false,typeAhead:true,mode:"local",triggerAction:"all",width:250,value:pm.util.getIf([g,"project_type","tid"])};this.fields.deadline={xtype:"datefield",fieldLabel:"Deadline",name:"deadline",value:pm.util.formatForDateField(g.deadline),width:100};var b="";if(g.delivery_formats){for(var h in g.delivery_formats){if(typeof g.delivery_formats[h]=="string"){b+=g.delivery_formats[h]+", "}}}this.fields.deliveryFormats={xtype:"combomulti",sep:",",fieldLabel:"Delivery Formats",name:"delivery_formats",store:this.deliveryDS,displayField:"value",forceSelection:true,typeAhead:true,mode:"local",triggerAction:"all",width:250,value:b};this.fields.masterTape={xtype:"textfield",fieldLabel:"Master Tape #",name:"master_tape_number",width:250,value:g.master_tape_number};this.fields.creativeSummary={xtype:"textarea",fieldLabel:"Creative Summary",name:"creative_summary",anchor:"-30",height:"150",value:g.creative_summary};this.fields.stockFootageDetails={xtype:"textarea",fieldLabel:"Stock Footage Details",name:"stock_footage_details",anchor:"-30",height:"150",value:g.stock_footage_details};this.fields.musicTrackDetails={xtype:"textarea",fieldLabel:"Music Track Details",name:"music_track_details",anchor:"-30",height:"150",value:g.music_track_details};this.fields.postProduction={xtype:"textarea",fieldLabel:"Post Production",name:"post_production",anchor:"-30",height:"150",value:g.post_production};this.fields.productionShooting={xtype:"textarea",fieldLabel:"Production Shooting Description",name:"production_shooting_descr",anchor:"-30",height:"150",value:g.production_shooting_descr};this.fields.clientSupplied={xtype:"textarea",fieldLabel:"Client Supplied Elements",name:"client_supplied_elements",anchor:"-30",height:"150",value:g.client_supplied_elements};this.tabs.project={xtype:"treegroup",title:"General Information",layout:"form",border:false,items:[this.fields.title,this.fields.projectProgress,this.fields.projectType,this.fields.projectNumber,this.fields.deadline]};this.tabs.media={xtype:"treegroup",title:"Media Project Details",layout:"form",border:false,items:[this.fields.masterTape,this.fields.deliveryFormats,this.fields.creativeSummary,this.fields.stockFootageDetails,this.fields.musicTrackDetails,this.fields.postProduction,this.fields.productionShooting,this.fields.clientSupplied]}},initForm2:function(a,b){this.initFormFields(a,b);this.formCfg={labelAlign:"left",labelWidth:90};this.formItems=[this.tabs.project,this.tabs.media];if(a.callback){a.callback.call(a.scope,{formItems:this.formItems,formCfg:this.formCfg})}}});pm.ProjectMiniEditUI=function(a){pm.ProjectMiniEditUI.superclass.constructor.call(this,a)};Ext.extend(pm.ProjectMiniEditUI,pm.NodeMiniEditUI,{initFormFields:function(a,b){}});pm.TaskViewUI=function(a){pm.TaskViewUI.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.TaskViewUI,Ext.util.Observable,{getFieldGroups:function(){var e=this.nodeObj.data;var f="";var a="";if(e.assigned_to){var c=pm.nodes.getDef(e.assigned_to.type);var a=pm.state.navLink({text:e.assigned_to.title,state:{path:c.paths.view,nid:e.assigned_to.nid}});if(e.assigned_by){var c=pm.nodes.getDef(e.assigned_by.type);var f=pm.state.navLink({text:e.assigned_by.title,state:{path:c.paths.view,nid:e.assigned_by.nid}})}}var b=pm.util.getIf([e.priority,"name"]);if(b){b=pm.state.navLink({text:b,state:{path:["category"],tid:this.nodeObj.data.priority.tid}})}return new pm.FieldGroup2({items:[{title:"Task Information",items:[{label:"Priority",value:b},{label:"Progress",value:e.progress},{label:"Completed",value:e.completed,format:"date"},{label:"Assigned to",value:a},{label:"Assigned by",value:f}]},{title:"More Information",collapsed:false,items:[{value:e.body,multiline:true}]}]})}});pm.TaskTeaserUI=function(a){pm.TaskTeaserUI.superclass.constructor.call(this,a)};Ext.extend(pm.TaskTeaserUI,pm.NodeTeaserUI,{getTeaser:function(){var a='<div class="fields">';a+=this.getPostedBy();var b=new pm.FieldGroup({items:[{label:"Priority",value:pm.util.getIf([this.nodeObj.data,"priority","name"])},{label:"Progress",value:this.nodeObj.data.progress},{label:"Completed",value:this.nodeObj.data.completed,format:"date"},{value:this.nodeObj.data.body,multiline:true}]});a+=b.getRender();a+="</div>";return a}});pm.TaskEditUI=function(a){pm.TaskEditUI.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.TaskEditUI,Ext.util.Observable,{initForm:function(a,b){pm.nodes.getList({type:"individual",isUser:true,scope:this,callback:function(c){this.ds=c;this.initForm2(a,b)}})},initForm2:function(a,g){if(!g){g={}}this.fields={};this.groups={};this.tabs={};this.btns={};var i=this.fields;var b=this.groups;var j=this.tabs;var f=this.btns;var e=new Ext.data.SimpleStore({data:[["Urgent"],["High"],["Medium"],["Someday/Maybe"]],fields:["value"],id:0});var d=new Ext.data.SimpleStore({data:[["Not Started"],["In Progress"],["Postponed"],["Completed"]],fields:["value"],id:0});var c=pm.util.getIf([g.assigned_to,"nid"])||pm.app.currentUser.data.nid;var m={xtype:"treegroup",title:"Action Step",layout:"form",labelAlign:"top",border:false,items:[{xtype:"textfield",fieldLabel:"Action Step",name:"title",allowBlank:false,anchor:"-20",value:g.title},{xtype:"textarea",fieldLabel:"Define the specific action that needs to be taken",name:"body",anchor:"-20",height:200,value:g.body},{xtype:"combo",fieldLabel:"Priority",name:"priority",store:e,displayField:"value",forceSelection:false,typeAhead:true,mode:"local",triggerAction:"all",width:150,value:pm.util.getIf([g,"priority","name"])},{xtype:"combo",fieldLabel:"Assigned to",name:"assigned_to_title",store:this.ds,displayField:"title",valueField:"nid",forceSelection:true,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,width:150,value:c}]};var l=function(n){return{autoHeight:true,autoWidth:true,layout:"table",border:false,defaults:{bodyStyle:"padding-right: 5px"},layoutConfig:{columns:3},items:[{layout:"form",labelAlign:"top",border:false,items:[{xtype:"xdatetime",name:"start",fieldLabel:"Send me an e-mail reminder",otherToNow:false,timeFormat:"g:i A",dateFormat:"m/d/Y",dateConfig:{value:""},timeConfig:{listClass:"x-combo-list-small",maxHeight:100,value:""}}]}]}};var k={xtype:"treegroup",title:"Notifications (not currently functional)",border:false,items:[{layout:"form",labelAlign:"left",labelWidth:205,border:false,bodyStyle:"padding: 0 0 15px 0",items:[{xtype:"checkbox",fieldLabel:"E-Mail me when this item changes?",name:"subscribe",allowBlank:true,value:g.subscribe}]},{xtype:"formrepeat",btnTitle:"Add another reminder",data:(g&&g.notifications)?g.notifications:[],getInstance:l}]};var h=function(n){var n=(n)?n:{};return{autoHeight:true,layout:"table",border:false,defaults:{bodyStyle:"padding-right: 5px"},layoutConfig:{columns:2},items:[{layout:"form",labelAlign:"top",border:false,items:[{xtype:"combo",fieldLabel:"Organization or Individual Contact",name:"reference_who[]",store:this.whoDS,displayField:"title",forceSelection:true,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,value:n.who,width:300}]},{layout:"form",labelAlign:"top",border:false,items:[{xtype:"combo",fieldLabel:"Involvement",name:"reference_how[]",store:this.howDS,displayField:"value",forceSelection:false,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,value:n.how,width:300}]}]}};this.formCfg={labelAlign:"left",labelWidth:90};this.formItems=[m,k];if(a.callback){a.callback.call(a.scope,{formItems:this.formItems,formCfg:this.formCfg})}}});pm.EventViewUI=function(a){pm.EventViewUI.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.EventViewUI,Ext.util.Observable,{getFieldGroups:function(){return new pm.FieldGroup2({items:[{label:"When",value:this.nodeObj.data.when.when},{label:"Timezone",value:[this.nodeObj.data.when.timezone,this.nodeObj.data.when.localOffset]},{label:"Local Time",value:this.nodeObj.data.when.whenLocal},{label:"Where",value:this.nodeObj.data.location},{label:"Description",value:this.nodeObj.data.body}]})}});pm.EventEditUI=function(a){pm.EventEditUI.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.EventEditUI,Ext.util.Observable,{initForm:function(a,b){this.timezoneDS=new Ext.data.Store({proxy:new pm.SystemProxy({method:"events.getTimezones"}),reader:new Ext.data.JsonReader({root:"records",totalProperty:"count",successProperty:"success",id:"nid"},[{name:"offset"},{name:"title"}])});this.timezoneDS.load({scope:this,callback:function(c,d,e){if(e){this.initForm2(a,b)}else{Ext.MessageBox.alert("Error","Unable to load timezones list")}}})},initForm2:function(e,g){var b=new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">{text}</div></tpl>');var d=pm.util.formatForDateField(g.start);var c=pm.util.formatForTimeField(g.start);var h=pm.util.formatForDateField(g.end);var i=pm.util.formatForTimeField(g.end);if((c=="12:00 AM")&&(i=="11:59 PM")){var l=true}else{var l=false}var a=new Ext.ux.form.DateTime({name:"start",fieldLabel:"Event Start",otherToNow:false,timeFormat:"g:i A",dateFormat:"m/d/Y",dateConfig:{value:d},timeConfig:{tpl:b,listClass:"x-combo-list-small",maxHeight:100,value:c,disabled:l}});a.on("render",function(){a.updateValue()},this);var f=new Ext.ux.form.DateTime({name:"end",fieldLabel:"Event End",otherToNow:false,timeFormat:"g:i A",dateFormat:"m/d/Y",dateConfig:{value:h},timeConfig:{tpl:b,listClass:"x-combo-list-small",maxHeight:100,value:i,disabled:l}});f.on("render",function(){f.updateValue()},this);var j=new Ext.form.Checkbox({name:"all_day",fieldLabel:"All Day?",checked:l});j.on("check",function(m,n){if(n){a.disableTime();f.disableTime()}else{a.enableTime();f.enableTime()}},this);var k={xtype:"treegroup",title:"Event",layout:"form",border:false,items:[{xtype:"textfield",fieldLabel:"What",name:"title",allowBlank:false,anchor:"-20",value:g.title},{xtype:"textarea",fieldLabel:"Description",name:"body",anchor:"-20",height:50,value:g.body},{xtype:"textfield",fieldLabel:"Where",name:"location",allowBlank:true,anchor:"-20",value:g.location},{xtype:"combo",fieldLabel:"Timezone",name:"timezone",store:this.timezoneDS,displayField:"title",allowBlank:false,forceSelection:true,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,value:g.timezone||"America/Los Angeles",anchor:"-20"},j,a,f]};this.formCfg={labelAlign:"left",labelWidth:90};this.formItems=[k];if(e.callback){e.callback.call(e.scope,{formItems:this.formItems,formCfg:this.formCfg})}}});pm.DocumentViewUI=function(a){pm.DocumentViewUI.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.DocumentViewUI,Ext.util.Observable,{getFieldGroups:function(){var a=pm.util.getIf([this.nodeObj.data.category,"name"]);if(a){a=pm.state.navLink({text:a,tip:"Browse more documents in this category",state:{path:["category"],tid:this.nodeObj.data.category.tid}})}return new pm.FieldGroup2({items:[{label:"Category",value:a},{value:this.nodeObj.data.body,multiline:true}]})}});pm.DocumentTeaserUI=function(a){pm.DocumentTeaserUI.superclass.constructor.call(this,a)};Ext.extend(pm.DocumentTeaserUI,pm.NodeTeaserUI,{getTeaser:function(){var a="";a+=this.getPostedBy();a+='<div class="teaser">'+pm.util.processText(this.nodeObj.data.body)+"</div>";return a}});pm.DocumentEditUI=function(a){pm.DocumentEditUI.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.DocumentEditUI,Ext.util.Observable,{initForm:function(a,b){pm.data.getCategoriesDS({name:"Document Categories",scope:this,callback:function(c){this.categoriesDS=c;this.initForm2(a,b)}})},initForm2:function(b,c){if(!c){c={}}this.fields={};this.tabs={};this.fields.type={xtype:"combo",fieldLabel:"Category",name:"category",store:this.categoriesDS,displayField:"name",valueField:"tid",forceSelection:false,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,anchor:"-20",value:pm.util.getIf([c,"category","tid"])};this.fields.title={xtype:"textfield",fieldLabel:"Title",name:"title",allowBlank:false,anchor:"-20",value:c.title};this.fields.body={xtype:"textarea",fieldLabel:"Body",name:"body",anchor:"-20",height:"250",value:c.body};var a=[];if(this.nodeDef.nodeType!="comment"){a.push(this.fields.type)}a.push(this.fields.title);a.push(this.fields.body);this.tabs.document={xtype:"treegroup",title:this.nodeDef.name,layout:"form",border:false,items:a};var a=[];a.push(this.tabs.document);this.formCfg={labelAlign:"left",labelWidth:90};this.formItems=a;if(b.callback){b.callback.call(b.scope,{formItems:this.formItems,formCfg:this.formCfg})}}});pm.DocumentMiniEditUI=function(a){pm.DocumentMiniEditUI.superclass.constructor.call(this,a)};Ext.extend(pm.DocumentMiniEditUI,pm.NodeMiniEditUI,{initFormFields:function(a,b){this.fields={};this.tabs={};this.fields.title={xtype:"textfield",fieldLabel:"Title",name:"title",allowBlank:false,anchor:"-30",value:b.title};this.fields.body={xtype:"textarea",fieldLabel:"Body",name:"body",anchor:"-30",height:"250",value:b.body}},initForm:function(a,b){this.initFormFields(a,b);this.form=new Ext.FormPanel({labelAlign:"top",frame:false,border:false,plain:true,items:[this.fields.title,this.fields.body],buttons:[{text:"Save",scope:this,handler:this.onSave},{text:"Cancel",scope:this,handler:this.onClose}]});if(a.callback){a.callback.call(a.scope)}}});pm.InventoryViewUI=function(a){pm.InventoryViewUI.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.InventoryViewUI,Ext.util.Observable,{getFieldGroups:function(){var a=pm.util.getIf([this.nodeObj.data.category,"name"]);if(a){a=pm.state.navLink({text:a,tip:"Browse more inventory items in this category",state:{path:["category"],tid:this.nodeObj.data.category.tid}})}return new pm.FieldGroup2({items:[{label:"Category",value:a},{label:"Checked Out By",value:this.nodeObj.data.checkout.title},{label:"Description",value:this.nodeObj.data.body}]})}});pm.InventoryEditUI=function(a){pm.InventoryEditUI.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.InventoryEditUI,Ext.util.Observable,{initForm:function(a,b){pm.nodes.getList({type:"individual",isUser:true,scope:this,callback:function(c){this.usersDS=c;pm.data.getCategoriesDS({name:"Inventory Categories",scope:this,callback:function(d){this.categoriesDS=d;this.initForm2(a,b)}})}})},initForm2:function(c,e){if(!e){e={}}var b={};var a={};var d={};b.title={xtype:"textfield",fieldLabel:"Item",name:"title",allowBlank:false,anchor:"-20",value:e.title};b.category={xtype:"combo",fieldLabel:"Category",name:"category",store:this.categoriesDS,displayField:"name",valueField:"tid",forceSelection:false,typeAhead:true,mode:"local",triggerAction:"all",anchor:"-20",value:pm.util.getIf([e,"category","tid"])};b.checkedOut={xtype:"combo",fieldLabel:"Checked Out By",name:"checkout_title",store:this.usersDS,displayField:"title",valueField:"nid",forceSelection:true,typeAhead:true,mode:"local",triggerAction:"all",anchor:"-20",value:pm.util.getIf([e,"checkout","nid"])};b.description={xtype:"textarea",fieldLabel:"Description",name:"body",anchor:"-20",height:"150",value:e.body};d.inventory={id:"inventory",title:"Inventory",layout:"form",border:false,items:[b.title,b.category,b.checkedOut,b.description]};this.formCfg={labelAlign:"left",labelWidth:90};this.formItems=[d.inventory];if(c.callback){c.callback.call(c.scope,{formItems:this.formItems,formCfg:this.formCfg})}}});pm.EmailViewUI=function(a){pm.EmailViewUI.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.EmailViewUI,Ext.util.Observable,{getFieldGroups:function(){return new pm.FieldGroup2({items:[{value:this.nodeObj.data.body,multiline:true}]})}});pm.EmailEditUI=function(a){pm.EmailEditUI.superclass.constructor.call(this,a);Ext.apply(this,a)};Ext.extend(pm.EmailEditUI,Ext.util.Observable,{initForm:function(c,e){var b={};var a={};var d={};b.title={xtype:"textfield",fieldLabel:"Title",name:"title",allowBlank:false,anchor:"-20"};b.body={xtype:"textarea",fieldLabel:"Body",name:"body",anchor:"-20",height:"250"};d.email={xtype:"treegroup",title:"Email",layout:"form",border:false,items:[b.title,b.body]};this.formCfg={labelAlign:"left",labelWidth:90};this.formItems=[d.email];if(c.callback){c.callback.call(c.scope,{formItems:this.formItems,formCfg:this.formCfg})}}});pm.FileList=Ext.extend(Ext.Component,{initComponent:function(){pm.FileList.superclass.initComponent.call(this);this.addEvents({deleteFile:true})},onRender:function(e,d){pm.FileList.superclass.onRender.call(this,e,d);var a=this.el=e.createChild({},d);var c=function(j){return[j.attributes.fid]};var f=function(j){j.leaf=true;Ext.apply(j,pm.nodes.getFileInfo({filename:j.filename,filemime:j.filemime}))};var b=function(k,j){};var i=function(k){var j=[];return j};var h=function(j,k){if(j.attributes.filepath){window.open(pm.util.url(j.attributes.filepath,"File Download"))}};var g={groupOrder:{field:"filename"},groupConfig:function(j){var k={key:j.type,icon:j.icon,optional:true,collapsed:true,addCount:true,title:j.labelPlural};return k}};this.tree=new Ext.ux.TreePanel({renderTo:a,cls:"file-list",autoHeight:true,border:false,baseParams:{nid:this.nid},nodeParams:c,idField:"fid",titleField:"filename",onNodeInit:f,onNodeLoad:b,dataUrl:pm.services.url("nodes.getFiles"),root:new Ext.ux.AsyncTreeNode({title:"Files",children:this.data}),maxTitleLen:14,scope:this,nodeLinks:function(k){var j=[];if(pm.util.inArray(k.attributes.ext,["png","jpg","jpeg"])>-1){j.push({text:'<img src="'+pm.app.iconPath+pm.app.icons.promoteImage+'" />',tip:"Make this the default image for this profile",scope:this,handler:function(n,o){var l=n.attributes;var m=pm.nodes.getNodeObj({nid:this.nid});m.setProfileFile({fid:l.fid})}})}j.push({text:'<img src="'+pm.app.iconPath+pm.app.icons.del+'" />',tip:"Delete this file",scope:this,handler:function(m,n){var l=n.getTarget();this.deleteConfirm({animEl:l,fid:m.attributes.fid,scope:this,success:function(){this.reload()}})}});return j},animate:false,showReadMore:false,autoScroll:false,containerScroll:true,defaultText:"No files to display.",getLinks:i,onClickNode:h,grouping:g,itemTpl:{}})},reload:function(){if(this.tree){this.tree.reload()}},deleteConfirm:function(a){if(!a.fid){Ext.MessageBox.alert("Failed","Unable to delete: The file ID could not be found!");return}Ext.MessageBox.show({title:"Confirm Delete",msg:"Are you sure you want to delete this file? There is no undo.",buttons:Ext.MessageBox.YESNO,animEl:a.animEl||"",scope:this,fn:function(b){if(b=="yes"){this.doDelete({fid:a.fid,scope:a.scope,success:a.success})}}})},doDelete:function(a){pm.services.post({method:"files.deleteFile",params:{fid:a.fid},scope:this,success:function(b){this.fireEvent("deleteFile",{fid:a.fid});if(typeof a.success=="function"){a.success.call(a.scope||this)}},failure:function(b){Ext.MessageBox.alert("Failed","Unable to delete: "+b.message)}})}});pm.FormRepeat=Ext.extend(Ext.Panel,{layout:"form",border:false,initComponent:function(){pm.FormRepeat.superclass.initComponent.call(this);this.initItems();this.data=(this.data)?this.data:{};this.addAll(this.data)},getInstance:function(a){},onRender:function(b,a){pm.FormRepeat.superclass.onRender.call(this,b,a)},addInstance:function(){var b=this.items.length-1;var a={};this.insert(b,this.getInstance(a));this.doLayout()},addAll:function(c){if(c.length>0){for(var b=0;b<Math.max(c.length,1);b++){this.add(this.getInstance(c[b]))}}else{c={};this.add(this.getInstance(c))}var a=new Ext.Button({xtype:"button",text:(this.btnTitle)?this.btnTitle:"Add another"});a.on("click",function(){this.addInstance()},this);this.add(a)}});Ext.reg("formrepeat",pm.FormRepeat);pm.Page=Ext.extend(Ext.BoxComponent,{autoHeight:true,initComponent:function(){pm.Page.superclass.initComponent.call(this);if(!this.state){this.state={}}if(!this.statePrefix){this.statePrefix=""}this.addEvents({load:true,setTitle:true,setSubTitle:true});if(this.title){this.setTitle(this.title)}if(this.startHidden){this.hide()}},load:function(a){if(!a){a={}}this.loaded=true;this.loading=false;if(a.callback){a.callback.call(a.scope||this)}},onRender:function(b,a){pm.Page.superclass.onRender.call(this,b,a);if(!this.isCancelled){this.el=b.createChild({cls:"page"},a);if(this.showLoader!==false){this.el.update('<div class="loading-indicator">Loading...</div>')}pm.util.callWhen.call(this,{args:arguments,scope:this,callback:function(){this.el.update();this.doRender()}})}},doRender:function(){this.isRendered=true},clear:function(){this.el.update()},aktivieren:function(a){this.isActive=true;this.state=a},deaktivieren:function(){this.isActive=false},setTitle:function(a){this.title=a;this.fireEvent("setTitle",a,this)},setSubTitle:function(a){this.subtitle=a;this.fireEvent("setSubTitle",a,this)},onDestroy:function(){pm.Page.superclass.onDestroy.call(this)}});Ext.reg("page",pm.Page);pm.TabPage=Ext.extend(Ext.TabPanel,{activeTab:0,border:false,autoHeight:true,defaults:{autoHeight:true},initComponent:function(){pm.TabPage.superclass.initComponent.call(this);if(!this.state){this.state={}}this.addEvents({load:true,setTitle:true,setSubTitle:true});if(this.title){this.setTitle(this.title)}this.on({beforetabchange:{scope:this,fn:function(a,c,b){if(this.tabClickListener){pm.state.navigate({tab:this.getTabIndex(c)},true,false)}else{this.tabClickListener=true}}},add:{scope:this,fn:function(b,c,a){c.on({deactivate:{scope:this,fn:function(d){pm.log("deactivate tab: "+d.id);if(d.instance){d.instance.deaktivieren()}}}})}}})},load:function(a){if(!a){a={}}this.loaded=true;this.loading=false;if(a.callback){a.callback.call(a.scope||this)}},onRender:function(b,a){pm.TabPage.superclass.onRender.call(this,b,a);this.doRender()},doRender:function(){this.activateTab();this.isRendered=true;var a=this.el.child(".x-tab-strip-wrap");var b=a.child(".x-tab-strip");this.subTitleEl=a.createChild({cls:"subtitle"},b)},getTabIndex:function(c){for(var b=0,a=this.items.items.length;b<a;b++){var d=this.items.items[b];if(d.getId()==c.getId()){return b}}},aktivieren:function(a){this.isActive=true;this.state=a;if(this.isRendered){this.activateTab()}},deaktivieren:function(){this.isActive=false;for(var b=0,a=this.items.items.length;b<a;b++){var c=this.items.items[b];if(c&&c.instance){c.instance.deaktivieren()}}},setTitle:function(a){this.title=a;this.fireEvent("setTitle",a,this)},setSubTitle:function(a){this.subtitle=a;if(this.subTitleEl){this.subTitleEl.update(a)}this.fireEvent("setSubTitle",a,this)},activateTab:function(){var b=this.state.tab;if(!b){b=0}this.tabClickListener=false;this.activate(b);var d;if(d=this.getActiveTab()){if(!d.instance){if(d.handler){var a=new d.handler(Ext.apply({state:this.state},d.params));a.on({setTitle:{scope:this,fn:function(f){this.setTitle(f)}},setSubTitle:{scope:this,fn:function(f){this.setSubTitle(f)}}});a.load();d.instance=a}}if(d.instance){var e=(d.instance.title)?d.instance.title:"";var c=(d.instance.subtitle)?d.instance.subtitle:"";if(!d.instance.rendered){d.instance.render(d.body)}d.instance.aktivieren(this.state)}else{var e=(d.title)?d.title:"";var c=(d.subtitle)?d.subtitle:""}}this.setTitle(e);this.setSubTitle(c)},onDestroy:function(){for(var b=0,a=this.items.items.length;b<a;b++){var c=this.items.items[b];if(c&&c.instance){c.instance.destroy()}}pm.TabPage.superclass.onDestroy.call(this)}});pm.Container=Ext.extend(pm.Page,{initComponent:function(){pm.Container.superclass.initComponent.call(this);this.container=new Ext.Container({});this.container.on({add:{scope:this,fn:function(a,b,c){b.instance.on({setTitle:{scope:this,fn:function(d){}},beforerender:{scope:this,fn:function(){}}});b.instance.load()}}})},doRender:function(){pm.Container.superclass.doRender.call(this)},aktivieren:function(d){pm.Container.superclass.aktivieren.call(this,d);if(this.container.items){for(var b=0,a=this.container.items.items.length;b<a;b++){var c=this.container.items.items[b];if(c&&c.instance){c.instance.aktivieren(d)}}}},deaktivieren:function(){pm.Container.superclass.deaktivieren.call(this);if(this.container.items){for(var b=0,a=this.container.items.items.length;b<a;b++){var c=this.container.items.items[b];if(c&&c.instance){c.instance.deaktivieren()}}}},onDestroy:function(){if(this.container.items){for(var b=0,a=this.container.items.items.length;b<a;b++){var c=this.container.items.items[b];if(c&&c.instance){c.instance.destroy()}}}this.container.destroy();pm.Container.superclass.aktivieren.call(this,state)}});pm.WidgetMgr=Ext.extend(Ext.Container,{initComponent:function(){pm.WidgetMgr.superclass.initComponent.call(this);if(!this.state){this.state={}}this.addEvents({validatedrop:true,beforedragover:true,dragover:true,beforedrop:true,drop:true,load:true,setTitle:true,setSubTitle:true});this.on({add:{scope:this,fn:function(a,c,b){c.on({deactivate:{scope:this,fn:function(d){if(d.instance){d.instance.deaktivieren()}}}})}}});if(pm.app.enableUserWidgets){pm.widgets.loadUserWidgets({nid:this.params.userNID||pm.app.currentUser.data.nid,scope:this,callback:this.init2})}else{this.init2()}},init2:function(){this.widgetsSorted=[];this.widgetsByName=[];if(pm.app.enableUserWidgets){var c=pm.widgets.userWidgets[pm.app.currentUser.data.nid];if(c){c=c[this.panelID];if(c){c=c[this.regionID];if(c){for(var e=0,b=c.length;e<b;e++){var d=pm.app.widgetDefs[c[e].widget];this.widgetsSorted.push(c[e]);this.widgetsSorted.push(Ext.apply({name:c[e].widget},d));this.widgetsByName[c[e].widget]=this.widgetsSorted.length-1}}}}}if(this.defaultWidgets){for(var e=0,b=this.defaultWidgets.length;e<b;e++){var g=this.defaultWidgets[e];if(typeof this.widgetsByName[g]!="number"){var d=pm.app.widgetDefs[g];this.widgetsSorted.push(Ext.apply({name:g},d))}}}for(var e=0,b=this.widgetsSorted.length;e<b;e++){if(this.widgetsSorted[e].handler){var d=this.widgetsSorted[e];var a=pm.util.apply({},{title:"Loading...",collapsible:true,autoHeight:true,defaults:{autoHeight:true},tools:pm.util.callIf([d,"getTools"],this,d),draggable:false},d);a.params=Ext.apply({},this.params,d.params);var f=new pm.Block(a);if(f.handler){f.instance=new f.handler(Ext.apply({owner:f,state:this.state},f.params));f.on({render:{fn:function(h){if(this.instance){this.instance.render(this.body)}}}});f.instance.on({setTitle:{fn:function(h){this.owner.setTitle(h)}},hide:{fn:function(){this.owner.hide()}},show:{fn:function(){this.owner.show()}}});if(f.instance.hidden){f.hide()}if(f.instance.title){f.setTitle(f.instance.title)}}this.add(f)}}},load:function(a){if(!a){a={}}if(this.items){this.items.each(function(d,c,b){if(d.instance){d.instance.load()}},this)}this.loaded=true;this.loading=false;if(a.callback){a.callback.call(a.scope||this)}},initEvents:function(){pm.WidgetMgr.superclass.initEvents.call(this)},onRender:function(b,a){pm.WidgetMgr.superclass.onRender.call(this,b,a);this.el=b.createChild({cls:"widgets"},a)},aktivieren:function(a){this.isActive=true;this.state=a;if(this.items){this.items.each(function(d,c,b){if(d.instance){d.instance.aktivieren(a)}},this)}},deaktivieren:function(){this.isActive=false;if(this.items){this.items.each(function(c,b,a){if(c.instance){c.instance.deaktivieren()}},this)}},onDestroy:function(){if(this.items){this.items.each(function(c,b,a){if(c.instance){c.instance.destroy()}},this)}pm.WidgetMgr.superclass.onDestroy.call(this)}});Ext.reg("widgetpanel",pm.WidgetMgr);pm.WidgetMgr.DropZone=function(a,b){this.portal=a;Ext.dd.ScrollManager.register(a.body);pm.WidgetMgr.DropZone.superclass.constructor.call(this,a.bwrap.dom,b);a.body.ddScrollConfig=this.ddScrollConfig};Ext.extend(pm.WidgetMgr.DropZone,Ext.dd.DropTarget,{ddScrollConfig:{vthresh:50,hthresh:-1,animate:true,increment:200},createEvent:function(a,f,d,b,h,g){return{portal:this.portal,panel:d.panel,columnIndex:b,column:h,position:g,data:d,source:a,rawEvent:f,status:this.dropAllowed}},notifyOver:function(u,s,v){var f=s.getXY(),a=this.portal,m=u.proxy;if(!this.grid){this.grid=this.getGrid()}var b=a.body.dom.clientWidth;if(!this.lastCW){this.lastCW=b}else{if(this.lastCW!=b){this.lastCW=b;a.doLayout();this.grid=this.getGrid()}}var d=0,k=this.grid.columnX,l=false;for(var q=k.length;d<q;d++){if(f[0]<(k[d].x+k[d].w)){l=true;break}}if(!l){d--}var o,j=false,i=0,t=a.items.itemAt(d),n=t.items.items;for(var q=n.length;i<q;i++){o=n[i];var r=o.el.getHeight();if(r!==0&&(o.el.getY()+(r/2))>f[1]){j=true;break}}var g=this.createEvent(u,s,v,d,t,j&&o?i:t.items.getCount());if(a.fireEvent("validatedrop",g)!==false&&a.fireEvent("beforedragover",g)!==false){m.getProxy().setWidth("auto");if(o){m.moveProxy(o.el.dom.parentNode,j?o.el.dom:null)}else{m.moveProxy(t.el.dom,null)}this.lastPos={c:t,col:d,p:j&&o?i:false};this.scrollPos=a.body.getScroll();a.fireEvent("dragover",g);return g.status}else{return g.status}},notifyOut:function(){delete this.grid},notifyDrop:function(k,g,f){delete this.grid;if(!this.lastPos){return}var i=this.lastPos.c,b=this.lastPos.col,j=this.lastPos.p;var a=this.createEvent(k,g,f,b,i,j!==false?j:i.items.getCount());if(this.portal.fireEvent("validatedrop",a)!==false&&this.portal.fireEvent("beforedrop",a)!==false){k.proxy.getProxy().remove();k.panel.el.dom.parentNode.removeChild(k.panel.el.dom);if(j!==false){i.insert(j,k.panel)}else{i.add(k.panel)}i.doLayout();this.portal.fireEvent("drop",a);var l=this.scrollPos.top;if(l){var h=this.portal.body.dom;setTimeout(function(){h.scrollTop=l},10)}}delete this.lastPos},getGrid:function(){var a=this.portal.bwrap.getBox();a.columnX=[];this.portal.items.each(function(b){a.columnX.push({x:b.el.getX(),w:b.el.getWidth()})});return a}});pm.ErrorPage=Ext.extend(pm.Page,{initComponent:function(){pm.ErrorPage.superclass.initComponent.call(this);if(!pm.tpl.errorPage){pm.tpl.errorPage=new Ext.XTemplate('<div class="error-page">','<div class="msg">{errMsg}</div>','<div class="plain-text">','<p>Please contact the <a href="mailto:{adminEmail}">system administrator</a> if this problem persists. ',"Be sure to mention: </p>","<ul>","<li>Your computer operating system and version (Mac OS Leopard, Windows XP, etc)</li>","<li>Your Internet browser and version (Firefox 2.0, Safari 3.0, Internet Explorer 7.0, etc)</li>","<li>Steps to reproduce this error.</li>","</ul>","</div>","</div>");pm.tpl.errorPage.compile()}},doRender:function(){pm.ErrorPage.superclass.doRender.call(this);pm.tpl.errorPage.overwrite(this.el,{errNum:404,errMsg:"Page Not Found",adminEmail:"ben@cookepictures.com"})}});pm.NodeRedirect=Ext.extend(pm.Page,{initComponent:function(){pm.NodeRedirect.superclass.initComponent.call(this);this.nid=this.state.nid;if(!this.nid){pm.log("The NID was not passed to NodeRedirect!");return}this.nodeObj=pm.nodes.getNodeObj({nid:this.nid})},redirect:function(){if(pm.util.getIf([this,"nodeObj","nodeDef","paths","view"])){pm.state.navigate2({state:{path:this.nodeObj.nodeDef.paths.view,nid:this.nid},skipHistoryMgr:true})}},load:function(a){if(!a){a={}}this.loading=true;this.loaded=false;this.nodeObj.load({scope:this,callback:this.redirect})},aktivieren:function(a){pm.NodeRedirect.superclass.aktivieren.call(this,a);this.redirect()}});pm.NodeViewUI=Ext.extend(pm.Page,{initComponent:function(){pm.NodeViewUI.superclass.initComponent.call(this);this.nid=this.state.nid||pm.app.currentUser.data.nid;if(!this.nid){pm.log("The NID was not passed to NodeViewUI!");return}this.nodeObj=pm.nodes.getNodeObj({nid:this.nid});this.nodeObj.on("load",function(a){this.title=a.data.title;this.fireEvent("setTitle",this.title)},this);if(!pm.tpl.nodeView){pm.tpl.nodeView=new Ext.XTemplate('<div class="profile-header"></div>','<table class="layout" width="100%" border="0" cellpadding="0" cellspacing="0">',"<tr>",'<td width="25%" valign="top" class="left">','<div class="profile-image"></div>','<div class="profile-left"></div>',"</td>",'<td width="75%" valign="top" align="left" class="right">','<div class="profile-breadcrumbs"></div>','<div class="profile-title"></div>','<div class="profile-tagline"></div>','<div class="profile-details"></div>','<div class="break"></div>','<div class="profile-right"></div>',"</td>","</tr>","</table>");pm.tpl.nodeView.compile()}},load:function(a){if(!a){a={}}this.loading=true;this.loaded=false;this.nodeObj.load({scope:this,callback:function(){this.onLoad();this.loaded=true;this.loading=false;this.fireEvent("load",this);if(a.callback){a.callback.call(a.scope||this)}}})},onLoad:function(){this.nodeDef=this.nodeObj.nodeDef;this.viewUI=new this.nodeDef.ui.view({nodeObj:this.nodeObj});this.widgetsLeft=new pm.WidgetMgr({state:this.state,panelID:"node",regionID:"left",params:{nodeObj:this.nodeObj,uid:pm.app.currentUser.data.account.uid,nid:this.nodeObj.data.nid,},defaultWidgets:["delegation","responsibilities","timeTracking","individuals","events","inventory","documents","financialSummary"]});this.widgetsLeft.load();this.widgetsRight=new pm.WidgetMgr({panelID:"node",regionID:"right",state:this.state,params:{nodeObj:this.nodeObj,uid:pm.app.currentUser.data.account.uid,nid:this.nodeObj.data.nid,},defaultWidgets:["tasks","projects","comments","financialRecords","gcalendar","newsFeed"]});this.widgetsRight.load();if(this.isActive){this.widgetsLeft.aktivieren(this.state);this.widgetsRight.aktivieren(this.state)}},doRender:function(){pm.NodeViewUI.superclass.doRender.call(this);var f=this.el;pm.tpl.nodeView.overwrite(this.el);this.headerEl=this.el.child("div.profile-header");this.titleEl=this.el.child("div.profile-title");this.taglineEl=this.el.child("div.profile-tagline");this.imageEl=this.el.child("div.profile-image");this.breadcrumbsEl=this.el.child("div.profile-breadcrumbs");this.leftEl=this.el.child("div.profile-left");this.rightEl=this.el.child("div.profile-right");this.detailsEl=this.el.child("div.profile-details");var h=this.leftEl.createChild({cls:"files"});this.fileList=new pm.FileList({data:this.nodeObj.data.files,nid:this.nodeObj.data.nid,renderTo:h});this.fileList.on("deleteFile",function(){this.nodeObj.load({reload:true});this.fileList.reload()},this);this.multiUploader=new Ext.form.MultiUploader({focusClass:"",uploadParams:{nid:this.nodeObj.data.nid,queue_only:false,form_id:0+"",},anchor:"98%",renderFirst:false,showUploadBtn:true,renderTo:this.leftEl});this.multiUploader.on("queuecomplete",function(){this.multiUploader.clearQueue();this.multiUploader.hide();this.nodeObj.load({reload:true});this.fileList.reload()},this);this.multiUploader.on("fileuploaded",function(){},this);var d=(this.isMyProfile)?"My Profile":this.nodeObj.nodeDef.name;var e={stop:{title:"Stop Sending Updates",icon:pm.app.icons.unsubscribe},start:{title:"Send Me Updates",icon:pm.app.icons.subscribe}};if(this.nodeObj.subscription.subscribed){var g=e.stop.title;var c=e.stop.icon}else{var g=e.start.title;var c=e.start.icon}var b={editNode:{id:"editNode",title:"Edit "+d,icon:this.nodeObj.nodeDef.icons.edit,callback:function(i){pm.state.navigate({path:this.nodeObj.nodeDef.paths.edit,nid:this.nodeObj.data.nid})}},deleteNode:{id:"deleteNode",title:"Delete "+this.nodeObj.nodeDef.name,icon:pm.app.icons.del,callback:function(j,i){this.nodeObj.deleteConfirm({animEl:i,scope:this,success:function(){this.nodeObj.gotoNodeList()}})}},subscription:{id:"subscription",title:g,icon:c,subscription:this.nodeObj.subscription,callback:function(k,j){var i=Ext.get(j);var l=function(){i.fadeOut({scope:this,callback:function(){if(k.subscription.subscribed){k.subscription.unsubscribe();i.child("img").dom.src=pm.app.iconPath+e.start.icon;i.child("span.title").dom.innerHTML=e.start.title}else{k.subscription.subscribe();i.child("img").dom.src=pm.app.iconPath+e.stop.icon;i.child("span.title").dom.innerHTML=e.stop.title}i.fadeIn()}})};if(!k.subscription.subscribed){if(!pm.util.getIf([pm.app.currentUser.data,"account","notification_level"])){if(!pm.subscriptionDlg){pm.subscriptionDlg=new Ext.Window({layout:"form",cls:"notify-win",title:"Notification Settings",width:300,height:200,closeAction:"hide",plain:true,border:false,bodyStyle:"padding:10px",buttonAlign:"center",resizable:false,modal:true,items:[{border:false,bodyStyle:"padding: 0 0 10px 0",html:"Your email notifications are currently disabled. Would you like to enable them?"},{xtype:"radio",name:"notify",checked:true,hideLabel:true,inputValue:"hourly",boxLabel:"Hourly"},{layout:"table",layoutConfig:{columns:2},border:false,items:[{xtype:"radio",name:"notify",checked:false,hideLabel:true,inputValue:"daily",boxLabel:"Daily at&nbsp;&nbsp;"},{xtype:"timefield",hideLabel:true,name:"notification_hour",minValue:"5:00am",maxValue:"11:00pm",increment:60,width:100}]},{border:false,bodyStyle:"padding: 0 0 10px 0",html:"If you ever want to change these settings, just edit your profile and scroll down to Settings."}],buttons:[{text:"Save ",icon:pm.app.iconPath+pm.app.icons.save,cls:"x-btn-text-icon",handler:function(p,s){var r=p.ownerCt;r.hide();var n=r.find("name","notify");if(n[0].checked){var o="Daily";var q=""}else{if(n[1].checked){var o="Hourly";var m=r.find("name","notification_hour");m=m[0];var q=m.getValue()}}if(o){pm.services.get({method:"notifications.setPrefs",scope:this,params:{uid:pm.util.getIf([pm.app.currentUser.data,"account","uid"]),notification_level:o,notification_hour:q},success:function(t){Ext.apply(pm.app.currentUser.data.account,t.settings);pm.app.currentUser.processData(pm.app.currentUser.data)},failure:function(t){Ext.MessageBox.alert("Failed","Unable to perform action: "+t.message)}})}}},{text:"Cancel",icon:pm.app.iconPath+pm.app.icons.cancel,cls:"x-btn-text-icon",handler:function(m,o){var n=m.ownerCt;n.hide()}}]});pm.subscriptionDlg.on({hide:{fn:function(n,m,o){l()},scope:this}})}pm.subscriptionDlg.show()}else{l()}}else{l()}}}};if(this.isMyProfile){var a=[b.editNode]}else{var a=[b.editNode,b.deleteNode,b.subscription]}pm.app.initActionLinks(this.leftEl,a,this);this.widgetsLeft.render(this.leftEl);this.widgetsRight.render(this.rightEl);this.renderContent();this.evtsID=pm.app.events.id();pm.app.events.listen({id:this.evtsID,listeners:[{type:"nodeEvent",scope:this,fn:function(i){if(i.node.data.nid!=this.nodeObj.data.nid){return}switch(i.action){case"load":case"changed":if(this.isActive){this.renderContent()}else{this.isDirty=true}break;case"deleted":pm.log("Node deleted. NodeViewUI should respond and do something, but I've no idea what...");break}}}]})},renderContent:function(){var c="";c+=this.getPostedBy();c+='<img src="'+pm.app.iconPath+this.nodeDef.icons.view+'" /><span class="title">'+this.nodeDef.name+"</span>";this.headerEl.update(c);this.titleEl.update(this.nodeObj.data.title);var b=this.getBreadcrumbs();this.breadcrumbsEl.update((b)?b.reverse().join(" > "):"");this.breadcrumbsEl.on("click",function(d,f){var e=Ext.get(f);if(e.is("span.a")){pm.state.navigate(pm.state.parseLink(f.id))}},this);var a=pm.util.getIf([this.nodeObj.data,"profile","image","medium"]);if(a){this.imageEl.update('<img src="'+a+'" />')}else{this.imageEl.update()}this.renderTagline(this.taglineEl);this.detailsEl.update();this.renderDetails(this.detailsEl)},renderTagline:function(a){if(!this.tagline){this.tagline=new pm.Tagline({nodeObj:this.nodeObj});this.tagline.render(a)}},renderDetails:function(a){this.fieldGroups=this.viewUI.getFieldGroups();this.fieldGroups.on("click",function(b,g,c,f){var d=f.getTarget("td.label-cell",3,true);if(d){pm.state.navigate({path:this.nodeObj.nodeDef.paths.edit,nid:this.nodeObj.nid})}},this);this.fieldGroups.render(a)},aktivieren:function(a){pm.NodeViewUI.superclass.aktivieren.call(this,a);if(this.isDirty){this.renderContent()}if(this.widgetsLeft&&this.widgetsRight){this.widgetsLeft.aktivieren(this.state);this.widgetsRight.aktivieren(this.state)}if(this.tagline){this.tagline.aktivieren(a)}},deaktivieren:function(){pm.NodeViewUI.superclass.deaktivieren.call(this);if(this.widgetsLeft&&this.widgetsRight){this.widgetsLeft.deaktivieren();this.widgetsRight.deaktivieren()}if(this.tagline){this.tagline.deaktivieren()}},onDestroy:function(){if(this.widgetsLeft&&this.widgetsRight){this.widgetsLeft.destroy();this.widgetsRight.destroy();delete this.widgetsLeft;delete this.widgetsRight}if(this.tagline){this.tagline.destroy()}this.tips.each(function(c,b,a){c.destroy();return true});pm.app.events.stopListening(this.evtsID);this.nodeObj=null;this.nodeDef=null;pm.NodeViewUI.superclass.onDestroy.call(this)},getBreadcrumbs:function(c,a){var c=c||this.nodeObj.data.parent;var a=a||[];if(c){var b=pm.app.nodeDefs[c.type];if(b){a.push(pm.state.navLink({text:c.title,state:{path:b.paths.view,nid:c.nid}}));if(c.parent){this.getBreadcrumbs(c.parent,a)}}return a}},getPostedBy:function(){if(this.nodeObj.data.created.timestamp!=this.nodeObj.data.changed.timestamp){var a="Edited "+this.nodeObj.data.changed.formatted.date+" at "+this.nodeObj.data.changed.formatted.time+"</span>"}else{var a="Added "+this.nodeObj.data.created.formatted.date+" at "+this.nodeObj.data.created.formatted.time+"</span>"}return'<div class="right">'+a+"</div>"}});pm.NodeEditUI=Ext.extend(pm.Page,{initComponent:function(){pm.NodeEditUI.superclass.initComponent.call(this);this.initNodeObj()},initNodeObj:function(){if(!this.state.nid&&!this.nodeDef){pm.log("Neither a node ID or a node definition were passed to NodeEditUI!");return}if(this.nodeObj){this.nodeObj.destroy();delete this.nodeObj}this.nodeObj=pm.nodes.getNodeObj({nid:this.state.nid,nodeDef:this.nodeDef,data:{}});this.nodeObj.on("load",function(a){this.title=a.data.title;this.fireEvent("setTitle",this.title)},this)},load:function(a){if(!a){a={}}this.loading=true;this.loaded=false;this.nodeObj.load({scope:this,callback:function(){this.load2(a)}})},load2:function(a){if(!a){a={}}this.nodeDef=this.nodeObj.nodeDef;this.editUI=new this.nodeDef.ui.edit({owner:this,nodeDef:this.nodeDef,nodeObj:this.nodeObj});this.form_id=new Date().getTime();this.editUI.initForm({scope:this,callback:function(b){this.formItems=b.formItems;this.formCfg=b.formCfg;this.load3(a)}},this.nodeObj.data)},load3:function(a){if(!a){a={}}this.parentNode={};if(this.nodeObj.data.parent){var b=this.nodeObj.data.parent.nid;if(pm.app.nodes[b]){this.parentNode=pm.app.nodes[b].data}else{this.parentNode=this.nodeObj.data.parent}}else{if(this.state.parent_nid){var b=this.state.parent_nid;if(pm.app.nodes[b]){this.parentNode=pm.app.nodes[b].data}else{pm.services.get({method:"nodes.getInfo",params:{nid:b},scope:this,success:function(c){this.parentNode=c.info;this.loaded=true;this.loading=false;this.fireEvent("load",this);if(a.callback){a.callback.call(a.scope||this)}},failure:function(c){Ext.MessageBox.alert("Failed","Unable to load: "+c.message)}});return}}}this.loaded=true;this.loading=false;this.fireEvent("load",this);if(a.callback){a.callback.call(a.scope||this)}},initForm:Ext.emptyFn,doRender:function(){pm.NodeEditUI.superclass.doRender.call(this);this.renderHeader();this.renderParent();this.renderContent()},renderHeader:function(){this.el.update();if(!pm.tpl.nodeEditPage){pm.tpl.nodeEditPage=new Ext.Template('<div class="profile-header">','<div class="right">{headerRight}</div>','<table border="0">',"<tr>",'<td><img src="{headerIcon}" /><span class="title">{title}</span></td>',"</tr>","</table>","</div>",'<div class="profile-parent"></div>','<div class="profile-form"></div>');pm.tpl.nodeEditPage.compile()}if(this.nodeObj.nid){var a="Edit "+this.nodeDef.name}else{var a="New "+this.nodeDef.name}pm.tpl.nodeEditPage.overwrite(this.el,{title:a,headerIcon:pm.app.iconPath+this.nodeDef.icons.edit,headerRight:""});this.headerRightEl=this.el.child("div.profile-header div.right");this.parentEl=this.el.child("div.profile-parent");this.formEl=this.el.child("div.profile-form");this.parentEl.enableDisplayMode();this.formEl.enableDisplayMode();if(!pm.tpl.nodeEditParent){pm.tpl.nodeEditParent=new Ext.Template('<span style="font-weight: bold;">{parentType}: </span>',"{parentTitle} ",'<span style="font-size: 10px">(<span class="a small">change</span>)</span>');pm.tpl.nodeEditParent.compile()}if(!pm.tpl.nodeSetParent){pm.tpl.nodeSetParent=new Ext.Template("Not attached to anything ",'<span style="font-size: 10px">(<span class="a small">select item</span>)</span>');pm.tpl.nodeSetParent.compile()}this.headerRightEl.on({click:{fn:function(c,b){var d=c.getTarget("span.a");if(d){pm.state.navigate({mode:"parenting"},true)}},scope:this}})},renderParent:function(){if(this.parentNode&&this.parentNode.type&&this.parentNode.title){var a=pm.nodes.getDef(this.parentNode.type);pm.tpl.nodeEditParent.overwrite(this.headerRightEl,{parentType:a.name,parentTitle:Ext.util.Format.ellipsis(this.parentNode.title,70)})}else{pm.tpl.nodeSetParent.overwrite(this.headerRightEl,{})}},renderContent:function(){if(!this.nodeObj.data.nid&&!this.parentNode.nid){if((this.nodeObj.data.type!="organization")&&(this.nodeObj.data.type!="individual")){this.state.mode="parenting"}}if(this.state.mode=="parenting"){this.showParenter()}else{this.showForm()}},showParenter:function(){this.formEl.hide();this.parentEl.show();if(this.parentForm){this.parentCombo.focus(true);this.parentCombo.setValue(pm.util.getIf([this,"parentNode","title"]))}else{this.parentEl.update('<div class="loading-indicator">Loading...</div>');this.showParenter2()}},showParenter2:function(){this.parentsDS=new Ext.data.Store({proxy:new pm.SystemProxy({method:"related.getParentChoices"}),reader:new Ext.data.JsonReader({root:"records",totalProperty:"count",id:"nid"},[{name:"nid"},{name:"title"},{name:"type"},{name:"created"},{name:"changed"},{name:"categories"}]),baseParams:{nid:this.nodeObj.nid,type:this.nodeObj.data.type}});this.parentsDS.load({scope:this,callback:function(){this.showParenter3()}})},showParenter3:function(){this.parentEl.update();this.parentForm=new Ext.FormPanel(Ext.apply({frame:false,border:false,bodyBorder:false,plain:true,autoScroll:true,items:{xtype:"panel",defaults:{bodyStyle:"padding:15px"},plain:true,border:false,items:[{xtype:"treegroup",title:"Select the parent item for this "+this.nodeObj.nodeDef.name.toLowerCase()+":",layout:"anchor",border:false,labelAlign:"top",items:[{xtype:"combo",fieldLabel:"Parent Item",name:"parent_title",store:this.parentsDS,displayField:"title",valueField:"nid",forceSelection:true,emptyText:"Select an item",typeAhead:true,mode:"local",triggerAction:"all",anchor:"100%",value:""}]}]},buttons:[{text:"Ok",icon:pm.app.iconPath+pm.app.icons.check,cls:"x-btn-text-icon",scope:this,handler:function(){var b=this.parentCombo.getValue();var c=this.parentsDS.findBy(function(d,e){if((d.data.nid==b)||(d.data.title==b)){return true}},this);var a=this.parentsDS.getAt(c);this.parentNode={nid:a.data.nid,type:a.data.type,title:a.data.title};pm.state.navigate({mode:"form",parent_nid:a.data.nid},true)}},{text:"Cancel",icon:pm.app.iconPath+pm.app.icons.cancel,cls:"x-btn-text-icon",scope:this,handler:function(){if(this.nodeObj.nid){pm.state.navigate({mode:"form"},true)}else{this.closeForm()}}}],renderTo:this.parentEl},this.formCfg));this.parentCombo=this.parentForm.form.findField(0);this.parentCombo.focus(true);this.parentCombo.setValue(pm.util.getIf([this,"parentNode","title"]))},showForm:function(){this.parentEl.hide();this.formEl.show();if(!this.formItems){return}if(!this.form){this.form=new Ext.FormPanel(Ext.apply({labelAlign:"left",labelWidth:90,autoWidth:true,autoHeight:true,frame:false,border:false,bodyBorder:false,plain:true,autoScroll:true,items:{xtype:"panel",defaults:{bodyStyle:"padding:15px"},plain:true,border:false,items:this.formItems},buttons:this.getButtons(),renderTo:this.formEl},this.formCfg))}this.form.form.findField(0).focus(true)},getButtons:function(){var a={save:{text:"Save",icon:pm.app.iconPath+pm.app.icons.save,cls:"x-btn-text-icon",scope:this,handler:this.saveAndClose},saveNew:{text:"Save and New",icon:pm.app.iconPath+pm.app.icons.saveMultiple,cls:"x-btn-text-icon",scope:this,handler:this.saveAndNew},cancel:{text:"Cancel",icon:pm.app.iconPath+pm.app.icons.cancel,cls:"x-btn-text-icon",scope:this,handler:this.closeForm}};if(this.nodeObj.data.nid){return[a.save,a.saveNew,a.cancel]}else{return[a.save,a.saveNew,a.cancel]}},saveAndClose:function(){this.submitForm({success:this.onSaveAndClose})},saveAndNew:function(){this.submitForm({success:this.onSaveAndNew})},submitForm:function(b){var a=function(){pm.services.submitForm(this.form.getForm(),{method:"nodes.saveNode",params:{form_id:this.form_id,nid:this.nodeObj.data.nid,type:this.nodeObj.data.type,parent_nid:pm.util.getIf([this.parentNode,"nid"])},scope:this,success:function(d){this.nodeObj.processData(d.node,true);this.nodeObj.fireEvent("save");if(b.success){b.success.call(this,d)}},failure:function(d){Ext.MessageBox.alert("Failed","Unable to save: "+d.message)}})};if(this.form.getForm().isValid()){var c=this.form.getForm().findField("files");if(!pm.app.disableMultiFileUploader&&c&&c.files.length>0){if(!c.wired){c.on("queuecomplete",function(){a.call(this)},this);c.wired=true}c.upload()}else{a.call(this)}}else{Ext.MessageBox.alert("Errors","Please fix the errors noted.")}},aktivieren:function(a){this.isActive=true;this.state=a;if(this.isRendered){if(this.state.parent_nid!=this.parentNode.nid){this.load3({scope:this,callback:function(){this.renderParent();this.renderContent()}})}else{this.renderParent();this.renderContent()}}},onDestroy:function(){if(this.form){this.form.destroy()}pm.NodeEditUI.superclass.onDestroy.call(this)},closeForm:function(){var b=this.nodeObj.data.nid;var a=this.nodeObj.nodeDef.paths.view;if(!this.state.nid){this.initNodeObj();if(this.form){this.form.form.reset()}this.parentNode={}}if(!pm.state.navigateBack(true)){if(b){pm.state.navigate({path:a,nid:b})}else{if(this.nodeDef.paths&&this.nodeDef.paths.list){pm.state.navigate({path:this.nodeDef.paths.list})}}}},onSaveAndNew:function(){this.form.un("actioncomplete",this.onSaveAndNew,this);if(this.state.nid){pm.state.navigate({path:this.nodeDef.paths.create,parent_nid:pm.util.getIf([this.nodeObj.data,"parent","nid"])})}else{this.initNodeObj();this.form.form.reset()}},onSaveAndClose:function(){this.form.un("actioncomplete",this.onSaveAndClose,this);this.closeForm()}});pm.NodeMgr=Ext.extend(pm.Page,{initComponent:function(){pm.NodeMgr.superclass.initComponent.call(this);this.addEvents({switchModes:true});if(this.nodeDef.ui.list){this.listUI=new this.nodeDef.ui.list({nodeDef:this.nodeDef})}else{this.listUI=new pm.NodeListHelper({nodeDef:this.nodeDef})}this.title=this.nodeDef.namePlural;this.initList();if(!pm.tpl.nodeListLayout){pm.tpl.nodeListLayout=new Ext.XTemplate('<tpl if="showHeader">','<div class="profile-header">','<div class="right">{headerRight}</div>','<table border="0">',"<tr>",'<td><img src="{headerIcon}" /><span class="title">{title}</span></td>',"</tr>","</table>","</div>","</tpl>",'<div class="profile-search"></div>','<table border="0" class="profile-buttons">',"<tr>",'<td class="btn"></td>','<td class="btn"></td>','<td class="btn"></td>','<td class="btn"></td>',"</tr>","</table>",'<div class="profile-list"></div>','<table border="0" class="profile-footer-buttons">',"<tr>",'<td class="btn"></td>','<td class="btn"></td>','<td class="btn"></td>','<td class="btn"></td>',"</tr>","</table>");pm.tpl.nodeListLayout.compile()}},initList:function(){var a=false;if(this.state.keywords){this.destroyGrpLists();if(!this.flatList){this.flatList=new pm.NodeListFlat({state:this.state,nodeDef:this.nodeDef,listUI:this.listUI,checkboxes:false});a=true}this.activeList=this.flatList}else{this.destroyFlatLists();if(!this.grpList){this.grpList=new pm.NodeListGrouped({nodeDef:this.nodeDef,state:this.state,listUI:this.listUI});a=true}this.activeList=this.grpList}if(a){this.activeList.on({load:{scope:this,fn:function(){if(typeof this.activeList.numRecords=="number"){this.headerRight=this.activeList.numRecords+" records"}else{this.headerRight=""}if(this.headerRightEl){this.headerRightEl.update(this.headerRight)}this.setSubTitle(this.headerRight)}},beforerender:{scope:this,fn:function(){this.listEl.update()}}});this.fireEvent("switchModes",this.activeList)}},doRender:function(){pm.NodeMgr.superclass.doRender.call(this);pm.tpl.nodeListLayout.append(this.el,{title:this.title,headerIcon:pm.app.iconPath+this.nodeDef.icons.view,showHeader:(this.hideHeader)?false:true});this.listEl=this.el.child("div.profile-list");var d=this.el.child("div.profile-search");if(!this.hideHeader){this.headerRightEl=this.el.child("div.profile-header div.right");this.headerRightEl.update(this.headerRight)}this.btnEls=this.el.query("td.btn");var e=this.listUI.getButtons();for(var c=0,a=Math.min(this.btnEls.length,e.length);c<a;c++){var b=new Ext.Button(e[c]);b.render(this.btnEls[c])}this.renderSearchForm(d);this.listEl.update(pm.app.loadingIndicator);this.activeList.render(this.listEl);this.on("switchModes",function(){this.listEl.update(pm.app.loadingIndicator);this.activeList.render(this.listEl)})},renderSearchForm:function(b){var c=new Ext.form.TextField({fieldLabel:"Search "+this.nodeDef.name+" Titles",name:"search",width:"95%",value:this.state.keywords||""});var a=new Ext.form.FormPanel({autoHeight:true,frame:true,layout:"form",labelAlign:"left",labelWidth:120,border:false,items:c,renderTo:b});c.on("specialkey",function(f,d){this.keywords=f.getValue();pm.state.navigate({keywords:this.keywords,page:1},true,false)},this)},aktivieren:function(a){pm.NodeMgr.superclass.aktivieren.call(this,a);this.initList();this.activeList.aktivieren(a)},deaktivieren:function(){pm.NodeMgr.superclass.deaktivieren.call(this);this.activeList.deaktivieren()},destroyFlatLists:function(){if(this.flatList){this.flatList.destroy();delete this.flatList}},destroyGrpLists:function(){if(this.grpList){this.grpList.destroy();delete this.grpList}},onDestroy:function(){this.destroyFlatLists();this.destroyGrpLists();pm.NodeMgr.superclass.onDestroy.call(this)}});pm.NodeListFlat=Ext.extend(pm.Page,{initComponent:function(){pm.NodeListFlat.superclass.initComponent.call(this);var a=[{name:"nid"},{name:"title"},{name:"type"},{name:"uid"},{name:"created"},{name:"changed"},{name:"categories"},{name:"tagline"}];if(this.nodeDef){for(var b=0;b<this.nodeDef.fields.length;b++){a.push({name:this.nodeDef.fields[b]})}}else{pm.log("The nodeDef was not passed to NodeListFlat.")}this.ds=new Ext.data.Store({proxy:new pm.SystemProxy({method:"nodes.getList"}),reader:new Ext.data.JsonReader({root:"records",totalProperty:"count",id:"nid"},a),baseParams:this.baseParams});this.ds.on("beforeload",function(){if(!this.ds.baseParams){this.ds.baseParams={}}this.ds.baseParams.keywords=this.state[this.statePrefix+"keywords"]||"";this.ds.baseParams.type=pm.util.getIf([this,"nodeDef","nodeType"])},this);this.ds.on("load",function(d,c,e){this.numRecords=this.ds.totalLength;if(d.reader.jsonData.term){this.setTitle(d.reader.jsonData.term.name)}this.loaded=true;this.loading=false;this.fireEvent("load",this)},this);if(!this.nodeListTpl){if(!pm.tpl.nodelist){pm.tpl.nodelist=new Ext.XTemplate('<div class="pm-list">','<table width="100%">','<tpl for=".">','<tr class="item">','<tpl if="showCheckboxes">','<td class="checkbox"><input type="checkbox" /></td>',"</tpl>",'<tpl if="icon">','<td class="icon"><img title="{typeName}" src="{icon}" /></td>',"</tpl>",'<td width="100%">','<div class="item {[values.completed === true ? "disabled" : ""]}">','<div class="title">','<span class="small right">{right}</span>',"{titleLink}","</div>",'<div class="small">{details}</div>','<div class="small tagline">{tagline}</div>',"</div>","</td>","</tr>","</tpl>","</div>");pm.tpl.nodelist.compile()}this.nodeListTpl=pm.tpl.nodelist}this.view=new Ext.DataView({tpl:this.nodeListTpl,store:this.ds,singleSelect:true,itemSelector:"tr.item",overClass:"item-over",emptyText:"No items to display",loadingText:"Loading",listUI:this.listUI,showCheckboxes:this.checkboxes,showIcons:this.icons});this.view.prepareData=function(d){var c=pm.nodes.getDef(d.type);d.titleLink='<span class="c">'+d.title+"</span>";if(c.listPrepare){d=c.listPrepare(d)}d.showCheckboxes=this.showCheckboxes;d.typeName=c.name;if(this.showIcons){d.icon=pm.app.iconPath+c.icons.view}else{d.icon=false}return d};this.view.on({click:{scope:this,preventDefault:true,fn:function(c,f,g,j){var k;if(k=j.getTarget("span.a",1,true)){pm.state.navigate(pm.state.parseLink(k.dom.id))}else{if(k=j.getTarget("td.checkbox",3,true)){var d=k.child("input");if(!j.getTarget("",1,true).is("input")){pm.util.toggleCheckbox(d)}else{d.blur()}}else{var h=this.ds.getAt(f).data;pm.piemenu.show({position:j.getXY(),scope:this,data:h,callback:function(i){var e=pm.nodes.getDef(h.type);switch(i){case"open":pm.state.navigate({path:e.paths.view,nid:h.nid});break;case"edit":pm.state.navigate({path:e.paths.edit,nid:h.nid});break;case"reply":var e=pm.nodes.getDef("comment");pm.state.navigate({path:e.paths.create,parent_nid:h.nid});break}}})}}}}});this.gEventsID=pm.app.events.id();pm.app.events.listen({id:this.gEventsID,listeners:[{type:"nodeEvent",scope:this,fn:function(c){switch(c.action){case"added":case"changed":case"deleted":if(this.isActive){this.load()}else{this.isDirty=true}break}}}]});if(!this.hidePager){this.pager=new pm.Pager({ds:this.ds,state:this.state,stateVars:{page:this.statePrefix+"page",limit:this.statePrefix+"limit"},enableShowAll:(this.pagerShowAll===false)?false:true})}this.loaded=false},getChecked:function(){},setTitle:function(a){this.title=a;this.fireEvent("setTitle",a,this)},load:function(a){if(!a){a={}}this.loading=true;this.loaded=false;this.ds.load(a)},doRender:function(){pm.NodeListFlat.superclass.doRender.call(this);this.view.render(this.el);if(this.pager){this.pager.render(this.el)}},aktivieren:function(d){this.isActive=true;var b=["page","limit","keywords","tid"];for(var c=0,a=b.length;c<a;c++){b[c]=this.statePrefix+b[c]}if(d&&pm.util.isChanged(this.state,d,b)){this.isDirty=true}this.state=Ext.apply(this.state,d);this.pager.state=this.state;if(this.isDirty){this.load()}},deaktivieren:function(){this.isActive=false},onDestroy:function(){pm.app.events.stopListening(this.gEventsID);if(this.view){this.view.destroy()}if(this.ds){this.ds.destroy()}if(this.pager){this.pager.destroy()}if(this.el){this.el.remove()}delete this.view;delete this.ds;delete this.pager;delete this.el;pm.NodeListFlat.superclass.onDestroy.call(this)}});pm.NodeListGrouped=Ext.extend(pm.Page,{initComponent:function(){pm.NodeListGrouped.superclass.initComponent.call(this);this.addEvents("load");if(!this.nodeDef){pm.log("The nodeDef was not passed to NodeListGrouped.");return}},load:function(a){if(!a){a={}}this.loading=true;this.loaded=false;pm.services.get({method:"nodes.getList",params:{type:this.nodeDef.nodeType,group:1},scope:this,success:function(b){this.groupDefs=b.groups;this.numRecords=b.count;this.loaded=true;this.loading=false;this.fireEvent("load",this);if(a.callback){a.callback.call(a.scope||this)}},failure:function(b){Ext.MessageBox.alert("Failed","Unable to load categories: "+b.message)}})},doRender:function(){pm.NodeListGrouped.superclass.doRender.call(this);this.renderGroups()},renderGroups:function(){this.destroyGroups();this.el.update();this.groups=[];this.renderGroupsRecur(this.groupDefs,this.el)},renderGroupsRecur:function(b,e,g){if(!b){return}for(var c=0,a=b.length;c<a;c++){var d=b[c];var f=new Ext.ux.TreeGroup({title:d.title+" ("+d.count+")",groupDef:d,bodyStyle:{padding:"0 0 0 30px"},collapsible:true,collapsed:true,loadingIndicator:true,renderTo:e});f.on("expand",this.onGroupExpand,this);this.groups.push(f)}if(g){pm.log("parentGroup remove indicator");g.removeLoadingIndicator();g.loadingIndicator=false}},onGroupExpand:function(a){var b=a.groupDef;if(b.groups&&!a.groups){this.renderGroupsRecur(b.groups,a.body.dom,a)}if(b.params&&!a.list){this.renderList(a)}a.un("expand",this.onGroupExpand,this)},renderList:function(a){if(!this.listID){this.listID=0}this.listID++;a.list=new pm.NodeListFlat({state:this.state,statePrefix:"id"+this.listID,nodeDef:this.nodeDef,baseParams:a.groupDef.params,listUI:this.listUI,showLoader:false});a.list.on({load:{scope:this,fn:function(){a.removeLoadingIndicator();a.loadingIndicator=false}}});a.list.load();a.list.render(a.body.dom)},aktivieren:function(c){pm.NodeListGrouped.superclass.aktivieren.call(this,c);pm.log("NodeListGrouped");if(pm.util.isChanged(this.state,c,["keywords"])){this.isDirty=true}this.state=c;if(this.isDirty){this.load({callback:function(){this.renderGroups()}})}if(this.groups){for(var b=0,a=this.groups.length;b<a;b++){var d=this.groups[b];if(d.list){d.list.aktivieren(c)}}}},activateLists:function(){},deaktivieren:function(){pm.NodeListGrouped.superclass.deaktivieren.call(this);if(this.groups){for(var b=0,a=this.groups.length;b<a;b++){var c=this.groups[b];if(c.list){c.list.deaktivieren()}}}},onDestroy:function(){pm.app.events.stopListening(this.gEventsID);this.destroyGroups();if(this.el){this.el.remove()}pm.NodeListGrouped.superclass.onDestroy.call(this)},destroyGroups:function(){if(this.groups){for(var b=0,a=this.groups.length;b<a;b++){var c=this.groups[b];if(c.list){c.list.destroy()}c.destroy()}delete this.groups}}});pm.NodeListTree=Ext.extend(pm.Page,{initComponent:function(){pm.NodeListTree.superclass.initComponent.call(this);this.addEvents({load:true,onCount:true})},doRender:function(){pm.NodeListTree.superclass.doRender.call(this);if(pm.app.isDebugging){this.debugEl=this.el.createChild({cls:"debug"})}var b=this.el;var a=function(l){var k=l.attributes};var f={field:"changed",method:"numeric",order:"desc"};var d=function(o){var k=o.attributes,l=o.getOwnerTree(),m={};if(!o.isRoot){m.loadNode=true;m.loadStats=true;if(l.loadFSummaries){m.loadFSummary=true}if(l.loadFRecords){m.loadFRecords=true}}m.nid=k.nid;return m};var j=function(l){var k=[];switch(l.attributes.type){case"comment":k.push({title:"edit"});k.push({title:"reply"});k.push({title:"delete"});break;default:k.push({title:"view"})}return k};var h=function(k){};var c=function(n,m){if(n.isRoot){return}if(!m){m={}}var l=pm.nodes.getDef(n.attributes.type);if(m.node){n.pmNodeObj=pm.nodes.getNodeObj({nid:n.attributes.nid,nodeDef:l,data:m.node});if(l.ui&&l.ui.teaser){n.pmNodeTeaser=new l.ui.teaser({nodeDef:l,nodeObj:n.pmNodeObj})}n.pmNodeObj.loadMore({attr:"financialSummary",data:m.f_summary});if(n.pmNodeTeaser){var k=n.pmNodeTeaser.getTeaser();n.setTeaser('<div class="clickedit" title="Click to edit">'+k+"</div>")}else{n.setTeaser("No details available for this "+l.name.toLowerCase())}}if(m.stats){n.updateMarks(m.stats)}};var g=function(k){pm.nodes.initTreeNodeEditor({treeNode:k,mode:"edit"})};var e=function(m,l){var k=pm.nodes.getDef(m.attributes.type);var n=l.firstChild.textContent;switch(n){case"edit":pm.nodes.initTreeNodeEditor({treeNode:m,mode:"edit"});break;case"reply":pm.nodes.initTreeNodeEditor({treeNode:m,mode:"reply"});break;case"delete":m.pmNodeObj=pm.nodes.getNodeObj({nid:m.attributes.nid});m.pmNodeObj.load({scope:this,callback:function(){m.pmNodeObj.deleteConfirm({scope:this,success:function(){pm.log("Node deleted -- TODO: Add handler for this event")}})}});break;case"view":pm.state.navigate({path:k.paths.view,nid:m.attributes.nid});break;case"reload":m.reload();break}};var i={groupOrder:{field:"title",method:"alpha",order:"asc",sticky:["organization","individual","project"]},groupConfig:function(k){var m=pm.nodes.getDef(k.type);if(m){var l="icon-"+m.nodeType}else{var l=""}var n={key:k.type,nodeDef:m,iconCls:l,optional:true,title:m.namePlural,nodeOrder:f,nodeConfig:a};switch(k.type){case"event":n.groupConfig=function(o){var p=new Date(o.event_start*1000);var r=Ext.util.Format.date(p,"Y");var s={key:r,title:r,nodeOrder:{field:"event_start",method:"numeric",order:"desc"}};var p=new Date();var q=Ext.util.Format.date(p,"Y");if(r<q-1){s.collapsed=true}return s};break;case"project":n.groupConfig=function(o){var p={key:pm.util.getIf([o,"project_progress","tid"])||"other",collapsed:true,nodeOrder:f,nodeConfig:a};switch(pm.util.getIf([o,"project_progress","name"])){case"Current Projects":p.title="Current Projects";p.collapsed=false;break;default:p.title=pm.util.getIf([o,"project_progress","name"])||"Other"}return p};n.groupOrder={sticky:["Current Projects","Bidding Projects","Potential Projects"],field:"title",method:"alpha",order:"asc"};break}return n}};this.tree=new Ext.ux.TreePanel({renderTo:b,autoHeight:true,border:false,baseParams:{},loadFSummaries:true,loadFRecords:true,nodeParams:d,idField:"nid",dataUrl:pm.services.url("nodes.getList"),root:new Ext.ux.AsyncTreeNode({nid:this.nodeObj.nid,id:this.nodeObj.nid,title:this.nodeObj.data.title,children:this.nodeObj.data.children}),preloadData:this.nodeObj.data.children,filters:this.filters,filterRootOnly:true,animate:false,autoScroll:false,containerScroll:true,defaultText:"No items to display.",getLinks:j,onNodeInit:h,onNodeLoad:c,onClickText:g,onClickLink:e,grouping:i});this.tree.on({onCount:{fn:function(k){this.fireEvent("onCount",k)},scope:this}});if(this.tree.childCount){this.fireEvent("onCount",this.tree.childCount)}if(pm.app.isDebugging){this.debugBtn=new Ext.Button({renderTo:this.debugEl,text:"Reload",scope:this,handler:function(){this.tree.root.reload()}})}pm.app.events.listen({id:pm.app.events.id(),listeners:[{type:"nodeEvent",scope:this,fn:function(l){switch(l.action){case"changed":if(l.whatChanged.parent){var k=this.tree.getNodeById(pm.util.getIf([l.node.lastData,"parent","nid"]));if(k){k.reload()}var m=this.tree.getNodeById(pm.util.getIf([l.node.data,"parent","nid"]));if(m){m.reload()}}else{var n=this.tree.getNodeById(l.node.data.nid);if(n){n.setTitle(l.node.data.title);if(n.pmNodeTeaser){n.setTeaser(n.pmNodeTeaser.getTeaser())}}}break;case"added":var m=this.tree.getNodeById(pm.util.getIf([l.node.data,"parent","nid"]));if(m){m.reload()}break;case"deleted":var m=this.tree.getNodeById(pm.util.getIf([l.node.data,"parent","nid"]));if(m){m.reload()}break}}}]})},onDestroy:function(){this.tree.destroy();this.el.remove();pm.NodeListTree.superclass.onDestroy.call(this)}});pm.NodeListChildren=Ext.extend(pm.NodeListTree,{initComponent:function(){pm.NodeListChildren.superclass.initComponent.call(this)},load:function(a){if(!a){a={}}this.loaded=false;this.loading=true;this.nodeObj.loadMore({attr:"children",method:"nodes.getList",params:{},cache:true,scope:this,callback:function(){this.loaded=true;this.loading=false;if(a.callback&&a.scope){a.callback.call(a.scope)}}})}});pm.Dashboard=Ext.extend(pm.Page,{initComponent:function(){pm.Dashboard.superclass.initComponent.call(this);if(this.state.uid){}else{this.nodeObj=pm.app.currentUser}this.widgetsLeft=new pm.WidgetMgr({panelID:"dashboard",regionID:"left",state:this.state,uid:this.nodeObj.data.account.uid,nid:this.nodeObj.data.nid,defaultWidgets:["myEmails","myTasks"]});this.widgetsRight=new pm.WidgetMgr({panelID:"dashboard",regionID:"right",state:this.state,params:{uid:this.nodeObj.data.account.uid},defaultWidgets:["myEvents","myNewsFeed"]});if(!pm.tpl.dashboard){pm.tpl.dashboard=new Ext.XTemplate('<table class="profile" width="100%" border="0" cellpadding="0" cellspacing="0">',"<tr>",'<tpl if="picture">','<td valign="top"><img class="profile-picture" src="{picture}" /></td>',"</tpl>",'<td width="100%" valign="top">','<div class="links" style="float: right;"></div>','<div class="profile-title">{name}</div>','<div class="profile-status"></div>',"</td>","</tr>","</table>",'<table width="100%">',"<tr>",'<td valign="top" width="50%" class="left"></td>','<td valign="top" width="50%" class="right"></td>',"</tr>","</table>");pm.tpl.dashboard.compile()}},doRender:function(){pm.Dashboard.superclass.doRender.call(this);pm.tpl.dashboard.overwrite(this.el,{picture:pm.util.getIf([this.nodeObj.data,"picture","small"]),name:this.nodeObj.data.title});var c=this.el.select("div.links",true).elements[0];var d=pm.app.nodeDefs.individual;pm.app.initActionLinks(c,[{id:"gotoProfile",title:"View profile",icon:d.icons.view,callback:function(e){pm.state.navigate({path:d.paths.view,nid:this.nodeObj.data.nid})}}],this);var a=this.el.select("td.left",true).elements[0];var b=this.el.select("td.right",true).elements[0];this.widgetsLeft.render(a);this.widgetsRight.render(b)},aktivieren:function(a){pm.Dashboard.superclass.aktivieren.call(this,a);this.widgetsLeft.aktivieren(a);this.widgetsRight.aktivieren(a)},deaktivieren:function(){pm.Dashboard.superclass.deaktivieren.call(this);this.widgetsLeft.deaktivieren();this.widgetsRight.deaktivieren()},onDestroy:function(){this.widgetsLeft.destroy();this.widgetsRight.destroy();this.el.remove();this.nodeObj=null;pm.Dashboard.superclass.onDestroy.call(this)}});pm.ChangeLog=Ext.extend(pm.Page,{initComponent:function(){pm.ChangeLog.superclass.initComponent.call(this);var a=[{name:"id"},{name:"text"},{name:"icon"},{name:"ref"},{name:"day"},{name:"time"}];this.ds=new Ext.data.Store({proxy:new pm.SystemProxy({method:"change_log.getList"}),reader:new Ext.data.JsonReader({root:"records",totalProperty:"count",id:"id"},a),baseParams:{uid:this.uid,nid:this.nid}});this.ds.on("load",function(c,b,d){this.loaded=true;this.loading=false;this.fireEvent("load",this);this.initEvents()},this);if(!pm.tpl.changeLog){pm.tpl.changeLog=new Ext.XTemplate('<div class="pm-list pm-list-icons">','<tpl for=".">','<tpl if="values.day">','<div class="group">{day}</div>',"</tpl>",'<tpl if="!values.day">','<div class="divider"></div>',"</tpl>",'<div class="item">','<div class="left"><img src="{icon}" /></div>','<div class="right">','<div>{text}. <span class="small">{time}</span></div>',"</div>","</div>","</tpl>","</div>");pm.tpl.changeLog.compile()}this.view=new Ext.DataView({tpl:pm.tpl.changeLog,singleSelect:false,store:this.ds,itemSelector:"div.item",emptyText:"No updates to display",loadingText:"Loading changes...",nid:this.nid});this.view.prepareData=function(f){if(this.previousDay==f.day){f.day=""}else{this.previousDay=f.day}if(pm.app.icons[f.icon]){f.icon=pm.app.iconPath+pm.app.icons[f.icon]}else{f.icon=Ext.BLANK_IMAGE_URL}for(var d in f.ref){var b=f.ref[d];if(b){var c=new RegExp("{"+d+"}","g");if(b.type=="node"){if(b.id==this.nid){f.text=f.text.replace(c,b.title)}else{var e=pm.nodes.getDef(b.node_type);if(e&&e.paths&&e.paths.view){f.text=f.text.replace(c,pm.state.navLink({text:b.title,state:{path:pm.nodes.getDef(b.node_type).paths.view,nid:b.id}}))}else{f.text=f.text.replace(c,b.title)}}}else{f.text=f.text.replace(c,b.title)}}}return f},this.view.on("click",function(b,d,f,g){var c=Ext.get(f);var h=Ext.get(g.getTarget());if(h.is("span.a")){pm.state.navigate(pm.state.parseLink(h.dom.id))}},this,{preventDefault:true});if(!this.hidePager){this.pager=new pm.Pager({ds:this.ds,state:this.state,enableShowAll:false,stateVars:{page:"clpage",limit:"cllimit"}})}this.loaded=false},load:function(a){this.loading=true;this.loaded=false;this.ds.load(a)},initEvents:function(){if(!this.gEventsID){this.gEventsID=pm.app.events.id();pm.app.events.listen({id:this.gEventsID,listeners:[{type:"nodeEvent",scope:this,fn:function(a){switch(a.action){case"added":case"changed":case"deleted":if(this.isActive){this.load()}else{this.isDirty=true}break}}},{type:"subscriptionEvent",scope:this,fn:function(a){if(a.subscription.uid==this.uid){if(this.isActive){this.load()}else{this.isDirty=true}}}}]})}},doRender:function(){pm.ChangeLog.superclass.doRender.call(this);this.view.render(this.el);if(this.pager){this.pager.render(this.el)}},aktivieren:function(b){this.isActive=true;if(this.isDirty){this.load()}else{var a=["clpage","cllimit"];if(b&&pm.util.isChanged(this.state,b,a)){this.state=b;this.pager.state=this.state;this.load()}}},deaktivieren:function(){this.isActive=false},destroy:function(){pm.app.events.stopListening(this.gEventsID);if(this.view){this.view.destroy()}if(this.ds){this.ds.destroy()}if(this.pager){this.pager.destroy()}if(this.el){this.el.remove()}delete this.view;delete this.ds;delete this.pager;delete this.el}});pm.RelatedContent=Ext.extend(pm.Page,{initComponent:function(){pm.RelatedContent.superclass.initComponent.call(this);this.addEvents({load:true,setTitle:true});var b=this.nodeObj.data.type;var c=this.nodeType;var d=[];var a=[];switch(b){case"individual":d=["organization"];break;case"organization":d=["organization"];break;case"project":d=["individual","organization"];break;case"inventory":d=["task","individual","organization","project","event","document"];break;case"document":d=["inventory","task","individual","organization","project","event","document"];a=["comment"];break;case"event":a=["comment","task"];break;default:d=["individual","organization","project"]}if(b!="comment"){d.push(b)}if(d.length){if(pm.util.inArray(c,d)!=-1){this.hide();return false}}if(a.length){if(pm.util.inArray(c,a)==-1){this.hide();return false}}this.nodeDef=pm.nodes.getDef(c);this.list=new pm.NodeListChildren({owner:this.owner,nodeObj:this.nodeObj,filters:{type:this.nodeType}});this.list.on({onCount:{fn:function(e){this.count=e;this.setTitle()},scope:this}});if(this.list.childCount){this.count=this.list.childCount}this.setTitle()},load:function(a){if(this.list){this.list.load(a)}},setTitle:function(){this.title=this.nodeDef.namePlural;if(typeof this.count=="number"){var a=this.title+" ("+this.count+")"}else{var a=this.title}this.fireEvent("setTitle",a)},doRender:function(){this.list.render(this.el)},aktivieren:function(a){pm.RelatedContent.superclass.aktivieren.call(this,a);if(this.list){this.list.aktivieren(a)}},deaktivieren:function(){pm.RelatedContent.superclass.deaktivieren.call(this);if(this.list){this.list.deaktivieren()}},onDestroy:function(){if(this.list){this.list.destroy()}pm.RelatedContent.superclass.onDestroy.call(this)}});pm.TimeTracker=Ext.extend(pm.Page,{initComponent:function(){pm.TimeTracker.superclass.initComponent.call(this);switch(this.nodeObj.data.type){case"project":case"task":this.show();break;default:this.hide()}this.addEvents({load:true});this.form=new pm.TimeTrackerForm({data:{parent_nid:this.nodeObj.data.nid}})},load:function(a){if(!a){a={}}this.loading=true;this.loaded=false;pm.services.get({method:"time.getSummary",params:{nid:this.nodeObj.data.nid},scope:this,success:function(b){this.byUser=b.users;this.totalHours=b.total_hours;this.loading=false;this.loaded=true;this.fireEvent("load");if(a.callback){a.callback.call(a.scope||this)}},failure:function(b){Ext.MessageBox.alert("Failed","Unable to load time records: "+b.message)}})},doRender:function(){pm.TimeTracker.superclass.doRender.call(this);this.groupsEl=this.el.createChild({});this.renderGroups();this.totalEl=this.el.createChild({cls:"time-total"});this.renderTotal();this.formEl=this.el.createChild({cls:"time-form",html:'<div class="title">Time Input</div>'});this.form.render(this.formEl);this.initGlobalListeners()},renderTotal:function(){this.totalEl.update('<span class="label">Total: </span>'+this.totalHours+" hours")},renderGroups:function(){this.groupsEl.update();if(!pm.tpl.timeRecords){pm.tpl.timeRecords=new Ext.XTemplate('<div class="pm-list time-records">','<tpl for=".">','<div class="item">','<div class="float-right">{icons}</div>','<div><span class="date a">{date}</span> / <span class="hours">{hours}</span></div>','<div class="desc">{description}</div>',"</div>","</tpl>","</div>");pm.tpl.timeRecords.compile()}this.groups=[];if(this.byUser){for(var b=0,a=this.byUser.length;b<a;b++){var c=this.byUser[b];var d=new Ext.ux.TreeGroup({title:c.name+": "+c.hours+" hrs",uid:c.uid,bodyStyle:{padding:"0 0 0 10px"},collapsible:true,collapsed:true,renderTo:this.groupsEl});d.on("expand",function(e){if(!e.ds){this.renderRecords(e)}},this);this.registerGroup(d)}}},renderRecords:function(a){a.ds=new Ext.data.Store({proxy:new pm.SystemProxy({method:"time.getRecords"}),reader:new Ext.data.JsonReader({root:"records",totalProperty:"count",id:"tid"},[{name:"tid"},{name:"entrydate"},{name:"hours"},{name:"description"}]),baseParams:{nid:this.nodeObj.data.nid,uid:a.uid}});a.view=new Ext.DataView({tpl:pm.tpl.timeRecords,singleSelect:false,store:a.ds,itemSelector:"div.item",emptyText:"No time records to display",loadingText:"Loading time records..."});a.view.prepareData=function(b){var c=b.entrydate;b.date=c.month+"/"+c.day+"/"+c.year.substr(2);if((b.hours*1)==1){b.hours="1 hour"}else{b.hours=b.hours+" hours"}b.icons='<span class="a del"><img src="'+pm.app.iconPath+pm.app.icons.del+'" /></a></span>';return b};a.view.on("click",function(b,d,f,h){var c=Ext.get(f);var j=h.getTarget("span.a",null,true);if(j&&j.is("span.a")){if(j.is(".date")){var g=b.store.getAt(d).data;this.form.data=g;this.form.load({callback:function(){this.loadData()}})}else{if(j.is(".del")){var g=b.store.getAt(d).data;this.form.data=g;this.form.data.parent_nid=this.nodeObj.data.nid;this.form.deleteRecord(j)}else{pm.state.navigate(pm.state.parseLink(j.dom.id))}}}},this,{preventDefault:true});a.view.render(a.body);a.ds.load()},initGlobalListeners:function(){this.gEventsID=pm.app.events.id();pm.app.events.listen({id:this.gEventsID,listeners:[{type:"timeEvent",scope:this,fn:function(a){if(a.action=="added"||a.action=="changed"||a.action=="deleted"){if(a.data.parent_nid==this.nodeObj.data.nid){this.load({scope:this,callback:function(){this.renderGroups();this.renderTotal()}})}}}}]})},registerGroup:function(a){this.groups[a.uid]=a},unregisterGroup:function(a){delete this.groups[a.uid]}});pm.TimeTrackerForm=Ext.extend(pm.Page,{initComponent:function(){pm.TimeTrackerForm.superclass.initComponent.call(this);if(!this.data){this.data={}}this.addEvents({reset:true,load:true,save:true,"delete":true});this.on("save",function(){var a=(this.lastData.tid)?"changed":"added";pm.app.events.fireEvent("timeEvent",{action:a,data:this.data});pm.alerts.add({msg:"Time record saved ("+this.data.hours+" hours)",icon:pm.app.iconPath+pm.app.icons.time})},this);this.on("delete",function(){pm.app.events.fireEvent("timeEvent",{action:"deleted",data:this.data});pm.alerts.add({msg:"Time record deleted ("+this.data.hours+" hours)",icon:pm.app.iconPath+pm.app.icons.time})},this)},load:function(a){this.loading=true;this.loaded=false;if(this.data.tid){pm.services.get({method:"time.getRecord",params:{tid:this.data.tid},scope:this,success:function(b){this.processData(b.data);if(a.callback){a.callback.call(a.scope||this)}},failure:function(b){Ext.MessageBox.alert("Failed","Unable to load: "+b.message)}})}else{this.loading=false;this.loaded=true;if(a.callback){a.callback.call(a.scope||this)}}},processData:function(a){this.lastData=pm.util.clone(this.data);Ext.apply(this.data,a);this.data.parent_nid=a.nid;this.loading=false;this.loaded=true;this.fireEvent("load")},doRender:function(){pm.TimeTrackerForm.superclass.doRender.call(this);if(!this.data){this.data={}}pm.nodes.getList({type:"individual",isUser:true,scope:this,callback:function(a){this.ds=a;this.renderForm()}})},loadData:function(){var a=this.form.getForm();a.setValues({user:this.data.user.title,entrydate:this.data.entrydate.month+"/"+this.data.entrydate.day+"/"+this.data.entrydate.year,hours:this.data.hours,description:this.data.description});var b=this.el.getY();b=(b>50)?b-50:0;window.scrollTo(0,b)},renderForm:function(){this.form=new Ext.FormPanel({labelAlign:"top",buttonAlign:"left",frame:false,border:false,bodyBorder:false,plain:true,width:165,items:[{xtype:"combo",fieldLabel:"Individual",name:"user",store:this.ds,displayField:"title",valueField:"nid",forceSelection:true,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,anchor:"-10",value:pm.app.currentUser.data.title},{layout:"column",border:false,items:[{columnWidth:0.55,layout:"form",border:false,items:{xtype:"datefield",fieldLabel:"Date",name:"entrydate",anchor:"-13",value:Ext.util.Format.date(Date())}},{columnWidth:0.45,layout:"form",border:false,items:{xtype:"numberfield",fieldLabel:"Hours",name:"hours",anchor:"-10"}}]},{xtype:"textfield",fieldLabel:"Description",name:"description",anchor:"-10"}],buttons:this.getButtons()});this.form.render(this.el)},getButtons:function(){var a=[];a.push({text:"Save",scope:this,handler:this.onSave});a.push({text:"Clear",scope:this,handler:this.onReset});return a},onSave:function(){var a=this.form.getForm().getValues(false);if(this.data.parent_nid){pm.services.get({method:"time.saveRecord",params:Ext.apply({tid:this.data.tid,parent_nid:this.data.parent_nid},a),scope:this,success:function(b){this.processData(b.data);this.fireEvent("save");this.onReset()},failure:function(b){Ext.MessageBox.alert("Failed","Unable to save: "+b.message)}})}else{Ext.MessageBox.alert("Failed","Unable to save: The content ID of the parent item could not be found!")}},deleteRecord:function(a){this.deleteConfirm({animEl:a,scope:this,success:function(){this.onReset()}})},onDelete:function(a,b){this.deleteConfirm({animEl:a.el,scope:this,success:function(){this.onReset()}})},deleteConfirm:function(a){if(!a){a={}}if(!this.data.tid){Ext.MessageBox.alert("Failed","Unable to delete: The record ID of this item could not be found!");return}Ext.MessageBox.show({title:"Confirm Delete",msg:"Are you sure you want to delete this time record? There is no undo.",buttons:Ext.MessageBox.YESNO,animEl:a.animEl||"",scope:this,fn:function(b){if(b=="yes"){this.doDelete({scope:a.scope,success:a.success})}}})},doDelete:function(a){pm.services.post({method:"time.deleteRecord",params:{tid:this.data.tid},scope:this,success:function(b){this.fireEvent("delete");if(typeof a.success=="function"){a.success.call(a.scope||this)}},failure:function(b){Ext.MessageBox.alert("Failed","Unable to delete: "+b.message)}})},onReset:function(){var b=this.data.parent_nid;this.data={};this.data.parent_nid=b;var a=this.form.getForm();a.reset()},onDestroy:function(){pm.TimeTrackerForm.superclass.onDestroy.call(this);this.loaded=false;this.data={}}});pm.Delegation=Ext.extend(pm.Page,{initComponent:function(){pm.Delegation.superclass.initComponent.call(this);this.title="Delegations";this.ds=new Ext.data.Store({proxy:new pm.SystemProxy({method:"delegation.getDelegations"}),reader:new Ext.data.JsonReader({root:"records",totalProperty:"count",id:"nid"},[{name:"nid"},{name:"type"},{name:"title"},{name:"date"},{name:"assigned_to"}]),baseParams:{nid:this.nodeObj.nid}});if(!pm.tpl.delegation){pm.tpl.delegation=new Ext.XTemplate('<div class="pm-list pm-list-icons">','<tpl for=".">','<div class="item">','<div class="left"><img src="{icon}" /></div>','<div class="right">',"<div>{title}</div>",'<div class="small">Assigned to {assignedTo} on {when}</div>',"</div>","</div>","</tpl>","</div>");pm.tpl.delegation.compile()}this.view=new Ext.DataView({tpl:pm.tpl.delegation,singleSelect:false,store:this.ds,itemSelector:"div.item",overClass:"item-over",emptyText:"No delegated items to display",loadingText:"Loading delegated items...",nid:this.nodeObj.nid});this.view.prepareData=function(b){var a=pm.nodes.getDef(b.type);b.title=pm.state.navLink({text:b.title,state:{path:a.paths.view,nid:b.nid}});var c=b.assigned_to;b.assignedTo=pm.state.navLink({text:c.title,state:{path:pm.nodes.getDef(c.type).paths.view,nid:c.nid}});b.when=pm.util.formatDate(b.date);b.icon=pm.app.iconPath+a.icons.view;return b};this.view.on("click",function(a,b,c,d){var f=d.getTarget("",1,true);if(f.is("span.a")){pm.state.navigate(pm.state.parseLink(f.dom.id))}},this,{preventDefault:true});this.gEventsID=pm.app.events.id();pm.app.events.listen({id:this.gEventsID,listeners:[{type:"nodeEvent",scope:this,fn:function(a){switch(a.action){case"added":case"changed":case"deleted":if(this.isActive){this.load()}else{this.isDirty=true}break}}}]})},load:function(a){this.loading=true;this.loaded=false;this.ds.load({scope:this,callback:function(c,b,d){if(this.ds.getCount()>0){this.show()}else{this.hide()}this.loaded=true;this.loading=false}})},doRender:function(){pm.Delegation.superclass.doRender.call(this);var a=this.el.createChild({html:this.nodeObj.data.title+" has delegated the following:"});this.view.render(this.el)},aktivieren:function(){this.isActive=true;if(this.isDirty){this.load()}},deaktivieren:function(){this.isActive=false},destroy:function(){pm.app.events.stopListening(this.gEventsID);this.view.destroy();this.ds.destroy();this.el.remove()}});pm.CalendarPage=Ext.extend(pm.TabPage,{initComponent:function(){pm.CalendarPage.superclass.initComponent.call(this);this.add({title:"Calendars",iconCls:"icon-cal",params:{title:"Calendars",cls:"padded10"},handler:pm.GCalendars});this.add({title:"Events",iconCls:"icon-event",params:{cls:"padded10",nodeDef:pm.app.nodeDefs.event,hideHeader:true},handler:pm.NodeMgr});this.add({title:"Settings",iconCls:"icon-connect",params:{cls:"padded10"},bodyStyle:{padding:"10px"},html:"Coming soon: Calendar and events settings and configurations page"})}});pm.GCalendar=Ext.extend(pm.Page,{initComponent:function(){pm.GCalendar.superclass.initComponent.call(this);this.title="Calendar";switch(this.nodeObj.data.type){case"individual":this.show();break;default:this.hide()}},load:function(a){if(!a){a={}}this.loading=true;this.loaded=false;if(this.nid){pm.services.get({method:"events.getGCalendar",params:{nid:this.nid},scope:this,success:function(b){this.gc_private_address=b.data.gc_private_address;this.loaded=true;this.loading=false;if(a.callback){a.callback.call(a.scope||this,this)}},failure:function(b){Ext.MessageBox.alert("Failed","Unable to load: "+b.message)}})}else{if(this.gc_private_address){if(a.callback){a.callback.call(a.scope||this,this)}}}},doRender:function(){if(!this.gc_private_address){return false}pm.GCalendar.superclass.doRender.call(this);if(!pm.tpl.gc){pm.tpl.gc=new Ext.Template('<iframe src="{baseUrl}&amp;{attributes}" style="border-width:0" width="{width}" height="600" frameborder="0" scrolling="no"></iframe>');pm.tpl.gc.compile()}var a=Ext.urlEncode({showTitle:0,width:(this.gcalWidth>0)?this.gcalWidth:700,height:600,wkst:1,ctz:"America%2FLos_Angeles"});pm.tpl.gc.overwrite(this.el,{baseUrl:this.gc_private_address,attributes:a,width:this.gcalWidth||"700"})}});pm.GCalendars=Ext.extend(pm.Page,{initComponent:function(){pm.GCalendars.superclass.initComponent.call(this);this.ds=new Ext.data.Store({proxy:new pm.SystemProxy({method:"events.getGCalendars"}),reader:new Ext.data.JsonReader({root:"records",totalProperty:"count",successProperty:"success",id:"cid"},[{name:"cid"},{name:"nid"},{name:"title"}])})},load:function(a){if(!a){a={}}this.loading=true;this.loaded=false;this.ds.load({scope:this,callback:function(b,c,d){if(d){this.loaded=true;this.loading=false;this.fireEvent("load",this);if(a.callback){a.callback.call(a.scope||this)}}else{Ext.MessageBox.alert("Error","Unable to load calendars list")}}})},doRender:function(){this.form=new Ext.Panel({border:false,items:{layout:"form",labelAlign:"left",labelWidth:55,border:false,items:{xtype:"combo",fieldLabel:"Calendar",name:"calendar",store:this.ds,displayField:"title",forceSelection:true,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,width:"200",valueField:"nid"}},renderTo:this.el});this.iframeCt=this.el.createChild({cls:"gc-iframe"});var c=this.form.findByType("combo")[0];c.on("select",function(f,d,e){f.setValue(d.json.title);this.renderIframe(d.json)},this);var a=this.ds.findBy(function(d,e){if(d.data.nid==pm.app.currentUser.data.nid){return true}},this);if(a>=0){var b=this.ds.getAt(a);c.setValue(b.json.title);this.renderIframe(b.json)}},renderIframe:function(b){if(!pm.tpl.gc){pm.tpl.gc=new Ext.Template('<iframe src="{baseUrl}{attributes}" width="720" height="600" frameborder="0" style="border-width: 0pt;" scrolling="no"></iframe>');pm.tpl.gc.compile()}var a=Ext.urlEncode({showTitle:0,showNav:0,showTabs:0,showCalendars:0,height:600,wkst:1,bgcolor:"%23FFFFFF",color:"%232952A3",ctz:"America%2FLos_Angeles"});pm.tpl.gc.overwrite(this.iframeCt,{baseUrl:b.gc_private_address,attributes:""})},onDestroy:function(){this.ds.destroy();pm.GCalendars.superclass.onDestroy.call(this)}});pm.FinancialSummary=Ext.extend(pm.Page,{initComponent:function(){pm.FinancialSummary.superclass.initComponent.call(this);switch(this.nodeObj.data.type){case"project":case"organization":case"event":this.show();break;default:this.hide()}this.addEvents({load:true})},load:function(a){if(!a){a={}}this.loading=true;this.loaded=true;pm.services.get({method:"finances.getSummary",params:{nid:this.nid},scope:this,success:function(b){this.data=b.summary;this.loaded=true;this.loading=false;this.fireEvent("load");if(a.callback){a.callback.call(a.scope||this,this)}},failure:function(b){Ext.MessageBox.alert("Failed","Unable to load: "+b.message)}})},doRender:function(){pm.FinancialSummary.superclass.doRender.call(this);if(!pm.tpl.financialSummary){pm.tpl.financialSummary=new Ext.Template('<div class="fncl fncl-sum">','<div class="tooltip" title="The sum of budget records">','<div class="title">Estimated Budget: </div>','<div class="value">','<span class="amount green">{estimated_budget:usMoney}</span>',"</div>",'<div class="details hide"></div>',"</div>",'<div class="tooltip" title="The sum of discounts">','<div class="title">Discount: </div>','<div class="value">','<span class="amount red">{discounts:usMoney}</span>',"</div>","</div>",'<div class="tooltip" title="The estimated budget minus the sum of discounts">','<div class="title">Actual Budget: </div>','<div class="value"><span class="amount green">{actual_budget:usMoney}</span></div>',"</div>",'<div class="tooltip" title="The sum of expense records">','<div class="title">Expenses: </div>','<div class="value"><span class="amount red">{expenses:usMoney}</span></div>',"</div>",'<div class="tooltip" title="The sum of invoices">','<div class="title">Invoiced: </div>','<div class="value"><span class="amount green">{invoices:usMoney}</span></div></div>','<div class="tooltip" title="The sum of payments received">','<div class="title">Payments Received: </div>','<div class="value"><span class="amount green">{payments:usMoney}</span></div></div>','<div class="tooltip" title="The sum of invoices minus the sum of payments received">','<div class="title">Accounts Receivable: </div>','<div class="value"><span class="amount green">{accounts_receivable:usMoney}</span></div></div>','<div class="tooltip" title="The sum of the invoices minus the sum of expenses">','<div class="title">Profit: </div>','<div class="value"><span class="amount green">{profit:usMoney}</span></div></div>','<div class="tooltip" title="Profit divided by the sum of invoices">','<div class="title">Gross Margin Percentage: </div>','<div class="value"><span class="percent green">{gross_margin}%</span></div>',"</div>","</div>");pm.tpl.financialSummary.compile()}pm.tpl.financialSummary.overwrite(this.el,this.data);this.on("load",function(){pm.tpl.financialSummary.overwrite(this.el,this.data)},this);this.gEventsID=pm.app.events.id();pm.app.events.listen({id:this.gEventsID,listeners:[{type:"financesEvent",scope:this,fn:function(a){if(a.action=="added"||a.action=="changed"||a.action=="deleted"){if(this.isVisible){this.load()}else{this.isDirty=true}}}}]})},aktivieren:function(a){this.isVisible=true;if(this.isDirty){this.load()}},deaktivieren:function(a){this.isVisible=false},onDestroy:function(){pm.app.events.stopListening(this.gEventsID);pm.FinancialSummary.superclass.onDestroy.call(this)}});pm.FinancialRecords=Ext.extend(pm.Page,{initComponent:function(){pm.FinancialRecords.superclass.initComponent.call(this);switch(this.nodeObj.data.type){case"project":case"organization":case"event":this.show();break;default:this.hide()}this.addEvents({load:true});var a=[{name:"rid"},{name:"amount"},{name:"type"},{name:"description"},{name:"created"}];this.ds=new Ext.data.Store({proxy:new pm.SystemProxy({method:"finances.getRecords"}),reader:new Ext.data.JsonReader({root:"records",totalProperty:"count",id:"rid"},a),baseParams:{nid:this.nid}});this.ds.on("load",function(c,b,d){this.loaded=true;this.loading=false;this.fireEvent("load",this)},this)},setTitle:function(a){this.title=a;this.fireEvent("setTitle",a,this)},load:function(a){if(!a){a={}}this.loading=true;this.loaded=false;this.ds.load(a)},doRender:function(){pm.FinancialRecords.superclass.doRender.call(this);var a=this.el;if(!pm.tpl.financialRecords){pm.tpl.financialRecords=new Ext.XTemplate('<div class="pm-list fncl fncl-records">','<table width="100%">','<tpl for=".">','<tr class="item">','<td class="date">{date}</div>','<td class="type">{type}</div>','<td class="desc">{description}</div>','<td class="amount {color}" align="right">{amount}</div>',"</tr>","</tpl>","</table>","</div>");pm.tpl.financialRecords.compile()}this.view=new Ext.DataView({tpl:pm.tpl.financialRecords,singleSelect:false,store:this.ds,itemSelector:"tr.item",overClass:"item-over",emptyText:"No financial records to display",loadingText:"Loading financial records...",nid:this.nid});this.view.prepareData=function(b){b.color=pm.finances.getColorByType(b.type);b.date=b.created.month+"/"+b.created.day+"/"+b.created.year.substr(2);b.date=pm.state.navLink({text:b.date,state:{path:["finances","edit"],rid:b.rid}});b.amount=pm.util.usMoney(b.amount,true);return b};this.view.on("click",function(b,d,f,g){var c=Ext.get(f);var h=Ext.get(g.getTarget("",a));if(h.is("span.a")){pm.state.navigate(pm.state.parseLink(h.dom.id))}},this,{preventDefault:true});this.view.render(this.el);this.gEventsID=pm.app.events.id();pm.app.events.listen({id:this.gEventsID,listeners:[{type:"financesEvent",scope:this,fn:function(b){if(b.action=="added"||b.action=="changed"||b.action=="deleted"){if(this.isActive){this.load()}else{this.isDirty=true}}}}]})},aktivieren:function(a){this.isActive=true;if(this.isDirty){this.load()}},deaktivieren:function(){this.isActive=false},onDestroy:function(){pm.app.events.stopListening(this.gEventsID);if(this.view){this.view.destroy()}if(this.ds){this.ds.destroy()}if(this.el){this.el.remove()}delete this.view;delete this.ds;delete this.el;pm.FinancialRecords.superclass.onDestroy.call(this)}});pm.FinancialForm=Ext.extend(pm.Page,{initComponent:function(){pm.FinancialForm.superclass.initComponent.call(this);if(!this.data){this.data={}}if(this.state.rid){this.isNew=false}else{this.isNew=true}this.addEvents({close:true,load:true,save:true,"delete":true});this.on("save",function(){var a=(this.lastData.rid)?"changed":"added";pm.app.events.fireEvent("financesEvent",{action:a,data:this.data});pm.alerts.add({msg:"'"+this.data.type.name+"' record saved in the amount of "+pm.util.usMoney(this.data.amount),icon:pm.app.iconPath+pm.app.icons.finances})},this);this.on("delete",function(){pm.app.events.fireEvent("financesEvent",{action:"deleted",node:this.data});pm.alerts.add({msg:"'"+this.data.type.name+"' record deleted in the amount of "+pm.util.usMoney(this.data.amount),icon:pm.app.iconPath+pm.app.icons.finances})},this)},load:function(a){if(!a){a={}}this.loading=true;this.loaded=false;if(this.state.rid){pm.services.get({method:"finances.getRecord",params:{rid:this.state.rid},scope:this,success:function(b){this.processData(b.data);this.load2(a)},failure:function(b){Ext.MessageBox.alert("Failed","Unable to load: "+b.message)}})}else{this.load2(a)}},load2:function(a){if(!a){a={}}this.parentNode={};if(pm.util.getIf([this,"data","parent_nid"])){var b=this.data.parent_nid}else{if(this.state.parent_nid){var b=this.state.parent_nid}}if(b){if(pm.app.nodes[b]){this.parentNode=pm.app.nodes[b].data;this.loaded=true;this.loading=false;this.fireEvent("load",this);if(a.callback){a.callback.call(a.scope||this)}}else{pm.services.get({method:"nodes.getInfo",params:{nid:b},scope:this,success:function(c){this.parentNode=c.info;this.loaded=true;this.loading=false;this.fireEvent("load",this);if(a.callback){a.callback.call(a.scope||this)}},failure:function(c){Ext.MessageBox.alert("Failed","Unable to load: "+c.message)}})}}else{Ext.MessageBox.alert("Error","Unable to find the parent item")}},processData:function(a){this.lastData=pm.util.clone(this.data);Ext.apply(this.data,a)},initFormFields:function(a,b){this.fields={};this.typesDS=new Ext.data.SimpleStore({data:[["Expense"],["Budget"],["Invoice"],["Payment Received"],["Discount"]],fields:["value"]});this.categoriesDS=new Ext.data.Store({reader:new Ext.data.JsonReader({id:"id",fields:[{name:"id"},{name:"name"}]}),data:pm.finances.categories})},initForm:function(b,c){c={};this.initFormFields(b,c);if(this.data.date){var a=this.data.date.month+"/"+this.data.date.day+"/"+this.data.date.year}else{var a=Ext.util.Format.date(Date())}this.form=new Ext.FormPanel({labelAlign:"left",labelWidth:90,defaults:{bodyStyle:"padding:15px"},autoWidth:true,frame:false,border:false,bodyBorder:false,plain:true,autoScroll:true,items:{xtype:"treegroup",title:"Financial Record",layout:"form",labelAlign:"left",labelWidth:90,border:false,items:[{xtype:"combo",fieldLabel:"Record Type",name:"type",store:this.typesDS,displayField:"value",forceSelection:true,typeAhead:true,allowBlank:false,mode:"local",triggerAction:"all",selectOnFocus:true,width:175,value:pm.util.getIf([this.data,"type","name"])||"Budget"},{xtype:"datefield",fieldLabel:"Date",allowBlank:false,name:"date",width:175,value:a},{xtype:"numberfield",fieldLabel:"Amount ($)",name:"amount",allowBlank:false,width:175,value:this.data.amount},{xtype:"textfield",fieldLabel:"Invoice #",name:"number",width:175,value:this.data.number},{xtype:"combo",fieldLabel:"Category",name:"category_name",store:this.categoriesDS,displayField:"name",valueField:"id",forceSelection:false,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,width:175,value:pm.util.getIf([this.data,"category","id"])},{xtype:"textarea",fieldLabel:"Description",name:"description",anchor:"-20",height:"100",value:this.data.description}]},buttons:this.getButtons()});if(b.callback){b.callback.call(b.scope)}},getButtons:function(){var a=[];if(this.data.rid){a.push({text:"Save",icon:pm.app.iconPath+pm.app.icons.save,cls:"x-btn-text-icon",scope:this,handler:this.onSaveAndClose});a.push({text:"Delete",icon:pm.app.iconPath+pm.app.icons.del,cls:"x-btn-text-icon",scope:this,handler:this.onDelete})}else{a.push({text:"Save and Close",icon:pm.app.iconPath+pm.app.icons.save,cls:"x-btn-text-icon",scope:this,handler:this.onSaveAndClose});a.push({text:"Save and New",icon:pm.app.iconPath+pm.app.icons.saveMultiple,cls:"x-btn-text-icon",scope:this,handler:this.onSaveAndNew})}a.push({text:"Cancel",icon:pm.app.iconPath+pm.app.icons.cancel,cls:"x-btn-text-icon",scope:this,handler:function(){this.onClose()}});return a},reset:function(){var b=this.data.parent_nid;this.data={};this.data.parent_nid=b;var a=this.form.getForm();a.reset()},doRender:function(){pm.FinancialForm.superclass.doRender.call(this);this.initForm({scope:this,callback:function(){this.renderHeader();this.renderParent();this.renderForm()}},this.data)},renderHeader:function(){this.el.update();if(!pm.tpl.financeEditPage){pm.tpl.financeEditPage=new Ext.Template('<div class="profile-header">','<div class="right">{headerRight}</div>','<table border="0">',"<tr>",'<td><img src="{headerIcon}" /><span class="title">{title}</span></td>',"</tr>","</table>","</div>",'<div class="profile-form"></div>');pm.tpl.financeEditPage.compile()}if(this.data.rid){var a="Edit Financial Record"}else{var a="New Financial Record"}pm.tpl.financeEditPage.overwrite(this.el,{title:a,headerIcon:pm.app.iconPath+pm.app.icons.finances,headerRight:""});this.headerRightEl=this.el.child("div.profile-header div.right");this.formEl=this.el.child("div.profile-form");this.formEl.enableDisplayMode();if(!pm.tpl.financeEditParent){pm.tpl.financeEditParent=new Ext.Template('<span style="font-weight: bold;">{parentType}: </span>',"{parentTitle}");pm.tpl.financeEditParent.compile()}},renderParent:function(){if(this.parentNode&&this.parentNode.type&&this.parentNode.title){this.parentNodeDef=pm.nodes.getDef(this.parentNode.type);pm.tpl.financeEditParent.overwrite(this.headerRightEl,{parentType:this.parentNodeDef.name,parentTitle:Ext.util.Format.ellipsis(this.parentNode.title,70)})}},renderForm:function(){if(!this.form.rendered){this.form.render(this.formEl)}this.form.form.findField(0).focus(true)},onSave:function(b){var a=this.form.getForm().getValues(false);if(this.parentNode.nid){pm.services.get({method:"finances.saveRecord",params:Ext.apply({rid:this.data.rid,parent_nid:this.parentNode.nid},a),scope:this,success:function(c){this.processData(c.data);this.fireEvent("save");if(this.isNew){pm.log("reset");this.reset()}if(b&&b.callback){b.callback.call(b.callback.scope||this)}}})}else{Ext.MessageBox.alert("Failed","Unable to save: The content ID of the parent item could not be found!")}},onSaveAndNew:function(){this.onSave({scope:this,callback:function(){}})},onSaveAndClose:function(){this.onSave({scope:this,callback:function(){this.onClose()}})},onDelete:function(a,b){this.deleteConfirm({animEl:a.el,scope:this,success:function(){this.onClose()}})},onClose:function(){if(pm.state.navigateBack(true)){this.fireEvent("close")}else{if(this.parentNode&&this.parentNodeDef){pm.state.navigate({path:this.parentNodeDef.paths.view,nid:this.parentNode.nid});this.fireEvent("close")}else{pm.state.navigate({path:["finances","list"]});this.fireEvent("close")}}},deleteConfirm:function(a){if(!a){a={}}if(!this.data.rid){Ext.MessageBox.alert("Failed","Unable to delete: The record ID of this item could not be found!");return}Ext.MessageBox.show({title:"Confirm Delete",msg:"Are you sure you want to delete this '"+pm.util.getIf([this,"data","type","name"])+"' record? There is no undo.",buttons:Ext.MessageBox.YESNO,animEl:a.animEl||"",scope:this,fn:function(b){if(b=="yes"){this.doDelete({scope:a.scope,success:a.success})}}})},doDelete:function(a){pm.services.post({method:"finances.deleteRecord",params:{rid:this.data.rid},scope:this,success:function(b){this.fireEvent("delete");if(typeof a.success=="function"){a.success.call(a.scope||this)}},failure:function(b){Ext.MessageBox.alert("Failed","Unable to delete: "+b.message)}})},aktivieren:function(a){this.isActive=true;this.state=a},deaktivieren:function(){this.isActive=false},onDestroy:function(){this.loaded=false;this.data={};pm.FinancialForm.superclass.onDestroy.call(this)}});pm.FinancialSearch=Ext.extend(pm.Page,{initComponent:function(){pm.FinancialSearch.superclass.initComponent.call(this);if(!this.data){this.data={}}this.results=new pm.FinancialQuery({state:this.state})},load:function(a){pm.log("FinancialSearch: load");if(!a){a={}}this.loading=true;this.loaded=false;if(this.data.rid){pm.services.get({method:"finances.getRecord",params:{rid:this.data.rid},scope:this,success:function(b){this.processData(b.data);if(a.callback){a.callback.call(a.scope||this)}},failure:function(b){Ext.MessageBox.alert("Failed","Unable to load: "+b.message)}})}else{this.loading=false;this.loaded=true;if(a.callback){a.callback.call(a.scope||this)}}this.results.load(a)},doRender:function(){pm.FinancialSearch.superclass.doRender.call(this);var c="";var b=[],a=pm.finances.fields;for(var d in a){b.push([a[d]]);if(d==this.state.field){c=a[d]}}if(!c){c="Profit"}this.form=new Ext.form.FormPanel({cls:"fncl-filter",labelWidth:75,labelAlign:"top",buttonAlign:"left",frame:true,border:false,bodyBorder:false,plain:false,width:710,layout:"table",layoutConfig:{columns:3},defaults:{bodyStyle:"padding: 5px 10px 0px 7px"},items:[{columnWidth:0.4,layout:"form",items:{xtype:"combo",fieldLabel:"Search for",name:"field",store:new Ext.data.SimpleStore({data:b,fields:["value"],id:0}),displayField:"value",forceSelection:true,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,width:200,value:c}},{columnWidth:0.3,layout:"form",items:{xtype:"datefield",fieldLabel:"Date Range Start (optional)",name:"start",width:130,value:""}},{columnWidth:0.3,layout:"form",items:{xtype:"datefield",fieldLabel:"Date Range End (optional)",name:"end",width:130,value:""}}],buttons:[{text:"Search Finances",scope:this,handler:this.onSearch}]});this.form.render(this.el);this.results.render(this.el)},onSearch:function(){pm.log("onSearch");if(this.form.getForm().isValid()){var b=this.form.getForm();var d=b.getValues();var e="";var a=pm.finances.fields;for(var c in a){if(a[c]==d.field){e=c}}pm.state.navigate({field:e,range_start:d.start,range_end:d.end},true)}else{Ext.MessageBox.alert("Errors","Please fix the errors noted.")}},aktivieren:function(a){this.isActive=true;this.state=a;this.results.aktivieren(a)},deaktivieren:function(){this.isActive=false;this.results.deaktivieren()},onDestroy:function(){this.results.destroy();pm.FinancialSearch.superclass.onDestroy.call(this)}});pm.FinancialQuery=Ext.extend(pm.Page,{initComponent:function(){pm.FinancialQuery.superclass.initComponent.call(this);var b=[{name:"nid"},{name:"title"},{name:"type"}];var a=pm.finances.fields;for(var c in a){if(typeof a[c]=="string"){b.push({name:c})}}if(!this.nodeType){this.nodeType="organization"}this.ds=new Ext.data.Store({proxy:new pm.SystemProxy({method:"finances.getSummaries",timeout:180000}),reader:new Ext.data.JsonReader({root:"records",totalProperty:"count",id:"nid"},b)});this.ds.on("load",function(e,d,f){this.loaded=true;this.loading=false;this.fireEvent("load",this);this.initEvents()},this);this.ds.on("beforeload",function(){this.ds.baseParams.field=this.getField();this.ds.baseParams.dir=this.getDir();this.ds.baseParams.range_start=this.state.range_start;this.ds.baseParams.range_end=this.state.range_end},this);if(!pm.tpl.FinancialQuery){pm.tpl.FinancialQuery=new Ext.XTemplate('<div class="pm-list fncl fncl-query-results">','<table width="100%">','<tpl for=".">','<tr class="item">','<td class="title">{title}</div>','<td class="amount {color}" align="right">{fieldValue}</div>',"</tr>","</tpl>","</table>","</div>");pm.tpl.FinancialQuery.compile()}this.view=new Ext.DataView({tpl:pm.tpl.FinancialQuery,singleSelect:false,store:this.ds,itemSelector:"tr.item",overClass:"item-over",emptyText:"No finances to display",loadingText:"Loading financial data.  This can take several minutes...",owner:this});this.view.prepareData=function(f){var e=pm.nodes.getDef(this.owner.nodeType);if(e){f.title=pm.state.navLink({text:f.title,state:{path:e.paths.view,nid:f.nid}})}var d=this.owner.getField();f.color=pm.finances.getColor(d,f[d]);f.fieldValue=pm.finances.formatVal(d,f[d]);return f};this.view.on("click",function(d,g,h,j){var f=Ext.get(h);var k=Ext.get(j.getTarget("",el));if(k.is("span.a")){pm.state.navigate(pm.state.parseLink(k.dom.id))}},this,{preventDefault:true})},load:function(a){pm.log("FinancialQuery: load");this.loading=true;this.loaded=false;this.setTitle();this.updateSort();this.ds.load(a)},doRender:function(){pm.FinancialQuery.superclass.doRender.call(this);this.el.addClass("fncl-query");if(!pm.tpl.FinancialQueryHeader){pm.tpl.FinancialQueryHeader=new Ext.Template('<table width="100%" class="header">',"<tr>",'<td class="title"></td>','<td align="right" class="sort">',"</td>","</tr>","</table>");pm.tpl.FinancialQueryHeader.compile()}this.headerEl=pm.tpl.FinancialQueryHeader.append(this.el,{},true);this.titleEl=this.headerEl.child(".title");this.sortEl=this.headerEl.child(".sort");this.setTitle();this.updateSort();this.headerEl.on({click:{scope:this,fn:function(b,a){var c=b.getTarget("",2,true);if(c.is("span.a")||c.is("img.arrow")){this.toggleSort()}}}});this.view.render(this.el)},setTitle:function(a){if(!a){a=pm.finances.fields[this.getField()]}this.title=a;if(this.titleEl){this.titleEl.update(a)}this.fireEvent("setTitle",a,this)},toggleSort:function(){pm.log("toggleSort");pm.state.navigate({dir:(this.state.dir=="DESC")?"ASC":"DESC"},true)},updateSort:function(){if(!pm.tpl.sortText){pm.tpl.sortText=new Ext.Template('<span class="a">{text}</span>','<img class="arrow" src="{icon}" />');pm.tpl.sortText.compile()}if(this.sortEl){if(this.getDir()=="DESC"){pm.tpl.sortText.overwrite(this.sortEl,{text:"Highest to Lowest",icon:pm.app.iconPath+"down.gif"})}else{pm.tpl.sortText.overwrite(this.sortEl,{text:"Lowest to Highest",icon:pm.app.iconPath+"up.gif"})}}},aktivieren:function(b){pm.log("FinancialQuery: activate");this.isActive=true;if(this.isDirty){this.load()}else{var a=["field","dir","range_start","range_end"];if(b&&pm.util.isChanged(this.state,b,a)){this.state=b;this.load()}}},getField:function(){return(this.state.field)?this.state.field:"profit"},getDir:function(){return(this.state.dir)?this.state.dir:"DESC"},deaktivieren:function(){this.isActive=false},onDestroy:function(){this.view.destroy();this.ds.destroy();pm.FinancialQuery.superclass.onDestroy.call(this)},initEvents:function(){}});pm.Responsibilities=Ext.extend(pm.Page,{initComponent:function(){pm.Responsibilities.superclass.initComponent.call(this);this.title="Responsibilities";this.ds=new Ext.data.Store({proxy:new pm.SystemProxy({method:"delegation.getResponsibilities"}),reader:new Ext.data.JsonReader({root:"records",totalProperty:"count",id:"nid"},[{name:"nid"},{name:"type"},{name:"title"},{name:"date"},{name:"assigned_by"}]),baseParams:{nid:this.nodeObj.nid}});if(!pm.tpl.responsibilities){pm.tpl.responsibilities=new Ext.XTemplate('<div class="pm-list pm-list-icons">','<tpl for=".">','<div class="item">','<div class="left"><img src="{icon}" /></div>','<div class="right">',"<div>{title}</div>",'<div class="small">Assigned by {assignedBy} on {when}</div>',"</div>","</div>","</tpl>","</div>");pm.tpl.responsibilities.compile()}this.view=new Ext.DataView({tpl:pm.tpl.responsibilities,singleSelect:false,store:this.ds,itemSelector:"div.item",overClass:"item-over",emptyText:"No reponsibilities to display",loadingText:"Loading responsibilities...",nid:this.nodeObj.nid});this.view.prepareData=function(b){var a=pm.nodes.getDef(b.type);b.title=pm.state.navLink({text:b.title,state:{path:a.paths.view,nid:b.nid}});var c=b.assigned_by;b.assignedBy=pm.state.navLink({text:c.title,state:{path:pm.nodes.getDef(c.type).paths.view,nid:c.nid}});b.when=pm.util.formatDate(b.date);b.icon=pm.app.iconPath+a.icons.view;return b},this.view.on("click",function(a,b,c,d){var f=d.getTarget("",1,true);if(f.is("span.a")){pm.state.navigate(pm.state.parseLink(f.dom.id))}},this,{preventDefault:true});this.gEventsID=pm.app.events.id();pm.app.events.listen({id:this.gEventsID,listeners:[{type:"nodeEvent",scope:this,fn:function(a){switch(a.action){case"added":case"changed":case"deleted":if(this.isActive){this.load()}else{this.isDirty=true}break}}}]})},load:function(a){this.loading=true;this.loaded=false;this.ds.load({scope:this,callback:function(c,b,d){if(this.ds.getCount()>0){this.show()}else{this.hide()}this.loaded=true;this.loading=false}})},doRender:function(){pm.Responsibilities.superclass.doRender.call(this);var a=this.el.createChild({html:this.nodeObj.data.title+" is responsible for the following:"});this.view.render(this.el)},aktivieren:function(a){pm.Responsibilities.superclass.aktivieren.call(this,a);if(this.isDirty){this.load()}},deaktivieren:function(){pm.Responsibilities.superclass.deaktivieren.call(this)},onDestroy:function(){pm.app.events.stopListening(this.gEventsID);this.view.destroy();this.ds.destroy();this.el.remove();pm.Responsibilities.superclass.onDestroy.call(this)}});pm.Search=Ext.extend(pm.Page,{initComponent:function(){pm.Search.superclass.initComponent.call(this);this.listUI=new pm.NodeListHelper({});this.list=new pm.NodeListFlat(Ext.apply(this.initialConfig,{state:this.state,listUI:this.listUI,checkboxes:false,icons:true}))},load:function(a){this.list.load(a)},doRender:function(){pm.Search.superclass.doRender.call(this);this.el.addClass("search-page");this.el.createChild({cls:"profile-title",html:"Search Results"});this.list.render(this.el)},aktivieren:function(a){pm.Search.superclass.aktivieren.call(this,a);this.list.aktivieren(a)},deaktivieren:function(){pm.Search.superclass.deaktivieren.call(this);this.list.deaktivieren()},onDestroy:function(){this.list.destroy();pm.Search.superclass.onDestroy.call(this)}});pm.Tagline=Ext.extend(pm.Page,{initComponent:function(){pm.Tagline.superclass.initComponent.call(this);this.addEvents("load","save","clear");this.loaded=true},load:function(a){if(!a){a={}}this.loading=true;this.loaded=false;this.loaded=true;this.loading=false},loadData:function(a){},doRender:function(){pm.Tagline.superclass.doRender.call(this);this.textEl=this.el.createChild();this.formEl=this.el.createChild();this.textEl.enableDisplayMode();this.formEl.enableDisplayMode();this.textEl.on({click:{fn:this.onClickText,scope:this},mouseover:{fn:this.onMouseOver,scope:this},mouseout:{fn:this.onMouseOut,scope:this}});this.renderText()},onClickText:function(c,b,a){var d=c.getTarget("",1,true);if(d.is(".clickable")){if(!this.editing){this.enterEditMode()}}},onMouseOver:function(c,b,a){if(b.className=="clickable"){this.textEl.addClass("over")}},onMouseOut:function(){this.textEl.removeClass("over")},enterEditMode:function(){this.editing=true;this.renderForm()},enterViewMode:function(){this.editing=false;this.renderText()},toggleMode:function(){if(this.editing){this.enterViewMode()}else{this.enterEditMode()}},renderText:function(){this.formEl.hide();this.textEl.show();var d=pm.util.getIf([this,"nodeObj","data","tagline","message"]);if(!d){d="Click to edit tagline..."}var c='<span class="clickable">'+d+"</span> ";var b=pm.util.getJSDate(pm.util.getIf([this,"nodeObj","data","tagline","updated"]));if(b){var a='&nbsp;<span class="small">Updated '+pm.util.dateFormatTimeAgo(b);+"</span>"}else{var a=""}this.textEl.update(c+a)},renderForm:function(){this.textEl.hide();if(this.form){this.formTextArea.setValue(pm.util.getIf([this,"nodeObj","data","tagline","message"]));this.formEl.show()}else{this.formTextArea=new Ext.form.TextArea({fieldLabel:"Tagline",name:"title",anchor:"0",emptyText:"",height:50,value:pm.util.getIf([this,"nodeObj","data","tagline","message"])});this.form=new Ext.FormPanel({layout:"anchor",labelAlign:"top",buttonAlign:"left",border:false,cls:"inline-form",items:this.formTextArea,buttons:[{text:"Save",icon:pm.app.iconPath+pm.app.icons.save,cls:"x-btn-text-icon",scope:this,handler:function(a,c){var b=this.formTextArea.getValue();pm.services.get({method:"taglines.setTagline",params:{nid:this.nodeObj.data.nid,message:b},scope:this,success:function(d){this.nodeObj.processData({tagline:d.tagline});this.nodeObj.fireEvent("save",{noAlert:true});this.fireEvent("save");this.enterViewMode()},failure:function(d){Ext.MessageBox.alert("Failed","Unable to load: "+d.message)}})}},{text:"Cancel",icon:pm.app.iconPath+pm.app.icons.cancel,cls:"x-btn-text-icon",scope:this,handler:function(){this.enterViewMode()}}]});this.formEl.show();this.form.render(this.formEl)}},aktivieren:function(a){pm.RelatedContent.superclass.aktivieren.call(this,a);if(this.isDirty){this.load()}},onDestroy:function(){pm.app.events.stopListening(this.gEventsID);this.form.destroy();this.formTextArea.destroy();if(this.textEl){this.textEl.remove()}if(this.formEl){this.formEl.remove()}delete this.textEl;delete this.formEl;pm.RelatedContent.superclass.onDestroy.call(this)}});pm.services=new Ext.util.Observable();pm.services.sessionID="";pm.services.addEvents({load:true});pm.services.get=function(a){pm.services.doAction("GET",a)};pm.services.post=function(a){pm.services.doAction("POST",a)};pm.services.url=function(a){return pm.util.url("rest/"+a)};pm.services.submitForm=function(b,a){if(pm.app.isOffline){}else{var c={url:pm.services.url(a.method),params:{},method:(pm.app.submitUsingGET)?"GET":"POST",success:function(e,d,f){if(a.success){a.success.call(a.scope,d.result)}},failure:function(e,d){if(a.failure){a.failure.call(a.scope,d.result)}}};Ext.apply(c.params,a.params);b.submit(c)}};pm.services.doAction=function(b,a){Ext.Ajax.request({url:pm.services.url(a.method),method:b,params:(a.params)?a.params:{},scope:(a.scope)?a.scope:this,success:function(c,d){var e=Ext.util.JSON.decode(c.responseText);pm.services.sessionID=e.PHPSESSID;if(e.stat=="ok"){if(a.success){a.success.call(a.scope,e)}}else{if(a.failure){a.failure.call(a.scope,e)}}},failure:function(c,d){if(a.failure){var e={stat:"fail",code:c.status,message:c.statusText};a.failure.call(a.scope,e)}}})};pm.services.onSuccess=function(a,b){};pm.data=function(){var a=[];return{getCategoriesDS:function(c){if(!a[c.name]){a[c.name]=new Ext.data.Store({proxy:new pm.SystemProxy({method:"categories.getList"}),reader:new Ext.data.JsonReader({root:"records",totalProperty:"count",id:"tid"},[{name:"tid"},{name:"name"}]),baseParams:{name:c.name},sortInfo:{field:"name",direction:"ASC"}})}var b=a[c.name];if(b.getCount()==0){b.load({scope:this,callback:function(e,d,f){if(c.callback){c.callback.call(c.scope||this,b)}}})}else{if(c.callback){c.callback.call(c.scope||this,b)}}},extract:function(e,d){var b=e;for(var c=0;c<d.length;c++){if(b[d[c]]){b=b[d[c]]}else{return""}}return b}}}();pm.data.states=new Ext.data.SimpleStore({data:[["AL","Alabama"],["AK","Alaska"],["AZ","Arizona"],["AR","Arkansas"],["CA","California"],["CO","Colorado"],["CT","Connecticut"],["DE","Delaware"],["DC","District of Columbia"],["FL","Florida"],["GA","Georgia"],["HI","Hawaii"],["ID","Idaho"],["IL","Illinois"],["IN","Indiana"],["IA","Iowa"],["KS","Kansas"],["KY","Kentucky"],["LA","Louisiana"],["ME","Maine"],["MD","Maryland"],["MA","Massachusetts"],["MI","Michigan"],["MN","Minnesota"],["MS","Mississippi"],["MO","Missouri"],["MT","Montana"],["NE","Nebraska"],["NV","Nevada"],["NH","New Hampshire"],["NJ","New Jersey"],["NM","New Mexico"],["NY","New York"],["NC","North Carolina"],["ND","North Dakota"],["OH","Ohio"],["OK","Oklahoma"],["OR","Oregon"],["PA","Pennsylvania"],["RI","Rhode Island"],["SC","South Carolina"],["SD","South Dakota"],["TN","Tennessee"],["TX","Texas"],["UT","Utah"],["VT","Vermont"],["VA","Virginia"],["WA","Washington"],["WV","West Virginia"],["WI","Wisconsin"],["WY","Wyoming"]],fields:["key","name"],id:0});pm.settings=function(){return{cleanurls:true,init:function(a){if(a&&a.callback){a.callback.call(a.scope||this)}}}}();pm.alerts=function(){return{init:function(){if(!this.el){this.el=Ext.get("alerts");this.alerts=[];this.all=new Ext.CompositeElementLite();this.visibleAlerts=[];this.itemSelector="div.alert";this.el.on("click",function(d,c){var b=d.getTarget(this.itemSelector,5);if(b){var a=this.indexOf(b);var g=this.visibleAlerts[a]}var f=d.getTarget("span.a",1,true);if(f){pm.state.navigate(pm.state.parseLink(f.dom.id))}else{var f=d.getTarget("span.close",3,true);if(f){this.alerts[g.id].el.remove();delete this.alerts[g.id]}}},this,{preventDefault:true});pm.state.on("navigate",function(){var b=pm.state.history.length-1;for(var a in this.alerts){if(typeof this.alerts[a]!="function"){if(this.alerts[a].historyID<(b-1)){this.alerts[a].el.remove();this.alerts[a].el=null;this.alerts[a]=null;delete this.alerts[a]}}}},this)}},add:function(d){this.init();if(!pm.tpl.alert){pm.tpl.alert=new Ext.Template('<div class="alert">','<span class="close"><img src="{close}" /></span>','<div class="icon"><img src="{icon}" /></div>','<div class="message">{msg}</div>',"</div>");pm.tpl.alert.compile()}var b=pm.state.history.length-1;var c=pm.tpl.alert.append(this.el,{msg:d.msg,icon:pm.app.iconPath+pm.app.icons.info,close:pm.app.iconPath+pm.app.icons.close});d.el=Ext.get(c);d.historyID=b;this.alerts.push(d);this.visibleAlerts=[];for(var a in this.alerts){if(typeof this.alerts[a]!="function"){this.alerts[a].id=a;this.visibleAlerts.push(this.alerts[a])}}this.all.fill(Ext.query(this.itemSelector,this.el.dom))},clear:function(){this.init();this.el.update("")},indexOf:function(a){if(typeof a=="string"){a=document.getElementById(a)}else{if(typeof a=="number"){a=this.all.elements[a]}}if(typeof a.viewIndex=="number"){return a.viewIndex}return this.all.indexOf(a)}}}();pm.delegate=function(){return{}}();pm.finances=function(){return{init:function(a){Ext.apply(pm.app.pageDefs,{finances:{list:{title:"Search Financial Records",params:{cls:"padded10"},handler:pm.FinancialSearch},edit:{required:"rid",params:{cls:"page-form"},handler:pm.FinancialForm},create:{required:"parent_nid",params:{cls:"page-form"},handler:pm.FinancialForm}}});if(a&&a.callback){a.callback.call(a.scope||this)}},load:function(a){pm.services.get({method:"finances.getCategories",scope:this,success:function(b){pm.finances.categories=b.records;if(a&&a.callback){a.callback.call(a.scope||this)}},failure:function(b){Ext.MessageBox.alert("Failed","Unable to load: "+b.message)}})},formatVal:function(a,b){if(!b){b=0}switch(a){case"gross_margin":return b+"%";default:return pm.util.usMoney(b,true)}},getColor:function(a,b){if(!b){b=0}switch(a){case"invoice":case"invoices":case"payment":case"payments":case"accounts_receivable":case"profit":case"gross_margin":if(b>=0){return"green"}else{return"red"}case"discount":case"discounts":case"expense":case"expenses":if(b>=0){return"red"}else{return"green"}case"budget":case"actual_budget":case"estimated_budget":default:return"black"}},getColorByType:function(a){switch(a){case"invoice":case"invoices":case"payment":case"payments":case"accounts_receivable":case"profit":case"gross_margin":return"green";case"discount":case"discounts":case"expense":case"expenses":return"red";case"budget":case"actual_budget":case"estimated_budget":default:return"black"}},fields:{estimated_budget:"Estimated Budget",actual_budget:"Actual Budget",accounts_receivable:"Accounts Receivable",uninvoiced:"Uninvoiced",invoices:"Invoices",expenses:"Expenses",discounts:"Discounts",payments:"Payments",profit:"Profit",gross_margin:"Gross Margin"}}}();pm.piemenu=function(){var b;var c;var a;return{show:function(d){var e=d.position;a=d.scope;c=d.callback;if(!b){b=new pm.PieMenu({btns:[{cls:"pie-menu-leaf1",coords:[[-20,-80],[20,-20]],scope:this,fn:function(){pm.piemenu.callback("open")}},{cls:"pie-menu-leaf2",coords:[[20,-20],[80,20]],scope:this,fn:function(){pm.piemenu.callback("reply")}},{cls:"pie-menu-leaf3",coords:[[-20,20],[20,80]],scope:this,fn:function(){pm.piemenu.callback("edit")}},{cls:"pie-menu-leaf4",coords:[[-80,-20],[-20,20]],scope:this,fn:function(){pm.piemenu.callback("flag")}}]})}b.showAt(e)},callback:function(d){c.call(c.scope||this,d)}}}();pm.widgets=function(){return{init:function(b){var a={getTools:function(c){if(c.params.nodeType){return[{id:"plus",scope:this,handler:function(f,e,d){pm.state.navigate({path:d.instance.nodeDef.paths.create,parent_nid:d.instance.nid})}}]}},params:{},handler:pm.RelatedContent};Ext.apply(pm.app.widgetDefs,{newsFeed:{title:"Updates...",params:{cls:"padded7"},handler:pm.ChangeLog},myNewsFeed:{title:"Recent Updates",params:{cls:"padded7"},handler:pm.ChangeLog},organizations:pm.util.apply({params:{nodeType:"organization"}},a),individuals:pm.util.apply({params:{nodeType:"individual"}},a),projects:pm.util.apply({params:{nodeType:"project"}},a),events:pm.util.apply({params:{nodeType:"event"}},a),tasks:pm.util.apply({params:{nodeType:"task"}},a),documents:pm.util.apply({params:{nodeType:"document"}},a),comments:pm.util.apply({params:{nodeType:"comment"}},a),inventory:pm.util.apply({params:{nodeType:"inventory"}},a),timeTracking:{title:"Time Tracking",autoHide:true,params:{cls:"padded7",startHidden:true},handler:pm.TimeTracker},delegation:{params:{cls:"padded7",startHidden:true},handler:pm.Delegation},responsibilities:{params:{cls:"padded7"},handler:pm.Responsibilities},financialSummary:{params:{title:"Financial Summary",cls:"padded7"},autoHide:true,handler:pm.FinancialSummary},financialRecords:{title:"Financial Records",params:{cls:"padded7"},handler:pm.FinancialRecords,getTools:function(c){return[{id:"plus",scope:this,handler:function(f,e,d){pm.state.navigate({path:["finances","create"],parent_nid:d.instance.nid})}}]}},gcalendar:{title:"Calendar",autoHide:true,params:{cls:"padded7",gcalWidth:500},handler:pm.GCalendar},myContacts:{title:"Contacts",params:{nodeDef:pm.app.nodeDefs.contact,statePrefix:"mycontacts",cls:"padded7",pagerShowAll:false},handler:pm.NodeListFlat},myEvents:{title:"My Events",params:{nodeDef:pm.app.nodeDefs.event,statePrefix:"myevents",cls:"padded7",pagerShowAll:false},handler:pm.NodeListFlat,getTools:function(c){return[{id:"plus",scope:this,handler:function(f,e,d){pm.state.navigate({path:d.instance.nodeDef.paths.create,parent_nid:d.instance.nid})}}]}},myEmails:{title:"Recently Forwarded Emails",params:{nodeDef:pm.app.nodeDefs.email,statePrefix:"myemail",pagerShowAll:false,cls:"padded7",baseParams:{mode:"sent"}},handler:pm.NodeListFlat},myTasks:{title:"My Tasks",params:{nodeDef:pm.app.nodeDefs.task,statePrefix:"mytask",pagerShowAll:false,cls:"padded7"},handler:pm.NodeListFlat,getTools:function(c){return[{id:"plus",scope:this,handler:function(f,e,d){pm.state.navigate({path:d.instance.nodeDef.paths.create,parent_nid:d.instance.nid})}}]}}});if(b&&b.callback){b.callback.call(b.scope||this)}},loadUserWidgets:function(b){if(!this.userWidgets){this.userWidgets=[]}if(this.loading){var c;var a=function(){if(!this.loading){clearInterval(c);this.loadUserWidgets(b)}}.createDelegate(this);c=setInterval(a,200);return}if(!this.userWidgets[b.nid]){this.loading=true;pm.services.get({method:"widgets.getAll",params:{},scope:this,success:function(d){this.userWidgets[b.nid]=d.widgets;this.loading=false;if(b&&b.callback){b.callback.call(b.scope||this)}},failure:function(d){Ext.MessageBox.alert("Failed","Unable to load data: "+d.message)}});return}if(b&&b.callback){b.callback.call(b.scope||this)}}}}();pm.nodes=function(){return{init:function(a){Ext.apply(pm.app.pageDefs,{category:{required:"tid",params:{cls:"padded10",display:"category"},handler:pm.NodeListFlat},node:{view:{required:"nid",params:{cls:"padded10"},handler:pm.NodeRedirect}}});if(a&&a.callback){a.callback.call(a.scope||this)}},setInitialValues:function(a){a.initial={};if(!a.data.nid){a.initial.parent={nid:pm.state.current.params.parent_nid}}},getDef:function(a){if(pm.app.nodeDefs[a]){return pm.app.nodeDefs[a]}else{return pm.app.nodeDefs.document}},getNodeObj:function(b){if(b.nid){if(pm.app.nodes[b.nid]){var a=pm.app.nodes[b.nid]}else{var a=new pm.NodeObj({nid:b.nid,data:b.data});pm.app.nodes[b.nid]=a}return a}else{if(b.nodeDef){var a=new pm.NodeObj({nodeDef:b.nodeDef,data:b.data});return a}else{pm.log("NID not passed to getNodeObj()")}}},getList:function(b){if(!this.nodeList||!this.nodeList[b.type]){if(!this.nodeList){this.nodeList={}}this.nodeList[b.type]=new Ext.data.Store({proxy:new pm.SystemProxy({method:"nodes.getList"}),reader:new Ext.data.JsonReader({root:"records",totalProperty:"count",id:"nid"},[{name:"nid"},{name:"title"}]),baseParams:{type:b.type,isUser:b.isUser||false,"fields[]":["nid","title"]},sortInfo:{field:"title",direction:"ASC"}})}var a=this.nodeList[b.type];if(a.getCount()>0){if(b.callback){b.callback.call(b.scope||this,a)}}else{a.load({scope:this,callback:function(d,c,e){if(e){if(b.callback){b.callback.call(b.scope||this,a)}}else{Ext.MessageBox.alert("Error","Unable to load "+b.type+" list")}}})}},getHowList:function(b){if(!this.howList||!this.howList[b.type]){if(!this.howList){this.howList={}}this.howList[b.type]=new Ext.data.Store({proxy:new pm.SystemProxy({method:"related.getHow"}),reader:new Ext.data.JsonReader({root:"records",totalProperty:"count",id:"id"},[{name:"id"},{name:"name"}])});pm.app.events.listen({id:"how-list",listeners:[{type:"relatedContentEvent",scope:this,fn:function(c){if(c.action=="save"||c.action=="delete"){if(c.nodeObj.data.type==b.type){this.nodeList[b.type].removeAll()}}}}]})}var a=this.nodeList[b.type];if(a.getCount()>0){if(b.callback){b.callback.call(b.scope||this,a)}}else{a.load({scope:this,callback:function(d,c,e){if(e){if(b.callback){b.callback.call(b.scope||this,a)}}else{Ext.MessageBox.alert("Error","Unable to load "+b.type+" list")}}})}},getFileExt:function(a){return a.match(/[^.]*$/)[0].toLowerCase()||""},getFileInfo:function(e){var d={};var a=e.filename;var c=e.filemime;if(a){d.ext=pm.nodes.getFileExt(a)}d.type=d.ext;var b=pm.app.icons;switch(c||d.ext){case"txt":case"application/text":d.icon=b.fileText;d.label="Text Document";d.labelPlural="Text Documents";break;case"doc":case"application/msword":d.icon=b.fileWord;d.label="Word Document";d.labelPlural="Word Documents";break;case"pdf":case"application/pdf":d.icon=b.filePDF;d.label="PDF";d.labelPlural="PDFs";break;case"xls":case"application/vnd.ms-excel":d.icon=b.fileExcel;d.label="Spreadsheet";d.labelPlural="Spreadsheets";break;case"jpg":case"jpeg":case"gif":case"tif":case"tiff":case"png":case"image/pjpeg":case"image/jpeg":case"image/gif":case"image/tiff":case"image/png":d.icon=b.fileImage;d.type="image";d.label="Image";d.labelPlural="Images";break;case"ppt":case"application/vnd.ms-powerpoint":d.icon=b.filePPT;d.label="Presentation";d.labelPlural="Presentations";break;case"mp3":case"aac":case"audio/mpeg":d.icon=b.fileAudio;d.type="audio";d.label="Audio File";d.labelPlural="Audio Files";break;case"mov":case"mpg":case"mpeg":case"video/quicktime":case"video/x-mpeg":d.icon=b.fileVideo;d.type="video";d.label="Video File";d.labelPlural="Video Files";break;default:d.icon=b.fileUnknown;d.type="unknown";d.label="Unknown File";d.labelPlural="Unknown Files";break}d.icon=pm.app.iconPath+d.icon;return d},getFileIcon:function(b){var a=pm.nodes.getFileInfo(b);return a.icon},initTreeNodeEditor:function(c){var a=c.treeNode;var b=c.mode;a.expand(false,false,function(){a.ui.setEditMode({mode:c.mode});var f=pm.nodes.getDef(a.attributes.type);if(b=="reply"){var g=new pm.NodeObj({nodeDef:f,data:{parent:{nid:a.attributes.nid}}})}else{var g=pm.nodes.getNodeObj({nid:a.attributes.nid,nodeDef:f})}var h=(b=="reply")?"Reply to ":"Edit ";h+=f.name;if(f.ui.miniEdit){var e=new f.ui.miniEdit({title:h,nodeObj:g,nodeDef:f,renderTo:a.ui.formEl});var d=function(){e.un("close",d,this);g.un("save",d,this);e.destroy();a.ui.endEditMode()};e.on("close",d,this);g.on("save",d,this)}}.createDelegate(this))}}}();pm.nodes.pageDefs={list:{params:{cls:"padded10"},handler:pm.NodeMgr},view:{params:{cls:"padded10"},required:"nid",handler:pm.NodeViewUI},edit:{params:{cls:"page-form"},required:"nid",handler:pm.NodeEditUI},create:{params:{cls:"page-form"},handler:pm.NodeEditUI}};pm.dashboard=function(){return{init:function(a){Ext.apply(pm.app.pageDefs,{dashboard:{view:{params:{cls:"padded10"},handler:pm.Dashboard}}});if(a&&a.callback){a.callback.call(a.scope||this)}}}}();pm.calendars=function(){return{renderBtnStrip:function(a){if(!pm.tpl.btnStrip){pm.tpl.btnStrip=new Ext.XTemplate('<div class="btn-strip">','<tpl for=".">','<span class="btn">','<span class="icon">{icon}</span>','<span class="text">{text}</span>',"</span>","</tpl>","</div>");pm.tpl.btnStrip.compile()}pm.tpl.btnStrip.append(a,[{text:pm.state.navLink({text:"Google Calendars",state:{path:["events","calendars","month"]}})},{text:pm.state.navLink({text:"System Events",state:{path:["events","list"]}})}]);Ext.get(a).select(".btn-strip").on("click",function(b,c){pm.state.navigate(pm.state.parseLink(c.id))},this)}}}();pm.contacts=function(){return{init:function(a){Ext.apply(pm.app.icons,{individual:"famfamfam/user.png",individualAdd:"famfamfam/user_add.png",individualEdit:"famfamfam/user_edit.png",individualDel:"famfamfam/user_delete.png",organization:"famfamfam/group.png",organizationAdd:"famfamfam/group_add.png",organizationEdit:"famfamfam/group_edit.png",organizationDel:"famfamfam/group_delete.png",contact:"famfamfam/vcard.png",contactAdd:"famfamfam/vcard_add.png",contactEdit:"famfamfam/vcard_edit.png",contactDel:"famfamfam/vcard_delete.png"});Ext.apply(pm.app.nodeDefs,{individual:{name:"Individual Contact",namePlural:"Individual Contacts",ui:{view:pm.IndividualViewUI,edit:pm.IndividualEditUI,teaser:pm.IndividualTeaserUI,miniEdit:pm.IndividualMiniEditUI},nodeType:"individual",section:"individuals",paths:{view:["contacts","individuals","view"],edit:["contacts","individuals","edit"],create:["contacts","individuals","create"],list:["contacts","list"]},fields:["first_name","last_name","nick_name","job_title"],icons:{view:pm.app.icons.individual,add:pm.app.icons.individualAdd,edit:pm.app.icons.individualEdit,del:pm.app.icons.individualDel},iconCls:{view:"fadfads"},listPrepare:pm.contacts.listPrepare},organization:{name:"Organization",namePlural:"Organizations",ui:{view:pm.OrganizationViewUI,edit:pm.OrganizationEditUI,teaser:pm.OrganizationTeaserUI,miniEdit:pm.OrganizationMiniEditUI},nodeType:"organization",section:"organizations",paths:{view:["contacts","organizations","view"],edit:["contacts","organizations","edit"],create:["contacts","organizations","create"],list:["contacts","list"]},fields:["title","abbrev"],icons:{view:pm.app.icons.organization,add:pm.app.icons.organizationAdd,edit:pm.app.icons.organizationEdit,del:pm.app.icons.organizationDel},listPrepare:pm.contacts.listPrepare,childTypes:["individual","project","event","task","inventory","document","comment"]},contact:{name:"Contact",namePlural:"Contacts",ui:{list:pm.ContactMgr},nodeType:"contact",nodeTypes:["contact","individual","organization"],section:"contacts",fields:["phone_number","email_address"],icons:{view:pm.app.icons.contact,add:pm.app.icons.contactAdd,edit:pm.app.icons.contactEdit,del:pm.app.icons.contactDel},listPrepare:pm.contacts.listPrepare}});Ext.apply(pm.app.pageDefs,{contacts:{list:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.contact},preload:[{path:["contacts","individuals","create"]},{path:["contacts","organizations","create"]}]},pm.nodes.pageDefs.list),individuals:{view:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.individual}},pm.nodes.pageDefs.view),edit:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.individual}},pm.nodes.pageDefs.edit),create:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.individual}},pm.nodes.pageDefs.create)},organizations:{view:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.organization}},pm.nodes.pageDefs.view),edit:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.organization}},pm.nodes.pageDefs.edit),create:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.organization}},pm.nodes.pageDefs.create)},my:{profile:{handler:pm.NodeViewUI,params:{cls:"padded10",nodeDef:pm.app.nodeDefs.individual}}}}});if(a&&a.callback){a.callback.call(a.scope||this)}},listPrepare:function(c){c.details="";var a=[];if(pm.util.getIf([c.phone_number,"number"])){a.push("Phone: "+c.phone_number.number)}if(pm.util.getIf([c.email_address,"email"])){var b='<a href="mailto:'+c.email_address.email+'" target="_blank">'+c.email_address.email+"</a>";a.push("E-Mail: "+b)}c.details=a.join("&nbsp;&nbsp;&nbsp;&nbsp;");c.right=pm.util.formatTerms(c.categories);return c},initFormFields:function(a){this.fields={};this.groups={};this.tabs={};this.data={};this.btns={};this.data.addressLabels=new Ext.data.SimpleStore({data:[["Office"],["Home"],["Studio"],["Warehouse"]],fields:["value"],id:0});this.data.phoneLabels=new Ext.data.SimpleStore({data:[["Office"],["Cell"],["Fax"],["Home"]],fields:["value"],id:0});this.data.emailLabels=new Ext.data.SimpleStore({data:[["Office"],["Mobile"],["Personal"]],fields:["value"],id:0});this.data.websiteLabels=new Ext.data.SimpleStore({data:[["Company"],["Blog"],["Personal"]],fields:["value"],id:0});this.data.shippingCarriers=new Ext.data.SimpleStore({data:[["FedEx"],["UPS"],["DHL"],["USPS"]],fields:["value"],id:0});this.employmentTypeDS=new Ext.data.SimpleStore({data:[["staff","Staff"],["freelance","Freelance"],["temporary","Temporary"],["intern","Intern"]],fields:["key","value"],id:0});this.employmentStatusDS=new Ext.data.SimpleStore({data:[["fulltime","Full-Time"],["parttime","Part-Time"]],fields:["key","value"],id:0});this.getTypeSelector=function(c,b){return{xtype:"treegroup",title:"Contact Type",layout:"form",border:false,items:[{xtype:"radio",name:"node_type",checked:(c.type=="individual")?true:false,hideLabel:true,inputValue:"individual",boxLabel:pm.nodes.getDef("individual").name},{xtype:"radio",name:"node_type",checked:(c.type=="organization")?true:false,hideLabel:true,inputValue:"organization",boxLabel:pm.nodes.getDef("organization").name},{xtype:"button",text:"Save ",icon:pm.app.iconPath+pm.app.icons.save,cls:"x-btn-text-icon",scope:b.owner,handler:b.owner.saveAndClose}]}};this.getAddressTab=function(b){return{xtype:"treegroup",title:"Addresses",layout:"form",border:false,autoHeight:true,items:{xtype:"formrepeat",btnTitle:"Add another address",data:(b&&b.addresses)?b.addresses:[{label:"Office"}],getInstance:pm.contacts.getAddressInstance}}};this.getAddressInstance=function(b){return{xtype:"fieldset",title:"Address",autoHeight:true,labelWidth:90,items:[{xtype:"combo",fieldLabel:"Location",name:"address_label[]",store:pm.contacts.data.addressLabels,displayField:"value",forceSelection:false,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,value:b.label,width:300},{xtype:"textfield",fieldLabel:"Line 1",name:"address1[]",value:b.address1,width:300},{xtype:"textfield",fieldLabel:"Line 2",name:"address2[]",value:b.address2,width:300},{xtype:"textfield",fieldLabel:"City",name:"city[]",value:b.city,width:300},{xtype:"combo",fieldLabel:"State",name:"state[]",store:pm.data.states,displayField:"key",valueField:"key",forceSelection:false,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,value:b.state,width:300},{xtype:"textfield",fieldLabel:"Postal Code",name:"zip[]",value:b.zip,width:300},{xtype:"textfield",fieldLabel:"Country",name:"country[]",value:b.country||"USA",width:300}]}};this.getPhoneTab=function(b){return{xtype:"treegroup",title:"Phone Numbers",layout:"form",border:false,autoHeight:true,items:{xtype:"formrepeat",btnTitle:"Add another phone number",data:(b&&b.phone_numbers)?b.phone_numbers:[{label:"Cell"},{label:"Office"},{label:"Home"},{label:"Fax"}],getInstance:pm.contacts.getPhoneInstance}}};this.getPhoneInstance=function(b){return{autoHeight:true,autoWidth:true,layout:"table",border:false,defaults:{bodyStyle:"padding-right: 5px"},layoutConfig:{columns:3},items:[{layout:"form",labelAlign:"top",border:false,items:[{xtype:"combo",fieldLabel:"Label",name:"phone_label[]",store:pm.contacts.data.phoneLabels,displayField:"value",forceSelection:false,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,value:b.label,width:100}]},{layout:"form",labelAlign:"top",border:false,items:[{xtype:"textfield",fieldLabel:"Number",name:"number[]",value:b.number,width:160}]},{layout:"form",labelAlign:"top",border:false,items:[{xtype:"textfield",fieldLabel:"Extension or Name",name:"extension[]",value:b.extension,width:120}]}]}};this.getShippingTab=function(b){return{xtype:"treegroup",title:"Shipping Numbers",layout:"form",border:false,autoHeight:true,items:{xtype:"formrepeat",btnTitle:"Add another shipping number",data:(b&&b.shipping_numbers)?b.shipping_numbers:[{label:"FedEx"},{label:"UPS"}],getInstance:pm.contacts.getShippingInstance}}};this.getShippingInstance=function(b){return{autoHeight:true,autoWidth:true,layout:"table",border:false,defaults:{bodyStyle:"padding-right: 5px"},layoutConfig:{columns:3},items:[{layout:"form",labelAlign:"top",border:false,items:[{xtype:"combo",fieldLabel:"Carrier",name:"shipping_carrier[]",store:pm.contacts.data.shippingCarriers,displayField:"value",forceSelection:false,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,value:b.label,width:100}]},{layout:"form",labelAlign:"top",border:false,items:[{xtype:"textfield",fieldLabel:"Number",name:"shipping_number[]",value:b.number,width:150}]}]}};this.getInternetTab=function(b){return{xtype:"treegroup",title:"Internet",layout:"form",border:false,autoHeight:true,items:[{xtype:"fieldset",title:"E-Mail Addresses",autoHeight:true,items:{xtype:"formrepeat",btnTitle:"Add another email address",data:(b&&b.email_addresses)?b.email_addresses:{},getInstance:pm.contacts.getEmailInstance}},{xtype:"fieldset",title:"Websites",autoHeight:true,items:{xtype:"formrepeat",btnTitle:"Add another website",data:(b&&b.websites)?b.websites:{},getInstance:pm.contacts.getWebsiteInstance}}]}};this.getEmailInstance=function(b){return{autoHeight:true,layout:"table",border:false,defaults:{bodyStyle:"padding-right: 5px"},cls:"inline-btn",layoutConfig:{columns:2,extraCls:"valign-bottom"},items:[{layout:"form",labelAlign:"top",border:false,items:[{xtype:"combo",fieldLabel:"Label",name:"email_label[]",store:pm.contacts.data.emailLabels,displayField:"value",forceSelection:false,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,value:b.label,width:100}]},{layout:"form",labelAlign:"top",border:false,items:[{xtype:"textfield",fieldLabel:"E-Mail",name:"email[]",value:b.email,width:300}]}]}};this.getWebsiteInstance=function(b){return{autoHeight:true,cls:"inline-btn",layout:"table",border:false,defaults:{bodyStyle:"padding-right: 5px"},layoutConfig:{columns:2},items:[{layout:"form",labelAlign:"top",border:false,items:[{xtype:"combo",fieldLabel:"Label",name:"website_label[]",store:pm.contacts.data.websiteLabels,displayField:"value",forceSelection:false,typeAhead:true,mode:"local",triggerAction:"all",selectOnFocus:true,value:b.label,width:100}]},{layout:"form",labelAlign:"top",border:false,items:[{xtype:"textfield",fieldLabel:"Website URL",name:"website_url[]",value:b.url,width:300}]}]}};this.getNotesTab=function(b){return{xtype:"treegroup",title:"Notes",layout:"form",border:false,autoHeight:true,labelAlign:"top",items:{xtype:"textarea",fieldLabel:"Notes",hideLabel:true,name:"body",anchor:"-20",height:"125",value:b.body}}}}}}();pm.projects=function(){return{init:function(a){Ext.apply(pm.app.icons,{project:"famfamfam/film.png",projectAdd:"famfamfam/film_add.png",projectEdit:"famfamfam/film_edit.png",projectDel:"famfamfam/film_delete.png"});Ext.apply(pm.app.nodeDefs,{project:{name:"Project",namePlural:"Projects",ui:{list:pm.ProjectMgr,view:pm.ProjectViewUI,edit:pm.ProjectEditUI,teaser:pm.ProjectTeaserUI,miniEdit:pm.ProjectMiniEditUI},nodeType:"project",section:"projects",paths:{view:["projects","view"],edit:["projects","edit"],create:["projects","create"],list:["projects","list"]},fields:["project_type","project_progress","deadline"],icons:{view:pm.app.icons.project,add:pm.app.icons.projectAdd,edit:pm.app.icons.projectEdit,del:pm.app.icons.projectDel},childTypes:["event","task","inventory","other"],listPrepare:pm.projects.listPrepare}});Ext.apply(pm.app.pageDefs,{projects:{list:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.project}},pm.nodes.pageDefs.list),view:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.project}},pm.nodes.pageDefs.view),edit:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.project}},pm.nodes.pageDefs.edit),create:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.project}},pm.nodes.pageDefs.create)}});if(a&&a.callback){a.callback.call(a.scope||this)}},load:function(a){if(a&&a.callback){a.callback.call(a.scope||this)}},progressDefs:[{id:"current",name:"Current Project",namePlural:"Current Projects",expanded:true},{id:"bidding",name:"Bidding Project",namePlural:"Bidding Projects",expanded:false},{id:"potential",name:"Potential Project",namePlural:"Potential Projects",expanded:false},{id:"completedawaitingpayment",name:"Completed Project Awaiting Payment",namePlural:"Completed Projects Awaiting Payment",expanded:false},{id:"completedpaid",name:"Completed & Paid Project",namePlural:"Completed & Paid Projects",expanded:false},{id:"cancelled",name:"Cancelled Project",namePlural:"Cancelled Projects",expanded:false}],listPrepare:function(b){b.details="";if(b.deadline){var a=['<span class="red bold">Deadline: ',pm.util.formatDate(b.deadline),"</span>"];b.details+=a.join("")}b.right=pm.util.formatTerms(b.project_type);return b}}}();pm.tasks=function(){return{init:function(a){Ext.apply(pm.app.icons,{task:"famfamfam/script.png",taskAdd:"famfamfam/script_add.png",taskEdit:"famfamfam/script_edit.png",taskDel:"famfamfam/script_delete.png"});Ext.apply(pm.app.nodeDefs,{task:{name:"Action Step",namePlural:"Action Steps",ui:{view:pm.TaskViewUI,edit:pm.TaskEditUI,teaser:pm.TaskTeaserUI,miniEdit:pm.TaskMiniEditUI},nodeType:"task",section:"tasks",paths:{view:["tasks","view"],edit:["tasks","edit"],create:["tasks","create"],list:["tasks","list"]},fields:["priority","progress","completed","due","who"],icons:{view:pm.app.icons.task,add:pm.app.icons.taskAdd,edit:pm.app.icons.taskEdit,del:pm.app.icons.taskDel},childTypes:["task","other"]}});Ext.apply(pm.app.pageDefs,{tasks:{list:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.task}},pm.nodes.pageDefs.list),view:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.task}},pm.nodes.pageDefs.view),edit:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.task}},pm.nodes.pageDefs.edit),create:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.task}},pm.nodes.pageDefs.create)}});if(a&&a.callback){a.callback.call(a.scope||this)}}}}();pm.events=function(){return{init:function(a){Ext.apply(pm.app.icons,{event:"famfamfam/date.png",eventAdd:"famfamfam/date_add.png",eventEdit:"famfamfam/date_edit.png",eventDel:"famfamfam/date_delete.png",calendar:"famfamfam/calendar.png",calendarAdd:"famfamfam/calendar_add.png",calendarEdit:"famfamfam/calendar_edit.png",calendarDel:"famfamfam/calendar_delete.png"});Ext.apply(pm.app.nodeDefs,{event:{name:"Event",namePlural:"Events",ui:{view:pm.EventViewUI,edit:pm.EventEditUI,teaser:pm.EventTeaserUI,miniEdit:pm.EventMiniEditUI},nodeType:"event",section:"events",paths:{view:["events","view"],edit:["events","edit"],create:["events","create"],list:["events","list"]},fields:["start","end","when","timezone","location"],icons:{view:pm.app.icons.event,add:pm.app.icons.eventAdd,edit:pm.app.icons.eventEdit,del:pm.app.icons.eventDel},icons2:{view:"icon-event",add:"icon-event-add",edit:"icon-event-edit",del:"icon-event-del"},childTypes:["task","inventory","other"],listPrepare:pm.events.listPrepare}});Ext.apply(pm.app.pageDefs,{events:{calendars:{month:{handler:pm.CalendarPage}},list:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.event}},pm.nodes.pageDefs.list),view:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.event}},pm.nodes.pageDefs.view),edit:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.event}},pm.nodes.pageDefs.edit),create:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.event}},pm.nodes.pageDefs.create)}});if(a&&a.callback){a.callback.call(a.scope||this)}},monthsHash:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsAbrvHash:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Decr"],listPrepare:function(b){b.details="";var a=[];if(pm.util.getIf([b.when,"when"])){a.push(b.when.when)}if(b.location){a.push("Location: "+b.location)}if(a){b.details+=a.join("&nbsp;&nbsp;&nbsp;&nbsp;")}b.right=pm.util.formatTerms(b.project_type);return b}}}();pm.documents=function(){return{init:function(b){Ext.apply(pm.app.icons,{document:"famfamfam/page.png",documentAdd:"famfamfam/page_add.png",documentEdit:"famfamfam/page_edit.png",documentDel:"famfamfam/page_delete.png"});var a={view:["documents","view"],edit:["documents","edit"],create:["documents","create"],list:["documents","list"]};Ext.apply(pm.app.nodeDefs,{document:{name:"Document",namePlural:"Documents",ui:{view:pm.DocumentViewUI,edit:pm.DocumentEditUI,teaser:pm.DocumentTeaserUI,miniEdit:pm.DocumentMiniEditUI},nodeType:"document",section:"documents",paths:a,fields:[],icons:{view:pm.app.icons.document,add:pm.app.icons.documentAdd,edit:pm.app.icons.documentEdit,del:pm.app.icons.documentDel}},comment:{name:"Comment",namePlural:"Comments",ui:{view:pm.DocumentViewUI,edit:pm.DocumentEditUI,teaser:pm.DocumentTeaserUI,miniEdit:pm.DocumentMiniEditUI},nodeType:"comment",paths:{view:["comments","view"],edit:["comments","edit"],create:["comments","create"]},fields:[],icons:{view:pm.app.icons.comment,add:pm.app.icons.commentAdd,edit:pm.app.icons.commentEdit,del:pm.app.icons.commentDel}},research:{name:"Research",namePlural:"Research",ui:{view:pm.DocumentViewUI,edit:pm.DocumentEditUI,teaser:pm.DocumentTeaserUI,miniEdit:pm.DocumentMiniEditUI},nodeType:"research",paths:{view:["research","view"],edit:["research","edit"],create:["research","create"]},fields:[],icons:{view:pm.app.icons.document,add:pm.app.icons.documentAdd,edit:pm.app.icons.documentEdit,del:pm.app.icons.documentDel}},goal:{name:"Goal",namePlural:"Goals",ui:{view:pm.DocumentViewUI,edit:pm.DocumentEditUI,teaser:pm.DocumentTeaserUI,miniEdit:pm.DocumentMiniEditUI},nodeType:"goal",paths:{view:["goal","view"],edit:["goal","edit"],create:["goal","create"]},fields:[],icons:{view:pm.app.icons.document,add:pm.app.icons.documentAdd,edit:pm.app.icons.documentEdit,del:pm.app.icons.documentDel}}});Ext.apply(pm.app.pageDefs,{documents:{list:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.document}},pm.nodes.pageDefs.list),view:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.document}},pm.nodes.pageDefs.view),edit:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.document}},pm.nodes.pageDefs.edit),create:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.document}},pm.nodes.pageDefs.create)},comments:{list:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.comment}},pm.nodes.pageDefs.list),view:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.comment}},pm.nodes.pageDefs.view),edit:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.comment}},pm.nodes.pageDefs.edit),create:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.comment}},pm.nodes.pageDefs.create)}});if(b&&b.callback){b.callback.call(b.scope||this)}}}}();pm.inventory=function(){return{init:function(a){Ext.apply(pm.app.icons,{inventory:"famfamfam/cart.png",inventoryAdd:"famfamfam/cart_add.png",inventoryEdit:"famfamfam/cart_edit.png",inventoryDel:"famfamfam/cart_delete.png"});Ext.apply(pm.app.nodeDefs,{inventory:{name:"Inventory Item",namePlural:"Inventory Items",ui:{view:pm.InventoryViewUI,edit:pm.InventoryEditUI,teaser:pm.InventoryTeaserUI,miniEdit:pm.InventoryMiniEditUI},nodeType:"inventory",section:"inventory",paths:{view:["inventory","view"],edit:["inventory","edit"],create:["inventory","create"],list:["inventory","list"]},fields:["checked_out_by","description"],icons:{view:pm.app.icons.inventory,add:pm.app.icons.inventoryAdd,edit:pm.app.icons.inventoryEdit,del:pm.app.icons.inventoryDel}}});Ext.apply(pm.app.pageDefs,{inventory:{list:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.inventory}},pm.nodes.pageDefs.list),view:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.inventory}},pm.nodes.pageDefs.view),edit:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.inventory}},pm.nodes.pageDefs.edit),create:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.inventory}},pm.nodes.pageDefs.create)}});if(a&&a.callback){a.callback.call(a.scope||this)}}}}();pm.emails=function(){return{init:function(a){Ext.apply(pm.app.icons,{email:"famfamfam/email.png",emailAdd:"famfamfam/email_add.png",emailEdit:"famfamfam/email_edit.png",emailDel:"famfamfam/email_delete.png"});Ext.apply(pm.app.nodeDefs,{email:{name:"Email",namePlural:"Emails",ui:{view:pm.EmailViewUI,edit:pm.EmailEditUI,teaser:pm.EmailTeaserUI,miniEdit:pm.EmailMiniEditUI},nodeType:"email",section:"emails",paths:{view:["emails","view"],edit:["emails","edit"],list:["emails","list"]},fields:[],icons:{view:pm.app.icons.email,add:pm.app.icons.emailAdd,edit:pm.app.icons.emailEdit,del:pm.app.icons.emailDel}}});Ext.apply(pm.app.pageDefs,{emails:{list:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.email}},pm.nodes.pageDefs.list),view:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.email}},pm.nodes.pageDefs.view),edit:pm.util.apply({params:{nodeDef:pm.app.nodeDefs.email}},pm.nodes.pageDefs.edit)}});if(a&&a.callback){a.callback.call(a.scope||this)}}}}();pm.search=function(){return{init:function(a){Ext.apply(pm.app.pageDefs,{search:{params:{cls:"padded10"},handler:pm.Search}});if(a&&a.callback){a.callback.call(a.scope||this)}}}}();