protected void Page_Load(object sender, EventArgs e)
    {
        i18n = new i18nHelper();
        this.Title = i18n.GetMessage("m261") + " @ " + i18n.GetMessage("m9");
        this.forwardSend.Text = i18n.GetMessage("m78");
        currentUser = WebUtility.GetCurrentKBUser();
        subjectid = currentUser.SubjectId;
        documentService = factory.GetDocumentService();
        categoryService = factory.GetCategoryService();
        ratingService = factory.GetRatingService();
        auditTrailService = factory.GetAuditTrailService();
        wfService = factory.GetWorkflowService();
        hitService = factory.GetHitService();
        documentClassService = factory.GetDocumentClassService();
        subscribeService = WebUtility.Repository.GetSubscribeService();
        docId = WebUtility.GetIntegerParameter("documentId");
        folderId = WebUtility.GetIntegerParameter("folderId", -1);
        ver = WebUtility.GetIntegerParameter("ver", 0);
        latestVersionNumber = buildVersionInfo();
        currentUserOutputConfig = WebUtility.GetUserOutputConfig(currentUser.SubjectId);
        attachMode = currentUserOutputConfig.AttachMode;
        showUsedTags = ConfigurationManager.AppSettings["ShowUsedTags"] != null ? ConfigurationManager.AppSettings["ShowUsedTags"] : "false";
        tagsAutoComplete = ConfigurationManager.AppSettings["TagsAutoComplete"] != null ? ConfigurationManager.AppSettings["TagsAutoComplete"] : "false";
        tagsSuggestListLen = ConfigurationManager.AppSettings["TagsSuggestListLen"] != null ? ConfigurationManager.AppSettings["TagsSuggestListLen"] : "10";
        subscriptionConfirm = Convert.ToBoolean(ConfigurationManager.AppSettings["SubscriptionConfirm"] != null ? ConfigurationManager.AppSettings["SubscriptionConfirm"].ToString() : "true");
        autoSubscription = Convert.ToBoolean(ConfigurationManager.AppSettings["AutoSubscription"] != null ? ConfigurationManager.AppSettings["AutoSubscription"].ToString() : "true");
        allowSendToNoPrivilegeUser = Convert.ToBoolean(ConfigurationManager.AppSettings["AllowSendToNoPrivilegeUser"] != null ? ConfigurationManager.AppSettings["AllowSendToNoPrivilegeUser"].ToString() : "true");
        TagMaxLength = ConfigurationManager.AppSettings["TagMaxLength"] != null ? ConfigurationManager.AppSettings["TagMaxLength"] : "30";
        IsSafari = (Request.Browser.Browser.ToLower().Equals("applemac-safari") && !Request.UserAgent.ToLower().Contains("chrome"));
        userHadSubscribeResource = subscribeService.UserHadSubscribedResource(currentUser.SubjectId, (int)currentUser.SubjectType, docId, (int)SubscribeRecord.ResourceType.Document);
        mailService = WebUtility.Repository.GetMailService();
        kbuserService = WebUtility.Repository.GetKBUserService();
        folderService = WebUtility.Repository.GetFolderService();
        forwardService = WebUtility.Repository.GetForwardService();
        if (ver == 0)
        {
            doc = documentService.GetDocument(currentUser, docId);
            ver = latestVersionNumber;
        }
        else
        {
            doc = documentService.GetDocument(currentUser, docId, ver);
        }
        readVersion.Text = ver.ToString();
        latestVersion.Text = latestVersionNumber.ToString();
        if (ver != latestVersionNumber)
        {
            Panel1.Visible = false;
        }
        if (folderId == -1)
        {
            FolderInfo f = documentService.GetParentFolders(currentUser, docId)[0];
            folderId = f.FolderId;
        }

        buildCategoriesList();
        buildDocumentView();

        #region For teamKube Xml Render
        if (IsACLiteSubjectProvider)
        {
            renderSpecXml = RenderSpecificXML(currentUser, doc.DocumentId, ver);
        }
        #endregion

        if(!doc.DocumentClass.ClassName.Trim().ToLower().Equals("filesystem"))
        {
            buildFileList();
        }

        buildRatingSummary();
        buildAuditTrailInfo();
        createHitInfo();
        buildRelatedTagList(20);
        buildRelatedDocumentList();
        checkWorkflowInvolved();
        isDiffDocClass = IsDiffDocumentClass();
        strDiffDocClass = String.Format(i18n.GetMessage("m801"), doc.DocumentClass.ClassName, i18n.GetMessage("m802"), i18n.GetMessage("m803"));

        isBuiltinDocumentClass = (doc.DocumentClass.IsBuiltIn == true) ? "true" : "false";
    }