function hideImages()
// hides images on left-hand column until it matches height of main content area
{
    var sidebar = document.getElementById("SideBar");
    if (sidebar) {
        var content = document.getElementById("MainContent");
        var imgs = sidebar.getElementsByTagName("img");
        var mainheight = content.offsetHeight;
        var leftheight = sidebar.offsetHeight;
        var counter = 2;
        while ( counter > -1 && mainheight < leftheight) {
            //for (var counter=2;mainheight < (leftheight-35) ;counter--) {
            //alert("Left: " + leftheight + ", main: " + mainheight);
            imgs[counter].parentNode.style.display = "none";
            leftheight = sidebar.clientHeight;
            counter--;
            imgs[counter].parentNode.style.marginBottom = "0px";
        }
        document.getElementById('HeaderImg').style.width='100%';
    }
}

function viewAddress()
// replaces emails in the form <a class="e">daniel[at]roseman.org.uk</a>
// with clickable links
// based on code from http://www.htmldog.com/ptg/archives/000063.php
{
    if (document.getElementsByTagName) {
        var a = document.getElementsByTagName("a")
        var i
        for (i = 0; i < a.length; i++) {
            if (a[i].className && a[i].className == "e") {
                address_to_replace = a[i].firstChild;
                real_address=address_to_replace.nodeValue.replace("[at]", "@");
                address_to_replace.nodeValue=real_address; 
                address_to_replace.parentNode.setAttribute("href", "mailto:"+real_address);
            }
        }
    }
}

window.onload = function() { hideImages(); viewAddress(); }
//window.onresize = hideImages;

