var em_div;
var em;

function extendSidebar()
{
	em_div = document.getElementById("em");
	em = em_div.offsetHeight;
	do_resize();
	window.onresize = do_resize;
	detect_font_change();
}

function detect_font_change()
{
	var new_em = em_div.offsetHeight;
	if(new_em != em)
	{
		em = new_em;
		do_resize();
	}
	setTimeout("detect_font_change()", 200);
}

function do_resize()
{
	var sidebar = document.getElementById("sidebar");
	var pie = document.getElementById("image_pie");
	var footer2 = document.getElementById("footer2");
	var footer = document.getElementById("footer");

	var em = document.getElementById("em").offsetHeight;

	var height = document.body.offsetHeight-pie.offsetHeight-footer.offsetHeight-footer2.offsetHeight+.5*em-5;
	//The size of the page minus the pie and the footers, plus .5em for the margin, minus 4 pixels for the graphical border

// 	height += .7*em;
	height += 12;
//Fudge factor.  Could possibly be tweaked some more.

	sidebar.style.height=height+"px";


	var windowWidth = getWindowWidth();
/*	var footer_image = document.getElementById("footer_image");
	if(windowWidth == 0 || windowWidth > 875)
	{ footer_image.style.visibility="visible"; }
	else
	{ footer_image.style.visibility="hidden"; }*/
}

function getWindowWidth()
{
    if (window.self && self.innerWidth)
    { return self.innerWidth; }
    if (document.documentElement &&
        document.documentElement.clientWidth)
    { return document.documentElement.clientWidth;}
    return 0;
}
