/* 
 * PROCERGS - Companhia de Processamento de Dados do Estado do Rio Grande do Sul
 * 
 * Desenvolvedor: Márcio Bordim Silveira
 * Data: 28/12/2011
 */
jQuery.noConflict();
jQuery(function($){

    openModalIframe('/popup/veraonumaboa/chamada.php', 420, 400);


    function openModalIframe(url, w, h){

        $('<div></div>')
        .attr('id', '_divModalAjax')
        .width(w)
        .height(h)
        .css('display', 'none')
        .appendTo($(document.body));

        $('<iframe></iframe>')
        .attr('frameborder', '0')
        .attr('scrolling', 'no')
        .width(w)
        .height(h)
        .attr('src', url)
        .appendTo($('#_divModalAjax'));

        openModal('#_divModalAjax');

    }

    function openModal(id_div){

        var maskHeight = $(document).height();
        var maskWidth = $(window).width();

        var winH = $(window).height();
        var winW = $(window).width();

        //CRIA A MASCARA DE FUNDO
        $('<div></div>')
        .attr('id', '_mask')
        .css('position', 'fixed')
        .css('top', 0)
        .css('z-index', 9000)
        .css('background-color','#000')
        .css('display', 'none')
        .height(maskHeight)
        .width(maskWidth)
        .appendTo($(document.body))
        .fadeTo("fast",0.8)
        .click(function(){
            closeModal();
        });

        //centraliza na tela a janela popup
        $(id_div)
        .css('top',  winH / 2 - $(id_div).outerHeight(true) / 2)
        .css('left', winW / 2 - $(id_div).outerWidth(true) / 2)
        .css('position', 'fixed')
        .css('z-index', 9001)
        .addClass('_JanelaModalAberta')
        //.appendTo($(document.body))
        .fadeIn(500);

    }
});
function closeModal(){
    jQuery('._JanelaModalAberta')
    .hide()
    .removeClass('_JanelaModalAberta');

    jQuery('#_mask, #_divModalAjax').remove();
    return false;
}


