<%@ Page Language="C#" AutoEventWireup="true" CodeFile="VisualPageEditor.aspx.cs" Inherits="bitrix_dialogs_VisualPageEditor" 
EnableViewState="false" ValidateRequest="false"%>

<html>
<head runat="server">
    <title></title> 
</head>
<body>
    <form id="form1" runat="server">
        <bx:BXPageAsDialogBehaviour runat="server" ID="Behaviour" OnSave="Behaviour_Save" />
        <asp:MultiView runat="server" ID="ViewContainer">
            <asp:View runat="server" ID="VisualEditorView">
                <bx:BXWebEditor ID="VisualEditor" runat="server"
                    RunningUnderModalDialog="true" EnableChildDialogsSelfdestrurctionOnModalDialogClose="true"
                    AutoLoadContent="true" ContentType="Text" FullScreen="False" LimitCodeAccess="false" 
                    OnIncludeWebEditorScript="VisualEditor_IncludeWebEditorScript" 
                    StartMode="HTMLVisual" StartModeSelector="False" TemplateId="" 
                    UseHTMLEditor="true" UseOnlyDefinedStyles="False" WithoutCode="false" >
                    <Taskbars>
			            <bx:BXWebEditorBar Name="BXPropertiesTaskbar" />
				        <bx:BXWebEditorBar Name="ASPXComponentsTaskbar" />
                    </Taskbars>
			        <Toolbars>
			            <bx:BXWebEditorBar Name="manage" />
				        <bx:BXWebEditorBar Name="standart" />
				        <bx:BXWebEditorBar Name="formating" />
				        <bx:BXWebEditorBar Name="source" />
				        <bx:BXWebEditorBar Name="table" />
                        <bx:BXWebEditorBar Name="template" />
				        <bx:BXWebEditorBar Name="style" />
                    </Toolbars>
                </bx:BXWebEditor>               
            </asp:View>
            <asp:View runat="server" ID="TextEditorView">
                <asp:TextBox ID="TextEditor" runat="server" TextMode="MultiLine" />    
            </asp:View>
        </asp:MultiView>     
    </form>

<%--
    <script type="text/javascript">         
        window.BXVisualPageEditorBefofeCloseDialog = function()
        {
            if(typeof(window["jsUtils"]) == "undefined") throw "Could not find jsUtils!";
            jsUtils.removeCustomEvent("OnBeforeCloseDialog", BXVisualPageEditorBefofeCloseDialog);
            window.setTimeout(function(){ <%= string.Format("jsUtils.Redirect(arguments, \"{0}\");", ClientPath) %>}, 1000);
        }         
        if(typeof(window["jsUtils"]) != "undefined"){
            jsUtils.addCustomEvent('OnBeforeCloseDialog', BXVisualPageEditorBefofeCloseDialog, [], window);
        }    
    </script>
        <script type="text/javascript">
        BXVisualPageEditorDialogManager.getInstance().start("<%= VisualEditor.ClientID %>");
    </script>
--%>

<script type="text/javascript" language="javascript">
    window.BXSetContentPlainTextEditorHeight = function(){
        var forms = null, form = null;
        forms = document.getElementsByName("<%= Form.Name %>");
        if(forms != null && forms.length > 0){
            for(var i = 0; i < forms.length; i++){
                if(forms[i].name == "<%= Form.Name %>"){
                    form = forms[i];
                    break;
                }
            }
        }
        if(form != null){
            var inputs = form.getElementsByTagName("INPUT");
            if(inputs != null && inputs.length > 0){
                for(var i = 0; i < inputs.length; i++){
                    if(inputs[i].id == "__EVENTTARGET" || inputs[i].id == "__EVENTVALIDATION")
                        inputs[i].parentNode.style.display="none";
                }
            }   
        }     
        var editor = document.getElementById("<%= TextEditor.ClientID %>");
        if(!editor) return;
        //debugger;
        //setElementHeight(document.getElementById(jsPopup.content_div_id), calculateElementContentHeightById(jsPopup.content_wrapper_div_id));
        setElementHeight(editor, calculateElementContentHeightById(jsPopup.content_div_id)); 
    }   
    
    BXSetContentPlainTextEditorHeight(); 
</script>

</body>
</html>
