function bodyOn (){

	// for printable documents

	document.getElementById("body").style.display = "block";
}

function sizing(){

	// for web pages

	d = document;

        h = d.getElementById("header");
	i = d.getElementById("initials");
        m = d.getElementById("menuBlock");
        e = d.getElementById("eyecandy");

	candies = e.getElementsByTagName('img');

        r = d.getElementById("rightbox");
        b = d.getElementById("body");
        f = d.getElementById("footer");

	margin = 30;
        
        // hide in advance of resizing (reverse order)
        
//        f.style.display = "none";
        b.style.display = "none";
        e.style.display = "none";
//        m.style.display = "inline";
        i.style.display = "none";
        
	i.style.marginLeft = margin + 'px';	
	i.style.display = "inline";

	m.style.display = "inline";
        
//        for ( x = 0 ; x < ( i.offsetWidth + 2 * margin ); x++ ) { m.style.marginLeft = x + 'px'; }
        m.style.marginLeft = ( i.offsetWidth + 2 * margin ) + 'px';
        
	// check sizes of two variable elements and set top bar height

	height = Math.max ( i.offsetHeight, m.offsetHeight );
        h.style.height = height + 'px';

	// set vertical positioning of first two elements

	i.style.marginTop = ( height - i.offsetHeight ) / 2 + 'px';
	m.style.marginTop = ( height - m.offsetHeight ) / 2 + 'px';
        
	// position eyecandy - contains constant height!

	e.style.marginTop = ( height - 60 ) / 2 + 'px';

        spaceUsed = i.offsetWidth + m.offsetWidth + 4 * margin; // both other elements' widths + four margins overall
	e.style.marginLeft = spaceUsed + 'px';
	availableSpace = h.offsetWidth - spaceUsed;

        e.style.display = "inline";

        // if any eyecandy exists, turn it all off, then activate some

	iterations=0;

	if ( candies [0] ) {

		while ( iterations ++ < 24 ) {
        	        candies [iterations].style.display = "none";
	        }

		iterations=0;        

                spareSpace = 140; // the width of one photo thumb, fudged upwards
                while ( ( e.offsetWidth + spareSpace < availableSpace ) && ( iterations ++ < 24 ) ) {
                
//                        spareSpace ++; // konqueror adding a pixel more in between each!!?
                        candies [iterations].style.display = "inline";

	       		// ineffective hack to remove a photo if we went over the border in konqueror
			// if ( e.offsetHeight > 60 ) { candies [iterations].style.display = "none"; }

//                        m.innerHTML = availableSpace + " available - " + e.offsetWidth + " in " + iterations + " photos " + "<br/>=" + ( availableSpace - e.offsetWidth ) + " excess";

/*			t = d.getElementById ( "test_growth" );
                        t.style.display="inline";
//                        t.innerHTML = t.innerHTML + "<hr height=\"1\" width=\"" + e.offsetWidth + "\">"
                        t.innerHTML = t.innerHTML + " ... " + e.offsetWidth + " x " + e.offsetHeight;
*/                       
                }
        }

	// turn on body and footer last so they don't have to move

        b.style.display = "block";
        f.style.display = "block";
}


window.onresize = sizing;

