var openLightBoxes = 0;

function showLightbox(id, callback) {
    if (callback) {
        callback();
    }

    blurAllSubmitButtons();
    var lightbox = document.getElementById("lightboxOverlay");
    var lightboxIFrame = document.getElementById("lightboxIFrame");
    var lightboxMessage = document.getElementById(id);
    var left = (getWindowWidth() - parseInt(lightboxMessage.style.width)) / 2;
    lightboxMessage.style.left = [left,'px'].join('');
    lightboxIFrame.style.display = 'block';    
    lightboxMessage.style.display = 'block';
    lightbox.style.display = 'block';
    var top = Math.floor(getScrollPosition() + (getWindowHeight() - lightboxMessage.offsetHeight) / 2)+"px";
    lightboxMessage.style.top = top;
    openLightBoxes = openLightBoxes + 1;
}

function hideLightbox(id, callback) {
	var lightbox = document.getElementById("lightboxOverlay");
    var lightboxIFrame = document.getElementById("lightboxIFrame");
    var lightboxMessage = document.getElementById(id);
    lightboxMessage.style.display = 'none';
    openLightBoxes = openLightBoxes - 1;
    
    if (openLightBoxes <= 0) {
        lightbox.style.display = 'none';    
        lightboxIFrame.style.display = 'none';
        openLightBoxes = 0;    
    }    
    
    if (callback) {
        callback();
    }
}
