var Journal={id:"Journal",title:"Journal",image:"journal16.png",allowItems:true,allowFolders:false,allowDrag:false,allowComments:true,varyByFilter:true,itemName:"Journal Entry",itemsName:"Journal Entry",EditDialog:"editdialog/60101053.js",UpdateSectionDialog:"updatesection/41981906.js",defaultLayout:"Details",detailLayout:"ItemDetail",_4:new ImageSizer(80,200,{minWidth:20,minHeight:20,minFileSize:100}),_3:200,renderStyle:function(w){w(".journalItemHeader {}",".journalItemBody {}",".journalItem {margin-top: 3px;}",".journalItemImage {margin: 0 5px 5px 0;}",".journalItemButtons {white-space:nowrap;}",".journalItemAge {",FontSize.xs,"white-space:nowrap; text-overflow:ellipsis; overflow: hidden;}",".journalItemAge span {font-size: 100%;}",".journalItemDescription {color: rgb(51,51,51);",FontSize.s,"}",".journalItemAuthor {",FontSize.xs,"color: #b2b2b2; white-space:nowrap; }")},layouts:{List:{itemTagName:"DIV",orderBy:"publishDateUtc desc",refreshSection:true,groupBy:function(item){return Journal._6(item)},formatGroup:function(v){return Journal._5(v)},getMaxItems:function(parent){return Journal._7(parent)},isItemRendered:function(item){return Journal._2(item)},renderItemContent:function(w,item,index){Journal._1(w,item)},renderItemDivider:function(w,s){Journal._8(w,s)}},Details:{itemTagName:"DIV",orderBy:"publishDateUtc desc",refreshSection:true,groupBy:function(item){return Journal._6(item)},formatGroup:function(v){return Journal._5(v)},getMaxItems:function(parent){return Journal._7(parent)},isItemRendered:function(item){return Journal._2(item)},renderItemContent:function(w,item,index){var s=item.section;if(index<s.maxDetailItems){Journal._16(w,item)}else if(index<(s.maxDetailItems+s.maxSummaryItems)){Journal._1(w,item)}},renderItemDivider:function(w,s){Journal._8(w,s)}},ItemDetail:{kind:1,renderItemContent:function(w,item,index){var t=Journal;var p=new ItemPanel(w,item);p.property("Title",item.title);p.property("Details",item.text);p.property("Attachments",Journal._14(item),{"vertical-align":"top"});var categoryList=[];var categories=Journal._12(item);if(categories){for(var i=0;i<categories.length;i++){categoryList.push(categories[i].title)}}p.property("Categories",categoryList.join(", "));p.created();p.modified();p.close()}}},_14:function(item){if(!item||!item.attachments||item.attachments.length==0)return null;var sb=new StringBuilder();var w=sb.write;w("<table cellspacing='4px'>","<col width=1 style='text-align:center'>","<col width=100 style='text-align:center'>","<col width=100 style='text-align:center'>","<thead>","<tr>","<th style='padding:0px;text-align:center;'>","File","</th>","<th style='padding:0px;text-align:center;'>","Size","</th>","<th style='padding:0px;text-align:center;'>","Uploaded","</th>","</tr>","</thead>");if(item.attachments){for(var i=0;i<item.attachments.length;i++){var a=item.attachments[i];var downloadHref=WebPath.fromPathKey(page.pageId)+"/"+item.nodeId+"/"+WindowEx.encodeFileName(a.fileName);var iconSrc=Journal._10(a.fileName);var d=Date.fromSeconds(a.created);var age=(d?Date.formatAge(d)+" ago":"");w("<tr>","<td>","<a",Html.attribute("href",downloadHref)," tip='attachment:",item.nodeId,"|",a.fileName+"'>",ImageEx.formatImg(iconSrc,16,16,{border:"0"},{"vertical-align":"middle",margin:"0px 3px 2px 0px"}),a.title||a.fileName,"</a>","</td>","<td>",a.size.toFileSize(),"</td>","<td style='text-align:center;'>",age,"</td>","</tr>")}}w("</table>");return sb.toString()},_6:function(item){if(!item.publishDateUtc)return 0;var publishDate=Date.fromSeconds(item.publishDateUtc);if(!publishDate)return 0;publishDate.setHours(0,0,0,0);return publishDate.getTime()},_5:function(v){var s="";if(v!=0){s=new Date(v).toDateTimeString("uDF")}return s},_8:function(w,s){w("<div class='hr divider' style='font-size: 4px;'>&nbsp;</div>")},_7:function(parent){var s=parent.section;return(s.maxDetailItems||0)+(s.maxSummaryItems||0)},_2:function(item){var inFilter=true;if(window.Filter&&window.Filter.filterStartTime&&item.publishDateUtc){var dt=Date.fromSeconds(item.publishDateUtc);inFilter=dt>window.Filter.filterStartTime}return(inFilter&&(!item.isDraft||item.permissions.edit))},renderEmpty:function(w,s){Section.renderEmpty(w,s,"Add Journal Entry")},addItems:function(id,beforeId){Module.showDialog(Journal,"EditDialog",{parentId:id,beforeId:beforeId})},updateItem:function(i){if(i){Module.showDialog(Journal,"EditDialog",{item:page.nodes[i]})}},deleteItem:function(id){ContentItem.deleteItem(id)},_16:function(w,item){var s=item.section;var d=Date.fromSeconds(item.publishDateUtc);w("<div class=journalItem >");w("<div style='padding-bottom:5px;'>","<span class='journalItemHeader'>",ImageEx.formatImg(A.imagesBase+"trianglebullet.png",5,9,{"class":"trianglebullet"}));var styles={};var atts={};PageNode.renderLink(w,item,atts,styles);w("</span>");if(U.un){w("<span class='journalItemButtons printHide'>&nbsp;");CommandBar.renderImg(w,5,"Journal._13("+item.nodeId+")",{alt:"Send Journal Entry"});w("</span>")}if(item.isDraft){w(" <span class='journalItemAge color-red'>[DRAFT]</span>")}else if(!item.publishDateUtc||item.publishDateUtc==0){w(" <span class='journalItemAge color-red'>[UNPUBLISHED]</span>")}w("</div>");if(item.categoryIds&&item.categoryIds.length>0){var i;var categories=Journal._12(item);if(categories&&categories.length>0){w("<div class=cg-title style='margin-left:0px;margin-top:3px;'>","Category: ");for(i=0;i<categories.length;i++){w(i>0?" | ":"");var cat=categories[i];w(cat.title);}w("</div><br/>")}}w("<div class=journalItemBody>",(item.text||""),"</div>");if(item.attachments&&item.attachments.length>0){w("<div class=cg-title style='margin-left:0px;margin-top:10px;'>","Attachments:","</div>","<table style='margin-left:8px;'>");for(i=0;i<item.attachments.length;i++){var a=item.attachments[i];var href=WebPath.fromPathKey(page.pageId)+"/"+item.nodeId+"/"+WindowEx.encodeFileName(a.fileName);w("<tr>","<td>",Journal._9(a.fileName),"<a",Html.attribute("href",href)," tip='attachment:",item.nodeId,"|",a.fileName+"'>",a.title||a.fileName,"</a>","</td>","</tr>")}w("</table>")}var user=item.userSummary||page.site;var postedBy="";if(user){postedBy=" by "+User.formatLink(user)}var postedAt="";if(d){postedAt=" at "+d.toDateTimeString("ut")}if(user||d){var text=(item.isDraft||!item.publishDateUtc)?"Created":"Published";w("<div class=cg-title style='padding-top:10px;padding-bottom:10px;margin-left:0px;'>",text,postedBy,postedAt)}if(!item.isDraft&&item.publishDateUtc){if(user||d){w(" | ")}ItemComment.renderCount(w,item,1)}w("</div>","</div>")},_1:function(w,item){var s=item.section;var postedBy="";var user=item.userSummary||page.site;if(user){postedBy=" - By "+User.formatLink(user)}var d=Date.fromSeconds(item.publishDateUtc);var postedAt="";if(d){postedAt=" At "+d.toDateTimeString("ut")}w("<div class=journalItem >");var hasImage=false;var image=item.image;if(image&&!Journal._4.isHidden(image)){if(Journal._4.render(w,{className:"journalItemImage",src:image,align:"left"})){hasImage=true}}var strippedText=Journal._17(item.text);if(strippedText.length>Journal._3){strippedText=strippedText.substring(0,Journal._3)+"..."+"<a href='"+PageNode.formatHref(item)+"'>[more]</a>"}w("<div style='padding-bottom:5px;'>","<span class='journalItemHeader'>",ImageEx.formatImg(A.imagesBase+"trianglebullet.png",5,9,{"class":"trianglebullet"}));var styles={};var atts={tip:"item:"+item.nodeId};PageNode.renderLink(w,item,atts,styles);w("</span>");if(U.un){w("<span class='journalItemButtons printHide'>&nbsp;");CommandBar.renderImg(w,5,"Journal._13("+item.nodeId+")",{alt:"Send Journal Entry"});w("</span>")}w("</div>","<div class=journalItemBody>","<span class=journalItemDescription>",strippedText,"</span>","<span class='journalItemAuthor color-lightest'>",postedBy,postedAt,"</span>","</div>",(hasImage?"<div class=clear>&nbsp;</div>":""),"</div>")},_12:function(item){var categories=[];var secCats=item.section.categories;if(item.categoryIds){for(var i=0;i<item.categoryIds.length;i++){var categoryId=item.categoryIds[i];var categoryTitle="";if(secCats){for(var j=0;j<secCats.length;j++){if(secCats[j].categoryId==categoryId){categories.push({id:categoryId,title:secCats[j].title});break}}}}}return categories},_17:function(text){var s="";if(text){s=text.replace(/<([^>'"]*|"[^"]*"|'[^']*')*>/g,"");s=s.replace(/ +/g," ");}return s},updateSection:function(s){Module.showDialog(Journal,"UpdateSectionDialog",{section:s})},_13:function(nodeId){var item=page.nodes[nodeId];if(item){var cr="<br/>";var body=StringEx.joinOptional(cr+cr,item.title,item.text,"Source: <a href='"+location.href+"'>"+page.title+"</a>");C.send({subject:item.title,body:body})}},onTip:function(evt){if(evt.tip||evt.tip.startsWith("attachment:")){var data=evt.tip.substring(11);var parts=data.split("|");if(parts.length!=2)return;var nodeId=parts[0];var fileName=parts[1];var item=page.nodes[nodeId];var a=null;if(item.attachments){for(var i=0;i<item.attachments.length;i++){if(item.attachments[i].fileName==fileName){a=item.attachments[i];break}}}if(a==null)return;var sb=new StringBuilder();var w=sb.write;w("<table>","<tr valign=top>","<td>",Journal._9(a.fileName),"</td>","<td>","<b>"+a.fileName+"</b><br/>");var cd=Date.fromSeconds(a.created);if(a.created&&cd){w("<span class=output-label>Uploaded: </span>"+Date.formatAge(cd)+" ago<br/>")}w("<span class=output-label>Size: </span>"+a.size.toFileSize());evt.tip=sb.toString()}},_9:function(fileName){var src=Journal._10(fileName);return ImageEx.formatImg(src,16,16,{},{"float":"left",margin:"0px 3px 2px 0px"})},_15:function(){if(!Journal._0){Journal._0={};for(var i=0;i<Journal._11.length;i++){var e=Journal._11[i];Journal._0[e]=true}}},_10:function(fileName){Journal._15();var ext=Journal.getFileExtension(fileName);ext=(Journal._0[ext])?ext:"document";return A.imagesBase+"DocumentIcons"+"/"+ext+".png"},getFileExtension:function(fileName){var ext="document";if(fileName){var pos=fileName.lastIndexOf('.');if(pos!=-1&&pos+1<fileName.length){ext=fileName.substring(pos+1)}}return ext},_18:function(c){Dialog.alert("Not Implemented.")},_11:["ade","adn","adp","as","asp","aspx","avi","bmp","chm","cpp","cs","csv","doc","eps","fla","gif","gz","htm","html","iso","jar","java","jpeg","jpg","js","log","m3u","mdb","mov","mp3","mpeg","msi","opml","pdf","png","pps","ppt","psd","ra","ram","raw","rm","rtf","sln","swf","tar","tif","txt","vb","vbs","vdx","vsd","wav","wma","wmv","xls","xml","zip"],_0:null};Module.add(Journal);