function JustifyElements(element, container, minMargin)
{
	this.elem = $(element);
	this.elemWidth = this.elem.width() + (parseInt(this.elem.css('border-left-width')) + parseInt(this.elem.css('border-right-width')));
	this.cont = $(container);
	this.minMargin = minMargin;
	this.justify = function()
	{
		var contWidth = this.cont.width();
		var num = Math.floor((contWidth - this.minMargin) / (this.elemWidth + this.minMargin));
		var sumMargin = contWidth - this.elemWidth * num;
		var newMargin = Math.floor(sumMargin / (num * 2));
		this.elem.css('margin-left', newMargin);
		this.elem.css('margin-right', newMargin);
		/*alert('this.elemWidth = '+this.elemWidth+', this.minMargin = '+this.minMargin +
				', contWidth = '+contWidth+', num = ' + num + ', sumMargin = '+ sumMargin+', newMargin = '+newMargin);*/
	};
	
	this.justify();
	
	var justifier = this;
	$(window).resize(function(){
		justifier.justify();
	});
}

