Index: EngineSource/LogEventType.cs
===================================================================
--- EngineSource/LogEventType.cs	(revision 641)
+++ EngineSource/LogEventType.cs	(working copy)
@@ -20,6 +20,7 @@
     WriteTopic, 
     DeleteTopic,
     CompareTopic,
-    NewsletterGeneration
+    NewsletterGeneration,
+    UploadFile
   };
 }
Index: FlexWiki.Web/flexwiki.config
===================================================================
--- FlexWiki.Web/flexwiki.config	(revision 641)
+++ FlexWiki.Web/flexwiki.config	(working copy)
@@ -167,6 +167,11 @@
         folder of the web application. Relative paths are relative to the root folder of the 
         web application. -->
   <!-- <Log4NetConfigPath>path\to\log4net.config</Log4NetConfigPath>-->
+  
+  <!-- The path to the upload directory. Path is relative to the root folder of the web application
+        and must exist prior to attmpted use (including subdirectories for:
+        doc, exe, files, html, images. -->
+  <ContentUploadPath>content\upload</ContentUploadPath>
 
   <!-- FlexWiki has a feature called newsletters, where the wiki will email members when 
         certain topics have changed. See http://www.flexwiki.com/default.aspx/FlexWiki/WikiNewsletter.html
Index: FlexWiki.Web/FlexWikiApplicationConfiguration.cs
===================================================================
--- FlexWiki.Web/FlexWikiApplicationConfiguration.cs	(revision 641)
+++ FlexWiki.Web/FlexWikiApplicationConfiguration.cs	(working copy)
@@ -12,7 +12,8 @@
         // Fields
 
         private string _captchaKey;
-        private int _captchaLinkThreshold; 
+        private int _captchaLinkThreshold;
+        private string _contentUploadPath;
         private string _defaultNamespaceProviderForNamespaceCreation = typeof(FileSystemNamespaceProvider).FullName;
         private bool _disableRenameFixup; 
         private bool _editOnDoubleClick = true;    // Required for legacy support - new properties should default to false
@@ -28,7 +29,7 @@
         private string _sendNamespaceCreationRequestsTo;
         private string _sendNamespaceRequestMailFrom;
         private bool _signNamespaceCreationMail;
-        
+
         // Properties
 
         public string CaptchaKey
@@ -41,6 +42,11 @@
             get { return _captchaLinkThreshold; }
             set { _captchaLinkThreshold = value; }
         }
+        public string ContentUploadPath
+        {
+            get { return _contentUploadPath; }
+            set { _contentUploadPath = value; }
+        }
         public string DefaultNamespaceProviderForNamespaceCreation
         {
             get { return _defaultNamespaceProviderForNamespaceCreation; }
Index: FlexWiki.Web/WikiEdit.aspx
===================================================================
--- FlexWiki.Web/WikiEdit.aspx	(revision 641)
+++ FlexWiki.Web/WikiEdit.aspx	(working copy)
@@ -1,4 +1,4 @@
-<%@ Page Language="c#" Codebehind="WikiEdit.aspx.cs" AutoEventWireup="false" Inherits="FlexWiki.Web.WikiEdit" %>
+<%@ Page Language="c#" AutoEventWireup="false" Inherits="FlexWiki.Web.WikiEdit" %>
 
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
 <html>
@@ -6,7 +6,7 @@
     <title>
         <%= TheTopic.ToString() %>
         (edit)</title>
-<meta name="Robots" content="NOINDEX, NOFOLLOW">
+<meta name="Robots" content="NOINDEX, NOFOLLOW" />
 <%= InsertStylesheetReferences() %>
 <script type="text/javascript" language="javascript" src="WikiEdit.js"></script>
 <style type="text/css"> @media all { tool\:tip { behavior: url(tooltip_js.htc) }}
@@ -17,5 +17,75 @@
 	.EditBox { font: 9pt Courier New; background: whitesmoke; height: 100%; height: expression(CalcEditBoxHeight()); width: 100%; }
 	</style>
 </head>
+<body class='EditBody' width='100%' height='100%' scroll='no'>
 <% DoPage(); %>
+       </td></tr></table><div id="AttachFile">
+                <table id="Table2" cellspacing="0" cellpadding="2" border="0" class="SidebarTile">
+                        <tr>
+                            <td valign="middle" class="SidebarTileTitle">
+                                File Attachment
+                            </td>
+                        </tr>
+                        <tr class="SidebarTileBody"><td>
+                               <form id="Form3" method="post" enctype="multipart/form-data" runat="server">
+
+                        <div id="ShowAttachmentControls" style="display: block" ><a onclick="javascript:Swap('ShowAttachmentControls', 'HideAttachmentControls')">Show Attachment Controls...</a> </div>
+                        <div id="HideAttachmentControls" style="display: none" ><a onclick="javascript:Swap('HideAttachmentControls', 'ShowAttachmentControls')" >Hide Attachment Controls...</a>
+                        <table><tr>
+                                <td colspan="2">
+                                        <p><input id="_filePath" type="file" size="30" name="_filePath" runat="server" />   
+                                                <button id="FileUploadSend" name="FileUploadSend" onclick="FileUploadSend_OnClick()">Send</button>
+                                                <input type='text' style='display:none' name='Topic' value ="<%= TheTopic.ToString() %>" />
+                                                <input type="text" style="display: none" id="Writable" name="Writable" value="<%= IsWritable.ToString() %>" />
+                                                <input type="text" style="display: none" id="Uploadable" name="Uploadable" value="<%= IsUploadable.ToString() %>" />
+                                                <textarea id="Text1" name="Text1" style="display:none" cols="20" rows="2"></textarea></p>
+                                </td>
+                        </tr>
+                        <tr>
+                                <td colspan="2">
+                                    <p><input id="Radio1" type="radio" name="attachFormat" value="Normal"  onfocus="showNormal_OnFocus()" />Normal Attachment</p>
+                                    <p><input id="Radio2" type="radio" name="attachFormat" value="Folder"  onfocus="showFolder_OnFocus()" />File Folder Attachment</p>
+                                    <p><input id="Radio3" type="radio" name="attachFormat"  value="DocMan" onfocus="showDocMan_OnFocus()" />Document Management Attachment</p>
+                                </td>
+                        </tr>
+                        <tr>
+                                <td colspan="2">
+                                        <div id="CommonFields" style="display:none" ><p>
+                                                Filename: <asp:Textbox id="_fileName" runat="server" Font-Bold="True" Visible="false"></asp:Textbox></p>
+                                        <p>
+                                                File Size: <asp:Textbox id="_fileSize" runat="server" Visible="False"></asp:Textbox></p>
+                                        <p>
+                                                <asp:Textbox id="_fileUrl" runat="server" Visible="false"></asp:Textbox> File URL</p>
+                                                <p><input id="Form3DocTitle" type="text" size="20" /> Document Title</p></div>
+                                                <div id="VersionFields" style="display:none" ><p><input id="Form3Version" type="text" /> Document Version</p></div>
+                                                <div id="FileNoFields" style="display:none" ><p><input id="Form3FileNo" type="text" /> Orig File No</p></div>
+                                                <div id="AuthorFields" style="display:none" ><p><input id="Form3Author" type="text" size="20" /> Originator</p></div>
+                                                <div id="PublishedFields" style="display:none" ><p><input id="Form3Published" type="text" /> Published</p></div>
+                                                <div id="FiledFields" style="display:none" ><p><input id="Form3Filed" type="text" /> Filed</p></div>
+                                                <div id="StatusFields" style="display:none" ><p>
+                                                    <select id="Form3Status">
+                                                        <option value="Draft">Draft</option>
+                                                        <option value="Review">Review</option>
+                                                        <option value="Acceptance">Acceptance</option>
+                                                        <option value="Published">Published</option>
+                                                        <option value="Cancelled">Cancelled</option>
+                                                    </select> Document Status
+                                                </p></div>
+                                                <div id="StatusDateFields" style="display:none" ><p>
+                                                    <input id="Form3StatusDate" type="text" /> Status Date</p></div>
+                                                <div id="CommentFields" style="display:none" ><p>Comment: <br /><textarea id="Form3Comment" cols="20" rows="2"></textarea></p></div>
+                                        <p>       
+                                                <asp:Label id="_errorMessage" runat="server" Visible="False"></asp:Label></p>
+                                                <p><button id="attachFile"  name="attachFile" onclick="attachFile_OnClick()" >Create Attachment</button> </p>
+                                </td>
+                        </tr>
+                        <tr>
+                                <td align="center" colspan="2">
+                                        <asp:Image id="_imgFile" runat="server" Visible="False"></asp:Image>
+                                </td>
+                        </tr></table></div></form></td></tr>
+                </table></div>
+</td></tr></table>
+</td></tr></table>
+</body>
 </html>
Index: FlexWiki.Web/WikiEdit.aspx.cs
===================================================================
--- FlexWiki.Web/WikiEdit.aspx.cs	(revision 641)
+++ FlexWiki.Web/WikiEdit.aspx.cs	(working copy)
@@ -13,6 +13,7 @@
 using System;
 using System.Collections;
 using System.ComponentModel;
+using System.Configuration;
 using System.Data;
 using System.Drawing;
 using System.IO;
@@ -35,13 +36,49 @@
     /// </summary>
     public class WikiEdit : BasePage
     {
+        protected System.Web.UI.WebControls.Image _imgFile;
+        protected System.Web.UI.WebControls.Label _errorMessage;
+        protected System.Web.UI.WebControls.TextBox _fileName;
+        protected System.Web.UI.WebControls.TextBox _fileUrl;
+        protected System.Web.UI.HtmlControls.HtmlInputFile _filePath;
+        protected System.Web.UI.WebControls.Button _fileUploadSend;
+        protected System.Web.UI.WebControls.TextBox _fileSize;
+
         private QualifiedTopicRevision _theTopic;
 
         private void Page_Load(object sender, System.EventArgs e)
         {
-            // Put user code to initialize the page here
+            //Page_Load code here
+            if (IsPostBack)
+            {
+                if (IsAttachment)
+                    FileUploadSendClick(sender, e);
+            }
         }
-
+        protected bool IsUploadable
+        {
+            get
+            {
+                string uploadDirectory = FlexWikiWebApplication.ApplicationConfiguration.ContentUploadPath;
+                if (uploadDirectory != null)
+                {
+                    return true;
+                }
+                else
+                {
+                    return false;
+                }
+            }
+        }
+        protected bool IsWritable
+        {
+            get
+            {
+                if (!Federation.TopicExists(TheTopic))
+                    return true;	// assume we can create
+                return Federation.IsExistingTopicWritable(TheTopic);
+            }
+        }
         protected string ReturnTopic
         {
             get
@@ -49,16 +86,16 @@
                 string answer = null;
                 if (IsPost)
                 {
-                    answer = Request.Form["ReturnTopic"];
-                }
+                    answer = Request.Form["Topic"];
+				}
                 else
                 {
-                    answer = Request.QueryString["return"];
-                }
+                    answer = Request.QueryString["topic"];
+				}
                 if (answer == "")
-                {
+				{
                     answer = null;
-                }
+				}
                 return answer;
             }
         }
@@ -78,6 +115,21 @@
             }
         }
 
+        private bool IsAttachment
+        {
+            get
+            {
+                if ((_filePath.Value.Length > 0) || (_fileName.Text.Length > 0))
+                {
+                    return true;
+                }
+                else
+                {
+                    return false;
+                }
+            }
+        }
+
         private bool IsBanned
         {
             get
@@ -154,15 +206,6 @@
                     !(currentStamp = Federation.GetTopicModificationTime(TheTopic)).ToString("s").Equals(lastEdit);
             }
         }
-        private bool IsWritable
-        {
-            get
-            {
-                if (!Federation.TopicExists(TheTopic))
-                    return true;	// assume we can create
-                return Federation.IsExistingTopicWritable(TheTopic);
-            }
-        }
         private string OriginalTopicText
         {
             get
@@ -185,6 +228,25 @@
         }
 
 
+        protected void DoPage()
+        {
+            if (IsPost && !IsConflictingChange && !IsBanned)
+            {
+                if (IsCaptchaVerified)
+                {
+                    ProcessPost();
+                }
+                else
+                {
+                    ShowEditPage(true);
+                }
+            }
+            else
+            {
+                ShowEditPage();
+            }
+        }
+
         protected void ProcessSave(bool back)
         {
             QualifiedTopicRevision returnTo = null;
@@ -232,19 +294,25 @@
                 string topic = "<<null>>";
                 if (TheTopic != null && TheTopic.DottedName != null)
                 {
-                    topic = TheTopic.DottedName;
-                    // On a null edit we want to make sure we go back to the right place. Without setting
-                    // returnTo, we'll wind up at the wiki default page. 
-                    returnTo = TheTopic; 
+                    topic = TheTopic.DottedName; 
                 }
                 FlexWikiWebApplication.LogDebug(this.GetType().ToString(), "A null edit was submitted for topic " + topic); 
             }
 
             if (returnTo == null)
             {
-                FlexWikiWebApplication.LogDebug(this.GetType().ToString(),
-                    "Redirecting to wiki root."); 
-                Response.Redirect(RootUrl);
+               
+                if (TheTopic != null && TheTopic.DottedName != null)
+                {
+                    Response.Redirect(TheLinkMaker.LinkToTopic(ReturnTopic.ToString()));
+                }
+                else
+                {
+                    FlexWikiWebApplication.LogDebug(this.GetType().ToString(),
+                        "Redirecting to wiki root.");
+                    Response.Redirect(RootUrl);
+                }
+                
             }
             else
             {
@@ -255,29 +323,120 @@
 
         }
 
-        protected void DoPage()
+        private int CountLinks(string text)
         {
-            if (IsPost && !IsConflictingChange && !IsBanned)
+            return TopicParser.CountExternalLinks(text); 
+        }
+        private void FileUploadSendClick(object sender, System.EventArgs e)
+        {
+
+            try
             {
-                if (IsCaptchaVerified)
+                // Check to        see        if file        was        uploaded
+                if (_filePath.PostedFile != null)
                 {
-                    ProcessPost();
+                    _errorMessage.Text = "";
+                    _errorMessage.Visible = false;
+                    _fileName.Visible = false;
+                    _fileSize.Visible = false;
+                    // Get a reference to PostedFile object
+                    HttpPostedFile fileToUpload = _filePath.PostedFile;
+                    int fileLength = fileToUpload.ContentLength;
+                    if (fileLength > 0)
+                    {
+                        // Allocate a buffer for reading of the file
+                        byte[] fileData = new byte[fileLength];
+                        string directoryToWriteTo;
+                        string writeToFile;
+                        string fileName;
+                        // Read        uploaded file from the Stream
+                        fileToUpload.InputStream.Read(fileData, 0, fileLength);
+                        directoryToWriteTo = ReturnDirectoryToWriteTo(fileToUpload.FileName);
+                        // Create a        name for the file to store
+                        fileName = Path.GetFileName(fileToUpload.FileName); //
+                        // Write data into a file
+                        writeToFile = Server.MapPath(fileName);
+                        // Get the current virtual directory, mapped to        a path
+                        writeToFile = Server.MapPath("") + "\\" + directoryToWriteTo + "\\" + fileName;
+                        // fileNumber var is the one digit number that is added        to a file name if it exists
+                        int fileNumber = 0;
+                        string fileNameAdder = "";
+                        string newFileName = "";
+
+
+                        // append a        three digit        int        to the file        name to        make it        unique
+                        while (File.Exists(writeToFile))
+                        {
+                            if (fileNumber > 9)
+                            {
+                                throw new System.IO.IOException("Too many copies of file exist on server.");
+                            }
+                            fileNumber++;
+                            fileNameAdder = ("-" + fileNumber.ToString("0") + ".");
+                            newFileName = Server.MapPath("") + "\\" + directoryToWriteTo + "\\" + fileName.Replace(".", fileNameAdder);
+
+
+                            if (File.Exists(newFileName))
+                            {
+                                // if the new file name is taken start over
+                                continue;
+                            }
+                            else
+                            {
+                                // if the new file name is not taken, terminate the loop
+                                writeToFile = newFileName;
+                                break;
+                            }
+                        }
+
+
+                        // write the file out
+                        WriteToFile(writeToFile, ref fileData);
+                        // get the name of the file
+                        fileName = Path.GetFileName(writeToFile);
+
+
+                        // Set label's text
+                        _fileName.Text = fileName;
+                        // show        the        location
+                        _fileSize.Text = fileLength.ToString("0,0") + " bytes";
+                        // show        the        full path
+                        _fileUrl.Text = RootUrl + directoryToWriteTo.Replace(@"\", @"/") + "/" + Path.GetFileName(writeToFile);
+                        _fileUrl.Visible = true;
+
+
+                        // Set URL of the the object to        point to the file we've        just saved
+                        if (IsImageFile(writeToFile))
+                        {
+
+                            _imgFile.ImageUrl = RootUrl + directoryToWriteTo.Replace(@"\", @"/") + "/" + Path.GetFileName(writeToFile);
+
+                            // show the images and text
+                            // fix for height and width to ensure edit text remains visible for large files.
+                            _imgFile.Visible = true;
+                            _fileUrl.Visible = true;
+                        }
+
+
+                        _fileSize.Visible = true;
+                        _fileName.Visible = true;
+                    }
+
+
                 }
-                else
-                {
-                    ShowEditPage(true); 
-                }
             }
-            else
+            catch (System.IO.IOException)
             {
-                ShowEditPage();
+                _errorMessage.Text = "There are too many files on the server with that name. Please rename it and upload again.";
+                _errorMessage.ForeColor = System.Drawing.Color.Red;
+                _errorMessage.Visible = true;
             }
+            //no changes ever made to the topic before the attachment was made
+            if (Request.Form["Text1"] == null)
+                Request.Form["Text1"] = OriginalTopicText;
+
         }
 
-        private int CountLinks(string text)
-        {
-            return TopicParser.CountExternalLinks(text); 
-        }
         private string GenerateNewCaptchaCode()
         {
             string code = CaptchaImage.GenerateRandomCode();
@@ -322,6 +481,17 @@
 
             return false;
         }
+        private bool IsImageFile(string fullPath)
+        {
+            bool blnIsImage = false;
+            fullPath = fullPath.ToUpper();
+            string extensionName = Path.GetExtension(fullPath);
+            if ((extensionName == ".JPG") || (extensionName == ".GIF") || (extensionName == ".PNG"))
+            {
+                blnIsImage = true;
+            }
+            return blnIsImage;
+        }
         private void LogBannedAttempt()
         {
             string to = FlexWikiWebApplication.ApplicationConfiguration.SendBanNotificationsToMailAddress;
@@ -354,15 +524,47 @@
         }
         private void ProcessPost()
         {
-            ProcessSave(true);
+            if (!IsAttachment)
+            {
+                ProcessSave(true);
+            }
+            else
+            {
+                ShowEditPage(true);
+            }
         }
+        private string ReturnDirectoryToWriteTo(string fileName)
+        {
+            // get the root        directory for uploaded files
+            string rootUploadDir = FlexWikiWebApplication.ApplicationConfiguration.ContentUploadPath;
+            string returnDirectory = "";
+            fileName = fileName.ToLower();
+            string extensionName = Path.GetExtension(fileName);
+            if ((extensionName == ".jpg") || (extensionName == ".gif") || (extensionName == ".png"))
+            {
+                returnDirectory = rootUploadDir + "\\images";
+            }
+            else if ((extensionName == ".htm") || (extensionName == ".html"))
+            {
+                returnDirectory = rootUploadDir + "\\html";
+            }
+            else if (extensionName == ".doc")
+            {
+                returnDirectory = rootUploadDir + "\\doc";
+            }
+            else
+            {
+                returnDirectory = rootUploadDir + "\\files";
+            }
+            return returnDirectory;
+        }
         private void ShowEditPage()
         {
             ShowEditPage(false); 
         }
         private void ShowEditPage(bool preserveContent)
         {
-            Response.Write("<body class='EditBody' width='100%' height='100%' scroll='no'>");
+            //Response.Write("<body class='EditBody' width='100%' height='100%' scroll='no'>");
 
             Response.Write("<table width='100%' id='MasterTable' height='100%' border='0' cellpadding='0' cellspacing='0'><tr><td valign='top'>");
             Response.Write("<div id='MainRegion' class='EditMain'>");
@@ -735,15 +937,14 @@
                     Response.Write("<tr><td colspan='2'><button onclick='javascript:SaveAndReturn()'  name='SaveButton'>Save and Back</button></td></tr>");
                 }
 
-
-                Response.Write("</table></div>");
+                //Response.Write("</table></div>");
             }
 
-            Response.Write("</td></tr></table>");
+            //Response.Write("</td></tr></table>");
 
-            Response.Write("</td></tr></table>");
+            //Response.Write("</td></tr></table>");
 
-            Response.Write("</body>");
+            //Response.Write("</body>");
 
         }
         private void WriteTip(string id, string text)
@@ -751,6 +952,26 @@
             Response.Write(@"<span onclick='javascript:ShowTip(""" + id + @""")'><b>" + text + "</b></span> ");
         }
 
+        // Writes file to specified path
+        private void WriteToFile(string filePath, ref byte[] Buffer)
+        {
+            LogEvent ev;
+            LogEventType evType = LogEventType.UploadFile;
+            ev = Federation.LogEventFactory.CreateAndStartEvent(Request.UserHostAddress, VisitorIdentityString, filePath, evType);
+
+            try
+            {
+                FileStream newFile = new FileStream(filePath, FileMode.Create);
+                newFile.Write(Buffer, 0, Buffer.Length);
+                newFile.Close();
+            }
+            finally
+            {
+                ev.Record();
+            }
+        }
+
+
         #region Web Form Designer generated code
         override protected void OnInit(EventArgs e)
         {
Index: FlexWiki.Web/WikiEdit.js
===================================================================
--- FlexWiki.Web/WikiEdit.js	(revision 641)
+++ FlexWiki.Web/WikiEdit.js	(working copy)
@@ -1,13 +1,108 @@
-function textArea_OnFocus(event)
+window.onload=AttachmentVisibility;
+
+function attachFile_OnClick()
 {
-	document.onkeypress = Document_OnKeyPress;
+    var insertText1 = "";
+    var insertText2 = "";
+    var insertText3 = "";
+    var insertText4 = "";
+    var textArea = document.forms["Form1"].Text1;
+    var docTitle = document.getElementById("Form3DocTitle").value;
+    var urlString = document.getElementById("_fileUrl").value;
+    var sizeString = document.getElementById("_fileSize").value;
+    var filedDate = document.getElementById("Form3Filed").value;
+    var publishedDate = document.getElementById("Form3Published").value;
+    var authorName = document.getElementById("Form3Author").value;
+    var fileNo = document.getElementById("Form3FileNo").value;
+    var versionNo = document.getElementById("Form3Version").value;
+    var commentText = document.getElementById("Form3Comment").value;
+    var attachFormatString = getCheckedValue(document.forms["Form3"].attachFormat);
+    var statusDate = document.getElementById("Form3StatusDate").value;
+    var templateCombo = document.getElementById("Form3Status");
+	if ((templateCombo) && (templateCombo.selectedIndex > -1))
+	{
+        var statusString = templateCombo.options[templateCombo.selectedIndex].value;
+    }
+    if (attachFormatString == "Normal")
+    {
+        insertText1 = '@@Presentations.Image(federation.LinkMaker.LinkToImage("images/attach/file.gif"))@@ '; 
+        insertText2 = '@@Presentations.Link("' + urlString + '", "' + docTitle + '", "' + sizeString + '")@@';
+    }
+    if (attachFormatString == "Folder")
+    {
+        insertText1 = '|| ' + filedDate + ' || @@Presentations.Image(federation.LinkMaker.LinkToImage("images/attach/file.gif"))@@ ';
+        insertText2 = '@@Presentations.Link("' + urlString + '", "' + docTitle + '", "' + sizeString + '")@@ || ';
+        insertText3 = fileNo + ' || ' + authorName + ' || ' + publishedDate + ' || ' + commentText + ' ||';
+    }
+    if (attachFormatString == "DocMan")
+    {
+        insertText1 = '|| ' + filedDate + ' || @@Presentations.Image(federation.LinkMaker.LinkToImage("images/attach/file.gif"))@@ ';
+        insertText2 = '@@Presentations.Link("' + urlString + '", "' + docTitle + '", "' + sizeString + '")@@ || ';
+        insertText3 = fileNo + ' || ' + authorName + ' || ' + statusString + ' || ' + statusDate + ' || ';
+        insertText4 = versionNo +  ' || @@Presentations.Checkbox("checkOut_' + statusString + '_' + versionNo + '", "strUrl", false)@@ ||' + commentText + ' ||';
+    }
+    textArea.value += "\n\r" + insertText1 + insertText2 + insertText3 + insertText4;
+    textArea.focus();
+    document.forms["Form3"].Text1.value = textArea.value;
 }
 
-function textArea_OnBlur(event)
+function AttachmentVisibility()
 {
-	document.onkeypress = null;
+    var writable = document.getElementById("Writable").value;
+    var uploadable = document.getElementById("Uploadable").value;
+    if ((writable == "True") && (uploadable == "True"))
+    {
+	writable = true;
+    }
+    else
+    {
+	writable = false;
+    }
+    ItemDisplay("AttachFile", writable);
 }
 
+function CalcEditBoxHeight()
+{
+	var answer = CalcEditZoneHeight();
+	return answer;
+}
+
+function CalcEditZoneHeight()
+{
+	var answer = MainHeight();
+	return answer;
+}
+
+function Cancel()
+{
+	history.back();
+}
+
+function ChangeTemplate(selectId)
+{
+	var templateCombo = document.getElementById(selectId);
+	if ((templateCombo) && (templateCombo.selectedIndex > -1))
+	{
+		var strInsertText = templateCombo.options[templateCombo.selectedIndex].value;
+		
+		var objTextArea = document.forms['Form1'].Text1;
+		if (document.selection && document.selection.createRange)
+		{
+			objTextArea.focus();
+			var objSelectedTextRange = document.selection.createRange();
+			var strSelectedText = objSelectedTextRange.text;
+			objSelectedTextRange.text = strInsertText + strSelectedText;
+		}
+		else
+		{
+			objTextArea.value += strInsertText;
+			objTextArea.focus();
+		}
+	}
+	var s = document.forms["Form1"].Text1.value;
+	document.forms["Form3"].Text1.value = s;
+}
+
 function Document_OnKeyPress(event)
 {
 	if (event != null) // FireFox only
@@ -28,23 +123,62 @@
 	return true;
 }
 
-function CalcEditBoxHeight()
+function FileUploadSend_OnClick()
 {
-	var answer = CalcEditZoneHeight();
-	return answer;
+	var s = document.forms["Form1"].Text1.value;
+	document.forms["Form3"].Text1.value = s;
+	document.getElementById("Form3").submit();
 }
 
-function CalcEditZoneHeight()
+// return the value of the radio button that is checked
+// return an empty string if none are checked, or
+// there are no radio buttons
+function getCheckedValue(radioObj) {
+	if(!radioObj)
+		return "";
+	var radioLength = radioObj.length;
+	if(radioLength == undefined)
+		if(radioObj.checked)
+			return radioObj.value;
+		else
+			return "";
+	for(var i = 0; i < radioLength; i++) {
+		if(radioObj[i].checked) {
+			return radioObj[i].value;
+		}
+	}
+	return "";
+}
+
+function ItemDisplay(itemId, display)
 {
-	var answer = MainHeight();
+    var a = document.getElementById(itemId);
+    if (display)
+    {
+        a.style.display = 'block';
+    }
+    else
+    {
+        a.style.display = 'none';
+    }
+}
+
+function MainHeight()
+{
+	var answer = document.body.clientHeight;
+	var e;
 	return answer;
 }
 
-function ShowTip(tipid)
+function MainWidth()
 {
-	var s = document.getElementById(tipid);
-	TipArea.innerHTML = s.innerHTML;
-	TipArea.style.display = 'block';
+	var answer = document.body.clientWidth;
+	var e;
+
+	e = document.getElementById("Sidebar");
+	if (e != null)
+		answer -= e.scrollWidth;
+	return answer;
 }
 
 function preview()
@@ -55,22 +189,27 @@
 	document.forms["Form2"].submit();
 }
 
-function Swap(alpha, beta)
+function Save()
 {
-	var a = document.getElementById(alpha);
-	var b = document.getElementById(beta);
-	if (a.style.display == 'block')
-	{
-		a.style.display = 'none';
-		b.style.display = 'block';
-	}
-	else
-	{
-		b.style.display = 'none';
-		a.style.display = 'block';
-	}	
+	SetUserName();
+	SetCaptcha();
+	var r = document.getElementById("ReturnTopic");
+	if (r != null)
+		r.value = ""; // prevent return action by emptying this out
+	document.getElementById("Form1").submit();
 }
 
+function SaveAndReturn()
+{
+	SetUserName();
+	document.getElementById("Form1").submit();
+}
+
+function search()
+{
+	window.open('Search.aspx');
+}
+
 function SetCaptcha()
 {
     var c = document.getElementById("CaptchaContext"); 
@@ -95,71 +234,77 @@
 		document.forms["Form1"].UserSuppliedName.value = r.value;
 }
 
-function Cancel()
+function showDocMan_OnFocus()
 {
-	history.back();
+    document.getElementById("Radio3").checked = true;
+    ItemDisplay("CommonFields", true)
+    ItemDisplay("FiledFields", true);
+    ItemDisplay("PublishedFields", false);
+    ItemDisplay("AuthorFields", true);
+    ItemDisplay("FileNoFields", true);
+    ItemDisplay("VersionFields", true);
+    ItemDisplay("CommentFields", true);
+    ItemDisplay("StatusDateFields", true);
+    ItemDisplay("StatusFields", true);
 }
 
-function Save()
+function showFolder_OnFocus()
 {
-	SetUserName();
-	SetCaptcha();
-	var r = document.getElementById("ReturnTopic");
-	if (r != null)
-		r.value = ""; // prevent return action by emptying this out
-	document.getElementById("Form1").submit();
+    document.getElementById("Radio2").checked = true;
+    ItemDisplay("CommonFields", true)
+    ItemDisplay("FiledFields", true);
+    ItemDisplay("PublishedFields", true);
+    ItemDisplay("AuthorFields", true);
+    ItemDisplay("FileNoFields", true);
+    ItemDisplay("VersionFields", false);
+    ItemDisplay("CommentFields", true);
+    ItemDisplay("StatusDateFields", false);
+    ItemDisplay("StatusFields", false);
 }
 
-function SaveAndReturn()
+function showNormal_OnFocus()
 {
-	SetUserName();
-	document.getElementById("Form1").submit();
+    document.getElementById("Radio1").checked = true;
+    ItemDisplay("CommonFields", true)
+    ItemDisplay("FiledFields", false);
+    ItemDisplay("PublishedFields", false);
+    ItemDisplay("AuthorFields", false);
+    ItemDisplay("FileNoFields", false);
+    ItemDisplay("VersionFields", false);
+    ItemDisplay("CommentFields", false);
+    ItemDisplay("StatusDateFields", false);
+    ItemDisplay("StatusFields", false);
 }
 
-function search()
+function ShowTip(tipid)
 {
-	window.open('Search.aspx');
+	var s = document.getElementById(tipid);
+	TipArea.innerHTML = s.innerHTML;
+	TipArea.style.display = 'block';
 }
 
-
-function MainHeight()
+function Swap(alpha, beta)
 {
-	var answer = document.body.clientHeight;
-	var e;
-	return answer;
+	var a = document.getElementById(alpha);
+	var b = document.getElementById(beta);
+	if (a.style.display == 'block')
+	{
+		a.style.display = 'none';
+		b.style.display = 'block';
+	}
+	else
+	{
+		b.style.display = 'none';
+		a.style.display = 'block';
+	}	
 }
 
-function MainWidth()
+function textArea_OnFocus(event)
 {
-	var answer = document.body.clientWidth;
-	var e;
-
-	e = document.getElementById("Sidebar");
-	if (e != null)
-		answer -= e.scrollWidth;
-	return answer;
+	document.onkeypress = Document_OnKeyPress;
 }
 
-
-function ChangeTemplate(selectId)
+function textArea_OnBlur(event)
 {
-	var templateCombo = document.getElementById(selectId);
-	if ((templateCombo) && (templateCombo.selectedIndex > -1))
-	{
-		var strInsertText = templateCombo.options[templateCombo.selectedIndex].value;
-		
-		var objTextArea = document.forms['Form1'].Text1;
-		if (document.selection && document.selection.createRange)
-		{
-			objTextArea.focus();
-			var objSelectedTextRange = document.selection.createRange();
-			var strSelectedText = objSelectedTextRange.text;
-			objSelectedTextRange.text = strInsertText + strSelectedText;
-		}
-		else
-		{
-			objTextArea.value += strInsertText;
-			objTextArea.focus();
-		}
-	}
+	document.onkeypress = null;
 }
