/**
 * Returns the max zOrder in the document (no parameter).
 * Sets max zOrder by passing a non-zero number which gets
 * added to the highest zOrder.
 * @param {Object} opt
 * 		inc: increment value. Default 10.
 * 		group: selector for zIndex elements to find max for. Default *.
 * @return {jQuery}
 */
$.maxZIndex = $.fn.maxZIndex = function(opt){
    var def = {
        inc: 10,
        group: "*"
    };
    $.extend(def, opt);
    var zmax = 0;
    $(def.group).each(function(){
        var cur = parseInt($(this).css('z-index'), 10);
        zmax = cur > zmax ? cur : zmax;
    });
    if (!this.jquery) {
        return zmax;
    }
    
    return this.each(function(){
        zmax += def.inc;
        $(this).css("z-index", zmax);
    });
};
