jQuery(document).ready(function($){

	var tabList = $('dl#who-uses-widget');
	var newDiv  = $("<div>").attr("id", tabList.attr("id"));

	tabList.find('dd').each(function(i) {
		newDiv.append(
			$("<div>").append(
				$(this).clone().contents()
			).attr("id", $(this).attr("id"))
			 .attr("class", $(this).attr("class"))
		);
	});

	var newUl = $("<ul>");
	tabList.find('dt').each(function() {
		var a    = $(this).clone().contents();
		var href = $(this).next('dd').find('.more a').first().attr('href');

		if ( $(this).parents('#main-content').length > 0 ) {
			$(a).click( function(){
				location.href = href;
			});
		}
		newUl.append( $("<li>").append(a) );
	});

	newDiv.append(newUl);
	$('dl#who-uses-widget').replaceWith(newDiv);

	if ( newDiv.parents('#main-content').length > 0 ) {
		newDiv.tabs({event: 'mouseover', cookie: {expires: (1 / 12)}});
	} else {
		newDiv.tabs();
		newDiv.tabs('select',  Math.floor(Math.random() * newDiv.tabs('length') ));
    		newDiv.tabs('option', 'fx', { opacity: 'toggle', speed: 'normal' } );
		newDiv.tabs('rotate', 7000);
	}

});

