<%@ Page Language="VB" MasterPageFile="~/Site.master" Title="Charter - CMS" AutoEventWireup="false"
    CodeFile="Edit.aspx.vb" Inherits="Edit" EnableSessionState="True" ValidateRequest="false" %>

<%@ Register Src="Controls/Header.ascx" TagName="Header" TagPrefix="uc1" %>
<%@ Register TagPrefix="FCKeditorV2" Namespace="FredCK.FCKeditorV2" Assembly="FredCK.FCKeditorV2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="adminPageBody" runat="Server">
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
    <%--    <script type="text/javascript" language="javascript">
//        function ParseHTML()
//            {
//                var obj;
//                obj = document.all["FCKeditor"];
//                try
//                {
//                if (window.ActiveXObject)
//                  {
//                  alert("a");
//                  var doc = new ActiveXObject("Microsoft.XMLDOM");
//                  alert("a");
//                  alert(obj.value);
//                  doc.loadXML(obj.value);
//                  alert("a");
//                  if(obj.value.search(/<script/i) != -1 )
//                    {
//                    alert("failed");
//                    throw(new exception("asdasd"));
//                    }
//                  
//                  }
//                else
//                  {
//                  alert("b");
//                  var parser = new DOMParser();
//                  alert("b");
//                  var doc = parser.parseFromString(obj.value,"text/xml");
//                  alert("b");
//                  }
//                
//                }
//                
//                catch(e)
//                {
//                  alert("Parsing failed due to the error: " + e.message);
//                  return false;
//                }
//               
//            }
    </script>--%>
    <div>
        <uc1:Header ID="Header1" runat="server" />
        <br />
        <asp:HyperLink ID="lnkCreate" Font-Bold="true" NavigateUrl="Default.aspx" runat="server">CMS Menu</asp:HyperLink>
        <br />
        <table border="0" cellpadding="5" cellspacing="5">
            <tr>
                <td rowspan="2" valign="top">
                    <asp:Table ID="Table3" runat="server">
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:Label ID="lbltemplate" runat="server" Text="Template ID" EnableTheming="True"
                                    EnableViewState="False"></asp:Label></asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:DropDownList ID="ddlTemplate" runat="server" EnableTheming="True" AutoPostBack="True">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="vldTemplateIdRequired" ControlToValidate="ddlTemplate"
                                    ErrorMessage="Template is Required" Text="*" runat="server"></asp:RequiredFieldValidator>
                                <asp:Button ID="btnCreateTemplate" runat="server" Text="Create Template"  Visible="false" />
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow ID="tblCreateTemplate" BackColor="ghostwhite" Visible="false">
                            <asp:TableCell>
                                <asp:Panel ID="Panel1" runat="server">
                                    <asp:Table ID="Table4" runat="server">
                                        <asp:TableRow>
                                            <asp:TableCell>
                                                    Template Name:
                                            </asp:TableCell>
                                            <asp:TableCell>
                                                <asp:TextBox ID="txtTemplateName" runat="server"></asp:TextBox>
                                            </asp:TableCell>
                                        </asp:TableRow>
                                        <asp:TableRow>
                                            <asp:TableCell>
                                                    Header Title:
                                            </asp:TableCell>
                                            <asp:TableCell>
                                                <asp:TextBox ID="txtTemplateHeaderTitle" runat="server"></asp:TextBox>
                                            </asp:TableCell>
                                        </asp:TableRow>
                                        <asp:TableRow>
                                            <asp:TableCell>
                                                    Live URL:
                                            </asp:TableCell>
                                            <asp:TableCell>
                                                <asp:TextBox ID="txtTemplateLiveURL" runat="server"></asp:TextBox>
                                            </asp:TableCell>
                                        </asp:TableRow>
                                        <asp:TableRow>
                                            <asp:TableCell ColumnSpan="2" HorizontalAlign="right">
                                                <asp:Button ID="btnCancelCreateTemplate" runat="server" Text="Cancel" />
                                                <asp:Button ID="btnSaveTemplate" runat="server" Text="Save" />
                                            </asp:TableCell>
                                        </asp:TableRow>
                                    </asp:Table>
                                </asp:Panel>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:Label ID="userControlIDLabel" runat="server" EnableTheming="True" EnableViewState="False"
                                    Text="User Control ID"></asp:Label>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:DropDownList ID="userControlIDDropDownList" runat="server" EnableTheming="True" AutoPostBack="true"
                                    DataSourceID="ObjectDataSource2" DataTextField="UserControlName" DataValueField="UserControlName">
                                </asp:DropDownList><asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="GetUserControl"
                                    TypeName="CMSContentManager">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="ddlTemplate" Name="TemplateID" PropertyName="SelectedValue"
                                            Type="Int32" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                                <asp:RequiredFieldValidator ID="vldUserControlIdRequired" runat="server" ErrorMessage="User Control Id is required"
                                    Text="*" ControlToValidate="userControlIDDropDownList"></asp:RequiredFieldValidator>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:Label ID="ownerTypeIDLabel" runat="server" Text="Owner Type" EnableTheming="True"
                                    EnableViewState="False"></asp:Label>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:DropDownList ID="ownerTypeIDDropDownList" runat="server" EnableTheming="True" AutoPostBack="true">
                                </asp:DropDownList><asp:RequiredFieldValidator ID="vldOwnerTypeRequired" ControlToValidate="ownerTypeIDDropDownList"
                                    runat="server" Text="*" ErrorMessage="Owner Type is required"></asp:RequiredFieldValidator>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:Label ID="ownerIDLabel" runat="server" Text="Owner ID" EnableTheming="True"
                                    EnableViewState="False"></asp:Label>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:ListBox ID="ownerIDTextBox" runat="server" EnableTheming="True">
                                </asp:ListBox>
                                <asp:RequiredFieldValidator ID="vldOwnerIdRequired" ControlToValidate="ownerIDTextBox"
                                    runat="server" Text="*" ErrorMessage="Owner ID is required"></asp:RequiredFieldValidator>
                                <%--<asp:RangeValidator ID="vldOwnerIdRegularExpression" runat="server" ControlToValidate="ownerIDTextBox"
                                    ErrorMessage="Please enter numeric Owner ID" MinimumValue="1" MaximumValue="9999999"
                                    Type="Integer"> </asp:RangeValidator>--%>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:Button ID="findButton" runat="server" Text="Find" />
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="BulletList"
                                    EnableTheming="True" />
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:Label ID="organizationUnitLabel" runat="server" Text="Organization Unit" EnableViewState="False"
                                    Visible="False"></asp:Label>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:Label ID="selectedUnitLabel" runat="server" EnableTheming="True" EnableViewState="False"
                                    Visible="False"></asp:Label>
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell>
                                <asp:Panel ID="organizationUnitTreePanel" runat="server" BorderStyle="Solid" BorderWidth="1"
                                    Height="325px" Width="290px" ScrollBars="Auto" EnableTheming="True" EnableViewState="False"
                                    Visible="False">
                                    <asp:TreeView ID="organizationUnitTreeView" runat="server" BorderStyle="None" BorderWidth="1px"
                                        AutoGenerateDataBindings="False" ShowLines="True" ExpandDepth="0" EnableTheming="True"
                                        Visible="False">
                                    </asp:TreeView>
                                </asp:Panel>
                            </asp:TableCell>
                        </asp:TableRow>
                    </asp:Table>
                </td>
                <td valign="top">
                    <table border="0" cellpadding="3" cellspacing="3">
                        <tr>
                            <td colspan="2">
                                <asp:Label ID="versionLabel" runat="server" Text="Version" EnableTheming="True" EnableViewState="False"></asp:Label></td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="versionListLabel" runat="server" Text="Name" EnableTheming="True"
                                    EnableViewState="False"></asp:Label><br />
                                <asp:DropDownList ID="versionDropDownList" runat="server" EnableTheming="True" Enabled="False">
                                </asp:DropDownList><br />
                                <br />
                                <asp:Button ID="newVersionButton" runat="server" Text="New" CausesValidation="False"
                                    Enabled="False" /></td>
                            <td>
                                <asp:Label ID="versionNameLabel" runat="server" Text="Name"></asp:Label><br />
                                <asp:TextBox ID="versionNameTextBox" runat="server" MaxLength="200"></asp:TextBox><br />
                                <br />
                                <asp:Button ID="submitVersionButton" runat="server" Text="Submit" Enabled="False" />
                                <br />
                            </td>
                            <td>
                                <asp:Label ID="SearchTypeLabel" runat="server" Text="Search Result Displayable" EnableTheming="True"
                                    EnableViewState="False"></asp:Label><br />
                                <asp:CheckBox ID="SearchResultDisplayableCheckBox" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <!-- Template Header CMS Area-->
                                <asp:Table ID="Table1" runat="server">
                                    <asp:TableHeaderRow>
                                        <asp:TableHeaderCell>Header Content</asp:TableHeaderCell></asp:TableHeaderRow>
                                    <asp:TableHeaderRow>
                                        <asp:TableHeaderCell>
                                            <asp:Label ID="lblErrorMessage" runat="server" Text="Label" Visible="false" ForeColor="red"></asp:Label>
                                        </asp:TableHeaderCell>
                                    </asp:TableHeaderRow>
                                    <asp:TableRow>
                                        <asp:TableCell>Template Header Title:</asp:TableCell>
                                        <asp:TableCell>
                                            <asp:TextBox ID="txtTitleText" runat="server"></asp:TextBox>
                                            <asp:Button ID="btnSave" runat="server" Text="Save Title" />
                                        </asp:TableCell>
                                    </asp:TableRow>
                                    <asp:TableRow>
                                        <asp:TableCell ColumnSpan="2">
                                            <asp:Table runat="server">
                                                <asp:TableRow>
                                                    <asp:TableCell> Global META List:</asp:TableCell>
                                                    <asp:TableCell></asp:TableCell>
                                                    <asp:TableCell>Template META List:</asp:TableCell>
                                                </asp:TableRow>
                                                <asp:TableRow Height="200px" >
                                                    <asp:TableCell>
                                                        <asp:ListBox ID="txtGlobalMetaList" runat="server" AutoPostBack="true" Width="100%"
                                                            Height="100%"></asp:ListBox>
                                                    </asp:TableCell>
                                                    <asp:TableCell VerticalAlign="Bottom">
                                                        <asp:Button ID="btnRegister" runat="server" Text="  -->>" /><br />
                                                        <asp:Button ID="btnRemove" runat="server" Text="<<--  " /><br />
                                                        <asp:Button ID="btnDelete" runat="server" Text="Delete" />                                                        
                                                    </asp:TableCell>
                                                    <asp:TableCell>
                                                        <asp:ListBox ID="txtMetaList" runat="server" AutoPostBack="true" Width="100%" Height="100%">
                                                        </asp:ListBox>
                                                    </asp:TableCell>
                                                </asp:TableRow>
                                            </asp:Table>
                                        </asp:TableCell>
                                    </asp:TableRow>
                                    <asp:TableRow>
                                        <asp:TableCell ColumnSpan="2" HorizontalAlign="Right">
                                            <asp:Button ID="btnAddMeta" runat="server" Text="Add META" />
                                        </asp:TableCell>
                                    </asp:TableRow>
                                    <asp:TableRow Visible="false" BackColor="ghostwhite" ID="tblAddMeta">
                                        <asp:TableCell ColumnSpan="2" HorizontalAlign="Center">
                                            <asp:Table ID="Table2" runat="server">
                                                <asp:TableRow>
                                                    <asp:TableCell>
                                                            Meta Alias:                                                            
                                                    </asp:TableCell>
                                                    <asp:TableCell>
                                                        <asp:TextBox ID="txtMetaAlias" runat="server"></asp:TextBox>
                                                    </asp:TableCell>
                                                </asp:TableRow>
                                                <asp:TableRow>
                                                    <asp:TableCell>
                                                            Meta Name:                                                            
                                                    </asp:TableCell>
                                                    <asp:TableCell>
                                                        <asp:TextBox ID="txtMetaName" runat="server"></asp:TextBox>
                                                    </asp:TableCell>
                                                </asp:TableRow>
                                                <asp:TableRow>
                                                    <asp:TableCell>
                                                            Meta Content:                                                            
                                                    </asp:TableCell>
                                                    <asp:TableCell>
                                                        <asp:TextBox ID="txtMetaContent" runat="server"></asp:TextBox>
                                                    </asp:TableCell>
                                                </asp:TableRow>
                                                <asp:TableRow>
                                                    <asp:TableCell RowSpan="2" HorizontalAlign="Right">
                                                        <asp:Button ID="btnSaveMeta" runat="server" Text="Save Meta" /></asp:TableCell>
                                                </asp:TableRow>
                                            </asp:Table>
                                        </asp:TableCell>
                                    </asp:TableRow>
                                </asp:Table>
                                <!-- end template header cms area  -->
                            </td>
                        </tr>
                    </table>
                </td>
                <td>
                    <table visible="false" border="0" cellpadding="3" cellspacing="3">
                        <tr>
                            <td colspan="2">
                                <asp:Label Visible="false" ID="scheduleLabel" runat="server" Text="Schedule" EnableTheming="True"
                                    EnableViewState="False"></asp:Label></td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label Visible="false" ID="scheduleListLabel" runat="server" Text="Begin Date"
                                    EnableTheming="True" EnableViewState="False"></asp:Label><br />
                                <asp:DropDownList Visible="false" ID="scheduleDropDownList" runat="server" EnableTheming="True"
                                    Enabled="False">
                                </asp:DropDownList><br />
                                <br />
                                <asp:Button Visible="false" ID="newScheduleButton" runat="server" Text="New" CausesValidation="False"
                                    Enabled="False" />
                            </td>
                            <td>
                                <asp:Label Visible="false" ID="beginDateLabel" runat="server" Text="Begin Date" EnableViewState="False"></asp:Label><br />
                                <asp:TextBox Visible="false" ID="beginDateTextBox" runat="server" EnableTheming="True"
                                    Enabled="False"></asp:TextBox><br />
                                <br />
                                <asp:Label Visible="false" ID="endDateLabel" runat="server" Text="End Date" EnableViewState="False"></asp:Label><br />
                                <asp:TextBox Visible="false" ID="endDateTextBox" runat="server" EnableTheming="True"
                                    Enabled="False"></asp:TextBox><br />
                                <br />
                                <asp:Button Visible="false" ID="submitScheduleButton" runat="server" Text="Submit"
                                    Enabled="False" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:Label ID="contentLabel" runat="server" Text="Content ID " Visible="False"></asp:Label><asp:Label
                        ID="contentIDLabel" runat="server" Text="" Visible="False"></asp:Label><br />
                    <FCKeditorV2:FCKeditor ID="FCKeditor" runat="server" BasePath="FCKeditor/" Height="295px"
                        ToolbarSet="Greenhouse" Width="550px" Visible="False">
                    </FCKeditorV2:FCKeditor>
                    <asp:Label ID="createNewContentLabel" runat="server" Text="<br />No content identifier was found matching you selection. Would you like to create one?<br />"
                        Visible="False"></asp:Label><br />
                    <asp:Button ID="submitButton" runat="server" Text="Submit for Approval" CausesValidation="False"
                        EnableTheming="True" Visible="False" Font-Bold="True" /><asp:Button ID="btnClearForceSubmit" Text="Clear Force Submit" runat="server"/><asp:Button ID="createNewContentButton"
                            runat="server" CausesValidation="False" Text="Create" Visible="False" /><asp:Label
                                ID="lblErrorMsg" runat="server" Text="" Font-Bold="true" Visible="false" ForeColor="red"></asp:Label>
                    <asp:Button ID="cancelNewContentButton" runat="server" Text="Cancel" Visible="False" /><br />
                    <br />
                    <strong>Versions pending Approval for the selected Template:
                        <br />
                        <br />
                        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
                            AutoGenerateColumns="False" CellPadding="4" DataSourceID="ObjectDataSource3"
                            ForeColor="#333333" GridLines="None">
                            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                            <Columns>
                                <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                                    SortExpression="ID" />
                                <asp:BoundField DataField="CONTENT_NAME" HeaderText="CONTENT_NAME" SortExpression="CONTENT_NAME" />
                                <asp:CheckBoxField DataField="SEARCH_RESULT_DISPLAYABLE" HeaderText="SEARCHABLE"
                                    SortExpression="SEARCH_RESULT_DISPLAYABLE" />
                                <asp:BoundField DataField="CreatedBy" HeaderText="Created By" />
                                <asp:BoundField DataField="CreatedDate" HeaderText="Created Date" />
                            </Columns>
                            <RowStyle BackColor="#EFF3FB" />
                            <EditRowStyle BackColor="#2461BF" />
                            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                            <AlternatingRowStyle BackColor="White" />
                        </asp:GridView>
                        <asp:ObjectDataSource ID="ObjectDataSource3" runat="server" SelectMethod="GetPendingVersions"
                            TypeName="CMSContentManager">
                            <SelectParameters>
                                <asp:ControlParameter ControlID="ddlTemplate" Name="TemplateID" PropertyName="SelectedValue"
                                    Type="Int32" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                        &nbsp;&nbsp; </strong>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
