/**
 * 
 */
function apartmentsAttrFilter(){
	this.compare_MIN_MAX = function(values,value){
		return ((value<=values[1]) && (value>=values[0]))
	};
	this.compare_IN = function(values,value,def){
		var vl = values.length;
		var tmp_res = false;
		if(vl==0)
			return def;
		for ( var int = 0; int < vl; int++) {
			if(values[int]!=value)
				continue;
			return true;
		}
		return false;
	};
	this.compare_EXACT = function(inA,inB){
		return (inA==inB);
	};
	this.compare_BITWISE = function(inA,inB){
		return ((inA&inB)==inB);
	};
	this.run = function(apartments,conpare){
		var al = apartments.length;
		var counted = 0;
		for ( var int = 0; int < al; int++) {
			var res_tmp = true;
			if(typeof(conpare.in_) != 'undefined')
				if((res_tmp = res_tmp && this.compare_IN(conpare.in_,apartments[int].at,true)) == false)
					continue;
			if((typeof(conpare.bitwise) != 'undefined') && conpare.bitwise)
				if((res_tmp = res_tmp && this.compare_BITWISE(apartments[int].am,conpare.bitwise)) == false)
					continue;
			if(typeof(conpare.minmax) != 'undefined'){
				if(typeof(conpare.minmax.ls) != 'undefined'){
					if((res_tmp = res_tmp && this.compare_MIN_MAX(conpare.minmax.ls,apartments[int].ls)) == false)
						continue;
				}
				if(typeof(conpare.minmax.ap) != 'undefined'){
					if((res_tmp = res_tmp && this.compare_MIN_MAX(conpare.minmax.ap,apartments[int].ap)) == false)
						continue;
				}
			}
			if(res_tmp)
				counted++;
		}
		return counted;
	};
};
