/*	
	*MODIFIED* TopZIndex plugin for jQuery
	Version: 1.1

	http://topzindex.googlecode.com/
------------------------------------------------------*/

(function ($) {

$.topZIndex = function (selector) {
	
	return Math.max(0, Math.max.apply(null, $.map($(selector || "div.new_tab"), 
		function (v) {
			return parseInt($(v).css("z-index")) || null;
		}
	)));
};

$.fn.topZIndex = function (opt) {
	// Do nothing if matched set is empty
	if (this.length === 0) {
		return this;
	}
	
	opt = $.extend({increment: 1, selector: "div.new_tab"}, opt);

	// Get the highest current z-index value
	var zmax = $.topZIndex(opt.selector), inc = opt.increment;

	// Increment the z-index of each element in the matched set to the next highest number
	return this.each(function () {
		$(this).css("z-index", zmax += inc);
	});
};

})(jQuery);


