//вернуть высоту блока с учетом падингов и бордеров
function returnBlockHeight(elem){
	$elem = $(elem);
	return $elem.height()+parseInt($elem.css('borderBottomWidth'))+parseInt($elem.css('borderTopWidth'))+parseInt($elem.css('paddingTop'))+parseInt($elem.css('paddingBottom'));
}

MinHeight100percent = function(elem, params){
	var params = params || {};
	this.params = params;
	this.subtract = params.subtract || '#footer';
	this.elem = elem || null;
	this.$elem = $(elem) || null;
	this.$body = $('body').eq(0);
	this.attachEvents();
}
MinHeight100percent.prototype.calcHeight = function(){
	var self = this;
	var body = this.$body.height();
	var subtract = 0;
	$(this.subtract).each(function(){
		subtract += returnBlockHeight(this);
	});
	this.$elem.each(function(){
		$elem = $(this);
		var contentHeight = 0;
		var top = this.offsetTop;
		var newHeight = body - top - subtract;
		$elem.height(newHeight);
	});
	/*$(this.subtract).each(function(){
		subtract += returnBlockHeight(this);
	});
	this.$elem.each(function(){
		$elem = $(this);
		var contentHeight = 0,
		    selector = (this.tagName.toLowerCase() == 'table') ? 'td > div' : '> *';
		$(selector, $elem).each(function(){
			if($(this).outerHeight(this) > contentHeight){
				contentHeight = $(this).outerHeight(true);
				if (contentHeight > 5000){
					contentHeight += 500;
				}
				if (contentHeight > 1000){
					contentHeight += 600;
				} 
				contentHeight += 80;
			}
		});
		var top = this.offsetTop;
		var newHeight = body - top - subtract;
		if(newHeight > contentHeight){
			$elem.height(newHeight);
		}
		else{
			$elem.height(contentHeight);
		}
	});*/
}
MinHeight100percent.prototype.attachEvents = function(){
	var self = this;
	self.calcHeight();
	$(window).resize(function(){
		self.calcHeight();
	});
	$(window).load(function(){//Chrome
		self.calcHeight();
	});
}

$(document).ready(function(){
	new MinHeight100percent('.js-100percentMinHeight');
    //new MinHeight100percent('.js-100percentMinHeight', {subtract : ['.b-header.g-ec', '.b-iblock .b-iblock__title']});;
})
