<%@ Page Title="" Language="C#" MasterPageFile="~/Master/Main.Master" AutoEventWireup="true" EnableViewState="false" CodeBehind="Default.aspx.cs" Inherits="MyCms.Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <%=!string.IsNullOrEmpty(Notice)?"<div class=\"notice\"><p>"+Notice+"</p></div>":string.Empty%>
    <asp:PlaceHolder ID="phFlash" runat="server">
        <div class="flash">
            <a target="<%=bannerFirst.Target %>" href="<%=bannerFirst.Url %>"><img src="<%=bannerFirst.ImgUrl %>" width="646px" height="248px" /></a>
        </div>
    </asp:PlaceHolder>
    
    
    

    <div class="news">
        <asp:Repeater ID="rpNews" runat="server">
            <ItemTemplate>
                <div class="news_li">
                    <h2 class="top"><a href="<%#ResolveUrl("~/Page/Content.aspx?id="+Eval("ArticleID")) %>"><%#Eval("Title") %></a></h2>
                    <div class="count"><a href="<%#ResolveUrl("~/Page/List.aspx?t=")+Eval("CategoryID") %>"><%#Eval("Category.CategoryName") %></a> <a href="javascript:;"><%#Eval("Keywords") %></a> <a href="<%#ResolveUrl("~/Page/Content.aspx?id="+Eval("ArticleID")) %>">阅读全文 <%#Eval("ReadCount") %></a></div>
                    <div class="date"><%#Convert.ToDateTime(Eval("CreateTime")).ToString("yyyy-MM-dd") %></div>
                    <div class="description">
                        <%#(Eval("CoverImg")==null||Eval("CoverImg")==string.Empty)?string.Empty:"<div class=\"coverimg\"><img src=\""+Eval("CoverImg")+"\" /></div>" %>
                        
                        <div <%#(Eval("CoverImg")==null||Eval("CoverImg")==string.Empty)?string.Empty:"class=\"descriptiontxt\"" %> >
                            <p><%#Eval("Description") %></p>
                        </div>
                        <div style="clear:both"></div> 
                    </div>
                </div>
            </ItemTemplate>
        </asp:Repeater>
        
    </div>
    <asp:PlaceHolder ID="phFlashJs" runat="server">
    <script>
        var flashImgs = new Array(<%=banners%>);
        var urls = new Array(<%=urls%>);
        var i = 1;
        $(function () {
            if (flashImgs.length > 1) {
                changeImg();
            }
        });
        function changeImg() {
            setTimeout(function () {
                $('.flash img').attr('src', flashImgs[i]);
                i++;
                if (i >= flashImgs.length)
                    i = 0;
                changeImg();
            }, 3000);
        }
    </script>
    </asp:PlaceHolder>
    <script>
        var hasmore = <%=hasmore%>;
        var p = 1;
        function loadMore() {
            p++;
            $.ajax({
                url: '<%=ResolveUrl("~/Handler/LoadMore.ashx")%>',
                type: 'post',
                dataType: 'json',
                data: { p:p,rnd:Math.random() },
                beforeSend: function () {
                    $('.loadmore a').attr('href','javascript:;');
                },
                success: function (data) {
                    $('.loadmore').remove();
                    if(data.status){
                        if(data.articles.length>0){
                            var html = '';
                            $(data.articles).each(function(index){
                                html+='<div class="news_li">';
                                html+='<h2 class="top"><a href="<%=ResolveUrl("~/Page/Content.aspx?id=") %>'+data.articles[index].ArticleID+'">'+data.articles[index].Title+'</a></h2>'
                                html+='<div class="count"><a href="<%=ResolveUrl("~/Page/List.aspx?t=") %>'+data.articles[index].CategoryID+'">'+data.articles[index].CategoryName+'</a> <a href="javascript:;">'+data.articles[index].Keywords+'</a> <a href="<%#ResolveUrl("~/Page/Content.aspx?id=") %>'+data.articles[index].ArticleID+'">阅读全文 '+data.articles[index].ReadCount+'</a></div>'
                                html+='<div class="date">'+data.articles[index].CreateTime+'</div>';
                                html +='<div class="description">';
                                if(data.articles[index].CoverImg!=''){
                                    html+='<div class="coverimg"><img src="'+data.articles[index].CoverImg+'"></div><div class="descriptiontxt">';
                                }else{
                                    html+='<div>';
                                }
                            
                                html+='<p>'+data.articles[index].Description+'</p></div><div style="clear:both"></div></div></div>';
                            });
                            $('.news').append(html);
                        }
                        hasmore = data.hasmore;
                        moreBtn();
                    }
                }
            });
        }
        $(function(){
            moreBtn();
        });
        function moreBtn(){
            if(hasmore){
                $('.news').append('<div class="loadmore"><a href="javascript:loadMore();">加载更多</a></div>');
            }
        }
    </script>
</asp:Content>
