var browseHeight;
var autoscroll;
var originalheight;
var divmargin = 230;

if (window.addEventListener){ window.addEventListener("load", setup, true); }
else if (window.attachEvent){ window.attachEvent("onload", setup); }

function setup() {
	window.onresize = tellsize;

	for ( i = 0; i < document.styleSheets.length; i++ ) {
		for ( j = 0; j < document.styleSheets[i].rules.length; j++ ) {
			var thisSelText = document.styleSheets[i].rules[j].selectorText;
			var thisStyle = document.styleSheets[i].rules[j].style;

			if (thisSelText == '.autoscrolldiv') {
				if (thisStyle.height != 'auto') {
					autoscroll = thisStyle;
					originalheight = parseInt(thisStyle.height);
				}
			}
		}
	}
	tellsize();
}

function tellsize() {
	if (document.layers) browseHeight=window.outerHeight;
	if (document.all) browseHeight=document.body.clientHeight;

	if (autoscroll) {
		if (browseHeight > (originalheight+divmargin)) 
			autoscroll.height = (browseHeight-divmargin)+'px';
		else autoscroll.height = originalheight+'px';
	}
}

