jQuery.fn.htmlPopup = function (options) {                      
var options = jQuery.extend({
html: "<div style='text-align: center; padding-top: 10px; background: white'>html code</div>",
width: false,
opacity: '0.5',
duration: 500,
top: 100,
minWidth: 998
}, options);
if ( !options.width ) return alert('jQuery htmljQuery_popup plugin error. Required parameter: width');
return this.each( function () {                 
jQuery('body')
.append('<div id="jQuery_overlay" style="position: absolute; z-index:5000; top:0; left:0; min-width: '+options.minWidth+'px; width: 100%; height: '+jQuery(document).height()+'px; background: black"></div>')
.prepend("<div id='jQuery_popup' style='position: relative; text-align: left; z-index: 10000; width: "+options.width+"px; margin: 0 auto;'><div style='display: none; position: absolute; z-index:10000; width: "+options.width+"px; overflow: hidden; left: 0px;'></div></div>");

jQuery('#jQuery_overlay')
.css({'opacity':'0'})
.animate({ 'opacity': options.opacity }, options.duration, function () {

});             
jQuery('#jQuery_popup div').html(options.html);

jQuery('#jQuery_popup>div')
.css({ 'display': 'block', 'opacity': '0', 'top': jQuery(window).scrollTop() + options.top + "px" })
.animate({'opacity':'1'}, options.duration );           
jQuery('#jQuery_overlay, #close-popup').bind( 'click', function () {
jQuery('#jQuery_popup div').html('').animate({'opacity': '0'}, options.duration, function () { jQuery('#jQuery_popup').remove(); });
jQuery('#jQuery_overlay').animate({'opacity': '0'}, options.duration, function () { jQuery('#jQuery_overlay').unbind('click').remove(); });
});
});
}
