<{include file="index/header.html"}> 
<{include file="caiji/nav.html"}> 
<div class="filter">  
	 
</div>
<style type="text/css">
.brandbox{ width:100%; height:300px; border:1px solid #efefef; overflow-y:scroll; float:left; }
.bbox{ width:200px; height:100px; overflow:hidden; border:1px solid #ddd; margin:5px; float:left; }
.bbox label{ width:200px; height:100px; margin:0; float:left; }
.bbox label .ck{ width:20px; text-align:center; line-height:100px; float:left; }
.bbox label .ck input{ float:none; } 
.bbox label .con{ width:178px; text-align:center; border-left:1px solid #efefef; float:left; }
.bbox label .con p{ width:100%; text-align:center; padding:0; }
input#get_brand{ padding:6px 10px; margin-left:5px; float: left; }
</style>
<div class="main">
	<table width="100%" class="etable">
		<tr>
			<td width="100">分类：</td>
			<td>
				<div class="cats_list"></div>
				<input type="hidden" name="cid" value="" id="cid"/>  
			</td>
		</tr> 
		<tr>
			<td>关键字：</td>
			<td>
				<input type="text" name="keyword" id="keyword" size="35"/>
				<input type="button" class="button" id="get_brand" value="获取"/>
			</td>
		</tr>
		<tr>
			<td valign="top" style="padding-top:10px;">品牌：</td>
			<td><div class="brandbox"></div></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td><input type="submit" name="submit" id="submit" value="采集"/></td>
		</tr> 
	</table> 
</div>
<{include file="index/footer.html"}> 
<script type="text/javascript">
category_next('0');	
$(function(){
	$("input#get_brand").click(function(){ 
		key = $("#keyword").val(); 
		$.post("?m=caiji&a=brand_get", {key:key}, function(result){
			data = jQuery.parseJSON(result); 
			html = '';
			$.each(data, function(key,val){
				if(val.images){
			html += '<div class="bbox" data-images="'+val.images+'" data-title="'+val.title+'">'+
						'<label>'+
						'	<div class="ck"><input class="ckbox" type="checkbox" name="ck" value=""/></div>'+
						'	<div class="con">'+
						'		<p><img src="'+val.images+'_150x10000.jpg"></p>'+
						'		<p>'+val.title+'</p>'+
						'	</div> '+
					 	'</label>'+
					'</div>';
				}else{
			html += '<div class="bbox" data-title="'+val.title+'>'+
						'<label>'+
						'	<div class="ck"><input type="checkbox" name="ck" value=""/></div>'+
						'	<div class="con">'+
						'		<p>'+val.title+'</p>'+
						'	</div> '+
					 	'</label>'+
					'</div>';
				} 
			});
			$(".brandbox").html(html);
		});	
	}); 
	
	$("#submit").click(function(){
		var cid = $("#cid").val();
		$(".bbox").each(function(){
			if($(this).find('input.ckbox').is(':checked')){
				title = $(this).attr('data-title');
				images = $(this).attr('data-images');
				$.post('?m=caiji&a=brand_post', {cid:cid, title:title, images:images}, function(result){
					data = jQuery.parseJSON(result); 
					if(data.error == '0'){
						alert('保存成功');
					}else{
						alert(data.msg);
					}
				});
				
			} 
		}); 
	});
	 
	
	
});

</script>