window.onload = init;
window.onresize = handleResize;

var originalHeight;

function init() {
	var j = 1;
	var sum = 0;
	while( d = document.getElementById( 'm'+j ) ){
		sum += d.offsetWidth + 1;
		j++;
	}
	var all = document.getElementById( 'all' );
	if( sum > 465 ){
    all.style.width = sum+'px';
	}else{
    all.style.width = '465px';
	}

	var cc = document.getElementById( 'centercol' );
	var h = windowHeight();
	originalHeight = cc.offsetHeight;
	if( cc.offsetHeight < h - 360 ){
    cc.style.height = (h - 360) + 'px';
	}
}

function windowHeight() {
    // Standard browsers (Mozilla, Safari, etc.)
    if (self.innerHeight)
        return self.innerHeight;
    // IE 6
    if (document.documentElement && document.documentElement.clientHeight)
        return document.documentElement.clientHeight;
    // IE 5
    if (document.body)
        return document.body.clientHeight;
    // Just in case.
    return 0;
}

function handleResize(){
	var cc = document.getElementById( 'centercol' );
	var h = windowHeight();
	if( originalHeight < h - 360 ){
    cc.style.height = (h - 360) + 'px';
	}
}

