﻿var intervalo_modal = "";
var intervalo_modal_processando = "";

function Abre_modal_popup(vDiv_fundo, vDiv_conteudo, vLargura_div_conteudo, vAltura_div_conteudo) {

    //var vDiv_fundo = "teste";
    //var vDiv_conteudo = "teste2";
    
    
    var windowWidth, windowHeight;
    if (self.innerHeight) {	// all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    //alert('largura_pagina:' + windowWidth + '\naltura_pagina:' + windowHeight);
    pos_x = 0;
    pos_y = 0;
    largura_pagina = windowWidth;
    altura_pagina = windowHeight;

    document.getElementById(vDiv_fundo).style.width = largura_pagina + "px";
    document.getElementById(vDiv_fundo).style.height = altura_pagina + "px";

    document.getElementById(vDiv_conteudo).style.width = vLargura_div_conteudo + "px";
    document.getElementById(vDiv_conteudo).style.height = vAltura_div_conteudo + "px";

    document.getElementById(vDiv_conteudo).style.right = ((largura_pagina / 2) - (parseInt(document.getElementById(vDiv_conteudo).style.width) / 2)) + "px";
    document.getElementById(vDiv_conteudo).style.top = ((altura_pagina / 2) - (parseInt(document.getElementById(vDiv_conteudo).style.height) / 2)) + "px";
    //alert(navigator.appName);
    //alert(navigator.userAgent);
    document.getElementById(vDiv_fundo).style.display = "block";
    document.getElementById(vDiv_conteudo).style.display = "block";
    
    //document.getElementById(vDiv_conteudo).style.zIndex = "30000";
    
    intervalo_modal = window.setTimeout("Abre_modal_popup(\"" + vDiv_fundo + "\",\"" + vDiv_conteudo + "\",\"" + vLargura_div_conteudo + "\",\"" + vAltura_div_conteudo + "\")", 1);
}

function Fecha_modal_popup(vDiv_fundo, vDiv_conteudo) {
    document.getElementById(vDiv_fundo).style.display = "none";
    document.getElementById(vDiv_conteudo).style.display = "none";
    clearInterval(intervalo_modal);
}

function Abre_Processando(vDiv_fundo, vDiv_conteudo, vLargura_div_fundo, vAltura_div_fundo, vLargura_div_conteudo, vAltura_div_conteudo) {

    //var vDiv_fundo = "teste";
    //var vDiv_conteudo = "teste2";


    var windowWidth, windowHeight;
    if (self.innerHeight) {	// all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    //alert('largura_pagina:' + windowWidth + '\naltura_pagina:' + windowHeight);
    pos_x = 0;
    pos_y = 0;
    largura_pagina = windowWidth;
    altura_pagina = windowHeight;

    if (vLargura_div_fundo == "") {
        document.getElementById(vDiv_fundo).style.width = largura_pagina + "px";
    }
    else {
        document.getElementById(vDiv_fundo).style.width = vLargura_div_fundo + "px";
        document.getElementById(vDiv_fundo).style.left = ((largura_pagina / 2) - (parseInt(document.getElementById(vDiv_fundo).style.width) / 2)) + "px";
    }
    if (vAltura_div_fundo == "") {
        document.getElementById(vDiv_fundo).style.height = altura_pagina + "px";
    }
    else {
        document.getElementById(vDiv_fundo).style.height = vAltura_div_fundo + "px";
        document.getElementById(vDiv_fundo).style.top = ((altura_pagina / 2) - (parseInt(document.getElementById(vDiv_fundo).style.height) / 2)) + "px";
    }

    document.getElementById(vDiv_conteudo).style.width = vLargura_div_conteudo + "px";
    document.getElementById(vDiv_conteudo).style.height = vAltura_div_conteudo + "px";

    document.getElementById(vDiv_conteudo).style.right = ((largura_pagina / 2) - (parseInt(document.getElementById(vDiv_conteudo).style.width) / 2)) + "px";
    document.getElementById(vDiv_conteudo).style.top = ((altura_pagina / 2) - (parseInt(document.getElementById(vDiv_conteudo).style.height) / 2)) + "px";
    //alert(navigator.appName);
    //alert(navigator.userAgent);

    document.getElementById(vDiv_fundo).style.display = "block";
    document.getElementById(vDiv_conteudo).style.display = "block";

    intervalo_modal_processando = window.setTimeout("Abre_Processando(\"" + vDiv_fundo + "\",\"" + vDiv_conteudo + "\",\"" + vLargura_div_fundo + "\",\"" + vAltura_div_fundo + "\",\"" + vLargura_div_conteudo + "\",\"" + vAltura_div_conteudo + "\")", 1);
}

function Fecha_Processando(vDiv_fundo, vDiv_conteudo) {
    document.getElementById(vDiv_fundo).style.display = "none";
    document.getElementById(vDiv_conteudo).style.display = "none";
    clearInterval(intervalo_modal_processando);
}

