<%@ Page Language="c#" Inherits="Web.User.addNews" CodeBehind="addNews.aspx.cs" Buffer="true" %>

<!DOCTYPE html>
<!--[if lt IE 9]><html class="lte-ie8"><![endif]-->
<!--[if gt IE 8]><!-->
<html>
<!--<![endif]-->
<head>
    <title>addnews</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="../Wpedt/My97DatePicker/WdatePicker.js"></script>
    <!--#include file="../Css/head.htm"-->
    <!--#include file = "../Css/userCssEdit.htm" -->
</head>
<body>
    <form id="addNews" method="post" runat="server">
        <div class="edit-func-box func-box">
            <div class="hd">编辑</div>
            <div class="bd">
                <table class="edit-table">
                    <tr>
                        <th>文章标题：
                        </th>
                        <td>
                            <asp:TextBox ID="intactTitle" runat="server" notNull="true" msgName="文章标题" class="input-md w3" MaxLength="250"></asp:TextBox>&emsp;
                         <asp:CheckBox ID="useListTitle" runat="server" CssClass="ckb-txt" onclick="showsubmenu();" Text="使用链接标题"></asp:CheckBox>
                            <asp:TextBox ID="listTitleUrl" runat="server" class="input-md w3" MaxLength="200" ToolTip="请填写自定义网址" Style="display: none;">http://</asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <th>副标题：
                        </th>
                        <td>
                            <asp:TextBox ID="subheading" runat="server" class="input-md w3" MaxLength="250"></asp:TextBox>
                            &emsp;<asp:CheckBox ID="useSubHeading" CssClass="ckb-txt" onclick="hiddenList();" runat="server" Text="使用副标题"></asp:CheckBox>
                            &emsp;&emsp;<asp:CheckBox ID="isTop" runat="server" Text="固顶" CssClass="chkbox"></asp:CheckBox>
                            &emsp;&emsp;<asp:CheckBox ID="isRecommand" runat="server" Text="推荐到今日导读"></asp:CheckBox>
                        </td>
                    </tr>
                    <tr runat="server" id="trdescript" visible="false">
                        <th>文章简介：
                        </th>
                        <td>
                            <asp:TextBox ID="tbDescript" runat="server" notNull="true" msgName="头条简介" Width="500px" TextMode="MultiLine" Height="60px" MaxLength="400" CssClass="input-md pull-left fn-mr20"></asp:TextBox>
                            <asp:Label ID="lbdeslen" runat="server" Style="color: Red;"></asp:Label><br />
                            <span id="lastlen"></span>
                        </td>
                    </tr>
                    <tr>
                        <th>文章内容：</th>
                        <td>
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <div class="more-edit-fn">
                                        发布时间：<asp:TextBox ID="releasetime" runat="server" MaxLength="19" notNull="true" msgName="发布时间" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" CssClass="input-md"></asp:TextBox>
                                        &nbsp;作者：
                                    <asp:TextBox ID="author" runat="server" CssClass="input-md" MaxLength="50"></asp:TextBox>
                                        &nbsp;来源：
                                    <asp:TextBox ID="copyFrom" runat="server" CssClass="input-md" MaxLength="50"></asp:TextBox>
                                        &nbsp;&nbsp;
                                    <asp:Label ID="cslabel" runat="server">
                                    <a href="javascript:void(0);" id="select"><span class="blue">抄送</span></a>
                                    &nbsp;
                                    <a href="javascript:void(0);" onclick="clearDuplicate();"><span class="blue">取消抄送</span></a>
                                    </asp:Label>
                                        <asp:TextBox ID="txtDuplicateBigClass" runat="server" ReadOnly="True" class="input-md" Style="display: none;"></asp:TextBox>
                                        &nbsp;                                    
                                <asp:CheckBox ID="isSynchro" runat="server" Text="同步更新源信息" CssClass="ckb-txt" Visible="false" />

                                        <a class="more-edit-fn-btn" href="#more-edit">更多设置</a>
                                    </div>
                                    <div class="more-edit-data">
                                        <span class="arrow"></span>
                                        <a class="close" href="#">&times;</a>
                                        <table class="edit-table">
                                            <tbody>
                                                <tr>
                                                    <th>标题配图：</th>
                                                    <td colspan="3">
                                                        <img alt="" src="../images/uploadfiles/nopic.gif" runat="server" id="pho" class="pic-div  pull-left" width="130" height="100" /><br>
                                                        <p><a id="uploadimg" href="javascript:void(0);" class="blue">上传图片</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onclick="delImg();" class="blue">删除</a></p>
                                                        <p><a href="javascript:void(0);" onclick="updateImg();" class="blue">从内容中自动选取</a></p>
                                                        <p><span class="lgrey">(若抄送给图文类栏目，请设置！)</span></p>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <th>所属专题：</th>
                                                    <td>
                                                        <asp:DropDownList ID="ddlspecial" runat="server" DataTextField="name" DataValueField="pkId" class="input-md"></asp:DropDownList>
                                                    </td>
                                                    <th>部门：</th>
                                                    <td>
                                                        <asp:DropDownList ID="department" runat="server" DataTextField="name" DataValueField="pkId" class="input-md">
                                                        </asp:DropDownList>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <th>浏览权限：</th>
                                                    <td>
                                                        <asp:DropDownList ID="gate" runat="server" class="input-md"></asp:DropDownList>
                                                    </td>
                                                    <th>显示等级：</th>
                                                    <td>
                                                        <asp:DropDownList ID="grade" runat="server" class="input-md"></asp:DropDownList>
                                                    </td>
                                                </tr>
                                                <tr>

                                                    <th>文章模板：</th>
                                                    <td>
                                                        <asp:DropDownList ID="itemType" runat="server" DataTextField="name" DataValueField="pkId" class="input-md">
                                                        </asp:DropDownList>
                                                    </td>
                                                    <th>点击量：</th>
                                                    <td>
                                                        <asp:TextBox ID="defaultClick" runat="server" notNull="true" dataType="integer" maxValue="99999999" minValue="0" msgName="初始点击率" class="input-md"></asp:TextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <th>作者信箱：</th>
                                                    <td>
                                                        <asp:TextBox ID="authorMail" runat="server" regex="/^(\w)+(\.\w+)*@(\w)+((\.\w{2,3}){1,3})$/" regexMsg="信箱格式不正确" class="input-md" MaxLength="50"></asp:TextBox>
                                                    </td>
                                                    <th>来源地址：</th>
                                                    <td>
                                                        <asp:TextBox ID="copyFromLink" runat="server" class="input-md" MaxLength="50"></asp:TextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <th>有效期设置：</th>
                                                    <td colspan="3">
                                                        <asp:DropDownList ID="ValidDaysOption" runat="server" onchange="ValidDaysOptionOnChange(this);" class="input-md">
                                                            <asp:ListItem Selected="True" Value="-1">永不过期</asp:ListItem>
                                                            <asp:ListItem Value="1">显示截止日期</asp:ListItem>
                                                            <asp:ListItem Value="0">已经过期</asp:ListItem>
                                                        </asp:DropDownList>
                                                        &nbsp;
                                                    <asp:TextBox ID="ValidDays" runat="server" Text="-1" class="input-md" onClick="WdatePicker()" Style="display: none;"></asp:TextBox>
                                                        <asp:CheckBox ID="showReviewLink" runat="server" Text="显示文章列表时在标题旁显示评论链接" Visible="False"></asp:CheckBox>
                                                    </td>

                                                </tr>
                                                <tr>
                                                    <th>相关信息：</th>
                                                    <td colspan="3">
                                                        <asp:TextBox ID="about" runat="server" regex="[^&quot;^'^\*^\?^,^\.^(^)]+" regexMsg="相关信息格式不正确" MaxLength="50" class="input-md" Style="width: 384px;"></asp:TextBox>
                                                        <p class="lgrey">用来查找相关文章，中间用“|”隔开；不能出现""'*?,.()等字符</p>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <th>内容分页：</th>
                                                    <td colspan="3">
                                                        <asp:DropDownList ID="pageType" runat="server" CssClass="input-md" onchange="ShowPageTag(this.selectedIndex);" class="input-md">
                                                            <asp:ListItem Value="0">不分页</asp:ListItem>
                                                            <asp:ListItem Value="2">分页</asp:ListItem>
                                                        </asp:DropDownList>
                                                        &emsp;<a id="pageTagA" href="javascript:void(0);" onclick="InsertPagingTag();" data-toggle="tooltip" data-placement="bottom" title="插入文章内容分页标记" style="display: none;"><span class="blue">插入分页标记</span></a>
                                                    </td>
                                                </tr>
                                                <tr style="display: none">
                                                    <th>分页字数(old)：                                                </th>
                                                    <td>
                                                        <asp:TextBox ID="autoPageCharNum" runat="server" Visible="False">10000</asp:TextBox></td>
                                                    <th>阅读点数(old)：</th>
                                                    <td>
                                                        <asp:Panel ID="ReadPointPanel" runat="server" Visible="False">
                                                            文章阅读点数：
                                    <asp:TextBox ID="readPoint" runat="server">0</asp:TextBox>
                                                        </asp:Panel>
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                                <div>
                                    <textarea name="content" style="width: 100%; height: 530px; visibility: hidden;"></textarea>
                                </div>

                            </div>

                        </td>
                    </tr>
                    <tr id="ContributeDiv" runat="server" visible="false">
                        <th></th>
                        <td>
                            <asp:CheckBox ID="chkIsContribute" runat="server" Text="投稿到主站" onclick="CheckContribute()" />&nbsp;
                        投稿栏目：<asp:DropDownList ID="ddlContributeClass" runat="server"></asp:DropDownList>
                            【内容中的图片和文件路径需使用绝对路径。格式：http://当前网站域名/图片路径】                            
                        </td>
                    </tr>
                </table>
            </div>
            <div class="ft">
                <div class="action-field text-center">
                    <asp:Button ID="btnOk" class="btn btn-sm btn-primary" runat="server" Text="添 加" OnClientClick="return checkAll();" OnClick="btn_Click"></asp:Button>&nbsp;
                    <asp:Button ID="btnCancel" runat="server" class="btn btn-sm btn-primary" Text="取 消"  OnClick="btn_Click" ></asp:Button>&nbsp;
                    <input id="btnView" type="button" class="btn btn-sm btn-primary" value="预 览" onclick="SubmitPreview();" style="display: none;" />
                    <input id="btnWord" type="button" class="btn btn-sm btn-primary" value="Word导入" style="display: none;" />&nbsp;
                    <asp:Button ID="btnDraft" runat="server" CssClass="btn btn-sm btn-primary" Text="存为草稿" OnClientClick="return checkDraft();" OnClick="btn_Click" />
                </div>
                <!--/action-field-->
            </div>
            <div>
                <input id="content1" type="hidden" name="content1" runat="server" />
                <input id="imageName" type="hidden" name="imageName" runat="server" value="../Images/uploadfiles/nopic.gif" />
                <input id="hiddenName" runat="server" type="hidden" />
                <input id="hiddenValue" runat="server" type="hidden" />
                <input id="hiddenOldValue" runat="server" name="hiddenOldValue" type="hidden" />
                <input id="hiddenIsDup" runat="server" name="hiddenIsDup" type="hidden" />
                <input id="hiddenOldNewsId" runat="server" name="hiddenOldNewsId" type="hidden" />
            </div>
        </div>
        <!--#include file = "../Css/foot.htm" -->
        <script type="text/javascript">
            //声明编辑器
            var listTxt;
            var contentTxt;
    
            jQuery(function ($) { 
            
                $("#select").click(function (){
                    return true; 
                }).fancybox({
                    'type': 'iframe',
                    'width':540,
                    'height': 450,
                    autoSize:false,
                    'hideOnOverlayClick': false,
                    'href': 'selectBigClass.aspx?menuId=<%=menuId %>&bigClassId=<%=bigClassId %>',
                    'padding':'0'
                }); 
            
                //设置作者、部门的默认值
                var edit= "<%=edit  %>" ;
                if (edit=="False")
                {
                    loadauthor();
                    //loaddepartment(); 
                }

            })

        </script>
        <script type="text/javascript" language="javascript">

            KindEditor.ready(function(K) {
                var editor = K.create('textarea[name="content"]');

                //加载自定义选择图片功能
                K('#uploadimg').click(function() {
                    editor.loadPlugin('zdyimage', function() {
                        editor.plugin.zdyimageDialog({
                            zdyimageUrl : K('#imageName').val(),
                            clickFn : function(url) {
                                K('#imageName').val(K.formatUrl(url, 'domain'));
                                editor.hideDialog();
                                change();//加载预览图片
                            }
                        });
                    });
                });
                K('#btnWord').click(function() {
                    editor.loadPlugin('word', function() {
                        editor.plugin.wordDialog({
                            clickFn : function(url) {
                                editor.hideDialog();
                                $.ajax({
                                    type: "post",
                                    url: "addnews.aspx/LoadHtml",
                                    data: "{'url':'" + K.formatUrl(url, 'domain') + "','fileName':'" + url + "'}",
                                    contentType: "application/json; charset=utf-8",
                                    dataType: "json",
                                    success: function(data) {
                                        var initcontxt=document.getElementById("content1");
                                        initcontxt.value=data;
                                        editor.insertHtml(initcontxt.value);
                                        contentTxt=editor;
                                    },
                                    error: function(err) {
                                        alert(err);
                                    }
                                });
                            }
                        });
                    });
                });
                //编辑时加载内容
                var initcontxt=document.getElementById("content1");
                editor.insertHtml(initcontxt.value);
                    
                contentTxt=editor;
            });
			
        </script>

        <script type="text/javascript">
    
            //更多设置
            $(".more-edit-fn-btn").click(function(){
                $(".more-edit-data").fadeIn(500);
            });
            $(".more-edit-data .close").click(function(){
                $(this).parent().fadeOut(500);
            });
	
            //预览图片change()写法修改，统一把document.formID.objectID.**替换为 $("ID").**
            function change() {
                var arr = $("#imageName").val();
                if (arr != "") {
                    $("#pho").attr('src',arr); 
                }
            }
    
            //显示列表标题
            function showsubmenu()
            {
                if (document.getElementById("useListTitle").checked == true)
                {
                    document.getElementById("useSubHeading").checked = false;
                    document.getElementById("listTitleUrl").style.display="inline-block";
                }
                else
                {
                    document.getElementById("listTitleUrl").style.display="none";
                }
            }
            //使用列表标题和使用副标题只能选一个
            function hiddenList()
            {
                if (document.getElementById("useSubHeading").checked == true)
                {
                    document.getElementById("useListTitle").checked = false;
                    document.getElementById("listTitleUrl").style.display="none";
                }
            }
 
            //是否投稿到主站
            function CheckContribute()
            {
        
            }
            // 显示分页标记
            function ShowPageTag(selectedIndex)
            {
                if (selectedIndex!=1)
                {
                    document.getElementById("pageTagA").style.display = "none";
                }
                else
                {
                    document.getElementById("pageTagA").style.display = "";
                }
            }
            //插入文章内容分页标记
            function InsertPagingTag()
            {
                contentTxt.focus();
                contentTxt.insertHtml("<button id=\"ZDSOFTPAGINGTAG\">分页标记</button>");
                contentTxt.focus();
            } 
	
            //选择抄送栏目
            //	function ShowDialog(menuId, bigClassId)
            //	{
            //	    showModalDialog("selectBigClass.aspx?menuId=" + menuId + "&bigClassId=" + bigClassId, window,"dialogWidth=500px; dialogHeight=420px;help=no;scroll=no;status=no");
            //	}
	
            //取消抄送
            function clearDuplicate()
            {
                document.getElementById("txtDuplicateBigClass").value = "";
                document.getElementById("txtDuplicateBigClass").style.display="none";  
                document.getElementById("hiddenName").value = "";
                document.getElementById("hiddenValue").value = "";                
            }
	
            //检查抄送栏目
            function checkform(optionName, optionValue)
            {
                if(optionName.LTrim().RTrim().length==0)
                {
                    clearDuplicate();                                  
                }
                else
                {
                    document.getElementById("txtDuplicateBigClass").style.display="";    
                }
                if(optionName.indexOf("|")==0)
                {
                    optionName = optionName.substring(1, optionName.length);    
                    optionValue = optionValue.substring(1, optionValue.length);
                }
                document.getElementById("hiddenName").value = optionName;
                document.getElementById("hiddenValue").value = optionValue;      
                document.getElementById("txtDuplicateBigClass").value = optionName;
            }
	
            String.prototype.Trim = function() 
            { 
                return this.replace(/(^\s*)|(\s*$)/g, ""); 
            } 

            String.prototype.LTrim = function() 
            {
                return this.replace(/(^\s*)/g, ""); 
            } 

            String.prototype.RTrim = function() 
            {
                return this.replace(/(\s*$)/g, ""); 
            }
    
    
            //obj.value值含义
            //-1:永久有效
            //0: 无效
            //1: 输入一个有效天数
            function ValidDaysOptionOnChange(obj)
            {
                var i = obj.value;
                var o = document.getElementById("ValidDays");
                if (i == 1)
                {
                    if (o.value < 1)
                    {
                        if (o.getAttribute("validDays") && o.getAttribute("validDays") > 0)
                        {
                            o.value = o.getAttribute("validDays");
                            EditValidDays();
                        }
                        else
                        {
                            var d = new Date();
                            var nowmonth=(d.getMonth()+1).toString();
                            if((d.getMonth()+1)<10)
                            {
                                nowmonth="0"+nowmonth;
                            }
                            var nowdate= d.getDate().toString();
                            if(d.getDate()<10){
                                nowdate="0"+nowdate;
                            }
                            o.value = (d.getFullYear() + 1).toString() + "-" + nowmonth + "-" + nowdate;
                        }
                    }
                    o.style.display = "";
                }
                else
                {
                    o.style.display = "none";
                    o.value = i;
                }
            }
            //保存草稿
            function checkDraft()
            {
                //验证
                if (checkAllValidate()){
                    //转换有效期
                    try
                    {
                        var vdo = document.getElementById("ValidDaysOption");
                        if (vdo.value != 1)
                        {
                            //保存
                            if (esave())
                            {   
                                //草稿状态下判断不能有抄送新闻
                                if(document.getElementById("txtDuplicateBigClass").value == "" )
                                {
                                    //document.getElementById("txtDuplicateBigClass").value = "";
                                    document.getElementById("hiddenName").value = "";
                                    document.getElementById("hiddenValue").value = "";                                
                                    return true ;
                                }
                                else
                                {
                                    alert("草稿状态下不能抄送信息!");
                                    return false ;
                                }
                            }else{
                                return false ;
                            }
                        }
                        var vd = document.getElementById("ValidDays");
                        var d = vd.value.split("-");
                        if (d.length < 3)
                        {
                            alert("有效期设置有误!");
                            return false;
                        }
                        var validday = new Date();                
                        validday.setDate(d[2]);
                        validday.setMonth(d[1] - 1);
                        validday.setFullYear(d[0]);
                        var sub = DaysBetween(validday, new Date());
                        if (sub < 0)
                        {
                            alert("有效期设置有误!");
                            return false;
                        }
                        vd.value = sub;
                    }
                    catch(err)
                    {
                        alert("有效期设置有误!");
                        return false;
                    } 
                    //保存
                    if (esave())
                    {   
                        //草稿状态下判断不能有抄送新闻
                        if(document.getElementById("txtDuplicateBigClass").value == "" )
                        {
                            //document.getElementById("txtDuplicateBigClass").value = "";
                            document.getElementById("hiddenName").value = "";
                            document.getElementById("hiddenValue").value = "";
                            return true ;
                        }
                        else
                        {
                            alert("草稿状态下不能抄送信息!");
                            return false ;
                        }
                
                    }else{
                        return false ;
                    }
                }else{
                    return false ;
                }
            }
     
            //在保存之前,验证输入是否正确；将有效日期值转换成相应的有效天数
            function checkAll()
            {
                //验证
                if (checkAllValidate()){
                    //转换有效期
                    try
                    {
                        var vdo = document.getElementById("ValidDaysOption");
                        if (vdo.value != 1)
                        {
                            //保存
                            if (esave())
                            {   
                                //加载load特效（防止在生成静态页阶段重复点击按钮） 不显示弹出层的关闭按钮，按ESC来关闭弹出层
                                $.fancybox({
                                    'type': 'image',
                                    'width': 50,
                                    'height': 50,
                                    'hideOnOverlayClick': false,
                                    'padding':'0',
                                    'scrolling':'no',
                                    'enableEscapeButton':'true',
                                    'showCloseButton':false,
                                    'href': '../images/resfile/loading.gif'
                                });
                                return true ;
                            }else{
                                return false ;
                            }
                        }
                        var vd = document.getElementById("ValidDays");
                        var d = vd.value.split("-");
                        if (d.length < 3)
                        {
                            alert("有效期设置有误!");
                            return false;
                        }
                        var validday = new Date();                
                        validday.setDate(d[2]);
                        validday.setMonth(d[1] - 1);
                        validday.setFullYear(d[0]);
                        var sub = DaysBetween(validday, new Date());
                        if (sub < 0)
                        {
                            alert("有效期设置有误!");
                            return false;
                        }
                        vd.value = sub;
                    }
                    catch(err)
                    {
                        alert("有效期设置有误!");
                        return false;
                    } 
                    //保存
                    if (esave())
                    {
                        //加载load（防止在生成静态页阶段重复点击按钮）不显示弹出层的关闭按钮，按ESC来关闭弹出层
                        $.fancybox({
                            'type': 'image',
                            'width': 50,
                            'height': 50,
                            'hideOnOverlayClick': false,
                            'padding':'0',
                            'scrolling':'no',
                            'enableEscapeButton':'true',
                            'showCloseButton':false,
                            'href': '../images/resfile/loading.gif'
                        });
                        return true ;
                    }else{
                        return false ;
                    }
                }else{
                    return false ;
                }
            }
            //有效期转换
            function EditValidDays()
            {
                var vdo = document.getElementById("ValidDaysOption");
                if (vdo.value != 1)
                {
                    return;
                } 
                var v = document.getElementById("ValidDays");
                var now = new Date();
                now.setHours(0);
                now.setMinutes(0);
                now.setSeconds(0);
                var r = new Date(now.getTime() + 1000 * 60 * 60 * 24 * v.value);
                var nowmonth=(r.getMonth()+1).toString();
                if((r.getMonth()+1)<10)
                {
                    nowmonth="0"+nowmonth.toString();
                }
                var nowdate= r.getDate().toString();
                if(r.getDate()<10){
                    nowdate="0"+nowdate;
                }
                v.value = r.getFullYear().toString() + "-" + nowmonth + "-" + nowdate;
            }
        
            //计算两个日期之间的天数
            function DaysBetween(d1, d2)
            {
                var ONE_DAY = 1000 * 60 * 60 *24;
                var date1_ms = d1.getTime();
                var date2_ms = d2.getTime();
                var diff_ms = date1_ms - date2_ms;
                return Math.round(diff_ms / ONE_DAY);
            }
            //预览
            function SubmitPreview()
            {
         
                document.getElementById("sTitle").value = document.getElementById("<%=intactTitle.ClientID %>").value;
                document.getElementById("sContent").value = document.getElementById("<%=content1.ClientID %>").value;
                document.getElementById("sItemType").value = document.getElementById("<%=itemType.ClientID %>").value;
                document.getElementById("preview").submit();
            }
    
    
            //添加保存
            function esave(){
                //判断是否使用了副标题
                if(document.getElementById("useSubHeading").checked == true){
                    var usubhead=document.getElementById("subheading");
                    if (usubhead.value=="" ||usubhead.value==null){
                        alert("使用副标题时，副标题内容不能为空！");
                        return false ;
                    }
                }
                //判断是否使用了链接标题
                if(document.getElementById("useListTitle").checked == true){
                    var uzdyurl=document.getElementById("listTitleUrl");
                    if (uzdyurl.value=="" ||uzdyurl.value==null){
                        alert("使用链接标题时，自定义网址不能为空！");
                        return false ;
                    }
                }
                //判断内容是否为空
                var etxtisempty = contentTxt.isEmpty();
                if(etxtisempty){
                    alert("文章内容不能为空！");
                    return false ;
                }else{
                    //获取文章内容
                    var gettxttitle= contentTxt.html();
                    var contxt=document.getElementById("content1");
                    contxt.value =gettxttitle;
                }
                return true ;
    
            }
   
            //
            //编辑时加载
            //
    
            //若是选择显示过期时间 则加载ValidDays显示 hezl
            function checkvalidday(){
                var editvdo= document.getElementById("ValidDaysOption");
                if (editvdo.value==1){
                    document.getElementById("ValidDays").style.display="";
                }
            }
            //若是选择使用列表标题 则加载列表标题显示 hezl
            function checkuserlisttitle(){
                var editult= document.getElementById("useListTitle");
                if (editult.checked==true ){
                    document.getElementById("submenu").style.display="";
                }
            }
    
            //获取默认作者为当前登录用户真实名称
            function loadauthor()
            {
                var thisauthor=document.getElementById("author");
                if(thisauthor.value=="")
                {
                    thisauthor.value="<%=FullName %>";
                }
            }
    
            function getSelectedText(name)
            {        
                var obj =document.getElementById(name);
                for(i=0;i<obj.length;i++){
                    if(obj[i].selected==true){
                        return obj[i].innerHTML; //关键是通过option对象的innerText属性获取到选项文本『注』要兼容Firefox需使用innerHTML属性
                    }
                }
            }
            //来源默认为部门名称
            function loaddepartment()    
            {
                var thisdep=document.getElementById("copyFrom");
                if(thisdep.value=="")
                {
                    thisdep.value=getSelectedText("department");
                }
            }
            //判断页面是否加载完毕
            document.onreadystatechange = function(){ 
                //当页面加载状态为完全结束时进入 
                if(document.readyState == "complete"){
                    checkvalidday();
                    checkuserlisttitle();
                    //加载有效期
                    EditValidDays();
                    //加载分页状态
                    ShowPageTag(document.all.pageType.selectedIndex);
                } 
            }
    
            //从内容中获取图片
            var uicounts=0;
            function updateImg()
            {
                var uistr = contentTxt.html();
                //var test = /\/([^\/]*?\.(jpg|bmp|gif))"\/>/gi;
                var test = /src="([^"]*)"/gi;
                var result = []; 
                var img ; 
                while(img = test.exec(uistr)){ 
                    result .push(img[1]);
                } 
                if(result.length<=0)
                {
                    alert("在内容中未检测到图片!");
                }
                else
                {
                    var imgurl;
                    if(uicounts < result.length )
                    {
                        imgurl = result[uicounts];
                        uicounts=uicounts+1;
                    }
                    else
                    {
                        uicounts= 1;
                        imgurl = result[0];
                    }
                    document.getElementById("imageName").value=imgurl;
                    change();//加载预览图片
                }
            }
            function ta(obj)
            {
                if(<%=deslength %>!="0") 
                {
                    var len=<%=deslength %>;
                    var text=$(obj).val();
                    var textlen=getLength(text);
                    if(textlen<=2*len)
                    {  
                        var word=len-Math.ceil(textlen/2);
                        $("#lastlen").html("还剩余 "+word+"字");
                        $("#lastlen").show();
                    }
                    else
                    {
                        var word=Math.ceil(textlen/2)-len;
                        $("#lastlen").html("已超出 "+word+"字");
                        $("#lastlen").show();
                    }
                }
            }
            //删除预览图
            function delImg()
            {
                document.getElementById("imageName").value="../images/uploadfiles/nopic.gif";
                change();//加载预览图片
            }
    
        </script>

    </form>
    <form id="preview" action="../newsInfo.aspx" method="post" target="_blank">
        <input id="sTitle" type="hidden" name="sTitle" />
        <input id="sContent" type="hidden" name="sContent" />
        <input id="sItemType" type="hidden" name="sItemType" />
        <input id="IsView" type="hidden" name="IsView" value="1" />
    </form>
</body>
</html>
