<%@ Control Language="C#" %>
<%@ Import Namespace="CommunityServer.Components" %>
<%@ Register TagPrefix="CS" Namespace="CommunityServer.Controls" Assembly="CommunityServer.Controls" %>
<%@ Register TagPrefix="CSD" Namespace="CommunityServer.Discussions.Controls" Assembly="CommunityServer.Discussions" %>
<%@ Register TagPrefix="CSDP" Namespace="CommunityServer.Discussions.Controls.PostDisplay" Assembly="CommunityServer.Discussions" %>
<%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %>
<%@ Import Namespace="CommunityServer.Discussions.Controls" %>
<%@ Import Namespace="CommunityServer.Discussions.Components" %>
<%@ Import Namespace="CommunityServer.Components" %>
<%@ Import Namespace="CommunityServer.Controls" %>
<%@ Import Namespace="CommunityServer" %>
<%@ Register TagPrefix="TWC" Namespace="Telligent.Web.UI" Assembly="Telligent.Web.UI" %>


<script language="javascript">

	function SelectPreview()
    {
        document.getElementById('Preview').innerHTML = '';
        document.getElementById('loading').style.display = 'block';
        CreateEditPost.PreviewPost('<%= this.Parent.ClientID %>', previewCallBack);
        
        InkCheck(false);
    }
    
    function previewCallBack(res)
    {
		if (res.error)
			alert(res.error);
		else
		{
			var e = document.getElementById('Preview');
			e.innerHTML = res.value;
		}
			
        document.getElementById('loading').style.display = 'none';
    }
    
       function toggleInk(cb)
       {
			if(cb.checked)
			{
				document.getElementById('<%= InkControl.ClientID %>').style.display = '';
			}
			else
			{
				document.getElementById('<%= InkControl.ClientID %>').style.display = 'none';
			}
       }
      
    var recentLookUp = null;
    function FetchRelated()
    {
        var query = document.getElementById('<%= PostSubject.ClientID %>').value;
        if(query != recentLookUp && query != '')
        {
            recentLookUp = query;
            <%= SearchCallBack.ClientID %>.Callback(query);
        }
        
        InkCheck(false);
    }
    
    function getAttachmentData(result)
	{
		// result = new Array(TemporaryPostAttachmentGuid, FileName, FriendlyFileName, IsRemote)
		if (result != null)
		{
			document.getElementById('<%= ServerUploadTempID.ClientID %>').value = result[0];
			document.getElementById('<%= ServerFilename.ClientID %>').value = result[1];
			document.getElementById('<%= Filename.ClientID %>').innerHTML = result[1];
			document.getElementById('<%= RemoveAttachment.ClientID %>').style.visibility = 'visible';
		}
	}
	
	function removeAttachment()
	{
		document.getElementById('<%= ServerUploadTempID.ClientID %>').value = '';
		document.getElementById('<%= ServerFilename.ClientID %>').value = '';
		document.getElementById('<%= Filename.ClientID %>').innerHTML = '';
		document.getElementById('<%= RemoveAttachment.ClientID %>').style.visibility = 'hidden';
	}

       function InkHidden()
       {
			InkCheck(false);
       }
       function InkVisible()
       {
			InkCheck(true);
       }
       function InkCheck(showInk)
       {
			var InkCheckCB = $('<%= EnableInk.ClientID %>');
			var InkCheckInkEditor = $('inkWrapper');
			if(showInk && InkCheckCB.checked)
			{
				$('inkWrapper').style.position= 'static';
			}
			else
 			{
				$('inkWrapper').style.position= 'absolute';
 			}
 			
 			return true;
      }
</script>

<div class="CommonContentArea">
	<div class="CommonBreadCrumbArea"><CSD:BreadCrumb ShowHome="true" runat="server" id="Breadcrumb2"/></div>
	<h2 class="CommonTitle"><asp:Label id="ForumName" Runat="server" /></h2>
	<div class="CommonContent">
		<div class="CommonDescription"><asp:Label id="ForumDescription" Runat="server" /></div>
		
	<TWC:TabbedPanes id="EditorTabs" runat="server"
		PanesCssClass="CommonPane"
		TabSetCssClass="CommonPaneTabSet"
		TabCssClasses="CommonPaneTab,CommonPaneTab1,CommonPaneTab2"
		TabSelectedCssClasses="CommonPaneTabSelected,CommonPaneTabSelected1,CommonPaneTabSelected2"
		TabHoverCssClasses="CommonPaneTabHover,CommonPaneTabHover1,CommonPaneTabHover2"
		>
		<TWC:TabbedPane runat="server" ID="ComposePane">
			<Tab OnClickClientFunction="InkHidden"><CS:ResourceControl runat="server" ResourceName="CreateEditPost_Tab_Compose" /></Tab>
			<Content>
				<div id="Reply" runat="server" Visible="false">
					<strong><asp:Literal id="ReplyDetails" Runat="server" /></strong>
					<div class="ForumReplyToPostArea">
					<asp:Literal id="ReplyBody" runat="server" />
					</div>
				</div>

				<div id="Post" runat="server" visible="true" class="CommonFormArea">
					<div id="Edit" runat="server" visible="false">
						<div class="CommonFormFieldName">
							<label><CS:ResourceControl runat="server" ResourceName="CreateEditPost_Inline6" ID="Resourcecontrol1"/> <asp:label id="PostEditor" runat="server" /></label>
						</div>
					</div>
					
					<div id="MessageTo" runat="server" visible="false">
						<div class="CommonFormFieldName">
							<label for="<%= To.ClientID %>" ><CS:ResourceControl runat="server" ResourceName="CreateEditPost_To" ID="Resourcecontrol5"/></label>
						</div>
						<div class="CommonFormField">
							<asp:textbox readonly="true"  autocomplete="off" id="To" runat="server"  style="width:80%;" />
						</div>
					</div>
					
					<div runat="server" visible="false" id="Tr1" NAME="Tr1">
						<div class="CommonFormFieldName">
							<label for="<%= Forums.ClientID %>"><CS:ResourceControl runat="server" ResourceName="CreateEditPost_Forums" ID="Resourcecontrol4"/> </label><br />
						</div>
						<div class="CommonFormField">
							<asp:textbox autocomplete="off" id="Forums" runat="server" style="width:80%;" />
						</div>
					</div>
					
					<div class="CommonFormFieldName">
						<label for="<%= PostSubject.ClientID %>" accesskey = "9"><CS:ResourceControl runat="server" ResourceName="CreateEditPost_Inline7" ID="Resourcecontrol2"/> <asp:requiredfieldvalidator id="postSubjectValidator" runat="server" CssClass="validationWarning" ControlToValidate="PostSubject" ErrorMessage="*" /></label><br />
					</div>
					<div class="CommonFormField">
						<asp:textbox autocomplete="off" id="PostSubject" CssClass="CommonInputBig" runat="server" style="width:80%;" />	
					</div>
					
					<div class="CommonFormFieldName">
						<label for="<%= PostBody.ClientID %>" ><CS:ResourceControl runat="server" ResourceName="CreateEditPost_Body" ID="Resourcecontrol3"/></label>
						<asp:requiredfieldvalidator id="postBodyValidator" runat="server" CssClass="validationWarning" ControlToValidate="postBody" EnableClientScript="False">*</asp:requiredfieldvalidator>
						<CSD:QuoteValidator id="postBodyQuoteValidator" runat="server" CssClass="validationWarning" ControlToValidate="PostBody" EnableClientScript="false">Non matching quote blocks in post</CSD:QuoteValidator>
					</div>
					<div class="CommonFormField">
						<CS:Editor Width="100%" runat="Server" id="PostBody" />
					</div>
					
					<asp:PlaceHolder ID="TaggingArea" Runat="server">
						<div class="CommonFormFieldName">
							<CS:ResourceControl runat="server" ResourceName="CreateEditPost_Tags" ID="Resourcecontrol10"/>
						</div>
						<div class="CommonFormField">
							<CS:TagEditor runat="server" id="Tags" />
						</div>
					</asp:PlaceHolder>
					
					<asp:PlaceHolder Runat="server" ID="EditNotesArea" Visible="False">
						<div class="CommonFormFieldName">
							<CS:ResourceLabel runat="server" ResourceName="CreateEditPost_EditNotes" ID="Resourcelabel2"/>
						</div>
						<div class="CommonFormField">
							<asp:textbox id="EditNotesBody" runat="server" columns="90" TextMode="MultiLine" rows="5"></asp:textbox>
							<asp:requiredfieldvalidator id="editNotesValidator" runat="server" CssClass="validationWarning" ControlToValidate="EditNotesBody" />
						</div>
	                    
						<div class="CommonFormFieldName">
							<CS:ResourceLabel runat="server" ResourceName="CreateEditPost_CurrentEditNotes" ID="Resourcelabel3"/>
						</div>
						<div class="CommonFormField">
							<asp:textbox ReadOnly="true" id="CurrentEditNotesBody" runat="server" columns="90" TextMode="MultiLine" rows="5"></asp:textbox>
						</div>
					</asp:PlaceHolder>
				</div>
			</Content>
		</TWC:TabbedPane>
		<TWC:TabbedPane runat="server" id="OptionsPane">
			<Tab OnClickClientFunction="InkHidden"><CS:ResourceControl runat="server" ResourceName="CreateEditPost_Tab_Options" /></Tab>
			<Content>
					<asp:PlaceHolder id="editAttachment" runat="server" Visible="False" >
						<div class="CommonFormFieldName">
							<label for="FileToUpload"><CS:ResourceControl id="NewAttachment" runat="server" ResourceName="CreateEditPost_Attachment" /></label> 
						</div>
						<div class="CommonFormField">
							<asp:Label id="Filename" runat="server" />
							<input type="hidden" id="ServerUploadTempID" runat="server" name="ServerUploadTempID">
							<input type="hidden" id="ServerFilename" runat="server" name="ServerFilename">
							<cs:modal modaltype="Link" CssClass="CommonTextButton" width="640" height="180" runat="Server" callback="getAttachmentData" id="AddUpdateAttachment" ResourceName="CreateEditPost_AddUpdateAttachment" />
							<a href="#" onclick="removeAttachment(); return false;" class="CommonTextButton" runat="server" id="RemoveAttachment"><CS:ResourceControl runat="server" ResourceName="CreateEditPost_RemoveAttachment" /></a>
						</div>
						<p />
					</asp:PlaceHolder>

					<div class="CommonFormField">
						<asp:checkbox id="IsLocked" runat="server" />    
					</div>
					
					<div class="CommonFormField">
						<asp:checkbox id="SubscribeToThread" Checked="true" runat="server"/>
					</div>
					
					<div class="CommonFormField">
						<asp:checkbox id="IsAnonymousPost" runat="server" />
					</div>
					
					<p />
					<div id="AllowPinnedPosts" runat="server" visible="false">
						<div class="CommonFormFieldName">
							<label for="<%=PinnedPost.ClientID %>" ><CS:ResourceControl runat="server" ResourceName="CreateEditPost_Stickiness" ID="Resourcecontrol6"/> </label>
						</div>
						<div class="CommonFormField">
							<asp:dropdownlist id="PinnedPost" runat="server" />
						</div>
					</div>
					
					<p />
					<div id="Icons" runat="Server" >
						<div class="CommonFormFieldName">
							<label><CS:ResourceLabel runat="server" ResourceName="CreateEditPost_PostIcon" ID="Resourcelabel1"/>:</label>
						</div>
						<div class="CommonFormField">
							<CSD:PostIconRadioButtonList id="PostIcon" class="txt3" cellpadding="0" cellspacing="0" width="400" RepeatColumns=18 runat="server" />
						</div>
					</div>

			</Content>
		</TWC:TabbedPane>
		<TWC:TabbedPane runat="server" id="InkPane">
			<Tab OnClickClientFunction="InkVisible"><CS:ResourceControl runat="server" ResourceName="CreateEditPost_Tab_Ink" /></Tab>
			<Content>
				<p>
					<asp:CheckBox ID = "EnableInk" Runat = "server" Checked = "True" Text = "Enable Ink?" onclick = "toggleInk(this);" />
				</p>
			</Content>
		</TWC:TabbedPane>
		<TWC:TabbedPane runat="server" id="VideoPane">
			<Tab OnClickClientFunction="InkHidden"><CS:ResourceControl runat="server" ResourceName="CreateEditPost_Tab_Video" /></Tab>
			<Content>
				<div class="CommonFormArea" style="width: 650px">
					<div class="CommonFormFieldName">
						<label for="<%= VideoUrl.ClientID %>"><CS:ResourceControl runat="server" ResourceName="CreateEditPost_VideoUrl" ID="Resourcecontrol7"/></label>
					</div>
					<div class="CommonFormField">
						<asp:textbox id="VideoUrl" runat="server" autocomplete="off" style="width:80%" />
					</div>
					
					<div class="CommonFormFieldName">
						<label for="<%= VideoImageUrl.ClientID %>"><CS:ResourceControl runat="server" ResourceName="CreateEditPost_PreviewImageUrl" ID="Resourcecontrol8"/></label>
					</div>
					<div class="CommonFormField">
						<asp:textbox id="VideoImageUrl" runat="server" autocomplete="off" style="width:80%" />
					</div>
					
					<div class="CommonFormFieldName">
						<label for="<%= VideoDuration.ClientID %>"><CS:ResourceControl runat="server" ResourceName="CreateEditPost_VideoDuration" ID="Resourcecontrol9"/></label>
					</div>
					<div class="CommonFormField">
						<asp:textbox id="VideoDuration" runat="server" autocomplete="off" style="width:80%" />
					</div>
					
					<div class="CommonFormFieldName">
						<label for "<%= VideoWidth.ClientID %>"><CS:ResourceControl runat="server" ResourceName="CreateEditPost_VideoWidth" ID="Resourcecontrol11"/></label>
					</div>
					<div class="CommonFormField">
						<asp:textbox id="VideoWidth" runat="server" autocomplete="off" style="width:80%" />
						<asp:RegularExpressionValidator id="VideoWidthValidator" ControlToValidate="VideoWidth" ValidationExpression="^[0-9]*$" runat="server">*</asp:RegularExpressionValidator>
					</div>
					
					<div class="CommonFormFieldName">
						<label for "<%= VideoDuration.ClientID %>"><CS:ResourceControl runat="server" ResourceName="CreateEditPost_VideoHeight" ID="Resourcecontrol12"/></label>
					</div>
					<div class="CommonFormField">
						<asp:textbox id="VideoHeight" runat="server" autocomplete="off" style="width:80%" />
						<asp:RegularExpressionValidator id="VideoHeightValidator" ControlToValidate="VideoHeight" ValidationExpression="^[0-9]*$" runat="server">*</asp:RegularExpressionValidator>
					</div>
				</div>
			</Content>
		</TWC:TabbedPane>
		<TWC:TabbedPane runat="server" id="PollPane">
			<Tab OnClickClientFunction="InkHidden"><CS:ResourceControl runat="server" ResourceName="CreateEditPost_Tab_Poll" /></Tab>
			<Content>
				<div class="CommonFormFieldName">
					<asp:CheckBox Runat="server" ID="IncludePoll" /> <CS:ResourceControl runat="server" ResourceName="CreateEditPost_IncludePoll" />
				</div>
				<div class="CommonFormField">
					<CS:ResourceControl runat="server" ResourceName="CreateEditPost_IncludePoll_Details" />
				</div>
				<p />				
				<div id="PollContainer">
					<CS:PollEditor runat="server" ID="PollEditor" />
				</div>
			</Content>
		</TWC:TabbedPane>
		<TWC:TabbedPane runat="server" id="PreviewPane">
			<Tab OnClickClientFunction="FetchRelated"><CS:ResourceControl runat="server" ResourceName="CreateEditPost_Tab_Related" /></Tab>
			<Content>
				<p>
				<ComponentArt:CallBack id="SearchCallBack" CacheContent="false" runat="server" >
					<Content>
							<asp:Repeater id="SearchRepeater" runat="Server" EnableViewState="false">
								<HeaderTemplate>
									<ul class="CommonSearchResultList">
								</HeaderTemplate>
								<ItemTemplate>
									<li>
									<div class="CommonSearchResultArea">
										<h4 class="CommonSearchResultName"><a target="_blank" href="<%# DataBinder.Eval(Container.DataItem, "Url") %>"><%# DataBinder.Eval(Container.DataItem, "Title") %></a></h4>
										<div class="CommonSearchResult">
											<%# Formatter.GetBodySummary(DataBinder.Eval(Container.DataItem, "BestMatch").ToString(),350, "", System.Drawing.Color.Black, System.Drawing.Color.Yellow) %>
										</div>
										<div class="CommonSearchResultDetails">
											Posted to <a href ="<%# DataBinder.Eval(Container.DataItem, "ApplicationUrl") %>"><%# DataBinder.Eval(Container.DataItem, "SectionName") %> (<%# DataBinder.Eval(Container.DataItem, "ApplicationType") %>)</a> by <a href="#"><%# DataBinder.Eval(Container.DataItem, "UserName") %></a> on <%# DataBinder.Eval(Container.DataItem, "PostDate","{0:MMMM d, yyyy}") %>
										</div>
									</div>
									</li>
								</ItemTemplate>
								<FooterTemplate>
									</ul>
								</FooterTemplate>
							</asp:Repeater>
					</Content>
					<LoadingPanelClientTemplate>
						Loading...<img src = "../utility/spinner.gif" />
					</LoadingPanelClientTemplate>
				</ComponentArt:CallBack>
				</p>
			</Content>
		</TWC:TabbedPane>
		<TWC:TabbedPane runat="server" id="RelatedPane">
			<Tab OnClickClientFunction="SelectPreview"><CS:ResourceControl runat="server" ResourceName="CreateEditPost_Tab_Preview" /></Tab>
			<Content>
					<div id="loading" style="display:none">Loading <asp:Image runat="server" ImageUrl="~/utility/spinner.gif" /></div>
					<div ID="Preview"><csd:PostFlatPreview runat="server" id="PostFlatPreview" /></div>
			</Content>
		</TWC:TabbedPane>
	</TWC:TabbedPanes>
<div id="inkWrapper" class="CommonPane" style="position:absolute;left:-5000px;">
<cs:inkwebcontrol runat="Server" id="InkControl" /></div>
		
	<div class="CommonFormArea">
		<div id="Buttons" class="CommonFormField">
			<asp:Button id="CancelButton" Name="CancelButton" Runat="server" ButtonType="CancelMessage" CausesValidation="False" Visible = "False" />
			<asp:button id="PostButton" Name="PostButton" runat="server" ButtonType="PostMessage" />
		</div>
	</div>
	</div>
</div>

<script language="javascript">

var e = document.getElementById('<%= ServerUploadTempID.ClientID %>');
if (e)
{
	if (e.value)
		document.getElementById('<%= RemoveAttachment.ClientID %>').style.visibility = 'visible';
	else
		document.getElementById('<%= RemoveAttachment.ClientID %>').style.visibility = 'hidden';
}
	
e = document.getElementById('<%= IncludePoll.ClientID %>');
if (e)
{
	e.onclick = new Function("if (document.getElementById('<%=IncludePoll.ClientID%>').checked) { document.getElementById('PollContainer').style.display = 'block'; } else { document.getElementById('PollContainer').style.display = 'none'; }");
	e.onclick();
}

</script>
