<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="store_product_add1.aspx.cs" Inherits="XpShop.Supplier.store_product_add1" %>
<%@ Register TagPrefix="uc1" TagName="Header" Src="Modules/Header.ascx" %>
<%@ Register TagPrefix="uc1" TagName="SupplierMenu" Src="Modules/SupplierMenu.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Helper" Src="Modules/Helper.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Footer" Src="Modules/Footer.ascx" %>
<!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>
    <!--#include file="inc/head.inc"-->
	<title>商家中心 <%=config.SiteTitle%></title>
	<script src="get_all_category.aspx?nocopyright=1" type="text/javascript"></script>
</head>
<body>
    <uc1:Header id="Header1" runat="server"></uc1:Header>
    <!--位置导航开始-->
	 <div class="ws path"><a href="<%=webSite %>supplier/default.<%=config.html%>">商家桌面</a> > 商品管理 > 上传商品</div>
	<!--位置导航结束-->
	<div class="ws xp-clear">
		<div class="content-left">
			<!--会员中心导航开始-->
			<uc1:SupplierMenu id="SupplierMenu1" runat="server"></uc1:SupplierMenu>
			<!--会员中心导航结束-->
		</div>
		<div class="content-middle">
		    <div class="rframe">
		        <div class="tm">上传商品</div>
		        <div class="mm">
		            <p style="padding-bottom:10px;">您当前选定的分类是：<em id="choosedcat" ></em></p>
		            <div class="xp-clear">
		                <div id="c1" class="topcat">
		                    <ul id="child1"></ul>
		                </div>
		            </div>
		            <div style="margin:20px auto;text-align:center;">
		                <form id="form1" method="post" action="store_product_add2.aspx">	 
                          <input name="catcache" value="|#4001001#4002522#4001006#|#4001001#4002522#4001036#|#4001001#4002522#4001007#|#4001001#4002522#4001021#|#4001001#4002522#4003372#|#4001001#4002520#4001022#|#4001001#4002520#4003288#|#4001001#4002520#4002525#|#4001001#4002623#4001028#|#4001001#4002520#4001030#|#4001001#4002520#4001020#|#4001001#4002520#4001038#|#4001001#4002522#4001003#|#4001001#4002520#4001035#|#4001001#4002623#4001032#|#4003973#|#4001001#4002522#4001031#|#4001001#4002623#4001004#|#4001001#4002520#4001014#" type="hidden">
                          <input name="catids" value="" type="hidden">
                          <input name="bidss" value="" type="hidden">
                          <input name="catid_bak" value="" type="hidden">
                          <input value="" name="catid" id="catid" type="hidden">
                          <input name="validCat" id="validCat" type="hidden">
                          <input value="" name="validCatid" id="validCatid" type="hidden">
                          <input value="" name="name_string" id="name_string" type="hidden">
                          <input value="" name="brand" id="brand" type="hidden">
                          <input value="" name="model" id="model" type="hidden">
                          <input name="is_new" id="is_new" value="is_new" type="hidden">
                          <input name="reselect_id" id="reselect_id" value="" type="hidden">
	          	          <input type="submit" disabled="disabled" value="下一步" name="btn_next" id="btn_next">
		                </form>
		            </div>
		             <script type="text/javascript">
		             $(document).ready(function(){  
		                for(var n=0;n<data.length/4;n++){
		                    $('<li id="'+data[n*4][1]+'_1" onClick="GetNextCat('+data[n*4][1]+',2,true)">'+data[n*4][0]+"</li>").appendTo($('#child1'));
		                }//end for
		             });
		             //arg_1:分类ID;arg_2:下一级分类的层级;arg_3:
		             function GetNextCat(arg_1,arg_2,arg_3){		    
		                var index =arg_1+"_"+(arg_2-1);
                        var next_index =arg_2+1;
                        $("#"+index).siblings().removeClass("hover");
                        $("#"+index).addClass("hover");
		                $('#catid').val(arg_1);
		                var str_name="";
		                var curdepth=arg_2-2;
		                if(curdepth==0){
                            str_name =$("#"+index).text().replace(" ->","");
                          }else{
                            var name_string =$("#name_string").val();
                            name_string_arr =name_string.split(" > "); 
                            for(i=0;i<curdepth;i++){
                              if(i<(curdepth-1)){
                                str_name +=name_string_arr[i]+" > ";
                              }else if(i ==(curdepth-1)){
                                str_name += name_string_arr[i];
                              }else{
                                break;
                              }
                            }
                            str_name += " > "+$("#"+index).text().replace("->","");
                          }
                        $('#choosedcat').text(str_name);
		                $('#name_string').val(str_name);
		                $("#"+index).parent().parent().nextAll().remove();
		                if($("#"+index).text().indexOf('->')>0)
		                {
                            $("#btn_next").attr("disabled","disabled").removeClass("hand");
                            var tmpRs ='<div class="topcat" style="margin-left:9px"><ul id="child_'+arg_2+'">';
                            var htmlShow ="";
		                    for(var i=0;i< data.length/4; i++){
                                var cd = data[i*4+(arg_2-1)];
                                if(arg_2 ==2){//获取第二级分类
                                  if(cd[0]==arg_1){
                                    for(var j=1;j< cd.length; j++)
                                      {
                                        //alert(j);
                                        if(cd[j][0] !="" && typeof cd[j][0]!="undefined"){
                                          if((cd[j][0]).indexOf("->") >0 ){
                                            var valid =true;
                                          }else{
                                            valid =false;
                                          }
                                          htmlShow +="<li id="+cd[j][1]+"_"+arg_2+" style=\"cursor:hand;\" onClick=\"GetNextCat("+cd[j][1]+","+next_index+","+valid+")\">"+cd[j][0]+"</li>";
                                        }
                                      }
                                  }
                                  else{
                                     continue;
                                  }

                                }else{//第三级或第四级
                                  if(cd !=""){
                                    for(var j=0;j< cd.length/2; j++)
                                      {
                                        if(cd[j*2]==arg_1){
                                          if(cd[j*2+1][0] !="" && cd[j*2+1][0]!="undefined" && typeof(cd[j*2+1][0])!="undefined"){
                                            if((cd[j*2+1][0]).indexOf("->") >0 ){
                                              var valid =true;         
                                            }else{
                                              valid =false;
                                            }
                                            htmlShow +="<li id=\""+cd[j*2+1][1]+"_"+arg_2+"\" style=\"cursor:hand;\" onClick=\"GetNextCat("+cd[j*2+1][1]+","+next_index+","+valid+")\">"+cd[j*2+1][0]+"</li>";
                                          }
                                        }
                                        else{
                                            continue;
                                        }
                                      }
                                    }
                                }
                              }
                             if( htmlShow !=""){
                                tmpRs +=htmlShow+'</ul></div>';
                              }else{
                                tmpRs ="";
                              }                 
                             $("#"+index).parent().parent().after(tmpRs);
                         }else{
                            $("#btn_next").removeAttr("disabled").addClass("hand");
                         }
		             };
		             </script> 
		        </div>
		    </div>
		</div>
	</div>
		<uc1:Helper id="Helper" runat="server"></uc1:Helper>
		<uc1:Footer id="Footer" runat="server"></uc1:Footer>
</body>
</html>
