/*
 * jQuery layer
 * Copyright (c) 2009 Dmitry (php-coder.ru) <diminapochta@gmail.com>
 */
(function($){
	$.layer = function(get){
		$('#layer').remove();
		$.post(get, {}, function(data){
			$("#layer").remove();
			html = '<div id="layer"><table class="box"><tr><td align="center"><div style="width:500px">'+data+'</div></td></tr></table></div>';
	        $(html).appendTo("body");
	        $("#layer").css({"width":document.body.scrollWidth, "height":document.body.scrollHeight});
            w = (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
    		h = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));
			$("#layer .box").css({"left":Math.ceil((w/2)-($("#layer .box").width()/2) + document.body.scrollLeft), "top":Math.ceil((h/2)-($("#layer .box").height()/2) + document.body.scrollTop)});
			$(".box").click(function(){
				return false;
			});
			$("#layer").click(function(){
				$('#layer').remove();
				return false;
			});
			return false;
		});
	}

})(jQuery);

