Imports System.Collections.Generic
Imports CharterDotCom.CommonEntities.Library
Imports CharterDotCom.CommonEntities.Library.Enumerations
Imports CharterDotCom.CommonEntities.Library.EntityMemberServices
'Imports CharterDotCom.CommonEntities.Library.EntityEBSServices
Imports CharterDotCom.CommonEntities.Library.EntitySupport
Imports CharterDotCom.CommonEntities.Library.EntitySearch
Imports CharterDotCom.CommonEntities.Library.EntityWebConfig
'Imports CharterDotCom.CommonEntities.Library.EntityG2BServices
Imports CharterDotCom.CommonEntities.Library.Common
Imports CharterDotCom.WebSite.Library

Partial Class Controls_CustomContent2
	Inherits System.Web.UI.UserControl

	Public Property ContentKey() As String
		Get
			If ViewState(Me.ID & "_ContentKey") Is Nothing Then
				Return Nothing
			Else
				Return CType(ViewState(Me.ID & "_ContentKey"), String)
			End If
		End Get

		Set(ByVal value As String)
			ViewState(Me.ID & "_ContentKey") = value
		End Set
	End Property

	Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		If Not Page.IsPostBack Then
			If Page.User.IsInRole(RoleName.Author) Then
				pContentHead.Style("border") = "red solid 1px"
				pContentHead.Attributes("onclick") = String.Format("top.editor.location.href='{0}/Authors/Editor.aspx?{1}={2}&{3}={4}&{5}={6}'", _
				 Request.ApplicationPath, QueryStringName.OwnerTypeID, OwnerType.Other.GetHashCode(), _
				 QueryStringName.OwnerID, 0, QueryStringName.ControlID, ContentKey & ":Head")

				pContentBody.Style("border") = "red solid 1px"
				pContentBody.Attributes("onclick") = String.Format("top.editor.location.href='{0}/Authors/Editor.aspx?{1}={2}&{3}={4}&{5}={6}'", _
				 Request.ApplicationPath, QueryStringName.OwnerTypeID, OwnerType.Other.GetHashCode(), _
				 QueryStringName.OwnerID, 0, QueryStringName.ControlID, ContentKey & ":Body")
			Else
				pContentHead.Style("border") = "0"
				pContentHead.Attributes.Remove("onclick")

				pContentBody.Style("border") = "0"
				pContentBody.Attributes.Remove("onclick")
			End If
		End If
	End Sub

	Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
		If Not Page.IsPostBack Then
            If ContentKey IsNot Nothing Then
                '#############################################################################
                'M O D I F I C A T I O N   9/24/2007     ROD COPELAND
                '#############################################################################
                'PERFORMANCE CHANGE FOR THIS CONTROL IN THE MYACCOUNT SECTION. RIGHT NOW, IT 
                'LOOKS LIKE THIS CONTROL DOES A REMOTING CALL TO GET CONTENT EVERY TIME 
                'THE PAGE_LOAD IS CALLED, LOOKS TO BE UNNECESSARY. TO RESOLVE THIS ISSUE FOR 
                'THE MOST CRITICAL PLACE THAT DOESNT USE OUTPUT CACHING (THE MYACCOUNT SECTION 
                'AND ALL ITS PERSONALIZATION), DETERMINE IF THIS CONTROL IS BEING USED IN THE 
                'MYACCOUNT AREA, IF SO, THEN USE A CACHED COPY OF THE VALUE RATHER THAN DOING 
                'A REMOTING CALL TO GET THE SAME THING.  THIS LOGIC APPLIES TO MYACCOUNT PAGES 
                'ONLY RIGHT NOW SINCE THE TIME HASN'T BEEN ALLOCATED TO RESEARCH THE IMPLICATIONS 
                'OF CACHING THE CONTROL ALL OVER THE SITE.  THE CURRENT VERSION OF THE CONTROL 
                'IS FOR A GROUP OF USERS, NOT INDIVIDUALS SO, ITS USED IN A APPLICATION VARIABLE 
                'RATHER THAN SESSION.
                '#############################################################################
                Select Case True
                    Case Request.Url.ToString().ToLower().Contains("order/login.aspx")
                        '###############################################
                        'GET THE GENERALIZED CONTENT, NOT USER SPECIFIC
                        '###############################################
                        ltrContentHead.Text = ContentManager.Instance.GetContent(ContentKey & ":Head", 1, OwnerType.Other)
                    Case Request.Url.ToString().ToLower().Contains("visitors/forgot.aspx")
                        '###############################################
                        'GET THE GENERALIZED CONTENT, NOT USER SPECIFIC
                        '###############################################
                        ltrContentHead.Text = ContentManager.Instance.GetContent(ContentKey & ":Head", 1, OwnerType.Other)
                    Case Request.Url.ToString().ToLower().Contains("account/myaccount.aspx")
                        '###############################################
                        'GET THE GENERALIZED CONTENT, NOT USER SPECIFIC
                        '###############################################
                        ltrContentHead.Text = ContentManager.Instance.GetContent(ContentKey & ":Head", 1, OwnerType.Other)
                    Case Request.Url.ToString().ToLower().Contains("account/manageemailaccounts.aspx")
                        '###############################################
                        'GET THE GENERALIZED CONTENT, NOT USER SPECIFIC
                        '###############################################
                        ltrContentHead.Text = ContentManager.Instance.GetContent(ContentKey & ":Head", 1, OwnerType.Other)
                    Case Request.Url.ToString().ToLower().Contains("account/highspeedsecurity.aspx")
                        '###############################################
                        'GET THE GENERALIZED CONTENT, NOT USER SPECIFIC
                        '###############################################
                        ltrContentHead.Text = ContentManager.Instance.GetContent(ContentKey & ":Head", 1, OwnerType.Other)
                    Case Request.Url.ToString().ToLower().Contains("account/managelogin.aspx")
                        '###############################################
                        'GET THE GENERALIZED CONTENT, NOT USER SPECIFIC
                        '###############################################
                        ltrContentHead.Text = ContentManager.Instance.GetContent(ContentKey & ":Head", 1, OwnerType.Other)
                    Case Request.Url.ToString().ToLower().Contains("account/managewebspace.aspx")
                        '###############################################
                        'GET THE GENERALIZED CONTENT, NOT USER SPECIFIC
                        '###############################################
                        ltrContentHead.Text = ContentManager.Instance.GetContent(ContentKey & ":Head", 1, OwnerType.Other)
                    Case Request.Url.ToString().ToLower().Contains("visitors/products.aspx")
                        '###############################################
                        'GET THE GENERALIZED CONTENT, NOT USER SPECIFIC
                        '###############################################
                        ltrContentHead.Text = ContentManager.Instance.GetContent(ContentKey & ":Head", 1, OwnerType.Other)
                    Case Else
                        '#########################################
                        'GET THE SESSION SPECIFIC CONTENT RECORD.
                        '#########################################
                        ltrContentHead.Text = ContentManager.Instance.GetContent(ContentKey & ":Head", 1, OwnerType.Other)
                End Select
                '#############################################################################




                If ltrContentHead.Text = String.Empty Then
                    ltrContentHead.Text = "ControlID - " & ContentKey & ":Head"
                End If







                '#############################################################################
                'M O D I F I C A T I O N   9/24/2007     ROD COPELAND
                '#############################################################################
                'PERFORMANCE CHANGE FOR THIS CONTROL IN THE MYACCOUNT SECTION. RIGHT NOW, IT 
                'LOOKS LIKE THIS CONTROL DOES A REMOTING CALL TO GET CONTENT EVERY TIME 
                'THE PAGE_LOAD IS CALLED, LOOKS TO BE UNNECESSARY. TO RESOLVE THIS ISSUE FOR 
                'THE MOST CRITICAL PLACE THAT DOESNT USE OUTPUT CACHING (THE MYACCOUNT SECTION 
                'AND ALL ITS PERSONALIZATION), DETERMINE IF THIS CONTROL IS BEING USED IN THE 
                'MYACCOUNT AREA, IF SO, THEN USE A CACHED COPY OF THE VALUE RATHER THAN DOING 
                'A REMOTING CALL TO GET THE SAME THING.  THIS LOGIC APPLIES TO MYACCOUNT PAGES 
                'ONLY RIGHT NOW SINCE THE TIME HASN'T BEEN ALLOCATED TO RESEARCH THE IMPLICATIONS 
                'OF CACHING THE CONTROL ALL OVER THE SITE.  THE CURRENT VERSION OF THE CONTROL 
                'IS FOR A GROUP OF USERS, NOT INDIVIDUALS SO, ITS USED IN A APPLICATION VARIABLE 
                'RATHER THAN SESSION.
                '#############################################################################
                Select Case True
                    Case Request.Url.ToString().ToLower().Contains("order/login.aspx")
                        '###############################################
                        'GET THE GENERALIZED CONTENT, NOT USER SPECIFIC
                        '###############################################
                        ltrContentBody.Text = ContentManager.Instance.GetContent(ContentKey & ":Body", 1, OwnerType.Other)
                    Case Request.Url.ToString().ToLower().Contains("visitors/forgot.aspx")
                        '###############################################
                        'GET THE GENERALIZED CONTENT, NOT USER SPECIFIC
                        '###############################################
                        ltrContentBody.Text = ContentManager.Instance.GetContent(ContentKey & ":Body", 1, OwnerType.Other)
                    Case Request.Url.ToString().ToLower().Contains("account/myaccount.aspx")
                        '###############################################
                        'GET THE GENERALIZED CONTENT, NOT USER SPECIFIC
                        '###############################################
                        ltrContentBody.Text = ContentManager.Instance.GetContent(ContentKey & ":Body", 1, OwnerType.Other)
                    Case Request.Url.ToString().ToLower().Contains("account/manageemailaccounts.aspx")
                        '###############################################
                        'GET THE GENERALIZED CONTENT, NOT USER SPECIFIC
                        '###############################################
                        ltrContentBody.Text = ContentManager.Instance.GetContent(ContentKey & ":Body", 1, OwnerType.Other)
                    Case Request.Url.ToString().ToLower().Contains("account/highspeedsecurity.aspx")
                        '###############################################
                        'GET THE GENERALIZED CONTENT, NOT USER SPECIFIC
                        '###############################################
                        ltrContentBody.Text = ContentManager.Instance.GetContent(ContentKey & ":Body", 1, OwnerType.Other)
                    Case Request.Url.ToString().ToLower().Contains("account/managelogin.aspx")
                        '###############################################
                        'GET THE GENERALIZED CONTENT, NOT USER SPECIFIC
                        '###############################################
                        ltrContentBody.Text = ContentManager.Instance.GetContent(ContentKey & ":Body", 1, OwnerType.Other)
                    Case Request.Url.ToString().ToLower().Contains("account/managewebspace.aspx")
                        '###############################################
                        'GET THE GENERALIZED CONTENT, NOT USER SPECIFIC
                        '###############################################
                        ltrContentBody.Text = ContentManager.Instance.GetContent(ContentKey & ":Body", 1, OwnerType.Other)
                    Case Request.Url.ToString().ToLower().Contains("visitors/products.aspx")
                        '###############################################
                        'GET THE GENERALIZED CONTENT, NOT USER SPECIFIC
                        '###############################################
                        ltrContentBody.Text = ContentManager.Instance.GetContent(ContentKey & ":Body", 1, OwnerType.Other)
                    Case Else
                        '#########################################
                        'GET THE SESSION SPECIFIC CONTENT RECORD.
                        '#########################################
                        ltrContentBody.Text = ContentManager.Instance.GetContent(ContentKey & ":Body", 1, OwnerType.Other)
                End Select
                '#############################################################################




                If ltrContentBody.Text = String.Empty Then
                    ltrContentBody.Text = "ControlID - " & ContentKey & ":Body"
                End If

                txtContentKey.Value = ContentKey
            End If
		End If
	End Sub
End Class