function showGallery() {
    var gallery;
    var overlay;
    
    // Get the element from the page
    gallery = document.getElementById('galleryContainer');
    
    // If the element isn't being shown, show it
    if (gallery.style.display !== 'block') {
        gallery.style.display = 'block';
    }
    
    // Add the overlay (fade the background)
    overlay = document.createElement('div');
    overlay.id = 'overlay';
    overlay.innerHTML
    document.body.appendChild(overlay);
    document.body.appendChild(gallery);
}

function hideGallery() {
    var gallery;
    var overlay;
    
    // Get the elements from the page
    gallery = document.getElementById('galleryContainer');
    overlay = document.getElementById('overlay');
    
    // If the element isn't being shown, show it
    if (gallery.style.display !== 'none') {
        gallery.style.display = 'none';
    }
    
    // Remove the overlay
    overlay.parentNode.removeChild(overlay);
}

function changeFrameHref(target) {
    var frame;
    
    frame = document.getElementById('galleryContainer');
    frame.src = target;
}

function centerGallery() {
    var gallery;
    var myWidth = 0;
    var myHeight = 0;
    
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }

    
    gallery = document.getElementById('galleryContainer');
    
    gallery.style.top = (myHeight / 2) - 360 + 'px';
    gallery.style.left = (myWidth /  2) - 400 + 'px';
}