var Files={id:"Files",title:"Files",image:"files16.gif",allowItems:true,allowFolders:true,allowDrag:true,allowComments:true,itemName:"File",itemClassName:"files",AddDialog:"adddialog/105232560.js",UpdateDialog:"updatedialog/60098140.js",defaultLayout:"List",detailLayout:"ItemDetail",fileTypes:{ade:"Microsoft Office Access Project Extension",adn:"Microsoft Office Access Blank Project Template",adp:"Microsoft Office Access Project",as:"Flash ActionScript File",asp:"Active Server Document",aspx:"ASP.NET Server Page",avi:"Video Clip",bmp:"Bitmap Image",chm:"Compiled HTML Help file",cpp:"C++ Source",cs:"Visual C# Source file",csv:"Microsoft Office Excel Comma Separated Values File",doc:"Microsoft Word Document",eml:"Internet E-Mail Message",eps:"EPS File",fla:"Flash Document",gif:"GIF Image",gz:"WinZip File",htm:"HTML Document",html:"HTML Document",iso:"Virtual Machine CD-ROM Image",jar:"Executable Jar File",java:"Java Language Source file",jpeg:"JPEG Image",jpg:"JPEG Image",js:"JScript Script File",log:"Text Document",m3u:"M3U file",mdb:"Microsoft Office Access Application",mov:"QuickTime Movie",mp3:"MP3 Format Sound",mpeg:"Movie Clip",msi:"MSI Package",opml:"OPML File",pdf:"Adobe Acrobat 7.0 Document",png:"PNG Image",pps:"Microsoft PowerPoint Slide Show",ppt:"Microsoft PowerPoint Presentation",psd:"Adobe Photoshop Image",ra:"RealAudio",ram:"RealPlayer Presentation",raw:"RAW File",rm:"RealAudio / RealVideo",rtf:"Rich Text Format",sln:"Microsoft Visual Studio Solution",swf:"Flash Movie",tar:"WinZip File",tif:"Microsoft Office Document Imaging File",txt:"Text Document",vb:"Visual Basic Source file",vbs:"VBScript Script File",vdx:"Microsoft Visio Drawing",vsd:"Microsoft Visio Drawing",wav:"Wave Sound",wma:"Windows Media Audio file",wmv:"Windows Media Audio/Video file",xls:"Microsoft Excel Worksheet",xml:"XML Document",zip:"WinZip File"},sendUpdateRequest:function(item,dlg){var t=Files;dlg.intro="Please update the information for this File.";dlg.fields=[{label:"File",type:"Html",value:"<img align=absMiddle src='"+t._5(item)+"' /> <a"+Html.attribute("href",t._0(item))+">"+item.fileName+"</a>"},{name:"title",label:"Title",value:item.title},{name:"text",label:"Description",value:item.text,type:"TextArea"},{name:"comments.add",label:"Comments",type:"TextArea"}]},renderStyle:function(w){w(".files {clear: both;}")},layouts:{List:{itemTagName:"DIV",renderItemsHeader:function(w,s,items){},renderItemsFooter:function(w,s,items){},renderItemContent:function(w,item){Files.renderItemContent(w,item)},renderItemDivider:function(w){w("<div class=divider style='font-size:2px;'>&nbsp;</div>")}},Details:{itemTagName:"DIV",renderItemContent:function(w,item){Files.renderItemContent(w,item);if(item.text){w("<div class=filesDescription>",item.text,"</div>")}ItemComment.renderCount(w,item)},renderItemDivider:function(w){w("<div class=divider style='font-size:2px;'>&nbsp;</div>")}},ItemDetail:{kind:1,renderItemContent:function(w,item,index){var filePath=WebPath.fromPathKey(page.pageId)+"/"+item.nodeId+"/"+WindowEx.encodeFileName(item.fileName);var extension=Files.getFileExtension(item.fileName);var iconPath=A.imagesBase+"DocumentIcons"+"/"+extension+".png";var modified=item.modified||item.created;var p=new ItemPanel(w,item);var fileNameHtml="<a"+Html.attribute("href",filePath)+">"+ImageEx.formatImg(iconPath,16,16,{border:"0"},{"float":"left",margin:"0px 3px 2px 0px"})+item.fileName+"</a>";p.property("File Name",fileNameHtml);p.property("Title",item.title);p.property("Description",item.text);p.property("File Size",item.size.toFileSize());p.property("File Type",Files.fileTypes[extension]);var d=Date.fromSeconds(item.uploaded);if(d){p.property("Uploaded",d.toString2()+" by "+User.formatLink({userName:item.modifiedBy}))}if(item.uploaded!=item.modified){p.modified()}p.property("Downloads",item.downloads);if(item.revisions&&item.revisions.length>0){var sb=new StringBuilder();Files._3(sb.write,item);w("<tr>","<th style='text-align:right; vertical-align:top' class=output-label>","Revisions: ","</th>","<td>",sb.toString(),"</td>","</tr>")}p.close()}}},_3:function(w,item){var t=Files;w("<table cellspacing='4px' style='width:100%;'>","<col width=1 style='text-align:center'>","<col width=1 style='text-align:center'>","<col style='width:100px;'>","<col >","<thead>","<tr>","<th style='padding:0px;text-align:center;''>","Version","</th>","<th style='padding:0px;text-align:center;'>","Download","</th>","<th style='padding:0px;text-align:center;'>","Uploaded","</th>","<th style='padding:0px'>","Notes","</th>","</tr>","</thead>");var downloadHref=t._0(item);t._1(w,"Current",downloadHref,(item.modified||item.created),(item.modifiedBy||item.createdBy),"");if(item.revisions&&item.revisions.length>0){item.revisions.sortByProperty("uploaded desc");for(var i=0;i<item.revisions.length;i++){var r=item.revisions[i];downloadHref=WebPath.fromPathKey(page.pageId)+"/"+item.nodeId+"/"+WindowEx.encodeFileName(r.fileName);t._1(w,r.revision,downloadHref,r.uploaded,r.user,r.notes)}}w("</table>")},_1:function(w,rev,href,uploaded,user,notes){w("<tr>","<td>",rev,"</td>","<td>","<a",Html.attribute("href",href),">","<img src='",A.imagesBase,"download.gif'  />","</a>","</td>","<td style='text-align:center;'>");var d=Date.fromSeconds(uploaded);if(d){w(Date.formatAge(d)," ago","<br/>","<span style='font-size:77%;color:gray;'>","by: ",User.formatLink({userName:user}),"</span>")}w("</td>","<td>",notes,"</td>","</tr>")},createItemMenuItems:function(menu,item){if(item.revisions&&item.revisions.length>0){menu.add("Show "+(item.revisions.length+1)+" Revisions...",Files._2,item);menu.addDivider()}},_2:function(item){Files.updateItem(item.nodeId,true)},renderEmpty:function(w,s){Section.renderEmpty(w,s)},addItems:function(id,beforeId){if(!beforeId)beforeId=-1;Module.showDialog(Files,"AddDialog",{parentId:id,beforeId:beforeId})},insertItem:function(parentId,beforeId,item){C.beginExec("files/add",{parent:parentId,beforeId:beforeId,url:item.url,title:item.title,text:item.text})},insertItem2:function(parentId,beforeId,id,title,text){C.beginExec("files/add",{parent:parentId,beforeId:beforeId,url:id,title:title,text:text})},updateItem:function(i,showRevisions){if(i){Module.showDialog(Files,"UpdateDialog",{item:page.nodes[i],showRevisions:showRevisions})}},deleteItem:function(id){ContentItem.deleteItem(id)},renderItemContent:function(w,item){var t=Files;var atts={tip:'id:'+item.nodeId};var filePath=t._0(item);var extension=t.getFileExtension(item.fileName);if(!Files.fileTypes[extension]){extension="document"}var iconPath=A.imagesBase+"DocumentIcons"+"/"+extension+".png";var title=item.title||item.fileName;w("<div style='overflow:hidden;text-overflow:ellipsis;width:100%' >","<span style='white-space:nowrap'>",ImageEx.formatImg(iconPath,16,16,{},{margin:"0px 3px 0px 0px","vertical-align":"middle"}),Html.a(filePath,title,atts),"</span>","</div>")},getFileExtension:function(fileName){var extension="document";var extensionStartPos=fileName.lastIndexOf('.');if(extensionStartPos!=-1&&extensionStartPos+1<fileName.length){extension=fileName.substring(extensionStartPos+1)}return extension},onTip:function(evt){if(evt.tip&&evt.tip.startsWith("id:")){var nodeId=evt.tip.substring(3);evt.tip=Files._4(nodeId)}},_0:function(item){return WebPath.fromPathKey(page.pageId)+"/"+item.nodeId+"/"+WindowEx.encodeFileName(item.fileName)},_5:function(item){return A.imagesBase+"DocumentIcons"+"/"+Files.getFileExtension(item.fileName)+".png"},_6:function(label,value){if(value){return"<span class=output-label>"+label+": </span>"+value+""}else{return""}},_4:function(nodeId){var item=page.nodes[nodeId];var f=this._6;var desc=(item.text)?"<br/>"+item.text:"";var extension=Files.getFileExtension(item.fileName);var iconPath=A.imagesBase+"DocumentIcons"+"/"+extension+".png";var modified=item.modified||item.created;var html=ImageEx.formatImg(iconPath,16,16,{},{"float":"left",margin:"0px 3px 2px 0px"})+"<b>"+item.fileName+"</b> "+desc+"<div class=clear>&nbsp;</div>";var versions=null;if(item.revisions&&item.revisions.length>0){versions=item.revisions.length+1}var cd=Date.fromSeconds(item.created);var md=Date.fromSeconds(modified);var ud=Date.fromSeconds(item.uploaded);html+=StringEx.joinOptional("<br/>",f("Type",Files.fileTypes[extension]),f("Created",(cd?Date.formatAge(cd)+" ago":null)),f("Modified",(md?Date.formatAge(md)+" ago":null)),f("Uploaded",(ud?Date.formatAge(ud)+" ago":null)),f("Size",item.size.toFileSize()),f("Versions",versions),f("Downloads",item.downloads));return html}};Module.add(Files);