 (function($){ $.fn.modal = function(options) { var defaults = { dialog: "#importer", delay: 1000, bgcolor: "#000000" }; var o = $.extend(defaults, options); this.click(function(e) { e.preventDefault(); $("body").remove('#jq_modal_mask'); $("body").append("<div id=\"jq_modal_mask\"></div>"); $("#jq_modal_mask").css({ "height":$(document).height(), "position":"absolute", "left":0, "top":0, "z-index":5000, "background":o.bgcolor, "display":"none", "width":"100%", "min-width":"900px" }); $('#jq_modal_mask').click(function(e) { e.preventDefault(); $('#jq_modal_mask').hide(); $(o.dialog).hide(); }); $('[rel=jq_modal_close]').click(function(e) { e.preventDefault(); $('#jq_modal_mask').hide(); $(o.dialog).hide(); }); $('#jq_modal_mask').fadeTo(0,0.7).fadeIn("normal"); var top = ($(window).height()/3)-($(o.dialog).height()/3)+$(window).scrollTop(); var left = ($(window).width()/2)-($(o.dialog).width()/2); $(o.dialog).css({ "position":"absolute", "z-index":5001, "top":(top < 0 ? 0 : top), "left":(left < 0 ? 0 : left) }); $(o.dialog).attr({ "rel":"jq_modal_mask_top" }); $(o.dialog).fadeIn("normal"); }); }; })(jQuery); jQuery.extend({ modal_close: function(dialog) { if (jQuery('#jq_modal_mask').length > 0) { jQuery('#jq_modal_mask').hide(); jQuery(dialog).hide(); } } }); jQuery(document).ready(function() { jQuery(window).resize(function() { if (jQuery('#jq_modal_mask').length > 0 && jQuery("#jq_modal_mask").css("display") == "block") { var id = "[rel=jq_modal_mask_top]"; var top = (jQuery(window).height()/3)-(jQuery(id).height()/3)+jQuery(window).scrollTop(); var left = (jQuery(window).width()/2)-(jQuery(id).width()/2); jQuery('#jq_modal_mask').css('height', jQuery(document).height()); jQuery(id).css('top', top < 0 ? 0 : top); jQuery(id).css('left', left < 0 ? 0 : left); } }); }); 
