function fecharBox() {
    $('div.mask').fadeOut('fast');
    $('div.lightbox').fadeOut('fast');
    if (jQuery.browser.msie) { 
      if(parseInt(jQuery.browser.version) == 6) { 
          $('select').each(function(){$(this).show()});
      }
  }
    setTimeout($('div.lightbox > div').remove(), '1000');
    setTimeout($('div.lightbox > iframe').remove(), '1000');
};
document.onkeydown = function(e) {
    if (e == null) {
        keycode = event.keyCode;
    } else {
        keycode = e.which;
    } if (keycode == 27) {
        fecharBox()
    }
};
function createLightbox(width, height) {
	var bodyHeight = document.documentElement.clientHeight;
	if ( height < bodyHeight ) {
        var top = (bodyHeight - height) /2;
	} else {
		var top = '5';
	}

	$('div.lightbox').css({
		'left': '48%',
		'top': top + "px",
		'width': width + 'px',
		'height': height + 'px',
		'margin-left': -width / 2
	});
};
function createMask() {
	$('div.mask').css({
		'width':'100%',
		'height':'100%',
		'filter': 'alpha(opacity=50)',
		'-moz-opacity': '0.5',
		'-khtml-opacity': '0.5',
		'opacity': '0.5'
	});
	$('div.mask').show();
    if (jQuery.browser.msie) { 
      if(parseInt(jQuery.browser.version) == 6) { 
          $('select').each(function(){$(this).hide()});
      }
    }
};
function fClose() {
    $('.fechar').each(function() { $(this).remove() });
    $('div.lightbox').append('<a href="javascript:fecharBox()" class="fechar">Fechar</a>');
};
function lightbox(pathUrl, vW, vH) {
    createMask();
    createLightbox(vW, vH);
    fClose();
    $('div.lightbox').append('<iframe src="' + pathUrl + '" width="' + vW + '" height="' + vH + '" frameborder="0" allowtransparency="true" scrolling="no">');
    $('div.lightbox').fadeIn();

};
$(document).ready(function() {
    $('body').append('<div class="mask" /><div class="lightbox"></div>');
});
