// resize script for pages with right content div

function xHeight(obj, h) {
	var height = obj.offsetHeight;

	if (h) {
		if (obj.style.pixelHeight) {
			obj.style.pixelHeight = h;
		} else {
			obj.style.height = h + 'px';
		}
	}

	return height;
}

var mh;		// menu height
var ch;		// content height
var crh;	// content right height

function adjustLayout(onload) {
	// get body height and content top
	var bh = document.body.clientHeight;
	var ct = document.getElementById("content").offsetTop;

	if (onload) {
		// get menu, content and content right heights at page load
		mh =  xHeight(document.getElementById("menu"));
		ch = xHeight(document.getElementById("content"));
		crh = xHeight(document.getElementById("contentright"));

		try{
			var menuborder = getComputedStyle(document.getElementById("content"), '').getPropertyValue('border-bottom-width');
		} catch(e){
			var menuborder = document.getElementById("content").currentStyle.borderWidth;
		}

		if (menuborder.indexOf("1px") >= 0) {
			mb = 1
		} else {
			mb = 0;
		}
	}

	if ((ct + ch + 30 <= bh) && (ct + crh + 30 <= bh) && (ct + mh + 30 <= bh)) {
		// content height is smaller then (body height - content top - footer (30))
		var h = bh - ct - 30; // use body height - content top - footer (30)
	} else {
		// content height + content top is larger then (body height - content top - footer (30))
		if ((mh > ch) & (mh > crh)) {
			var h = mh + 1;
		} else if ((ch > mh) & (ch > crh)) {
			var h = ch;
		} else {
			var h = crh;
		}
	}

	// substract 15 px for margins
	h -= 30;
	h -= mb;

	xHeight(document.getElementById("content"), h);
	xHeight(document.getElementById("contentright"), h);
}

function adjustLayoutLoad() {
	adjustLayout(true);
}

function adjustLayoutResize() {
	adjustLayout(false);
}