var PageHeight = function(heights, setid) {
	var This = this;
	this.tjs  = $("#" + setid);
	this.hArr = new Array();
	for(var i = 0; i < heights.length; i++) {
		var div = $("#" + heights[i]);
		if(div)
			this.hArr.push(div);
	}

	this.resizeTimer = false;
	$(window).bind('resize', function() { This.resizeTimerEvent() });
	$(document).ready(function() { This.resize() });

}

PageHeight.prototype.resizeTimerEvent = function() {
	var This = this;
	if(this.resizeTimer) {
		clearTimeout(this.resizeTimer);
		this.resizeTimer = false;
	}
	this.resizeTimer = setTimeout(function() { This.resize() }, 100);
}

PageHeight.prototype.resize = function() {

	if(this.resizeTimer) {
		clearTimeout(this.resizeTimer);
		this.resizeTimer = false;
	}

	var h1 = $(window).height();
	var h2 = 0;
	for(var i = 0; i < this.hArr.length; i++) {
		var el = this.hArr[i]
		h2 = Math.max(h2, el.height());
	}

	var h = Math.max(h1 - this.tjs.offset().top, h2 + 1)
	if(this.tjs.height() != h)
		this.tjs.css("height", h + "px");

}

