var openDiv = null;
        
function showDiv(object, width, height) {
    scroll(0, 0);
    //centrar o popup na horizontal
    if(window.innerWidth) {
        document.getElementById(object).style.left = ((window.innerWidth / 2) - (width / 2)) + 'px';
    } else {
        document.getElementById(object).style.left = ((document.body.offsetWidth / 2) - (width / 2)) + 'px';
    }
    
    //centrar o popup na vertical
    if(window.innerHeight) {
        document.getElementById(object).style.top = ((window.innerHeight / 2) - (height / 2)) + 'px';
    } else {
        document.getElementById(object).style.top = ((document.body.offsetHeight / 2) - (height / 2)) + 'px';
    }
    
    document.getElementById('overlay_popup').style.display = 'block';
    document.getElementById(object).style.display = 'block';
    
    openDiv = object;
}

function hideDiv(object) {
    document.getElementById(object).style.display = 'none';
    document.getElementById('overlay_popup').style.display = 'none';
    openDiv = null;
}

var page = new Array();
var lastpage = new Array();
function abre(div){
    var prefixDiv = div.substring(0,div.indexOf('_',0));
    var sufixDiv = div.substring(div.indexOf('_',0)+1, div.length);
    
    if (document.getElementById(div) != null) {
        if (document.getElementById(div).style.display == 'block') {
            document.getElementById(div).style.display = 'none';
        }
        else {
            document.getElementById(div).style.display = 'block';
        }
    }
    
    //fechar todas as divs do mesmo nivel
    if (prefixDiv != 'lasterpage'){
        if(prefixDiv == 'page'){
            for (i in page){
                if (sufixDiv != page[i]){
                    element = prefixDiv + '_' + page[i];
                    if (document.getElementById(element) != null) {
                        document.getElementById(element).style.display='none';  
                    }
                    
                }
            }
        } else if (prefixDiv == 'lastpage'){
            for (i in lastpage){
                if(sufixDiv != lastpage[i]){
                    element = prefixDiv + '_' + lastpage[i];
                    if (document.getElementById(element) != null) {
                        document.getElementById(element).style.display='none';
                    }
                }
            }
        }
    }
}


