<ol style="padding-left: 0px;">
	<?php foreach ($search_list as $key => $list) { ?>
		<?php if ((!isset($search_type) && !in_array($list->ic_id, explode(',', $ic_id_list))) || isset($search_type)) { ?>
		<li style="line-height:30px;">
			<a target="_blank" href="<?php echo $this->config->item('site_url').$list->ic_url; ?>"><?php echo $list->ic_url_title; ?><?php if (isset($search_type) && $search_type=='recommended') echo '[Selected]'; ?></a>
			<?php if (isset($search_type) && $search_type=='recommended') { ?>
				<span class="pull-right text-danger" style="cursor: pointer;" data-icid="<?php echo $list->ic_id; ?>" onclick="javascript:del_recommend(this,<?php echo $list->ic_id; ?>);">Remove</span>
			<?php }else{ ?>
				<span class="pull-right" style="cursor: pointer;" data-icid="<?php echo $list->ic_id; ?>" onclick="javascript:add_recommend_list(this,<?php echo $list->ic_id; ?>);">Add</span>
			<?php } ?>
		</li>
		<?php } ?>
	<?php } ?>
</ol>
<script type="text/javascript">

	resize_recommend_list(10);

	var popoverID=$(".recommend_info_popover").prev('input').attr('id');

	function del_recommend (that,ic_id) {
		var list=$('#'+popoverID).val().split(',');
		var new_list='';
		for (var i=0; i < list.length; i++) {
			if (ic_id!=list[i] && list[i]!='') {
				new_list+=list[i]+',';
			};
		};
		$('#'+popoverID).val(new_list);

		var $a=$(that).prev('a');
		var href=$a.attr('href');
		var ic_url_title=$a.text().replace('[Selected]','');
		var html='<li style="line-height:30px;"><a target="_blank" href="'+href+'">'+ic_url_title+'</a><span class="pull-right" style="cursor: pointer;" data-icid="'+ic_id+'" onclick="javascript:add_recommend_list(this,'+ic_id+');">Add</span></li>';
		if ($("#recommend_list>ol").length==0) {
			$("#recommend_list").append('<ol style="padding-left: 0px;padding-top:0px;"></ol>');
		};
		$("#recommend_list>ol").prepend(html);
		setTimeout(resize_recommend_list(9),0);
		$(that).parent('li').remove();
	}

	function add_recommend_list(that,ic_id){
		var stringflag=$('#'+popoverID).val()==''?'':',';
		var icid=$('#'+popoverID).val()+stringflag+ic_id;
		icid=icid.replace(',,',',');
		$('#'+popoverID).val(icid);
		var $a=$(that).prev('a');
		var href=$a.attr('href');
		var ic_url_title=$a.text();
		var html='<li style="line-height:30px;"><a target="_blank" href="'+href+'">'+ic_url_title+'[Selected]</a><span class="pull-right text-danger" style="cursor: pointer;" data-icid="'+ic_id+'" onclick="javascript:del_recommend(this,'+ic_id+');">Remove</span></li>';
		if ($("#recommended_list>ol").length==0) {
			$("#recommended_list").append('<ol style="padding-left: 0px;padding-top:0px;border-bottom:1px dashed #555;"></ol>');
		};
		$("#recommended_list>ol").append(html);
		setTimeout(resize_recommend_list(10),0);
		$(that).parent('li').remove();
	}

	function resize_recommend_list(count){
		if($("#recommend_list>ol>li").length>count){
			$("#recommend_list").css({"margin-right":"-16px"});
		}else{
			$("#recommend_list").css({"margin-right":"0px"});
		}
	}
</script>