
(function ($) {
$.topZIndex = function (selector) {
										
return Math.max(0, Math.max.apply(null, $.map(((selector || "*") === "*")? $.makeArray(document.getElementsByTagName("*")) : $(selector),
function (v) {
return parseFloat($(v).css("z-index")) || null;
}
)));
};
$.fn.topZIndex = function (opt) {
													
	if (this.length === 0) {
return this;
}
opt = $.extend({increment: 1}, opt);
	var zmax = $.topZIndex(opt.selector),
inc = opt.increment;
	return this.each(function () {
this.style.zIndex = (zmax += inc);
});
};
})(jQuery);

