// JavaScript Document

;(function($){//根据高度来过滤
		   $.fn.jFilterCaseList=function(options){
			   var settings={
				   rowCount:5,
				   caseLayout:"",
				   callBack:function(){} //过滤好后执行的函数
				   }
			   
			   
			   var op=$.extend(settings,options);
			   var $this=$(this);
			   
			   var addColumLastClass=function(obj){
				   var $showCaseListList=obj.filter(":visible");
				   $showCaseListList.each(function(index){
												   index % op.rowCount == op.rowCount-1 ? $(this).addClass("columnlast") : $(this).removeClass("columnlast") //初始化所有的最后一列maggin
												   })
				   }
			   
			   var init=function(obj){
				   var $showCaseListList=obj.filter(":visible");
				   $showCaseListList.each(function(index){
												   //求当前行
												   var currentRow=Math.round(((index+1) / op.rowCount) + 0.455)
												   //计算出当前行起始的数字和结束的数字
												   var startPosition=(currentRow-1) * op.rowCount ==0 ? 0 : (currentRow-1) * op.rowCount
												   var endPosition=startPosition+op.rowCount
												   var $currentRow=$showCaseListList.slice(startPosition,endPosition)
												   
												   var maxHeight=0;
												   //求出当前行的相应层的最大高度
												   $currentRow.each(function(){
																			 if ($(this).find(op.caseLayout).height() > maxHeight) maxHeight=$(this).find(op.caseLayout).height()
																			 })
												   //把当前行的相应层的高度调整下
												   $currentRow.find(op.caseLayout).height(maxHeight);
												   })
				   if ($.isFunction(op.callBack)){
					   op.callBack()
					   }
				   }
			   init($this);
			   return $this;
			   
			   
			   }
		   
		   })( jQuery );
