<%@ Page language="c#" Codebehind="ProductAdd_Step1.aspx.cs" AutoEventWireup="true" Inherits="XpShop.Manage.ProductAdd_Step1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML>
	<HEAD>
		<title>ProductAdd_Step1</title> 
		<!--#include file="../inc/head2.inc"-->
		<script type="text/javascript" src="../inc/commond.js"></script>
		<script src="<%=webSite%>get_all_category.aspx?nocopyright=1" type="text/javascript"></script>
	</HEAD>
	<body>
		<div id="JsContent" style="DISPLAY:none"></div>
		<div class="container">
			<div class="sub_container">				
				<div class="sub_container_title"><a href="<%=AdminDefault%>" target="_top">桌面</a><img src="images/admin_title.jpg" height="9" width="8" align="absMiddle"><%--商品添加--%><asp:label id="lblTitleInfo" Runat="server" CssClass="tableHeaderText">商品添加</asp:label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%--<A href="../ProductAdd_excel.aspx">批量添加</A>--%></div>
				<div class="sub_container_content">
					<div class="frame tab">
						<div class="frame_title">第一步：选择商品分类</div>
						<div class="frame_content">
							<form id="Form1" method="post" action="ProductAdd_Step2.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">
							<table cellspacing="0" cellpadding="0" class="ptable" style="width:100%">
								<tr>
									<td class="mm">
										<div id="categorys">
											<ul id="cul">
												<li>
													<ul id="child1"></ul>
												</li>
											</ul>
										</div>
									</td>
								</tr>
								<tr>
									<td class="mm"><div id="btn_next" class="next disable"></div></td>
								</tr>
							</table>								
							</FORM>
							<script type="text/javascript">
							$(document).ready(function(){  
								for(var n=0;n<data.length/4;n++){
									$('<li id="'+data[n*4][1]+'_1" class="citem" 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("selected");
								$("#"+index).addClass("selected");
								$('#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").removeClass("enable").addClass("disable").unbind();
									var tmpRs ='<li><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+"  class=\"citem\" 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+"\"  class=\"citem\" onClick=\"GetNextCat("+cd[j*2+1][1]+","+next_index+","+valid+")\">"+cd[j*2+1][0]+"</li>";
												}
												}
												else{
													continue;
												}
											}
											}
										}
									}
									if( htmlShow !=""){
										tmpRs +=htmlShow;
									}else{
										tmpRs ="";
									}                 
									$("#"+index).parent().parent().after(tmpRs);
								}else{
									$("#btn_next").removeClass("disable").addClass("enable").click(function(){
										$("#Form1").submit();
									});
								}
							};
							</script> 
						</div>
					</div>
				</div>			
			</div>			
		</div>
	</body>
</HTML>
