//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using CommunityServer.Blogs.Components;
using CommunityServer.ControlPanel.Controls;
using CommunityServer.ControlPanel.Controls.Blogs;
using CommunityServer.ControlPanel.UI;
using CommunityServer.Controls;
using TWC = Telligent.Web.UI;
using ResourceControl = CommunityServer.ControlPanel.Controls.ResourceControl;
using ResourceLinkButton = CommunityServer.ControlPanel.Controls.ResourceLinkButton;

namespace CommunityServer.ControlPanel.Blogs
{
	/// <summary>
	/// Summary description for PostEditorPage.
	/// </summary>
	public class SkinsOptionsPage : BaseBlogPage
	{
		protected ResourceLinkButton SaveButton;
		protected SkinOptionsControl Skin1;
		protected SkinOptionsCSSControl CSS1;
		protected ControlPanelSelectedNavigation SelectedNavigation1;
		protected ResourceControl Resourcecontrol1;
		protected MPContent DescriptionRegion;
		protected ResourceControl Resourcecontrol2;
		protected TWC.TabbedPanes EditorTabs;
		protected MPContent TaskRegion;
		protected MPContainer MPContainer;
		protected ConfigOKStatusMessage Status;

		private void Page_Load(object sender, EventArgs e)
		{
			if(!IsPostBack)
			{
				Skin1.Weblog = CSS1.Weblog = CurrentWeblog;
			}
		}

		override protected void OnInit(EventArgs e)
		{
			this.Load += new EventHandler(this.Page_Load);
			base.OnInit(e);
			this.SaveButton.Click += new EventHandler(this.SaveButton_Click);
		}

		private void InitializeComponent()
		{
		
		}

		private void SaveButton_Click(object sender, EventArgs e)
		{
			if(Page.IsValid && WeblogConfiguration.Instance().EnableThemes)
			{
				Skin1.GetFormValues(CurrentWeblog); 
				CSS1.GetFormValues(CurrentWeblog); 
				
				Weblogs.Update(CurrentWeblog);

				Skin1.SetSelectedTheme(CurrentWeblog) ;
				
				Status.Success = true;
				Status.Visible = true;
			}
		}
   }
}
