﻿/*
Função que cria janela LightBox na tela
width: tamanho da janela
height: altura da janela
popup: ClientID da janela
popupClass: classe da janela
IMPORTANTE:     A função deve estar dentro de $(document).ready(function() { AQUI }
EXEMPLO DE USO:
CriarLightboxClick(500, 400, 'janela', 'popup');
<etani>
*/
function CriarLightboxClick(width, height, popup, popupClass) {
    if (Number(height) > 0) {
        $('#' + popup)
      .fadeIn()
   .css({ 'width': Number(width), 'height': Number(height) })
      .prepend('<a href="#" class="btn-pop-fechar"></a>');
    }
    else {
        $('#' + popup)
      .fadeIn()
   .css({ 'width': Number(width) })
      .prepend('<a href="#" class="btn-pop-fechar"></a>');
    }

    var popMargTop = ($('#' + popup).height() + 80) / 2;
    var popMargLeft = ($('#' + popup).width() + 80) / 2;

    $('#' + popup).css({
        'margin-top': -(popMargTop - 30),
        'margin-left': -popMargLeft
    });

    $('body').append('<div id="fade"></div>');
    $('#fade').css({ 'filter': 'alpha(opacity=80)' }).fadeIn();

    $('a.btn-pop-fechar, #fade').live('click', function() {
        $('#fade , .' + popupClass).fadeOut(function() {
            $('#fade, a.btn-pop-fechar').remove();
        });

        return false;
    });
}
