jQuery.fn.selectFilter = function (options){
	var defaults = {
		callBack : function (res){}
	};
	var ops = $.extend({}, defaults, options);
	var selectList = $(this).find('select option');
	var that = this;
	var html = '';
	
	// 读取select 标签的值
	html += '<ul class="filter-list">';
	
	$(selectList).each(function (idx, item){
		var val = $(item).val();
		var valText = $(item).html();
		var selected = $(item).attr('selected');
		var disabled = $(item).attr('disabled');
		var isSelected = selected ? 'filter-selected' : '';
		var isDisabled = disabled ? 'filter-disabled' : '';
		if(selected) {
			html += '<li class="'+ isSelected +'" data-value="'+val+'"><a title="'+valText+'">'+valText+'</a></li>';
			$(that).find('.filter-title').val(valText);
		}else if (disabled){
			html += '<li class="'+ isDisabled +'" data-value="'+val+'"><a>'+valText+'</a></li>';
		}else {
			html += '<li data-value="'+val+'"><a title="'+valText+'">'+valText+'</a></li>';
		};
	});
	
	html += '</ul>';
	$(that).append(html);
	$(that).find('select').hide();
	
	//点击选择
	$(that).on('click', '.filter-text', function (){
		$(that).find('.filter-list').slideToggle(100);
		$(that).find('.filter-list').toggleClass('filter-open');
		$(that).find('.icon-filter-arrow').toggleClass('filter-show');
	});
	
	//点击选择列表
	$(that).find('.filter-list li').not('.filter-disabled').on('click', function (){
		var val = $(this).data('value');
		var valText =  $(this).find('a').html();
		$(that).find('.filter-title').val(valText);
		$(that).find('.icon-filter-arrow').toggleClass('filter-show');
		$(this).addClass('filter-selected').siblings().removeClass('filter-selected');
		$(this).parent().slideToggle(50);
		for(var i=0; i<selectList.length; i++){
			var selectVal = selectList.eq(i).val();
			if(val == selectVal) {
				$(that).find('select').val(val);
			};
		};
		ops.callBack(val); //返回值
	});
	
	//其他元素被点击则收起选择
	$(document).on('mousedown', function(e){
		closeSelect(that, e);
	});
	$(document).on('touchstart', function(e){
		closeSelect(that, e);
	});
	
	function closeSelect(that, e) {
		var filter = $(that).find('.filter-list'),
			filterEl = $(that).find('.filter-list')[0];
		var filterBoxEl = $(that)[0];
		var target = e.target;
		if(filterEl !== target && !$.contains(filterEl, target) && !$.contains(filterBoxEl, target)) {
			filter.slideUp(50);
			$(that).find('.filter-list').removeClass('filter-open');
			$(that).find('.icon-filter-arrow').removeClass('filter-show');
		};
	}
};
function jianshuo_gengduo(id) {
	$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');// 这行是 Opera 的补丁, 少了它 Opera 是直接用跳的而且画面闪烁
	$body.animate({ scrollTop: $('#jianshuo_gengduo').offset().top }, 1000);
    $.ajax({
        url: quanjuurl + "inc/huiyuan.php?jianshuo=json",
        type: "post",
        data: {page:id},
        dataType: "json",
        success: function(result) {
			if(result.jianshuo == null){
				xtip.msg('歇会吧，没有了！');
			}else{
				var arr = result.jianshuo;
				var content = $("#jianshuo_lieiao").html();
				for(var i=0;i<arr.length;i++){
					var content = content+'<section id="cd-timeline"><div class="yanglong_comment"style="margin-bottom:10px;"><ol class="comment-list"><li class="comment-list__item"><div class="comment-list__item-contain"><div class="term"><div class="content"><div class="user"><i class="owner"style="background:#000;border-radius:4px;transform:translateY(-25%);">'+arr[i].author+'</i><div class="agent xinqingdaxiao '+arr[i].type+'"></div></div><div class="substance">'+arr[i].content+'</div><div class="agent"><div style="float:right;"><span style="margin-left:5px;color:#617d0e;font-size:13px;font-weight:800">'+arr[i].create_time+'</span></div></section>';
				}
				$('#jianshuo_lieiao').html(content);
				$('#jianshuo_gengduo').html('<div class="joe_load" onclick="jianshuo_gengduo('+result.page+')">查看更多</div>');
			}
        }
    })
}
function mycheck1(){
    var url = quanjuurl+'inc/huiyuan.php?jianshuo=xinqing';
	var neirong = $("#comment").val();
	$.ajax({
        url: url,
        type: "post",
        data: {neirong:neirong, xinqing:$("#jianshuoblogsort").val()},
        dataType: "TEXT",
        success: function(result) {
			xtip.msg(result);
			var reg = RegExp(/base64/);
			if(neirong.match(reg)){
				var ghtrhtrhjryt = '<img class="draw_image ls-is-cached lazyloaded" src="'+neirong.substring(neirong.indexOf("[img]") + 5,neirong.indexOf("[/img]"))+'" alt="画图"/>';      
			}else{
				var ghtrhtrhjryt = neirong;  
			}
			var content1 = $("#jianshuo_lieiao").html();
			var content = '<section id="cd-timeline"><div class="yanglong_comment"style="margin-bottom:10px;"><ol class="comment-list"><li class="comment-list__item"><div class="comment-list__item-contain"><div class="term"><div class="content"><div class="user"><i class="owner"style="background:#000;border-radius:4px;transform:translateY(-25%);">我</i><div class="agent xinqingdaxiao '+$("#jianshuoblogsort").val()+'"></div></div><div class="substance">'+ghtrhtrhjryt+'</div><div class="agent"><div style="float:right;"><span style="margin-left:5px;color:#617d0e;font-size:13px;font-weight:800">刚刚</span></div></section>'+content1;
			$('#jianshuo_lieiao').html(content);
			$("html, body, #evt_container").animate({scrollTop:0}, 1000);
        }
    });
}