$.fn.nextUntilInc = function(expr) 
{
    var match = [];

		match.push(this.get(0));
    // We need to figure out which elements to push onto the array
    this.each(function(){
        // Traverse through the sibling nodes
        for( var i = this.nextSibling; i; i = i.nextSibling ) {
            // Make sure that we're only dealing with elements
            if ( i.nodeType != 1 ) continue;

            // If we find a match then we need to stop
            if ( jQuery.filter( expr, [i] ).r.length ) break;

            // Otherwise, add it on to the stack
            match.push( i );
        }
    });

    return this.pushStack( match, arguments );
};

$.fn.wrapAll = function() 
{
    // There needs to be at least one matched element for this to work
    if ( !this.length ) return this;

    // Find the element that we're wrapping with
    var b = jQuery.clean(arguments)[0];
    // alert (b);

    // Make sure that its in the right position in the DOM
    this[0].parentNode.insertBefore( b, this[0] );

    // Find its lowest point
    while ( b.firstChild ) b = b.firstChild;

    // And add all the elements there
    return this.appendTo(b);
};

function makeContentTabs()
{
	var ix = 0;
	$(".contabs h2").each(function(){
		if(ix == 0) $(this).before("<ul class='anchors'></ul>");
		newid = "s" + parseInt(ix + 1);
		$(this).nextUntilInc("h2").wrapAll("<div class='fragment' id='" + newid + "'></div>");
		$(".contabs ul:eq(0)").append( "<li><a href='#" + newid + "'>" + $(this).html() + "</a></li>");		
		ix++;
	});
	$(".contabs").tabs();
}

$(document).ready(function() 
{
	tb.init();
	$("table").each(function(){ $("tr:even", this).addClass("evenrow"); $("tr:last", this).addClass("last"); });		
});            
