<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="SelectCategory.aspx.cs" Inherits="OAWeb.crm.product.SelectCategory" %>

<%@ Register Src="../../UserControls/ProductNav.ascx" TagName="ProductNav" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlace" runat="server">
    <table id="plc_profile" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td class="main_left">
                <uc1:ProductNav ID="ProductNav1" runat="server" />
            </td>
            <td class="main_center">
                <!--主体-->
                <div class="page_main">
                    <div class="page_content">
                        <div class="form" style="border: solid 1px #ddd; padding: 5px;">
                            <table cellpadding="0" cellspacing="0" border="0" class="table_form">
                                <tr>
                                    <td class="title">
                                        <em style="float: left">
                                            <img src="/images/03.gif" />
                                        </em>
                                        <h1>
                                            分类选择</h1>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="select_category">
                                            <div class="category_main">
                                                <div class="category_item">
                                                    <ul>
                                                        <asp:Repeater ID="rptData" runat="server" OnItemDataBound="rptData_ItemDataBound">
                                                            <ItemTemplate>
                                                                <li class="" id="<%#Eval("CategoryId") %>">
                                                                    <%#Eval("CategoryName")%></li></ItemTemplate>
                                                        </asp:Repeater>
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="category_bottom">
                                            你当前选择的是：<span id="categoryName"></span>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="text-align: center">
                                        <input id="btnSave" type="button" value=" 下一步 " class="btn_77px" /><input name="hidvalue"
                                            id="hidselect_value" type="hidden" />
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
    </table>
    <script type="text/javascript">
        $(document).ready(function () {
            $(".category_item li").live("click", function () {
                $(this).parent().find(".select").removeClass("select");
                $(this).addClass("select");
                var id = $(this).attr("id");
                var itemIndex = $(this).parent().parent().index();
                $.get("/Ajax.aspx?op=LoadProductCategory&id=" + id, function (result) {
                    $(".category_main .category_item:eq(" + itemIndex + ")").nextAll().remove();
                    $(".category_main").append(result);
                })
                var rel = "";
                $.each($(".category_main").find(".select"), function (index, item) {
                    if (index == 0)
                        rel += $(item).text();
                    else
                        rel += " >> " + $(item).text();
                })
                $("#categoryName").html(rel);
                $("#hidselect_value").val(id);
            })
            $("#btnSave").click(function () {
                var cid= $("#hidselect_value").val();
                if(cid == "")
                {
                   alert("请选择分类");
                   return;
                }
                var url = "ProductEdit.aspx?categoryId=" + cid;
                var id = <%=Id %>;
                if(id > 0)
                    url += "&productId=" + id;
                window.location.href = url;
                return false;
            })
        });
    </script>
</asp:Content>
