function log(text) {
    if (window.console) {
        console.log(text);
    }
}

function onResize() {
    element= document.getElementById('page');
    if (element) {
        height = element.clientHeight;
        log(height);
        
        /* hide / show optional elements */
        if (height < 650) {
            hide("events");
            hide("news");
        } else if (height < 785) {
            hide("events");
            
            moveDown("news");
            show("news");
        } else {
            moveUp("news");
            
            show("news");
            show("events");
        }
        
        /* center page in browser window if window size > 1000 */
        if (height > 600) {
            element.style.marginTop="auto";
            element.style.marginBottom="auto";
        } else {
            element.style.marginTop="inherit";
            element.style.marginBottom="inherit";
        }
    }
}

function moveDown(id) {
    elem= document.getElementById(id);
    if (elem) {
        elem.style.bottom="0em";
    }
}

function moveUp(id) {
    elem= document.getElementById(id);
    if (elem) {
        elem.style.bottom="0em";
    }
}

function hide(id) {
    //safe function to hide an element with a specified id
    if (document.getElementById(id)) {
        document.getElementById(id).style.display = 'none';
    }
}
function show(id) {
    if (document.getElementById(id)) {
        document.getElementById(id).style.display = 'block';
    }
}

