<{import file="header.html" title="产品发布"}> 
<style type="text/css">
.cname{ font-size:16px; border-bottom:1px solid #efefef; width:940px; padding:2px 0 10px 0; float:left; }

.cats_list{ width:920px; height:405px; float:left; overflow:hidden; margin:15px 0 0 0; float:left;}
.cats_list .menu{ width:229px; height:400px; padding:0; overflow-y:scroll; border:1px solid #efefef; float:left;}
.cats_list .menu ul{}
.cats_list .menu ul li{}
.cats_list .menu ul li a{ width:168px; padding:8px 0 8px 15px;border-left:2px solid #fff; font-size:12px; float:left;}
.cats_list .menu ul li.ch{ padding-right:25px; background:#f8f8f8; border-left:2px solid #0099FF; float:left; }
.cats_list .menu ul li.ch a{ }

.addBtton{ width:100%; text-align:center; padding:10px 0 30px;  float:left;}
.addBtton input{ float:none; margin:20px 0 0 0; padding:10px 38px; border-radius:3px; background: #efefef; color:#666; font-size:14px;} 
.addBtton input.ch{ background: #1583EF; color:#fff; }

</style>
<div class="cname">商品发布</div>
<div class="lbox"> 
	<form action="<{$__SELLER__}>goods/edit" method="get">	
		<div class="cats_list"></div> 
		<input type="hidden" name="cid" id="cid" value="<{if $smarty.get.cid}><{$smarty.get.cid}><{/if}>"/> 
		<{if $smarty.get.gid}>
			<input type="hidden" name="id" id="gid" value="<{$smarty.get.gid}>"/>
		<{/if}> 
		<div class="addBtton"><input type="submit" id="submit_cats" value="下一步，发布商品" disabled="disabled"/></div> 
	</form> 
</div>
<{import file="footer.html"}>  
<script type="text/javascript">
$(function(){
	$(document).on("click",".menu ul li a",function(){
		var $this = $(this);
 		var cid = $this.attr('data-cid'); 
		$this.parent('li').addClass('ch').siblings().removeClass('ch');
		$this.parents('.menu').nextAll().remove();
		category_next(cid);
 	}); 
	function category_next(pcid){ 
		cid = cid?cid:'0';
		$.post('<{$__SELLER__}>goods/ajax_get_next_list',{pcid:pcid}, function(result){
			var data = jQuery.parseJSON(result);
			if(data.error == '0'){
				if(data.last == '0'){
					html = '<div class="menu menu_'+cid+'"><ul>';
					$.each(data.category, function(key, val){
						html += '<li><a href="javascript:;" data-cid="'+val.cid+'" >'+val.name+'</a></li>'; 
					});
					html += '<ul></div>';
					if($('.menu').length == 0){ 
						$('.cats_list').html(html);		
					}else{
						$('.menu:last').after(html);		
					} 
					$("#cid").val('');
					$("#submit_cats").attr('disabled',true).removeClass('ch');
				}else{
					$("#cid").val(pcid);
					$("#submit_cats").attr('disabled',false).addClass('ch'); 
				} 
			}else{
				alert('系统繁忙');
			}
		}); 
	}
	<{if $smarty.get.cid}>
		$.post("<{$__SELLER__}>goods/ajax_get_parents_list",{cid:'<{$smarty.get.cid}>'},function(result){ 
			var data = jQuery.parseJSON(result); 
			html = '';
			$(data).each(function(key, val){
				html += '<div class="menu"><ul>';
				$.each(val.list, function(index, obj){
					if(obj.cid == val.cid){
						html += '<li class="ch"><a href="javascript:;" data-cid="'+obj.cid+'">'+obj.name+'</a></li>'; 
					}else{
						html += '<li><a href="javascript:;" data-cid="'+obj.cid+'" >'+obj.name+'</a></li>'; 
					} 
				}); 
				html += '<ul></div>'; 
			});
			$('.cats_list').html(html); 
		});
		$("#cid").val('<{$smarty.get.cid}>'); 
		$("#submit_cats").attr('disabled',false).addClass('ch'); 
	<{else}>
		category_next('0');	
	<{/if}> 
});
</script>