The code is very concise. The outermost layer is a large DIV as the container of the pop-up layer, H4 as the title of the pop-up layer, another DIV for displaying the text content of the pop-up layer, and another DIV for placing some buttons.
function popupDiv(div_id) {
var div_obj = $("#" div_id);
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = div_obj.height();
var popupWidth = div_obj.width() ;
//Add and display the mask layer
$("
").addClass("mask")
.width(windowWidth * 0.99)
.height(windowHeight * 0.99)
.click(function() {hideDiv(div_id); })
.appendTo("body")
.fadeIn(200);
div_obj.css({"position": "absolute"})
.animate({left: windowWidth/2-popupWidth/2,
top: windowHeight/2-popupHeight/2, opacity: "show" }, "slow");
}
function hideDiv(div_id) {
$("#mask").remove();
$("#" div_id).animate ({left: 0, top: 0, opacity: "hide" }, "slow");
}