<%@ page language="C#" autoeventwireup="true" inherits="WebAdmin_FriLinks, LebiMall" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>友情链接</title>
    <link rel="stylesheet" type="text/css" href="css/css.css" media="screen"/>
    <script type="text/javascript" language="javascript" src="js/topHead.js"></script>
    <script src="js/checked.js" type="text/javascript"></script>
    <link href="css/tipswindown.css" type="text/css" rel="stylesheet" />
    <script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/tipswindown.js" type="text/javascript"></script>
    <script type="text/javascript">
        var pages='<%=page %>';
        function update(id_,i){
            var wname=document.getElementById("txt_wname"+i).value; 
            var wurl=document.getElementById("txt_wz"+i).value;
            var wsort=document.getElementById("txt_sort"+i).value;
            if(wname!="" && wurl!="" && wsort!=""){
                window.location.href="FriLinksm.aspx?id="+id_+"&wname="+escape(wname)+"&wurl="+escape(wurl)+"&wsort="+wsort+"&type=update&page="+pages;
            }else{
                document.getElementById("msg").innerHTML="<span class='msg_submit'>以下填写不能为空！</span>";
            }
        }
        function del(id){
            if (confirm("确认要删除？")) {
                window.location.href="FriLinksm.aspx?id="+id+"&type=del&page="+pages;
            }
        }
        //批量删除
        function dels(id){
            var form =document.forms[0];
            var strid="";
            if (confirm("确认要删除？")) {
                for(i=0;i<form.elements.length;i++)
                {
                    if(form.elements[i].type=="checkbox")
                    {
                        if(form.elements[i].checked==true){
                            if(form.elements[i].value!="")
                            strid+=form.elements[i].value+",";
                        }
                    }
                }
                if(strid!=""){
                window.location.href="FriLinksm.aspx?strid="+strid+"&type=dels&page="+pages;}
            }
        }
        //保存
        function updates(){
            var form =document.forms[0];
            var flag=false;
            for(i=0;i<form.elements.length;i++)
            {
                if(form.elements[i].type=="text")
                {   
                    if(form.elements[i].id!="txt_wname"&&form.elements[i].id!="txt_wz"&&form.elements[i].id!="txt_sort"){
                        if(form.elements[i].value==""){
                            document.getElementById("msg").innerHTML="<span class='msg_submit'>以下填写不能为空！</span>";
                            flag=false;
                            break;
                        }else{
                            flag=true;
                        }
                    }
                }
            }
            if(flag){
                document.getElementById("form1").submit();
            }
        }
        function val(){
            var name=document.getElementById("txt_wname").value;
            var wz=document.getElementById("txt_wz").value;
            var sort=document.getElementById("txt_sort").value;
            if(name==""||wz==""||sort==""){
                document.getElementById("msg_a").innerHTML="<span class='msg_submit'>以下填写不能为空！</span>";
                return false;
            }else{
                return true;
            }
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
        <script>header(6,3,"images/");</script>
        <div class="blank clearfix"></div>
        <div class="tab-mainbody3">
            <div class="tab-mainbody4">
                <div class="functionHandleArea clearfix">
                    <asp:Button ID="Button1" runat="server" CssClass="btn-app" OnClick="Button2_ServerClick" OnClientClick="return val();" />
                    <span id="msg_a"></span>
                </div>
                <div id="datalist">
                    <table cellspacing="0" border="0" id="Table2" style="width: 100%; border-collapse: collapse;">
                    <!-- table 导航 -->
                        <tr class="table_title">
                            <th style="width: 5%">&nbsp;
                            </th>
                            <th style="width: 25%">
                                网站名称</th>
                            <th style="width: 25%">
                                网址
                            </th>
                            <th style="width: 45%">
                                排序
                            </th>
                        </tr>
                        <tr>
                            <td style="height:30px;">&nbsp;
                            </td>
                            <td>
                                <input type="text" id="txt_wname" style="width: 200px" runat="server"
                                    class="input" />
                            </td>
                            <td>
                                <input type="text" id="txt_wz" style="width: 200px" runat="server"
                                    class="input" />
                            </td>
                            <td>
                                <input type="text" id="txt_sort" value="0" runat="server"
                                    style="width: 30px;" class="input" onblur='value=value.replace(/[^\d]/g,"");this.style.border="1px solid #e5e5e5"'
                                    onfocus="this.style.border='1px solid #66BBFF'" onkeyup='value=value.replace(/[^\d]/g,"")'
                                    onbeforepaste='clipboardData.setData("text",clipboardData.getData("text").replace(/[^\d]/g,""))' />
                            </td>
                        </tr>
                    </table>
                    <div class="functionHandleArea clearfix" style="margin-top:5px;">
                        <input type="image" title=" 保存 " onclick="updates();return false;" src="images/bt_app.gif"
                                align="absmiddle">
                            <input type="image" title=" 删除 " onclick="dels();return false;" src="images/bt_delete.gif"
                                align="absmiddle">
                            <span id="msg"></span>
                    </div>
                    <table cellspacing="0" border="0" id="Table1" style="width: 100%; border-collapse: collapse;">
                        <tr class="table_title">
                            <th style="width: 5%; cursor: pointer;" title="全选" onclick="AllChecked()">
                                选择</th>
                            <th style="width: 25%">
                                网站名称</th>
                            <th style="width: 25%">
                                网址
                            </th>
                            <th style="width: 35%">
                                排序
                            </th>
                            <th style="width: 10%">
                                操作
                            </th>
                        </tr>
                        <%for (int i = 0; i < ds.Tables[0].Rows.Count; i++){%>
                        <tr>
                            <td>
                                <input type="checkbox" value="<%=ds.Tables[0].Rows[i]["id"] %>" />
                                <input type="hidden" id="hidden_id<%=i %>" name="hidden_id<%=i %>" value="<%=ds.Tables[0].Rows[i]["id"] %>" />
                            </td>
                            <td>
                                <input type="text" id="txt_wname<%=i %>" name="txt_wname<%=i %>" style="width: 200px"
                                    value="<%=ds.Tables[0].Rows[i]["wname"] %>" class="input" />
                            </td>
                            <td>
                                <input type="text" id="txt_wz<%=i %>" name="txt_wz<%=i %>" style="width: 200px" value="<%=ds.Tables[0].Rows[i]["wurl"] %>"
                                    class="input" />
                            </td>
                            <td>
                                <input type="text" id="txt_sort<%=i %>" name="txt_sort<%=i %>" value="<%=ds.Tables[0].Rows[i]["wsort"] %>"
                                    style="width: 30px;" class="input" onblur='value=value.replace(/[^\d]/g,"");this.style.border="1px solid #e5e5e5"'
                                    onfocus="this.style.border='1px solid #66BBFF'" onkeyup='value=value.replace(/[^\d]/g,"")'
                                    onbeforepaste='clipboardData.setData("text",clipboardData.getData("text").replace(/[^\d]/g,""))' />
                            </td>
                            <td>
                                <a href="javascript:del(<%=ds.Tables[0].Rows[i]["id"] %>)">删除</a>&nbsp;|&nbsp;<a
                                    href="javascript:update(<%=ds.Tables[0].Rows[i]["id"] %>,<%=i %>)"> 修改</a>
                            </td>
                        </tr>
                        <%} %>
                        <tr>
                            <td class="list-foot" colspan="5">
                                <div style="float: left; padding-top: 3px;">
                                </div>
                                <div id="divAsp" runat="server" style="float: right; padding-top: 3px;">
                                    <webdiyer:AspNetPager CssClass="pages" CurrentPageButtonClass="cpb" ID="AspNetPager1"
                                        runat="server" RecordCount="228" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页"
                                        PrevPageText="上一页" PageSize="20" UrlPaging="True" CustomInfoClass="pages1" CurrentPageButtonPosition="Center" ShowBoxThreshold="50"
                                        ShowFirstLast="true" NumericButtonCount="4" BackColor="Transparent" ShowDisabledButtons="False" EnableViewState="False">
                                    </webdiyer:AspNetPager>
                                </div>
                            </td>
                        </tr>
                    </table>
                    <script type="text/javascript">tdshowm("Table1");tdshowm("Table2");</script>
                </div>
            </div>
        </div>
    </form>
</body>
</html>
