function squareImages(selector) {
	var blocks = $(selector);
	var squareBlocks = new Array();

	var SquareBlock = function(jqElem) {
		var SquareBlockPub = new Object();
		
		var oldWidth = null;
		
		SquareBlockPub.squareUp = function() {
			if (oldWidth != jqElem.width()) {
				jqElem.height(jqElem.width());
				oldWidth = jqElem.width();			
			}
		}
		
		return SquareBlockPub;
	}
	
	blocks.each(function(){
		squareBlocks.push( SquareBlock($(this)) );
	});
	
	function checkResize() {
		var len = squareBlocks.length;
		for (var i = 0; i < len; i++) {
			squareBlocks[i].squareUp();
		}
	}
	
	var resizeInterval = setInterval(checkResize, 10);
	$(window).resize(checkResize);
}

$(document).ready(function(){
	squareImages(".image-square")
})